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