diff options
Diffstat (limited to 'openmp/runtime/src/kmp_wrapper_getpid.h')
-rw-r--r-- | openmp/runtime/src/kmp_wrapper_getpid.h | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/openmp/runtime/src/kmp_wrapper_getpid.h b/openmp/runtime/src/kmp_wrapper_getpid.h index 68c2be7915f..490e5cb10ff 100644 --- a/openmp/runtime/src/kmp_wrapper_getpid.h +++ b/openmp/runtime/src/kmp_wrapper_getpid.h @@ -18,50 +18,52 @@ #if KMP_OS_UNIX - // On Unix-like systems (Linux* OS and OS X*) getpid() is declared in standard headers. - #include <sys/types.h> - #include <unistd.h> - #include <sys/syscall.h> - #if KMP_OS_DARWIN - //OS X - #define __kmp_gettid() syscall(SYS_thread_selfid) - #elif defined(SYS_gettid) - // Hopefully other Unix systems define SYS_gettid syscall for getting os thread id - #define __kmp_gettid() syscall(SYS_gettid) - #else - #warning No gettid found, use getpid instead - #define __kmp_gettid() getpid() - #endif +// On Unix-like systems (Linux* OS and OS X*) getpid() is declared in standard +// headers. +#include <sys/syscall.h> +#include <sys/types.h> +#include <unistd.h> +#if KMP_OS_DARWIN +// OS X +#define __kmp_gettid() syscall(SYS_thread_selfid) +#elif defined(SYS_gettid) +// Hopefully other Unix systems define SYS_gettid syscall for getting os thread +// id +#define __kmp_gettid() syscall(SYS_gettid) +#else +#warning No gettid found, use getpid instead +#define __kmp_gettid() getpid() +#endif #elif KMP_OS_WINDOWS - // On Windows* OS _getpid() returns int (not pid_t) and is declared in "process.h". - #include <process.h> - // Let us simulate Unix. - typedef int pid_t; - #define getpid _getpid - #define __kmp_gettid() GetCurrentThreadId() +// On Windows* OS _getpid() returns int (not pid_t) and is declared in +// "process.h". +#include <process.h> +// Let us simulate Unix. +typedef int pid_t; +#define getpid _getpid +#define __kmp_gettid() GetCurrentThreadId() #else - #error Unknown or unsupported OS. +#error Unknown or unsupported OS. #endif -/* - TODO: All the libomp source code uses pid_t type for storing the result of getpid(), it is good. - But often it printed as "%d", that is not good, because it ignores pid_t definition (may pid_t - be longer that int?). It seems all pid prints should be rewritten as - - printf( "%" KMP_UINT64_SPEC, (kmp_uint64) pid ); +/* TODO: All the libomp source code uses pid_t type for storing the result of + getpid(), it is good. But often it printed as "%d", that is not good, because + it ignores pid_t definition (may pid_t be longer that int?). It seems all pid + prints should be rewritten as: - or (at least) as + printf( "%" KMP_UINT64_SPEC, (kmp_uint64) pid ); - printf( "%" KMP_UINT32_SPEC, (kmp_uint32) pid ); + or (at least) as - (kmp_uint32, kmp_uint64, KMP_UINT64_SPEC, and KMP_UNIT32_SPEC are defined in "kmp_os.h".) + printf( "%" KMP_UINT32_SPEC, (kmp_uint32) pid ); -*/ + (kmp_uint32, kmp_uint64, KMP_UINT64_SPEC, and KMP_UNIT32_SPEC are defined in + "kmp_os.h".) */ #endif // KMP_WRAPPER_GETPID_H |