From c7ece60e2d3715a1b37973fd503eea0848a795d5 Mon Sep 17 00:00:00 2001 From: liaogang Date: Mon, 12 Sep 2016 19:43:12 +0800 Subject: [PATCH] add gettid syscall for MAC OS --- paddle/utils/Stat.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/paddle/utils/Stat.cpp b/paddle/utils/Stat.cpp index 14aae6909d4..aab5446a98c 100644 --- a/paddle/utils/Stat.cpp +++ b/paddle/utils/Stat.cpp @@ -23,10 +23,14 @@ namespace paddle { // return the thread id used by glog pid_t getTID() { -#ifndef __NR_gettid -#define __NR_gettid 224 -#endif - pid_t tid = syscall(__NR_gettid); + #if defined(__APPLE__) || defined(__OSX__) + pid_t tid = syscall(SYS_thread_selfid); + #elif defined(__LINUX__) + #ifndef __NR_gettid + #define __NR_gettid 224 + #endif + pid_t tid = syscall(__NR_gettid); + #endif CHECK_NE(tid, -1); return tid; } -- GitLab