1
#ifndef MULTIPROCESSING_H
2
#define MULTIPROCESSING_H
4
#define PY_SSIZE_T_CLEAN
7
#include "structmember.h"
11
* Platform includes and definitions
15
# define WIN32_LEAN_AND_MEAN
17
# include <winsock2.h>
18
# include <process.h> /* getpid() */
19
# define SEM_HANDLE HANDLE
20
# define SEM_VALUE_MAX LONG_MAX
22
# include <fcntl.h> /* O_CREAT and O_EXCL */
23
# include <netinet/in.h>
24
# include <sys/socket.h>
26
# include <arpa/inet.h> /* htonl() and ntohl() */
28
# include <semaphore.h>
29
typedef sem_t *SEM_HANDLE;
34
# define UINT32 uint32_t
35
# define INT32 int32_t
38
# define INVALID_HANDLE_VALUE (-1)
42
* Issue 3110 - Solaris does not define SEM_VALUE_MAX
45
# ifdef _SEM_VALUE_MAX
46
# define SEM_VALUE_MAX _SEM_VALUE_MAX
48
# define SEM_VALUE_MAX INT_MAX
53
* Make sure Py_ssize_t available
56
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
57
typedef int Py_ssize_t;
58
# define PY_SSIZE_T_MAX INT_MAX
59
# define PY_SSIZE_T_MIN INT_MIN
60
# define F_PY_SSIZE_T "i"
61
# define PyInt_FromSsize_t(n) PyInt_FromLong((long)n)
63
# define F_PY_SSIZE_T "n"
70
#if SIZEOF_VOID_P == SIZEOF_LONG
71
# define F_POINTER "k"
72
# define T_POINTER T_ULONG
73
#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P == SIZEOF_LONG_LONG)
74
# define F_POINTER "K"
75
# define T_POINTER T_ULONGLONG
77
# error "can't find format code for unsigned integer of same size as void*"
81
# define F_HANDLE F_POINTER
82
# define T_HANDLE T_POINTER
83
# define F_SEM_HANDLE F_HANDLE
84
# define T_SEM_HANDLE T_HANDLE
86
# define T_DWORD T_ULONG
89
# define T_HANDLE T_INT
90
# define F_SEM_HANDLE F_POINTER
91
# define T_SEM_HANDLE T_POINTER
94
#if PY_VERSION_HEX >= 0x03000000
95
# define F_RBUFFER "y"
97
# define F_RBUFFER "s"
101
* Error codes which can be returned by functions called without GIL
104
#define MP_SUCCESS (0)
105
#define MP_STANDARD_ERROR (-1)
106
#define MP_MEMORY_ERROR (-1001)
107
#define MP_END_OF_FILE (-1002)
108
#define MP_EARLY_END_OF_FILE (-1003)
109
#define MP_BAD_MESSAGE_LENGTH (-1004)
110
#define MP_SOCKET_ERROR (-1005)
111
#define MP_EXCEPTION_HAS_BEEN_SET (-1006)
113
PyObject *mp_SetError(PyObject *Type, int num);
116
* Externs - not all will really exist on all platforms
119
extern PyObject *pickle_dumps;
120
extern PyObject *pickle_loads;
121
extern PyObject *pickle_protocol;
122
extern PyObject *BufferTooShort;
123
extern PyTypeObject SemLockType;
124
extern PyTypeObject ConnectionType;
125
extern PyTypeObject PipeConnectionType;
126
extern HANDLE sigint_event;
132
#if PY_VERSION_HEX >= 0x03000000
133
# define PICKLE_MODULE "pickle"
134
# define FROM_FORMAT PyUnicode_FromFormat
135
# define PyInt_FromLong PyLong_FromLong
136
# define PyInt_FromSsize_t PyLong_FromSsize_t
138
# define PICKLE_MODULE "cPickle"
139
# define FROM_FORMAT PyString_FromFormat
142
#ifndef PyVarObject_HEAD_INIT
143
# define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
146
#ifndef Py_TPFLAGS_HAVE_WEAKREFS
147
# define Py_TPFLAGS_HAVE_WEAKREFS 0
151
* Connection definition
154
#define CONNECTION_BUFFER_SIZE 1024
160
PyObject *weakreflist;
161
char buffer[CONNECTION_BUFFER_SIZE];
168
#define MAX_MESSAGE_LENGTH 0x7fffffff
171
# define MIN(x, y) ((x) < (y) ? x : y)
172
# define MAX(x, y) ((x) > (y) ? x : y)
175
#endif /* MULTIPROCESSING_H */