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/logprint.c b/liblog/logprint.c
index 4ef62a1..19a3e27 100644
--- a/liblog/logprint.c
+++ b/liblog/logprint.c
@@ -34,12 +34,11 @@
#include <log/logprint.h>
#include <private/android_filesystem_config.h>
+#include "log_cdefs.h"
+
#define MS_PER_NSEC 1000000
#define US_PER_NSEC 1000
-/* open coded fragment, prevent circular dependencies */
-#define WEAK static
-
typedef struct FilterInfo_t {
char *mTag;
android_LogPriority mPri;
@@ -185,13 +184,15 @@
* returns 1 if this log line should be printed based on its priority
* and tag, and 0 if it should not
*/
-int android_log_shouldPrintLine (
- AndroidLogFormat *p_format, const char *tag, android_LogPriority pri)
+LIBLOG_ABI_PUBLIC int android_log_shouldPrintLine (
+ AndroidLogFormat *p_format,
+ const char *tag,
+ android_LogPriority pri)
{
return pri >= filterPriForTag(p_format, tag);
}
-AndroidLogFormat *android_log_format_new()
+LIBLOG_ABI_PUBLIC AndroidLogFormat *android_log_format_new()
{
AndroidLogFormat *p_ret;
@@ -213,7 +214,7 @@
static list_declare(convertHead);
-void android_log_format_free(AndroidLogFormat *p_format)
+LIBLOG_ABI_PUBLIC void android_log_format_free(AndroidLogFormat *p_format)
{
FilterInfo *p_info, *p_info_old;
@@ -236,7 +237,8 @@
}
}
-int android_log_setPrintFormat(AndroidLogFormat *p_format,
+LIBLOG_ABI_PUBLIC int android_log_setPrintFormat(
+ AndroidLogFormat *p_format,
AndroidLogPrintFormat format)
{
switch (format) {
@@ -277,7 +279,8 @@
/**
* Returns FORMAT_OFF on invalid string
*/
-AndroidLogPrintFormat android_log_formatFromString(const char * formatString)
+LIBLOG_ABI_PUBLIC AndroidLogPrintFormat android_log_formatFromString(
+ const char * formatString)
{
static AndroidLogPrintFormat format;
@@ -341,7 +344,8 @@
* Assumes single threaded execution
*/
-int android_log_addFilterRule(AndroidLogFormat *p_format,
+LIBLOG_ABI_PUBLIC int android_log_addFilterRule(
+ AndroidLogFormat *p_format,
const char *filterExpression)
{
size_t tagNameLength;
@@ -419,7 +423,8 @@
*
*/
-int android_log_addFilterString(AndroidLogFormat *p_format,
+LIBLOG_ABI_PUBLIC int android_log_addFilterString(
+ AndroidLogFormat *p_format,
const char *filterString)
{
char *filterStringCopy = strdup (filterString);
@@ -453,8 +458,9 @@
* Returns 0 on success and -1 on invalid wire format (entry will be
* in unspecified state)
*/
-int android_log_processLogBuffer(struct logger_entry *buf,
- AndroidLogEntry *entry)
+LIBLOG_ABI_PUBLIC int android_log_processLogBuffer(
+ struct logger_entry *buf,
+ AndroidLogEntry *entry)
{
entry->tv_sec = buf->sec;
entry->tv_nsec = buf->nsec;
@@ -734,9 +740,11 @@
* it however we choose, which means we can't really use a fixed-size buffer
* here.
*/
-int android_log_processBinaryLogBuffer(struct logger_entry *buf,
- AndroidLogEntry *entry, const EventTagMap* map, char* messageBuf,
- int messageBufLen)
+LIBLOG_ABI_PUBLIC int android_log_processBinaryLogBuffer(
+ struct logger_entry *buf,
+ AndroidLogEntry *entry,
+ const EventTagMap *map,
+ char *messageBuf, int messageBufLen)
{
size_t inCount;
unsigned int tagIndex;
@@ -852,7 +860,7 @@
* _also_ be part of libutils/Unicode.cpp if its usefullness needs to
* propagate globally.
*/
-WEAK ssize_t utf8_character_length(const char *src, size_t len)
+LIBLOG_WEAK ssize_t utf8_character_length(const char *src, size_t len)
{
const char *cur = src;
const char first_char = *cur++;
@@ -956,7 +964,7 @@
return p - begin;
}
-char *readSeconds(char *e, struct timespec *t)
+static char *readSeconds(char *e, struct timespec *t)
{
unsigned long multiplier;
char *p;
@@ -1243,12 +1251,12 @@
* Returns NULL on malloc error
*/
-char *android_log_formatLogLine (
- AndroidLogFormat *p_format,
- char *defaultBuffer,
- size_t defaultBufferSize,
- const AndroidLogEntry *entry,
- size_t *p_outLength)
+LIBLOG_ABI_PUBLIC char *android_log_formatLogLine (
+ AndroidLogFormat *p_format,
+ char *defaultBuffer,
+ size_t defaultBufferSize,
+ const AndroidLogEntry *entry,
+ size_t *p_outLength)
{
#if !defined(_WIN32)
struct tm tmBuf;
@@ -1526,10 +1534,10 @@
* Returns count bytes written
*/
-int android_log_printLogLine(
- AndroidLogFormat *p_format,
- int fd,
- const AndroidLogEntry *entry)
+LIBLOG_ABI_PUBLIC int android_log_printLogLine(
+ AndroidLogFormat *p_format,
+ int fd,
+ const AndroidLogEntry *entry)
{
int ret;
char defaultBuffer[512];