diff --git a/src/os/inc/osDarwin.h b/src/os/inc/osDarwin.h index f8e3c65d63f6da7649a7ffc113b3f7ac17c66886..c90f604f6ea90e0229f149e491953f03e79d6fb4 100644 --- a/src/os/inc/osDarwin.h +++ b/src/os/inc/osDarwin.h @@ -74,17 +74,9 @@ extern "C" { #define TAOS_OS_FUNC_FILE_SENDIFLE -#define TAOS_OS_FUNC_SEMPHONE - typedef struct tsem_s *tsem_t; - int tsem_init(tsem_t *sem, int pshared, unsigned int value); - int tsem_wait(tsem_t *sem); - int tsem_post(tsem_t *sem); - int tsem_destroy(tsem_t *sem); - #define TAOS_OS_FUNC_SOCKET_SETSOCKETOPT #define TAOS_OS_FUNC_SYSINFO -#define TAOS_OS_FUNC_TIMER -#define TAOS_OS_FUNC_SEMPHONE_PTHREAD +#define TAOS_OS_FUNC_TIMERD // specific typedef int(*__compar_fn_t)(const void *, const void *); @@ -104,8 +96,6 @@ typedef int(*__compar_fn_t)(const void *, const void *); #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE #endif -#define TAOS_OS_FUNC_PTHREAD_RWLOCK - #include "eok.h" void taos_block_sigalrm(void); diff --git a/src/os/inc/osSemphone.h b/src/os/inc/osSemphone.h index 3332a9234b040aaa49c1d097e63f03a6c9bde25b..2e2d432607bdc96de63edf5993345f9780452c1f 100644 --- a/src/os/inc/osSemphone.h +++ b/src/os/inc/osSemphone.h @@ -20,15 +20,21 @@ extern "C" { #endif -#ifndef TAOS_OS_FUNC_SEMPHONE +#if defined (_TD_DARWIN_64) + typedef struct tsem_s *tsem_t; + int tsem_init(tsem_t *sem, int pshared, unsigned int value); + int tsem_wait(tsem_t *sem); + int tsem_post(tsem_t *sem); + int tsem_destroy(tsem_t *sem); +#else #define tsem_t sem_t #define tsem_init sem_init - int tsem_wait(tsem_t* sem); + int32_t tsem_wait(tsem_t* sem); #define tsem_post sem_post #define tsem_destroy sem_destroy #endif -#ifdef TAOS_OS_FUNC_PTHREAD_RWLOCK +#if defined (_TD_DARWIN_64) #define pthread_rwlock_t pthread_mutex_t #define pthread_rwlock_init(lock, NULL) pthread_mutex_init(lock, NULL) #define pthread_rwlock_destroy(lock) pthread_mutex_destroy(lock) @@ -43,7 +49,6 @@ extern "C" { #define pthread_spin_unlock(lock) pthread_mutex_unlock(lock) #endif -// TAOS_OS_FUNC_SEMPHONE_PTHREAD bool taosCheckPthreadValid(pthread_t thread); int64_t taosGetSelfPthreadId(); int64_t taosGetPthreadId(pthread_t thread); diff --git a/src/os/inc/osString.h b/src/os/inc/osString.h index f2e8b381fe7d4f6d48bc30ec902c1ef576064e78..33f858485c4291f7c7c9098685c8c70a02799fe6 100644 --- a/src/os/inc/osString.h +++ b/src/os/inc/osString.h @@ -28,7 +28,7 @@ extern "C" { #else #define tstrdup(str) strdup(str) #define tstrndup(str, size) strndup(str, size) - #define tgetline(lineptr, n, stream) getline(lineptr, n , stream) + #define tgetline(lineptr, n, stream) getline(lineptr, n, stream) #define twcslen wcslen #endif diff --git a/src/os/inc/osWindows.h b/src/os/inc/osWindows.h index f90ae6f059442722c4a4d458b37455ee1519881b..bfb3811176ed691120df19303a94db416359a6a9 100644 --- a/src/os/inc/osWindows.h +++ b/src/os/inc/osWindows.h @@ -65,7 +65,6 @@ extern "C" { #define TAOS_OS_FUNC_FILE_FTRUNCATE -#define TAOS_OS_FUNC_SEMPHONE_PTHREAD #define TAOS_OS_FUNC_SOCKET #define TAOS_OS_FUNC_SOCKET_SETSOCKETOPT diff --git a/src/os/src/darwin/darwinSemphone.c b/src/os/src/darwin/darwinSemphone.c index 5bb926732a99a1c2094366624b2a0577c85528d2..1805fd176fad22355c4ef1bc6535574cab072a83 100644 --- a/src/os/src/darwin/darwinSemphone.c +++ b/src/os/src/darwin/darwinSemphone.c @@ -37,7 +37,7 @@ static pthread_t sem_thread; static pthread_once_t sem_once; static task_t sem_port; -static volatile int sem_inited = 0; +static volatile int32_t sem_inited = 0; static semaphore_t sem_exit; static void* sem_thread_routine(void *arg) { @@ -55,7 +55,7 @@ static void* sem_thread_routine(void *arg) { } static void once_init(void) { - int r = 0; + int32_t r = 0; r = pthread_create(&sem_thread, NULL, sem_thread_routine, NULL); if (r) { fprintf(stderr, "==%s[%d]%s()==failed to create thread\n", basename(__FILE__), __LINE__, __func__); @@ -81,10 +81,10 @@ struct tsem_s { dispatch_semaphore_t sem; #endif // SEM_USE_PTHREAD - volatile unsigned int valid:1; + volatile unsigned int32_t valid:1; }; -int tsem_init(tsem_t *sem, int pshared, unsigned int value) { +int32_t tsem_init(tsem_t *sem, int32_t pshared, unsigned int32_t value) { // fprintf(stderr, "==%s[%d]%s():[%p]==creating\n", basename(__FILE__), __LINE__, __func__, sem); if (*sem) { fprintf(stderr, "==%s[%d]%s():[%p]==already initialized\n", basename(__FILE__), __LINE__, __func__, sem); @@ -97,7 +97,7 @@ int tsem_init(tsem_t *sem, int pshared, unsigned int value) { } #ifdef SEM_USE_PTHREAD - int r = pthread_mutex_init(&p->lock, NULL); + int32_t r = pthread_mutex_init(&p->lock, NULL); do { if (r) break; r = pthread_cond_init(&p->cond, NULL); @@ -124,7 +124,7 @@ int tsem_init(tsem_t *sem, int pshared, unsigned int value) { p->sem = sem_open(name, O_CREAT|O_EXCL, pshared, value); p->id = id; if (p->sem!=SEM_FAILED) break; - int e = errno; + int32_t e = errno; if (e==EEXIST) continue; if (e==EINTR) continue; fprintf(stderr, "==%s[%d]%s():[%p]==not created[%d]%s\n", basename(__FILE__), __LINE__, __func__, sem, e, strerror(e)); @@ -158,7 +158,7 @@ int tsem_init(tsem_t *sem, int pshared, unsigned int value) { return 0; } -int tsem_wait(tsem_t *sem) { +int32_t tsem_wait(tsem_t *sem) { if (!*sem) { fprintf(stderr, "==%s[%d]%s():[%p]==not initialized\n", basename(__FILE__), __LINE__, __func__, sem); abort(); @@ -194,7 +194,7 @@ int tsem_wait(tsem_t *sem) { #endif // SEM_USE_PTHREAD } -int tsem_post(tsem_t *sem) { +int32_t tsem_post(tsem_t *sem) { if (!*sem) { fprintf(stderr, "==%s[%d]%s():[%p]==not initialized\n", basename(__FILE__), __LINE__, __func__, sem); abort(); @@ -230,7 +230,7 @@ int tsem_post(tsem_t *sem) { #endif // SEM_USE_PTHREAD } -int tsem_destroy(tsem_t *sem) { +int32_t tsem_destroy(tsem_t *sem) { // fprintf(stderr, "==%s[%d]%s():[%p]==destroying\n", basename(__FILE__), __LINE__, __func__, sem); if (!*sem) { // fprintf(stderr, "==%s[%d]%s():[%p]==not initialized\n", basename(__FILE__), __LINE__, __func__, sem); @@ -264,9 +264,9 @@ int tsem_destroy(tsem_t *sem) { #elif defined(SEM_USE_POSIX) char name[NAME_MAX-4]; snprintf(name, sizeof(name), "/t%ld", p->id); - int r = sem_unlink(name); + int32_t r = sem_unlink(name); if (r) { - int e = errno; + int32_t e = errno; fprintf(stderr, "==%s[%d]%s():[%p]==unlink failed[%d]%s\n", basename(__FILE__), __LINE__, __func__, sem, e, strerror(e)); abort(); } @@ -284,7 +284,7 @@ int tsem_destroy(tsem_t *sem) { bool taosCheckPthreadValid(pthread_t thread) { uint64_t id = 0; - int r = pthread_threadid_np(thread, &id); + int32_t r = pthread_threadid_np(thread, &id); return r ? false : true; } diff --git a/src/os/src/detail/osSemphone.c b/src/os/src/detail/osSemphone.c index 2bf2f2448752bf468497fc48a8871c5f0120b9ab..06907d52582e8cdb5cfdbe6da4724c4cf2bc8151 100644 --- a/src/os/src/detail/osSemphone.c +++ b/src/os/src/detail/osSemphone.c @@ -16,9 +16,9 @@ #define _DEFAULT_SOURCE #include "os.h" -#ifndef TAOS_OS_FUNC_SEMPHONE +#if !defined (_TD_DARWIN_64) -int tsem_wait(tsem_t* sem) { +int32_t tsem_wait(tsem_t* sem) { int ret = 0; do { ret = sem_wait(sem); @@ -28,9 +28,9 @@ int tsem_wait(tsem_t* sem) { #endif -#ifndef TAOS_OS_FUNC_SEMPHONE_PTHREAD +#if !(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) || defined (_TD_DARWIN_64)) -bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; } +bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; } int64_t taosGetSelfPthreadId() { static __thread int id = 0; diff --git a/src/os/src/windows/wGetline.c b/src/os/src/windows/wGetline.c index b9d8ccf928b38a647de5655ed361f43f60d05778..553aecaf0a9be65fb5d532668d28ee1a77fbbd39 100644 --- a/src/os/src/windows/wGetline.c +++ b/src/os/src/windows/wGetline.c @@ -22,6 +22,7 @@ General Public License for more details. */ #include #include #include +#include #if STDC_HEADERS #include