diff --git a/src/os/inc/osSemphone.h b/src/os/inc/osSemphone.h index 7c64aa80e5e21dfad42ff48e3841167ac24f9482..3332a9234b040aaa49c1d097e63f03a6c9bde25b 100644 --- a/src/os/inc/osSemphone.h +++ b/src/os/inc/osSemphone.h @@ -30,10 +30,17 @@ extern "C" { #ifdef TAOS_OS_FUNC_PTHREAD_RWLOCK #define pthread_rwlock_t pthread_mutex_t - #define pthread_rwlock_init(lock) pthread_mutex_init(lock) - #define pthread_mutex_destroy(lock) pthread_mutex_destroy(lock) + #define pthread_rwlock_init(lock, NULL) pthread_mutex_init(lock, NULL) + #define pthread_rwlock_destroy(lock) pthread_mutex_destroy(lock) #define pthread_rwlock_wrlock(lock) pthread_mutex_lock(lock) + #define pthread_rwlock_rdlock(lock) pthread_mutex_lock(lock) #define pthread_rwlock_unlock(lock) pthread_mutex_unlock(lock) + + #define pthread_spinlock_t pthread_mutex_t + #define pthread_spin_init(lock, NULL) pthread_mutex_init(lock, NULL) + #define pthread_spin_destroy(lock) pthread_mutex_destroy(lock) + #define pthread_spin_lock(lock) pthread_mutex_lock(lock) + #define pthread_spin_unlock(lock) pthread_mutex_unlock(lock) #endif // TAOS_OS_FUNC_SEMPHONE_PTHREAD diff --git a/src/os/src/darwin/darwinSysInfo.c b/src/os/src/darwin/darwinSysInfo.c index 394fd7debe6fe9929b2b2df0d20a19df3e405793..bce60429c5efa3358928b74dcd297b473e877587 100644 --- a/src/os/src/darwin/darwinSysInfo.c +++ b/src/os/src/darwin/darwinSysInfo.c @@ -18,6 +18,7 @@ #include "tconfig.h" #include "tglobal.h" #include "tulog.h" +#include "taoserror.h" #include #include @@ -70,8 +71,6 @@ void taosGetSystemInfo() { taosGetSystemLocale(); } -void taosGetDisk() {} - bool taosGetProcIO(float *readKB, float *writeKB) { *readKB = 0; *writeKB = 0; @@ -106,6 +105,19 @@ int taosSystem(const char *cmd) { void taosSetCoreDump() {} +int32_t taosGetDiskSize(char *dataDir, SysDiskSize *diskSize) { + struct statvfs info; + if (statvfs(tsDataDir, &info)) { + uError("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno)); + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } else { + diskSize->tsize = info.f_blocks * info.f_frsize; + diskSize->avail = info.f_bavail * info.f_frsize; + return 0; + } +} + char cmdline[1024]; char *taosGetCmdlineByPID(int pid) {