liblog: audit declare LIBLOG_ABI_PUBLIC
- 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
diff --git a/liblog/logd_write.c b/liblog/logd_write.c
index b173d1a..85a4aab 100644
--- a/liblog/logd_write.c
+++ b/liblog/logd_write.c
@@ -46,6 +46,8 @@
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>
+#include "log_cdefs.h"
+
#define LOG_BUF_SIZE 1024
#if FAKE_LOG_DEVICE
@@ -56,10 +58,6 @@
static int __write_to_log_init(log_id_t, struct iovec *vec, size_t nr);
static int (*write_to_log)(log_id_t, struct iovec *vec, size_t nr) = __write_to_log_init;
-#ifndef __unused
-#define __unused __attribute__((__unused__))
-#endif
-
#if !defined(_WIN32)
static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -106,7 +104,7 @@
kLogUninitialized, kLogNotAvailable, kLogAvailable
} g_log_status = kLogUninitialized;
-int __android_log_dev_available(void)
+LIBLOG_ABI_PUBLIC int __android_log_dev_available()
{
if (g_log_status == kLogUninitialized) {
if (access("/dev/socket/logdw", W_OK) == 0)
@@ -485,7 +483,7 @@
[LOG_ID_KERNEL] = "kernel",
};
-const char *android_log_id_to_name(log_id_t log_id)
+LIBLOG_ABI_PUBLIC const char *android_log_id_to_name(log_id_t log_id)
{
if (log_id >= LOG_ID_MAX) {
log_id = LOG_ID_MAIN;
@@ -520,12 +518,14 @@
return write_to_log(log_id, vec, nr);
}
-int __android_log_write(int prio, const char *tag, const char *msg)
+LIBLOG_ABI_PUBLIC int __android_log_write(int prio, const char *tag,
+ const char *msg)
{
return __android_log_buf_write(LOG_ID_MAIN, prio, tag, msg);
}
-int __android_log_buf_write(int bufID, int prio, const char *tag, const char *msg)
+LIBLOG_ABI_PUBLIC int __android_log_buf_write(int bufID, int prio,
+ const char *tag, const char *msg)
{
struct iovec vec[3];
char tmp_tag[32];
@@ -566,7 +566,8 @@
return write_to_log(bufID, vec, 3);
}
-int __android_log_vprint(int prio, const char *tag, const char *fmt, va_list ap)
+LIBLOG_ABI_PUBLIC int __android_log_vprint(int prio, const char *tag,
+ const char *fmt, va_list ap)
{
char buf[LOG_BUF_SIZE];
@@ -575,7 +576,8 @@
return __android_log_write(prio, tag, buf);
}
-int __android_log_print(int prio, const char *tag, const char *fmt, ...)
+LIBLOG_ABI_PUBLIC int __android_log_print(int prio, const char *tag,
+ const char *fmt, ...)
{
va_list ap;
char buf[LOG_BUF_SIZE];
@@ -587,7 +589,9 @@
return __android_log_write(prio, tag, buf);
}
-int __android_log_buf_print(int bufID, int prio, const char *tag, const char *fmt, ...)
+LIBLOG_ABI_PUBLIC int __android_log_buf_print(int bufID, int prio,
+ const char *tag,
+ const char *fmt, ...)
{
va_list ap;
char buf[LOG_BUF_SIZE];
@@ -599,8 +603,10 @@
return __android_log_buf_write(bufID, prio, tag, buf);
}
-void __android_log_assert(const char *cond, const char *tag,
- const char *fmt, ...)
+LIBLOG_ABI_PUBLIC void __android_log_assert(
+ const char *cond,
+ const char *tag,
+ const char *fmt, ...)
{
char buf[LOG_BUF_SIZE];
@@ -625,7 +631,8 @@
/* NOTREACHED */
}
-int __android_log_bwrite(int32_t tag, const void *payload, size_t len)
+LIBLOG_ABI_PUBLIC int __android_log_bwrite(int32_t tag,
+ const void *payload, size_t len)
{
struct iovec vec[2];
@@ -637,7 +644,9 @@
return write_to_log(LOG_ID_EVENTS, vec, 2);
}
-int __android_log_security_bwrite(int32_t tag, const void *payload, size_t len)
+LIBLOG_ABI_PUBLIC int __android_log_security_bwrite(int32_t tag,
+ const void *payload,
+ size_t len)
{
struct iovec vec[2];
@@ -654,8 +663,8 @@
* for the general case where we're generating lists of stuff, but very
* handy if we just want to dump an integer into the log.
*/
-int __android_log_btwrite(int32_t tag, char type, const void *payload,
- size_t len)
+LIBLOG_ABI_PUBLIC int __android_log_btwrite(int32_t tag, char type,
+ const void *payload, size_t len)
{
struct iovec vec[3];
@@ -673,7 +682,7 @@
* Like __android_log_bwrite, but used for writing strings to the
* event log.
*/
-int __android_log_bswrite(int32_t tag, const char *payload)
+LIBLOG_ABI_PUBLIC int __android_log_bswrite(int32_t tag, const char *payload)
{
struct iovec vec[4];
char type = EVENT_TYPE_STRING;
@@ -695,7 +704,8 @@
* Like __android_log_security_bwrite, but used for writing strings to the
* security log.
*/
-int __android_log_security_bswrite(int32_t tag, const char *payload)
+LIBLOG_ABI_PUBLIC int __android_log_security_bswrite(int32_t tag,
+ const char *payload)
{
struct iovec vec[4];
char type = EVENT_TYPE_STRING;