diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c446b19a548e2f2f84d147d59327bee66d56caa..938997b23ea077ae2d1466c3516c0678587c7584 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,13 @@ IF (NOT DEFINED TD_CLUSTER) ENDIF () ENDIF () + # + # Get OS information and store in variable TD_OS_INFO. + # + execute_process(COMMAND chmod 777 ${TD_COMMUNITY_DIR}/packaging/tools/get_os.sh) + execute_process(COMMAND ${TD_COMMUNITY_DIR}/packaging/tools/get_os.sh "" OUTPUT_VARIABLE TD_OS_INFO) + MESSAGE(STATUS "The current os is " ${TD_OS_INFO}) + IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) SET(TD_LINUX_64 TRUE) @@ -150,6 +157,13 @@ IF (NOT DEFINED TD_CLUSTER) ENDIF () ADD_DEFINITIONS(-DLINUX) ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT) + IF (${TD_OS_INFO} MATCHES "Alpine") + MESSAGE(STATUS "The current OS is Alpine, append extra flags") + SET(COMMON_FLAGS "${COMMON_FLAGS} -largp") + link_libraries(/usr/lib/libargp.a) + ELSE () + ADD_DEFINITIONS(-D__USE_GNU) + ENDIF () ELSEIF (TD_LINUX_32) IF (NOT TD_ARM) EXIT () @@ -160,6 +174,13 @@ IF (NOT DEFINED TD_CLUSTER) ADD_DEFINITIONS(-DLINUX) ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT) ADD_DEFINITIONS(-DUSE_LIBICONV) + IF (${TD_OS_INFO} MATCHES "Alpine") + MESSAGE(STATUS "The current OS is Alpine, add extra flags") + SET(COMMON_FLAGS "${COMMON_FLAGS} -largp") + link_library(/usr/lib/libargp.a) + ELSE () + ADD_DEFINITIONS(-D__USE_GNU) + ENDIF () ELSEIF (TD_WINDOWS_64) SET(CMAKE_GENERATOR "NMake Makefiles" CACHE INTERNAL "" FORCE) SET(COMMON_FLAGS "/nologo /WX- /Oi /Oy- /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:prompt /analyze-") diff --git a/packaging/tools/get_os.sh b/packaging/tools/get_os.sh new file mode 100644 index 0000000000000000000000000000000000000000..13f9f63228697c7abb69daf6abe14e49a4977f13 --- /dev/null +++ b/packaging/tools/get_os.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# +# This file is used to install TAOS time-series database on linux systems. The operating system +# is required to use systemd to manage services at boot + +set -e +# set -x + +# -----------------------Variables definition--------------------- +OS=$(cat /etc/*-release | grep "^NAME=" | cut -d= -f2) +len=$(echo ${#OS}) +len=$((len-2)) +retval=$(echo -ne ${OS:1:${len}} | cut -d" " -f0) +echo -ne $retval diff --git a/src/kit/shell/src/shellLinux.c b/src/kit/shell/src/shellLinux.c index e9e988c6c687a8eaefd858d6628f50f45a142af7..12202f95ac1d32a0e73ee5f521758b06fb509c33 100644 --- a/src/kit/shell/src/shellLinux.c +++ b/src/kit/shell/src/shellLinux.c @@ -130,7 +130,11 @@ void shellParseArgument(int argc, char *argv[], struct arguments *arguments) { argp_parse(&argp, argc, argv, 0, 0, arguments); if (arguments->abort) { - error(10, 0, "ABORTED"); + #ifdef __USE_GNU + error(10, 0, "ABORTED"); + #else + abort(); + #endif } } diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 40fbabe1f76027860c8f3b863618f870b833a91f..d95a27548c94a0595349a80ab6a164e9e7239e63 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -17,7 +17,10 @@ #include #include +#if !defined (__USE_GNU) && defined (LINUX) +#else #include +#endif #include #include #include @@ -309,7 +312,13 @@ int main(int argc, char *argv[]) { argp_parse(&argp, argc, argv, 0, 0, &arguments); - if (arguments.abort) error(10, 0, "ABORTED"); + if (arguments.abort) { + #ifdef __USE_GNU + error(10, 0, "ABORTED"); + #else + abort(); + #endif + } enum MODE query_mode = arguments.mode; char *ip_addr = arguments.host; diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index c8ef3bc0481c72d284485d7c369db97de6d780e9..ba2c6c107466a103c6390087241f06d6e361577b 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -15,7 +15,10 @@ #include #include +#if !defined (__USE_GNU) && defined (LINUX) +#else #include +#endif #include #include #include @@ -335,7 +338,13 @@ int main(int argc, char *argv[]) { reflected in arguments. */ argp_parse(&argp, argc, argv, 0, 0, &arguments); - if (arguments.abort) error(10, 0, "ABORTED"); + if (arguments.abort) { + #ifdef __USE_GNU + error(10, 0, "ABORTED"); + #else + abort(); + #endif + } if (taosCheckParam(&arguments) < 0) { exit(EXIT_FAILURE); diff --git a/src/os/linux/inc/os.h b/src/os/linux/inc/os.h index acfd284737cadbe5232983958ef79546117d4ef8..e0fca096518f778889a46373dbe3033f25a9d46b 100644 --- a/src/os/linux/inc/os.h +++ b/src/os/linux/inc/os.h @@ -229,6 +229,14 @@ void taosSetCoreDump(); void taosBlockSIGPIPE(); +#ifndef __USE_GNU + typedef int(*__compar_fn_t)(const void *, const void *); + void error (int, int, const char *); + #ifndef PTHREAD_MUTEX_RECURSIVE_NP + #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE + #endif +#endif + #define BUILDIN_CLZL(val) __builtin_clzl(val) #define BUILDIN_CLZ(val) __builtin_clz(val) #define BUILDIN_CTZL(val) __builtin_ctzl(val) diff --git a/src/os/linux/src/tlinux.c b/src/os/linux/src/tlinux.c index a23919e458709490d45a5bcadebf84ee5fed743d..1591806d368e374a1550c2fa8eb7ff018c785f35 100644 --- a/src/os/linux/src/tlinux.c +++ b/src/os/linux/src/tlinux.c @@ -234,8 +234,15 @@ void *taosProcessAlarmSignal(void *tharg) { timer_t timerId; struct sigevent sevent; - sevent.sigev_notify = SIGEV_THREAD_ID; - sevent._sigev_un._tid = syscall(__NR_gettid); + + #ifndef __USE_GNU + sevent.sigev_notify = SIGEV_THREAD; + sevent.sigev_value.sival_int = syscall(__NR_gettid); + #else + sevent.sigev_notify = SIGEV_THREAD_ID; + sevent._sigev_un._tid = syscall(__NR_gettid); + #endif + sevent.sigev_signo = SIGALRM; if (timer_create(CLOCK_REALTIME, &sevent, &timerId) == -1) { diff --git a/src/os/linux/src/tsystem.c b/src/os/linux/src/tsystem.c index 055a67e0772f1a9595fa2825514358e9ef16083c..afb595552ff7afd87660acdf7d563649bb9e13ac 100644 --- a/src/os/linux/src/tsystem.c +++ b/src/os/linux/src/tsystem.c @@ -27,12 +27,15 @@ #include #include #include -#include -#include #include #include #include + +#ifndef __USE_GNU #include +#else +#include +#endif #include "tglobalcfg.h" #include "tlog.h"