1 /* 2 * kmp_wrapper_getpid.h -- getpid() declaration. 3 */ 4 5 6 //===----------------------------------------------------------------------===// 7 // 8 // The LLVM Compiler Infrastructure 9 // 10 // This file is dual licensed under the MIT and the University of Illinois Open 11 // Source Licenses. See LICENSE.txt for details. 12 // 13 //===----------------------------------------------------------------------===// 14 15 16 #ifndef KMP_WRAPPER_GETPID_H 17 #define KMP_WRAPPER_GETPID_H 18 19 #if KMP_OS_UNIX 20 21 // On Unix-like systems (Linux* OS and OS X*) getpid() is declared in standard headers. 22 #include <sys/types.h> 23 #include <unistd.h> 24 25 #elif KMP_OS_WINDOWS 26 27 // On Windows* OS _getpid() returns int (not pid_t) and is declared in "process.h". 28 #include <process.h> 29 // Let us simulate Unix. 30 typedef int pid_t; 31 #define getpid _getpid 32 33 #else 34 35 #error Unknown or unsupported OS. 36 37 #endif 38 39 /* 40 TODO: All the libomp source code uses pid_t type for storing the result of getpid(), it is good. 41 But often it printed as "%d", that is not good, because it ignores pid_t definition (may pid_t 42 be longer that int?). It seems all pid prints should be rewritten as 43 44 printf( "%" KMP_UINT64_SPEC, (kmp_uint64) pid ); 45 46 or (at least) as 47 48 printf( "%" KMP_UINT32_SPEC, (kmp_uint32) pid ); 49 50 (kmp_uint32, kmp_uint64, KMP_UINT64_SPEC, and KMP_UNIT32_SPEC are defined in "kmp_os.h".) 51 52 */ 53 54 #endif // KMP_WRAPPER_GETPID_H 55 56 // end of file // 57