- Notifications
You must be signed in to change notification settings - Fork 31.7k
/
Copy pathmultiprocessing.h
103 lines (88 loc) · 2.34 KB
/
multiprocessing.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndefMULTIPROCESSING_H
#defineMULTIPROCESSING_H
#definePY_SSIZE_T_CLEAN
#include"Python.h"
#include"structmember.h"
#include"pythread.h"
/*
* Platform includes and definitions
*/
#ifdefMS_WINDOWS
# defineWIN32_LEAN_AND_MEAN
# include<windows.h>
# include<winsock2.h>
# include<process.h>/* getpid() */
# ifdefPy_DEBUG
# include<crtdbg.h>
# endif
# defineSEM_HANDLE HANDLE
# defineSEM_VALUE_MAX LONG_MAX
#else
# include<fcntl.h>/* O_CREAT and O_EXCL */
# if defined(HAVE_SEM_OPEN) && !defined(POSIX_SEMAPHORES_NOT_ENABLED)
# include<semaphore.h>
typedefsem_t*SEM_HANDLE;
# endif
# defineHANDLE int
# defineSOCKET int
# defineBOOL int
# defineUINT32 uint32_t
# defineINT32 int32_t
# defineTRUE 1
# defineFALSE 0
# defineINVALID_HANDLE_VALUE (-1)
#endif
/*
* Issue 3110 - Solaris does not define SEM_VALUE_MAX
*/
#ifndefSEM_VALUE_MAX
#if defined(HAVE_SYSCONF) && defined(_SC_SEM_VALUE_MAX)
# defineSEM_VALUE_MAX sysconf(_SC_SEM_VALUE_MAX)
#elif defined(_SEM_VALUE_MAX)
# defineSEM_VALUE_MAX _SEM_VALUE_MAX
#elif defined(_POSIX_SEM_VALUE_MAX)
# defineSEM_VALUE_MAX _POSIX_SEM_VALUE_MAX
#else
# defineSEM_VALUE_MAX INT_MAX
#endif
#endif
/*
* Format codes
*/
#ifSIZEOF_VOID_P==SIZEOF_LONG
# defineF_POINTER "k"
# defineT_POINTER T_ULONG
#elifSIZEOF_VOID_P==SIZEOF_LONG_LONG
# defineF_POINTER "K"
# defineT_POINTER T_ULONGLONG
#else
# error "can't find format code for unsigned integer of same size as void*"
#endif
#ifdefMS_WINDOWS
# defineF_HANDLE F_POINTER
# defineT_HANDLE T_POINTER
# defineF_SEM_HANDLE F_HANDLE
# defineT_SEM_HANDLE T_HANDLE
# defineF_DWORD "k"
# defineT_DWORD T_ULONG
#else
# defineF_HANDLE "i"
# defineT_HANDLE T_INT
# defineF_SEM_HANDLE F_POINTER
# defineT_SEM_HANDLE T_POINTER
#endif
/*
* Error codes which can be returned by functions called without GIL
*/
#defineMP_SUCCESS (0)
#defineMP_STANDARD_ERROR (-1)
#defineMP_MEMORY_ERROR (-1001)
#defineMP_SOCKET_ERROR (-1002)
#defineMP_EXCEPTION_HAS_BEEN_SET (-1003)
PyObject*_PyMp_SetError(PyObject*Type, intnum);
/*
* Externs - not all will really exist on all platforms
*/
externPyTypeObject_PyMp_SemLockType;
externPyObject*_PyMp_sem_unlink(PyObject*ignore, PyObject*args);
#endif/* MULTIPROCESSING_H */