From ddd9c137c0d02f7254dc8d44d187b5aa72053b45 Mon Sep 17 00:00:00 2001 From: slguan Date: Mon, 1 Feb 2021 15:59:17 +0800 Subject: [PATCH] compile error in mac --- src/os/inc/osSemphone.h | 11 +++++++++-- src/os/src/darwin/darwinSysInfo.c | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/os/inc/osSemphone.h b/src/os/inc/osSemphone.h index 7c64aa80e5..3332a9234b 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 394fd7debe..bce60429c5 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) { -- GitLab