diff --git a/src/os/inc/os.h b/src/os/inc/os.h index 6006f1b9690373158300734728a2a21e472a8776..6731ca6d7db9ce72e72a88a1b9dadf76fb8ec87e 100644 --- a/src/os/inc/os.h +++ b/src/os/inc/os.h @@ -20,42 +20,7 @@ extern "C" { #endif -#ifdef _TD_DARWIN_64 -#include "osDarwin.h" -#endif - -#ifdef _TD_ARM_64 -#include "osArm64.h" -#endif - -#ifdef _TD_ARM_32 -#include "osArm32.h" -#endif - -#ifdef _TD_MIPS_64 -#include "osMips64.h" -#endif - -#ifdef _TD_LINUX_64 -#include "osLinux64.h" -#endif - -#ifdef _TD_LINUX_32 -#include "osLinux32.h" -#endif - -#ifdef _ALPINE -#include "osAlpine.h" -#endif - -#ifdef _TD_NINGSI_60 -#include "osNingsi.h" -#endif - -#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) -#include "osWindows.h" -#endif - +#include "osInc.h" #include "osDef.h" #include "osAtomic.h" #include "osDir.h" diff --git a/src/os/inc/osAlpine.h b/src/os/inc/osAlpine.h deleted file mode 100644 index eba94593955e32fc354500758bd2af53060eaa7a..0000000000000000000000000000000000000000 --- a/src/os/inc/osAlpine.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_OS_ALPINE_H -#define TDENGINE_OS_ALPINE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -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 - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/os/inc/osArm32.h b/src/os/inc/osArm32.h deleted file mode 100644 index 54835a1ca8d95b1b05707f165301ac5defc3e961..0000000000000000000000000000000000000000 --- a/src/os/inc/osArm32.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_OS_ARM32_H -#define TDENGINE_OS_ARM32_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define TAOS_OS_FUNC_LZ4 - #define BUILDIN_CLZL(val) __builtin_clzll(val) - #define BUILDIN_CTZL(val) __builtin_ctzll(val) - #define BUILDIN_CLZ(val) __builtin_clz(val) - #define BUILDIN_CTZ(val) __builtin_ctz(val) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/os/inc/osArm64.h b/src/os/inc/osArm64.h deleted file mode 100644 index 76098f684617abb7d96a17c2a13238b82cb69cef..0000000000000000000000000000000000000000 --- a/src/os/inc/osArm64.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_OS_ARM64_H -#define TDENGINE_OS_ARM64_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/os/inc/osDarwin.h b/src/os/inc/osDarwin.h deleted file mode 100644 index 5b8d27568db325026feec2d79d66bcf09bc3bc97..0000000000000000000000000000000000000000 --- a/src/os/inc/osDarwin.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_OS_DARWIN_H -#define TDENGINE_OS_DARWIN_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "osEok.h" - -// specific -typedef int(*__compar_fn_t)(const void *, const void *); - -// for send function in tsocket.c -#if defined(MSG_NOSIGNAL) -#undef MSG_NOSIGNAL -#endif - -#define MSG_NOSIGNAL 0 - -#define SO_NO_CHECK 0x1234 -#define SOL_TCP 0x1234 -#define TCP_KEEPIDLE 0x1234 - -#ifndef PTHREAD_MUTEX_RECURSIVE_NP - #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE -#endif - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/os/inc/osDef.h b/src/os/inc/osDef.h index 74256e009165d16854225d9c4d40d17e5b378359..7b5e9c84477db8dc1ee8d9afedbf5a04b06dccda 100644 --- a/src/os/inc/osDef.h +++ b/src/os/inc/osDef.h @@ -20,6 +20,109 @@ extern "C" { #endif +#if defined(TD_DARWIN_64) + // specific + typedef int(*__compar_fn_t)(const void *, const void *); + + // for send function in tsocket.c + #if defined(MSG_NOSIGNAL) + #undef MSG_NOSIGNAL + #endif + + #define MSG_NOSIGNAL 0 + + #define SO_NO_CHECK 0x1234 + #define SOL_TCP 0x1234 + #define TCP_KEEPIDLE 0x1234 + + #ifndef PTHREAD_MUTEX_RECURSIVE_NP + #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE + #endif +#endif + +#if defined(_ALPINE) + 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 + +#if defined(_TD_ARM_32) + #define BUILDIN_CTZL(val) __builtin_ctzll(val) + #define BUILDIN_CLZ(val) __builtin_clz(val) + #define BUILDIN_CTZ(val) __builtin_ctz(val) +#endif + +#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) + char *stpcpy (char *dest, const char *src); + char *stpncpy (char *dest, const char *src, size_t n); + + // specific + typedef int (*__compar_fn_t)(const void *, const void *); + #define ssize_t int + #define bzero(ptr, size) memset((ptr), 0, (size)) + #define strcasecmp _stricmp + #define strncasecmp _strnicmp + #define wcsncasecmp _wcsnicmp + #define strtok_r strtok_s + #define snprintf _snprintf + #define in_addr_t unsigned long + #define socklen_t int + + struct tm *localtime_r(const time_t *timep, struct tm *result); + char * strptime(const char *buf, const char *fmt, struct tm *tm); + char * strsep(char **stringp, const char *delim); + char * getpass(const char *prefix); + int flock(int fd, int option); + char * strndup(const char *s, size_t n); + int gettimeofday(struct timeval *ptv, void *pTimeZone); + + // for send function in tsocket.c + #define MSG_NOSIGNAL 0 + #define SO_NO_CHECK 0x1234 + #define SOL_TCP 0x1234 + + #ifndef TCP_KEEPCNT + #define TCP_KEEPCNT 0x1234 + #endif + + #ifndef TCP_KEEPIDLE + #define TCP_KEEPIDLE 0x1234 + #endif + + #ifndef TCP_KEEPINTVL + #define TCP_KEEPINTVL 0x1234 + #endif + + #define SHUT_RDWR SD_BOTH + #define SHUT_RD SD_RECEIVE + #define SHUT_WR SD_SEND + + #define LOCK_EX 1 + #define LOCK_NB 2 + #define LOCK_UN 3 + + #ifndef PATH_MAX + #define PATH_MAX 256 + #endif + + typedef struct { + int we_wordc; + char *we_wordv[1]; + int we_offs; + char wordPos[1025]; + } wordexp_t; + int wordexp(char *words, wordexp_t *pwordexp, int flags); + void wordfree(wordexp_t *pwordexp); + + #define openlog(a, b, c) + #define closelog() + #define LOG_ERR 0 + #define LOG_INFO 1 + void syslog(int unused, const char *format, ...); +#endif + #ifndef WINDOWS #ifndef O_BINARY #define O_BINARY 0 diff --git a/src/os/inc/osInc.h b/src/os/inc/osInc.h new file mode 100644 index 0000000000000000000000000000000000000000..3776501139b816e458297baad12fe597ee13fe16 --- /dev/null +++ b/src/os/inc/osInc.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_OS_LINUX64_H +#define TDENGINE_OS_LINUX64_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(_TD_LINUX_64) || defined(_TD_LINUX_32) || defined(_TD_MIPS_64) || defined(_TD_ARM_32) || defined(_TD_ARM_64) || defined(_TD_DARWIN_64) + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + #if defined(TD_DARWIN_64) + #include + #include "osEok.h" + #else + #include + #include + #include + #include + #include + #include + #include + #include + + #if !(defined(_ALPINE)) + #include + #endif + #endif +#endif + +#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) + #include + #include + #include "winsock2.h" + #include + #include + #include + #include + #include + #include "msvcProcess.h" + #include "msvcDirect.h" + #include "msvcFcntl.h" + #include "msvcLibgen.h" + #include "msvcStdio.h" + #include "msvcUnistd.h" + #include "msvcLibgen.h" + #include "sys/msvcStat.h" + #include "sys/msvcTypes.h" +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/os/inc/osLinux32.h b/src/os/inc/osLinux32.h deleted file mode 100644 index 6d9a01a9a899c60e9dcaa0b9691ae724548bb9a8..0000000000000000000000000000000000000000 --- a/src/os/inc/osLinux32.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_OS_LINUX32_H -#define TDENGINE_OS_LINUX32_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/os/inc/osLinux64.h b/src/os/inc/osLinux64.h deleted file mode 100644 index 0dfc819da339bfba77b5778aa27a8b60c48ca447..0000000000000000000000000000000000000000 --- a/src/os/inc/osLinux64.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_OS_LINUX64_H -#define TDENGINE_OS_LINUX64_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef _ALPINE -#include -#endif -#include -#include - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/os/inc/osMips64.h b/src/os/inc/osMips64.h deleted file mode 100644 index ed7b08a31116d20a8eaaaacfa3a9a64ea75dbcee..0000000000000000000000000000000000000000 --- a/src/os/inc/osMips64.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_OS_MIPS64_H -#define TDENGINE_OS_MIPS64_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/os/inc/osWindows.h b/src/os/inc/osWindows.h deleted file mode 100644 index 5a29471034ccf7c6b1548cfb9ebfba7481b60b7f..0000000000000000000000000000000000000000 --- a/src/os/inc/osWindows.h +++ /dev/null @@ -1,128 +0,0 @@ -/* -* Copyright (c) 2019 TAOS Data, Inc. -* -* This program is free software: you can use, redistribute, and/or modify -* it under the terms of the GNU Affero General Public License, version 3 -* or later ("AGPL"), as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see . -*/ - -#ifndef TDENGINE_OS_WINDOWS_H -#define TDENGINE_OS_WINDOWS_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "winsock2.h" -#include -#include -#include -#include -#include -#include -#include -#include "msvcProcess.h" -#include "msvcDirect.h" -#include "msvcFcntl.h" -#include "msvcLibgen.h" -#include "msvcStdio.h" -#include "msvcUnistd.h" -#include "msvcLibgen.h" -#include "sys/msvcStat.h" -#include "sys/msvcTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -char *stpcpy (char *dest, const char *src); -char *stpncpy (char *dest, const char *src, size_t n); - -// specific -typedef int (*__compar_fn_t)(const void *, const void *); -#define ssize_t int -#define bzero(ptr, size) memset((ptr), 0, (size)) -#define strcasecmp _stricmp -#define strncasecmp _strnicmp -#define wcsncasecmp _wcsnicmp -#define strtok_r strtok_s -#define snprintf _snprintf -#define in_addr_t unsigned long -#define socklen_t int - -struct tm *localtime_r(const time_t *timep, struct tm *result); -char * strptime(const char *buf, const char *fmt, struct tm *tm); -char * strsep(char **stringp, const char *delim); -char * getpass(const char *prefix); -int flock(int fd, int option); -char * strndup(const char *s, size_t n); -int gettimeofday(struct timeval *ptv, void *pTimeZone); - -// for send function in tsocket.c -#define MSG_NOSIGNAL 0 -#define SO_NO_CHECK 0x1234 -#define SOL_TCP 0x1234 - -#ifndef TCP_KEEPCNT - #define TCP_KEEPCNT 0x1234 -#endif - -#ifndef TCP_KEEPIDLE - #define TCP_KEEPIDLE 0x1234 -#endif - -#ifndef TCP_KEEPINTVL - #define TCP_KEEPINTVL 0x1234 -#endif - -#define SHUT_RDWR SD_BOTH -#define SHUT_RD SD_RECEIVE -#define SHUT_WR SD_SEND - -#define LOCK_EX 1 -#define LOCK_NB 2 -#define LOCK_UN 3 - -#ifndef PATH_MAX - #define PATH_MAX 256 -#endif - -typedef struct { - int we_wordc; - char *we_wordv[1]; - int we_offs; - char wordPos[1025]; -} wordexp_t; -int wordexp(char *words, wordexp_t *pwordexp, int flags); -void wordfree(wordexp_t *pwordexp); - -#define openlog(a, b, c) -#define closelog() -#define LOG_ERR 0 -#define LOG_INFO 1 -void syslog(int unused, const char *format, ...); - -#ifdef __cplusplus -} -#endif -#endif