提交 ce6aa6d0 编写于 作者: S Shengliang Guan

TD-4088

上级 b4fa11df
...@@ -138,7 +138,7 @@ IF (TD_DARWIN_64) ...@@ -138,7 +138,7 @@ IF (TD_DARWIN_64)
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT) ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
ADD_DEFINITIONS(-DUSE_LIBICONV) ADD_DEFINITIONS(-DUSE_LIBICONV)
MESSAGE(STATUS "darwin64 is defined") MESSAGE(STATUS "darwin64 is defined")
SET(COMMON_FLAGS "-Wall -Werror -Wno-missing-braces -fPIC -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") SET(COMMON_FLAGS "-Wall -Werror -Wno-missing-braces -fPIC -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG") SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG")
SET(RELEASE_FLAGS "-Og") SET(RELEASE_FLAGS "-Og")
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc)
......
...@@ -29,7 +29,7 @@ extern "C" { ...@@ -29,7 +29,7 @@ extern "C" {
#else #else
#define tsem_t sem_t #define tsem_t sem_t
#define tsem_init sem_init #define tsem_init sem_init
int32_t tsem_wait(tsem_t* sem); int tsem_wait(tsem_t* sem);
#define tsem_post sem_post #define tsem_post sem_post
#define tsem_destroy sem_destroy #define tsem_destroy sem_destroy
#endif #endif
......
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
// https://stackoverflow.com/questions/4393197/erlangs-let-it-crash-philosophy-applicable-elsewhere // https://stackoverflow.com/questions/4393197/erlangs-let-it-crash-philosophy-applicable-elsewhere
// experimentally, we follow log-and-crash here // experimentally, we follow log-and-crash here
#include "osEok.h" #define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#include "osEok.h"
#include <sys/event.h> #include <sys/event.h>
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#include <stdint.h>
#include <libproc.h> #include <libproc.h>
// #define SEM_USE_PTHREAD // #define SEM_USE_PTHREAD
...@@ -38,7 +36,7 @@ ...@@ -38,7 +36,7 @@
static pthread_t sem_thread; static pthread_t sem_thread;
static pthread_once_t sem_once; static pthread_once_t sem_once;
static task_t sem_port; static task_t sem_port;
static volatile int32_t sem_inited = 0; static volatile int sem_inited = 0;
static semaphore_t sem_exit; static semaphore_t sem_exit;
static void* sem_thread_routine(void *arg) { static void* sem_thread_routine(void *arg) {
...@@ -56,7 +54,7 @@ static void* sem_thread_routine(void *arg) { ...@@ -56,7 +54,7 @@ static void* sem_thread_routine(void *arg) {
} }
static void once_init(void) { static void once_init(void) {
int32_t r = 0; int r = 0;
r = pthread_create(&sem_thread, NULL, sem_thread_routine, NULL); r = pthread_create(&sem_thread, NULL, sem_thread_routine, NULL);
if (r) { if (r) {
fprintf(stderr, "==%s[%d]%s()==failed to create thread\n", basename(__FILE__), __LINE__, __func__); fprintf(stderr, "==%s[%d]%s()==failed to create thread\n", basename(__FILE__), __LINE__, __func__);
...@@ -82,10 +80,10 @@ struct tsem_s { ...@@ -82,10 +80,10 @@ struct tsem_s {
dispatch_semaphore_t sem; dispatch_semaphore_t sem;
#endif // SEM_USE_PTHREAD #endif // SEM_USE_PTHREAD
volatile unsigned int32_t valid:1; volatile unsigned int valid:1;
}; };
int32_t tsem_init(tsem_t *sem, int32_t pshared, unsigned int32_t value) { int tsem_init(tsem_t *sem, int pshared, unsigned int value) {
// fprintf(stderr, "==%s[%d]%s():[%p]==creating\n", basename(__FILE__), __LINE__, __func__, sem); // fprintf(stderr, "==%s[%d]%s():[%p]==creating\n", basename(__FILE__), __LINE__, __func__, sem);
if (*sem) { if (*sem) {
fprintf(stderr, "==%s[%d]%s():[%p]==already initialized\n", basename(__FILE__), __LINE__, __func__, sem); fprintf(stderr, "==%s[%d]%s():[%p]==already initialized\n", basename(__FILE__), __LINE__, __func__, sem);
...@@ -98,7 +96,7 @@ int32_t tsem_init(tsem_t *sem, int32_t pshared, unsigned int32_t value) { ...@@ -98,7 +96,7 @@ int32_t tsem_init(tsem_t *sem, int32_t pshared, unsigned int32_t value) {
} }
#ifdef SEM_USE_PTHREAD #ifdef SEM_USE_PTHREAD
int32_t r = pthread_mutex_init(&p->lock, NULL); int r = pthread_mutex_init(&p->lock, NULL);
do { do {
if (r) break; if (r) break;
r = pthread_cond_init(&p->cond, NULL); r = pthread_cond_init(&p->cond, NULL);
...@@ -125,7 +123,7 @@ int32_t tsem_init(tsem_t *sem, int32_t pshared, unsigned int32_t value) { ...@@ -125,7 +123,7 @@ int32_t tsem_init(tsem_t *sem, int32_t pshared, unsigned int32_t value) {
p->sem = sem_open(name, O_CREAT|O_EXCL, pshared, value); p->sem = sem_open(name, O_CREAT|O_EXCL, pshared, value);
p->id = id; p->id = id;
if (p->sem!=SEM_FAILED) break; if (p->sem!=SEM_FAILED) break;
int32_t e = errno; int e = errno;
if (e==EEXIST) continue; if (e==EEXIST) continue;
if (e==EINTR) continue; if (e==EINTR) continue;
fprintf(stderr, "==%s[%d]%s():[%p]==not created[%d]%s\n", basename(__FILE__), __LINE__, __func__, sem, e, strerror(e)); fprintf(stderr, "==%s[%d]%s():[%p]==not created[%d]%s\n", basename(__FILE__), __LINE__, __func__, sem, e, strerror(e));
...@@ -159,7 +157,7 @@ int32_t tsem_init(tsem_t *sem, int32_t pshared, unsigned int32_t value) { ...@@ -159,7 +157,7 @@ int32_t tsem_init(tsem_t *sem, int32_t pshared, unsigned int32_t value) {
return 0; return 0;
} }
int32_t tsem_wait(tsem_t *sem) { int tsem_wait(tsem_t *sem) {
if (!*sem) { if (!*sem) {
fprintf(stderr, "==%s[%d]%s():[%p]==not initialized\n", basename(__FILE__), __LINE__, __func__, sem); fprintf(stderr, "==%s[%d]%s():[%p]==not initialized\n", basename(__FILE__), __LINE__, __func__, sem);
abort(); abort();
...@@ -195,7 +193,7 @@ int32_t tsem_wait(tsem_t *sem) { ...@@ -195,7 +193,7 @@ int32_t tsem_wait(tsem_t *sem) {
#endif // SEM_USE_PTHREAD #endif // SEM_USE_PTHREAD
} }
int32_t tsem_post(tsem_t *sem) { int tsem_post(tsem_t *sem) {
if (!*sem) { if (!*sem) {
fprintf(stderr, "==%s[%d]%s():[%p]==not initialized\n", basename(__FILE__), __LINE__, __func__, sem); fprintf(stderr, "==%s[%d]%s():[%p]==not initialized\n", basename(__FILE__), __LINE__, __func__, sem);
abort(); abort();
...@@ -231,7 +229,7 @@ int32_t tsem_post(tsem_t *sem) { ...@@ -231,7 +229,7 @@ int32_t tsem_post(tsem_t *sem) {
#endif // SEM_USE_PTHREAD #endif // SEM_USE_PTHREAD
} }
int32_t tsem_destroy(tsem_t *sem) { int tsem_destroy(tsem_t *sem) {
// fprintf(stderr, "==%s[%d]%s():[%p]==destroying\n", basename(__FILE__), __LINE__, __func__, sem); // fprintf(stderr, "==%s[%d]%s():[%p]==destroying\n", basename(__FILE__), __LINE__, __func__, sem);
if (!*sem) { if (!*sem) {
// fprintf(stderr, "==%s[%d]%s():[%p]==not initialized\n", basename(__FILE__), __LINE__, __func__, sem); // fprintf(stderr, "==%s[%d]%s():[%p]==not initialized\n", basename(__FILE__), __LINE__, __func__, sem);
...@@ -265,9 +263,9 @@ int32_t tsem_destroy(tsem_t *sem) { ...@@ -265,9 +263,9 @@ int32_t tsem_destroy(tsem_t *sem) {
#elif defined(SEM_USE_POSIX) #elif defined(SEM_USE_POSIX)
char name[NAME_MAX-4]; char name[NAME_MAX-4];
snprintf(name, sizeof(name), "/t%ld", p->id); snprintf(name, sizeof(name), "/t%ld", p->id);
int32_t r = sem_unlink(name); int r = sem_unlink(name);
if (r) { if (r) {
int32_t e = errno; int e = errno;
fprintf(stderr, "==%s[%d]%s():[%p]==unlink failed[%d]%s\n", basename(__FILE__), __LINE__, __func__, sem, e, strerror(e)); fprintf(stderr, "==%s[%d]%s():[%p]==unlink failed[%d]%s\n", basename(__FILE__), __LINE__, __func__, sem, e, strerror(e));
abort(); abort();
} }
...@@ -285,7 +283,7 @@ int32_t tsem_destroy(tsem_t *sem) { ...@@ -285,7 +283,7 @@ int32_t tsem_destroy(tsem_t *sem) {
bool taosCheckPthreadValid(pthread_t thread) { bool taosCheckPthreadValid(pthread_t thread) {
uint64_t id = 0; uint64_t id = 0;
int32_t r = pthread_threadid_np(thread, &id); int r = pthread_threadid_np(thread, &id);
return r ? false : true; return r ? false : true;
} }
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <errno.h> #include <errno.h>
#include <libproc.h> #include <libproc.h>
static void taosGetSystemTimezone() { static void taosGetSystemTimezone() {
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone"); SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
if (cfg_timezone == NULL) return; if (cfg_timezone == NULL) return;
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "ttimer.h" #include "ttimer.h"
#include "tulog.h" #include "tulog.h"
#if !(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)) #if !(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) || defined(_TD_DARWIN_64))
static void taosDeleteTimer(void *tharg) { static void taosDeleteTimer(void *tharg) {
timer_t *pTimer = tharg; timer_t *pTimer = tharg;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册