diff --git a/frameworks/native/hilog_base.cpp b/frameworks/native/hilog_base.cpp index dc6e78545fe8c70257bf464c8dd9590cdc364eea..fb4e11dcf99b01b7fb5a5092f1e5309367137028 100644 --- a/frameworks/native/hilog_base.cpp +++ b/frameworks/native/hilog_base.cpp @@ -29,26 +29,6 @@ #include #include -#ifdef DEBUG -static const int MAX_PATH_LEN = 1024; - -static size_t GetExecutablePath(char *processdir, char *processname, size_t len) -{ - char* path_end = nullptr; - if (readlink("/proc/self/exe", processdir, len) <= 0) - return -1; - path_end = strrchr(processdir, '/'); - if (path_end == NULL) - return -1; - ++path_end; - if (strncpy_s(processname, MAX_PATH_LEN, path_end, MAX_PATH_LEN - 1)) { - return 0; - } - *path_end = '\0'; - return (size_t)(path_end - processdir); -} -#endif - namespace { constexpr int SOCKET_TYPE = SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC; @@ -67,7 +47,7 @@ struct SocketHandler { } }; -int GenerateFD() +static int GenerateFD() { int tmpFd = TEMP_FAILURE_RETRY(socket(AF_UNIX, SOCKET_TYPE, 0)); int res = tmpFd; @@ -78,7 +58,7 @@ int GenerateFD() return res; } -int CheckSocket(SocketHandler& socketHandler) +static int CheckSocket(SocketHandler& socketHandler) { int currentFd = socketHandler.socketFd.load(); if (currentFd >= 0) { @@ -99,7 +79,7 @@ int CheckSocket(SocketHandler& socketHandler) return fd; } -int CheckConnection(SocketHandler& socketHandler) +static int CheckConnection(SocketHandler& socketHandler) { bool isConnected = socketHandler.isConnected.load(); if (isConnected) { @@ -121,7 +101,7 @@ int CheckConnection(SocketHandler& socketHandler) return 0; } -int SendMessage(HilogMsg *header, const char *tag, int tagLen, const char *fmt, int fmtLen) +static int SendMessage(HilogMsg *header, const char *tag, int tagLen, const char *fmt, int fmtLen) { SocketHandler socketHandler; int ret = CheckSocket(socketHandler); @@ -151,7 +131,7 @@ int SendMessage(HilogMsg *header, const char *tag, int tagLen, const char *fmt, return ret; } -int HiLogBasePrintArgs(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, +static int HiLogBasePrintArgs(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, const char *fmt, va_list ap) { #ifdef DEBUG diff --git a/frameworks/native/include/hilog_common.h b/frameworks/native/include/hilog_common.h index 738191558ff3c44be2ba34021d3ada6b971512f6..154702a169bf7834d4653adb08f41aa3af8df3d7 100644 --- a/frameworks/native/include/hilog_common.h +++ b/frameworks/native/include/hilog_common.h @@ -98,6 +98,14 @@ using OptCRef = std::optional>; #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) +#if defined(__GNUC__) && (__GNUC__ >= 4) + #define HILOG_PUBLIC_API __attribute__((visibility ("default"))) + #define HILOG_LOCAL_API __attribute__((visibility("hidden"))) +#else + #define HILOG_PUBLIC_API + #define HILOG_LOCAL_API +#endif + /* * ******************************************** * Error codes list diff --git a/frameworks/native/output_p.inl b/frameworks/native/output_p.inl index 3ecf34de48d8b1698ab722fb3646112ba2e0c7f9..816b1b9ee83f9f5d69737f8b1de382e41feb1b9f 100755 --- a/frameworks/native/output_p.inl +++ b/frameworks/native/output_p.inl @@ -400,7 +400,7 @@ static int SecDecodeTypeS(SecFormatAttr *attr, char *argPtr, SecFormatBuf *forma return textLen; } -int SecOutputPS(SecPrintfStream *stream, int priv, const char *cformat, va_list arglist) +HILOG_LOCAL_API int SecOutputPS(SecPrintfStream *stream, int priv, const char *cformat, va_list arglist) { const SecChar *format = cformat; diff --git a/frameworks/native/vsnprintf_s_p.cpp b/frameworks/native/vsnprintf_s_p.cpp index d2077144b771745488a100296596f3e147e24bc1..e9199c238df3d5e1b0da4151436262cefb8d9cf9 100644 --- a/frameworks/native/vsnprintf_s_p.cpp +++ b/frameworks/native/vsnprintf_s_p.cpp @@ -214,6 +214,7 @@ static inline int SecVsnprintfPImpl(char *string, size_t count, int priv, const * If there is a runtime-constraint violation, strDest[0] will be set to the '\0' when strDest and destMax valid ******************************************************************************* */ + HILOG_LOCAL_API int vsnprintfp_s(char *strDest, size_t destMax, size_t count, int priv, const char *format, va_list arglist) { int retVal; diff --git a/frameworks/native/vsnprintf_s_p.h b/frameworks/native/vsnprintf_s_p.h index 5820a0aec01fec56763f82bff69a6d0109128f73..222e3ae07c828ef5a18a1f23df0c07246bdeca93 100644 --- a/frameworks/native/vsnprintf_s_p.h +++ b/frameworks/native/vsnprintf_s_p.h @@ -31,6 +31,7 @@ * @return:return the number of characters printed(not including the terminating null byte ('\0')), * If an error occurred return -1.Pay special attention to returning -1 when truncation occurs */ +HILOG_LOCAL_API int vsnprintfp_s(char *strDest, size_t destMax, size_t count, int priv, const char *format, va_list arglist); #endif /* __VSNPRINTFP_S_H__ */