diff --git a/porting/linux/user/src/hilog/hilog_adapter.c b/porting/linux/user/src/hilog/hilog_adapter.c index 4a203caa08c7a9e4187c9f0754b32d15732ed33d..b4a28cbaf03772ec8b0b89faa1bcd6ad12a006b3 100644 --- a/porting/linux/user/src/hilog/hilog_adapter.c +++ b/porting/linux/user/src/hilog/hilog_adapter.c @@ -91,7 +91,8 @@ static int SendMessage(HilogMsg *header, const char *tag, uint16_t tagLen, const return ret; } -static int HiLogAdapterPrintArgs( +HILOG_LOCAL_API +int HiLogAdapterPrintArgs( const LogType type, const LogLevel level, const unsigned int domain, const char *tag, const char *fmt, va_list ap) { char buf[MAX_LOG_LEN] = {0}; @@ -112,6 +113,7 @@ static int HiLogAdapterPrintArgs( return SendMessage(&header, tag, tagLen + 1, buf, logLen + 1); } +HILOG_LOCAL_API int HiLogAdapterPrint(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) { if (!HiLogAdapterIsLoggable(domain, tag, level)) { diff --git a/porting/linux/user/src/hilog/vsnprintf_s_p.c b/porting/linux/user/src/hilog/vsnprintf_s_p.c index 6677407a6ed5afe170e15efca8febc3830a5b86b..6699b4cc082f439072010886936590f253672f53 100644 --- a/porting/linux/user/src/hilog/vsnprintf_s_p.c +++ b/porting/linux/user/src/hilog/vsnprintf_s_p.c @@ -20,6 +20,8 @@ #include #include "malloc_impl.h" +/* Do not malloc in vsnprintf, thus the log api can be called inside signal handler*/ +#define HILOG_PROHIBIT_ALLOCATION /* Define the max length of the string */ #ifndef SECUREC_STRING_MAX_LEN @@ -137,8 +139,8 @@ typedef enum { #endif #else -#define SECUREC_MALLOC(x) (nullptr) -#define SECUREC_FREE(x) { printf("Malloc is not allowed, so free should not be possible to execute!"); std::abort(); } +#define SECUREC_MALLOC(x) (NULL) +#define SECUREC_FREE(x) {} #endif #if (defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER)) || defined(__ARMCC_VERSION)