summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2016-03-10 10:25:33 -0600
committerMark Salyzyn2016-03-10 16:44:27 -0600
commit6d753faaf8694792433eb78c5c3572efd74a3d54 (patch)
treee492ecad9e80855575f7050fab0e250bf8963b7f /liblog/fake_log_device.c
parent029c7373801b9e1791df334efa36588c216b4ab2 (diff)
downloadplatform-system-core-6d753faaf8694792433eb78c5c3572efd74a3d54.tar.gz
platform-system-core-6d753faaf8694792433eb78c5c3572efd74a3d54.tar.xz
platform-system-core-6d753faaf8694792433eb78c5c3572efd74a3d54.zip
liblog: audit declare LIBLOG_ABI_PUBLIC
(cherry pick from commit be1d3c21b57d3e67c6a9682f3b2f0838486a3ee8) - replace <sys/cdefs.h> with local "log_cdefs.h" which fortifies and expands definitions, adding LIBLOG_ABI_PUBLIC, LIBLOG_HIDDEN, LIBLOG_ABI_PRIVATE and LIBLOG_WEAK. - clearly tag each interface as LIBLOG_ABI_PUBLIC, LIBLOG_HIDDEN, LIBLOG_ABI_PRIVATE, LIBLOG_WEAK or static depending on scope - Add -fvisibility=hidden to ensure nothing else leaks - some code standard adjustments Bug: 27566046 Change-Id: Ic14033c4e6d833d973beb035ddc1c6134fb35a3f
Diffstat (limited to 'liblog/fake_log_device.c')
-rw-r--r--liblog/fake_log_device.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/liblog/fake_log_device.c b/liblog/fake_log_device.c
index aa88bedf8..c73e03e21 100644
--- a/liblog/fake_log_device.c
+++ b/liblog/fake_log_device.c
@@ -19,23 +19,19 @@
19 * passed on to the underlying (fake) log device. When not in the 19 * passed on to the underlying (fake) log device. When not in the
20 * simulator, messages are printed to stderr. 20 * simulator, messages are printed to stderr.
21 */ 21 */
22#include "fake_log_device.h"
23
24#include <ctype.h> 22#include <ctype.h>
25#include <errno.h> 23#include <errno.h>
26#include <fcntl.h> 24#include <fcntl.h>
25#if !defined(_WIN32)
26#include <pthread.h>
27#endif
27#include <stdlib.h> 28#include <stdlib.h>
28#include <string.h> 29#include <string.h>
29 30
30#include <log/logd.h> 31#include <log/logd.h>
31 32
32#if !defined(_WIN32) 33#include "fake_log_device.h"
33#include <pthread.h> 34#include "log_cdefs.h"
34#endif
35
36#ifndef __unused
37#define __unused __attribute__((__unused__))
38#endif
39 35
40#define kMaxTagLen 16 /* from the long-dead utils/Log.cpp */ 36#define kMaxTagLen 16 /* from the long-dead utils/Log.cpp */
41 37
@@ -512,7 +508,7 @@ static void showLog(LogState *state,
512 } 508 }
513 numLines -= 1; 509 numLines -= 1;
514 } 510 }
515 511
516 /* 512 /*
517 * Write the entire message to the log file with a single writev() call. 513 * Write the entire message to the log file with a single writev() call.
518 * We need to use this rather than a collection of printf()s on a FILE* 514 * We need to use this rather than a collection of printf()s on a FILE*
@@ -531,10 +527,10 @@ static void showLog(LogState *state,
531 int cc = writev(fileno(stderr), vec, v-vec); 527 int cc = writev(fileno(stderr), vec, v-vec);
532 528
533 if (cc == totalLen) break; 529 if (cc == totalLen) break;
534 530
535 if (cc < 0) { 531 if (cc < 0) {
536 if(errno == EINTR) continue; 532 if(errno == EINTR) continue;
537 533
538 /* can't really log the failure; for now, throw out a stderr */ 534 /* can't really log the failure; for now, throw out a stderr */
539 fprintf(stderr, "+++ LOG: write failed (errno=%d)\n", errno); 535 fprintf(stderr, "+++ LOG: write failed (errno=%d)\n", errno);
540 break; 536 break;
@@ -683,7 +679,7 @@ static void setRedirects()
683 } 679 }
684} 680}
685 681
686int fakeLogOpen(const char *pathName, int flags) 682LIBLOG_HIDDEN int fakeLogOpen(const char *pathName, int flags)
687{ 683{
688 if (redirectOpen == NULL) { 684 if (redirectOpen == NULL) {
689 setRedirects(); 685 setRedirects();
@@ -702,19 +698,22 @@ int fakeLogOpen(const char *pathName, int flags)
702 * call is in the exit handler. Logging can continue in the exit handler to 698 * call is in the exit handler. Logging can continue in the exit handler to
703 * help debug HOST tools ... 699 * help debug HOST tools ...
704 */ 700 */
705int fakeLogClose(int fd) 701LIBLOG_HIDDEN int fakeLogClose(int fd)
706{ 702{
707 /* Assume that open() was called first. */ 703 /* Assume that open() was called first. */
708 return redirectClose(fd); 704 return redirectClose(fd);
709} 705}
710 706
711ssize_t fakeLogWritev(int fd, const struct iovec* vector, int count) 707LIBLOG_HIDDEN ssize_t fakeLogWritev(int fd,
708 const struct iovec* vector, int count)
712{ 709{
713 /* Assume that open() was called first. */ 710 /* Assume that open() was called first. */
714 return redirectWritev(fd, vector, count); 711 return redirectWritev(fd, vector, count);
715} 712}
716 713
717int __android_log_is_loggable(int prio, const char *tag __unused, int def) 714LIBLOG_ABI_PUBLIC int __android_log_is_loggable(int prio,
715 const char *tag __unused,
716 int def)
718{ 717{
719 int logLevel = def; 718 int logLevel = def;
720 return logLevel >= 0 && prio >= logLevel; 719 return logLevel >= 0 && prio >= logLevel;