diff --git a/include/util.h b/include/util.h index 23096b08..9f5b22a5 100644 --- a/include/util.h +++ b/include/util.h @@ -51,7 +51,7 @@ uint64_t rdtsc(); #define atomic_read(v) __sync_fetch_and_add((v), (0)) inline int GetRandom(int min, int max) { - static __thread unsigned int tid = (unsigned int) syscall(SYS_gettid); + static thread_local unsigned int tid = (unsigned int) syscall(SYS_gettid); epicLog(LOG_DEBUG, "tid = %d", tid); int ret = (rand_r(&tid) % (max - min)) + min; return ret; diff --git a/src/local_request.cc b/src/local_request.cc index 0cb1b771..064607c3 100644 --- a/src/local_request.cc +++ b/src/local_request.cc @@ -125,7 +125,7 @@ int Worker::ProcessLocalMalloc(WorkRequest* wr) { wr->addr = TO_GLOB(addr, base, GetWorkerId()); wr->status = SUCCESS; ghost_size += wr->size; - if (abs(ghost_size.load()) > conf->ghost_th) + if (labs(ghost_size.load()) > conf->ghost_th) SyncMaster(); } else { wr->status = ALLOC_ERROR; @@ -159,7 +159,7 @@ int Worker::ProcessLocalFree(WorkRequest* wr) { void* addr = ToLocal(wr->addr); Size size = sb.sb_free(addr); ghost_size -= size; - if (abs(ghost_size.load()) > conf->ghost_th) + if (labs(ghost_size.load()) > conf->ghost_th) SyncMaster(); } else { Client* cli = GetClient(wr->addr); diff --git a/src/remote_request.cc b/src/remote_request.cc index f7676d86..e10db9d4 100644 --- a/src/remote_request.cc +++ b/src/remote_request.cc @@ -255,7 +255,7 @@ void Worker::ProcessRequest(Client* client, WorkRequest* wr) { epicAssert(IsLocal(wr->addr)); Size size = sb.sb_free(ToLocal(wr->addr)); ghost_size -= size; - if (abs(ghost_size.load()) > conf->ghost_th) + if (labs(ghost_size.load()) > conf->ghost_th) SyncMaster(); delete wr; wr = nullptr;