diff --git a/frameworks/native/BUILD.gn b/frameworks/native/BUILD.gn index 4e5bffbdfeced53ec79504acbff22b743f9dd15d..25df7ce9f1d3ad5704213073ebb0e61a7d35c62b 100644 --- a/frameworks/native/BUILD.gn +++ b/frameworks/native/BUILD.gn @@ -55,6 +55,12 @@ config("libhilogutil_config") { "//base/hiviewdfx/hilog/adapter", "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", ] + + if (use_musl) { + include_dirs += [ + "//base/startup/init_lite/interfaces/innerkits/include", + ] + } } ohos_shared_library("libhilogutil") { @@ -76,6 +82,14 @@ ohos_shared_library("libhilogutil") { "//utils/native/base:utilsecurec_shared", ] + if (use_musl) { + defines = [ "HILOG_USE_MUSL" ] + deps += [ + "//base/startup/init_lite/interfaces/innerkits/socket:libsocket", + ] + } + + output_extension = "so" install_enable = true diff --git a/frameworks/native/include/hilog_common.h b/frameworks/native/include/hilog_common.h index 2c2ce50bf1f2f4711efc0527865586e0739a4397..f1e8269c59c6751bd6f97551f85f2cb9a8c9fbf0 100644 --- a/frameworks/native/include/hilog_common.h +++ b/frameworks/native/include/hilog_common.h @@ -18,7 +18,11 @@ #include +#ifdef HILOG_USE_MUSL +#define SOCKET_FILE_DIR "/dev/unix/socket/" +#else #define SOCKET_FILE_DIR "/dev/socket/" +#endif #define INPUT_SOCKET_NAME "hilogInput" #define INPUT_SOCKET SOCKET_FILE_DIR INPUT_SOCKET_NAME #define CONTROL_SOCKET_NAME "hilogControl" diff --git a/frameworks/native/socket_server.cpp b/frameworks/native/socket_server.cpp index bb2e02952fe82b307895d52234ba55d5e225ae80..d5cc8e7d1c07491af6c1f455a996e724092050c4 100644 --- a/frameworks/native/socket_server.cpp +++ b/frameworks/native/socket_server.cpp @@ -25,6 +25,11 @@ #include "socket_server_adapter.h" +#ifdef HILOG_USE_MUSL +extern "C" { +#include "init_socket.h" +} +#endif namespace OHOS { namespace HiviewDFX { SocketServer::SocketServer(const std::string& serverPath, uint32_t socketType) @@ -43,7 +48,11 @@ SocketServer::SocketServer(const std::string& serverPath, uint32_t socketType) int SocketServer::Init() { if (sockName.length()) { +#ifdef HILOG_USE_MUSL + socketHandler = GetControlSocket(sockName.c_str()); +#else socketHandler = GetExistingSocketServer(sockName.c_str(), socketType); +#endif if (socketHandler >= 0) { return socketHandler; }