Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Extension module used by multiprocessing package |
| 3 | * |
| 4 | * multiprocessing.c |
| 5 | * |
| 6 | * Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt |
| 7 | */ |
| 8 | |
| 9 | #include "multiprocessing.h" |
| 10 | |
Benjamin Peterson | 965ce87 | 2009-04-05 21:24:58 +0000 | [diff] [blame] | 11 | #ifdef SCM_RIGHTS |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 12 | #define HAVE_FD_TRANSFER 1 |
Benjamin Peterson | 965ce87 | 2009-04-05 21:24:58 +0000 | [diff] [blame] | 13 | #else |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 14 | #define HAVE_FD_TRANSFER 0 |
Benjamin Peterson | 965ce87 | 2009-04-05 21:24:58 +0000 | [diff] [blame] | 15 | #endif |
| 16 | |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 17 | PyObject *create_win32_namespace(void); |
| 18 | |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 19 | PyObject *ProcessError, *BufferTooShort; |
| 20 | |
| 21 | /* |
| 22 | * Function which raises exceptions based on error codes |
| 23 | */ |
| 24 | |
| 25 | PyObject * |
| 26 | mp_SetError(PyObject *Type, int num) |
| 27 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 28 | switch (num) { |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 29 | #ifdef MS_WINDOWS |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 30 | case MP_STANDARD_ERROR: |
| 31 | if (Type == NULL) |
| 32 | Type = PyExc_WindowsError; |
| 33 | PyErr_SetExcFromWindowsErr(Type, 0); |
| 34 | break; |
| 35 | case MP_SOCKET_ERROR: |
| 36 | if (Type == NULL) |
| 37 | Type = PyExc_WindowsError; |
| 38 | PyErr_SetExcFromWindowsErr(Type, WSAGetLastError()); |
| 39 | break; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 40 | #else /* !MS_WINDOWS */ |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 41 | case MP_STANDARD_ERROR: |
| 42 | case MP_SOCKET_ERROR: |
| 43 | if (Type == NULL) |
| 44 | Type = PyExc_OSError; |
| 45 | PyErr_SetFromErrno(Type); |
| 46 | break; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 47 | #endif /* !MS_WINDOWS */ |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 48 | case MP_MEMORY_ERROR: |
| 49 | PyErr_NoMemory(); |
| 50 | break; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 51 | case MP_EXCEPTION_HAS_BEEN_SET: |
| 52 | break; |
| 53 | default: |
| 54 | PyErr_Format(PyExc_RuntimeError, |
| 55 | "unkown error number %d", num); |
| 56 | } |
| 57 | return NULL; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | |
| 61 | /* |
| 62 | * Windows only |
| 63 | */ |
| 64 | |
| 65 | #ifdef MS_WINDOWS |
| 66 | |
| 67 | /* On Windows we set an event to signal Ctrl-C; compare with timemodule.c */ |
| 68 | |
| 69 | HANDLE sigint_event = NULL; |
| 70 | |
| 71 | static BOOL WINAPI |
| 72 | ProcessingCtrlHandler(DWORD dwCtrlType) |
| 73 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 74 | SetEvent(sigint_event); |
| 75 | return FALSE; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | /* |
| 79 | * Unix only |
| 80 | */ |
| 81 | |
| 82 | #else /* !MS_WINDOWS */ |
| 83 | |
| 84 | #if HAVE_FD_TRANSFER |
| 85 | |
| 86 | /* Functions for transferring file descriptors between processes. |
| 87 | Reimplements some of the functionality of the fdcred |
| 88 | module at http://www.mca-ltd.com/resources/fdcred_1.tgz. */ |
Jesus Cea | bbd8bec | 2011-09-10 04:04:09 +0200 | [diff] [blame^] | 89 | /* Based in http://resin.csoft.net/cgi-bin/man.cgi?section=3&topic=CMSG_DATA */ |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 90 | |
| 91 | static PyObject * |
| 92 | multiprocessing_sendfd(PyObject *self, PyObject *args) |
| 93 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 94 | int conn, fd, res; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 95 | struct iovec dummy_iov; |
Jesus Cea | bbd8bec | 2011-09-10 04:04:09 +0200 | [diff] [blame^] | 96 | char dummy_char; |
| 97 | struct msghdr msg; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 98 | struct cmsghdr *cmsg; |
Jesus Cea | bbd8bec | 2011-09-10 04:04:09 +0200 | [diff] [blame^] | 99 | union { |
| 100 | struct cmsghdr hdr; |
| 101 | unsigned char buf[CMSG_SPACE(sizeof(int))]; |
| 102 | } cmsgbuf; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 103 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 104 | if (!PyArg_ParseTuple(args, "ii", &conn, &fd)) |
| 105 | return NULL; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 106 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 107 | dummy_iov.iov_base = &dummy_char; |
| 108 | dummy_iov.iov_len = 1; |
Jesus Cea | bbd8bec | 2011-09-10 04:04:09 +0200 | [diff] [blame^] | 109 | |
| 110 | memset(&msg, 0, sizeof(msg)); |
| 111 | msg.msg_control = &cmsgbuf.buf; |
| 112 | msg.msg_controllen = sizeof(cmsgbuf.buf); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 113 | msg.msg_iov = &dummy_iov; |
| 114 | msg.msg_iovlen = 1; |
Jesus Cea | bbd8bec | 2011-09-10 04:04:09 +0200 | [diff] [blame^] | 115 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 116 | cmsg = CMSG_FIRSTHDR(&msg); |
Jesus Cea | bbd8bec | 2011-09-10 04:04:09 +0200 | [diff] [blame^] | 117 | cmsg->cmsg_len = CMSG_LEN(sizeof(int)); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 118 | cmsg->cmsg_level = SOL_SOCKET; |
| 119 | cmsg->cmsg_type = SCM_RIGHTS; |
Antoine Pitrou | bcb39d4 | 2011-08-23 19:46:22 +0200 | [diff] [blame] | 120 | * (int *) CMSG_DATA(cmsg) = fd; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 121 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 122 | Py_BEGIN_ALLOW_THREADS |
| 123 | res = sendmsg(conn, &msg, 0); |
| 124 | Py_END_ALLOW_THREADS |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 125 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 126 | if (res < 0) |
| 127 | return PyErr_SetFromErrno(PyExc_OSError); |
| 128 | Py_RETURN_NONE; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | static PyObject * |
| 132 | multiprocessing_recvfd(PyObject *self, PyObject *args) |
| 133 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 134 | int conn, fd, res; |
| 135 | char dummy_char; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 136 | struct iovec dummy_iov; |
Jesus Cea | bbd8bec | 2011-09-10 04:04:09 +0200 | [diff] [blame^] | 137 | struct msghdr msg = {0}; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 138 | struct cmsghdr *cmsg; |
Jesus Cea | bbd8bec | 2011-09-10 04:04:09 +0200 | [diff] [blame^] | 139 | union { |
| 140 | struct cmsghdr hdr; |
| 141 | unsigned char buf[CMSG_SPACE(sizeof(int))]; |
| 142 | } cmsgbuf; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 143 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 144 | if (!PyArg_ParseTuple(args, "i", &conn)) |
| 145 | return NULL; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 146 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 147 | dummy_iov.iov_base = &dummy_char; |
| 148 | dummy_iov.iov_len = 1; |
Jesus Cea | bbd8bec | 2011-09-10 04:04:09 +0200 | [diff] [blame^] | 149 | |
| 150 | memset(&msg, 0, sizeof(msg)); |
| 151 | msg.msg_control = &cmsgbuf.buf; |
| 152 | msg.msg_controllen = sizeof(cmsgbuf.buf); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 153 | msg.msg_iov = &dummy_iov; |
| 154 | msg.msg_iovlen = 1; |
Jesus Cea | bbd8bec | 2011-09-10 04:04:09 +0200 | [diff] [blame^] | 155 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 156 | cmsg = CMSG_FIRSTHDR(&msg); |
| 157 | cmsg->cmsg_level = SOL_SOCKET; |
| 158 | cmsg->cmsg_type = SCM_RIGHTS; |
| 159 | cmsg->cmsg_len = CMSG_LEN(sizeof(int)); |
| 160 | msg.msg_controllen = cmsg->cmsg_len; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 161 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 162 | Py_BEGIN_ALLOW_THREADS |
| 163 | res = recvmsg(conn, &msg, 0); |
| 164 | Py_END_ALLOW_THREADS |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 165 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 166 | if (res < 0) |
| 167 | return PyErr_SetFromErrno(PyExc_OSError); |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 168 | |
Antoine Pitrou | bcb39d4 | 2011-08-23 19:46:22 +0200 | [diff] [blame] | 169 | fd = * (int *) CMSG_DATA(cmsg); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 170 | return Py_BuildValue("i", fd); |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | #endif /* HAVE_FD_TRANSFER */ |
| 174 | |
| 175 | #endif /* !MS_WINDOWS */ |
| 176 | |
| 177 | |
| 178 | /* |
| 179 | * All platforms |
| 180 | */ |
| 181 | |
| 182 | static PyObject* |
| 183 | multiprocessing_address_of_buffer(PyObject *self, PyObject *obj) |
| 184 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 185 | void *buffer; |
| 186 | Py_ssize_t buffer_len; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 187 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 188 | if (PyObject_AsWriteBuffer(obj, &buffer, &buffer_len) < 0) |
| 189 | return NULL; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 190 | |
Antoine Pitrou | 2341f9b | 2011-05-09 20:55:03 +0200 | [diff] [blame] | 191 | return Py_BuildValue("Nn", |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 192 | PyLong_FromVoidPtr(buffer), buffer_len); |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | |
| 196 | /* |
| 197 | * Function table |
| 198 | */ |
| 199 | |
| 200 | static PyMethodDef module_methods[] = { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 201 | {"address_of_buffer", multiprocessing_address_of_buffer, METH_O, |
| 202 | "address_of_buffer(obj) -> int\n" |
| 203 | "Return address of obj assuming obj supports buffer inteface"}, |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 204 | #if HAVE_FD_TRANSFER |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 205 | {"sendfd", multiprocessing_sendfd, METH_VARARGS, |
| 206 | "sendfd(sockfd, fd) -> None\n" |
| 207 | "Send file descriptor given by fd over the unix domain socket\n" |
| 208 | "whose file decriptor is sockfd"}, |
| 209 | {"recvfd", multiprocessing_recvfd, METH_VARARGS, |
| 210 | "recvfd(sockfd) -> fd\n" |
| 211 | "Receive a file descriptor over a unix domain socket\n" |
| 212 | "whose file decriptor is sockfd"}, |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 213 | #endif |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 214 | {NULL} |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 215 | }; |
| 216 | |
| 217 | |
| 218 | /* |
| 219 | * Initialize |
| 220 | */ |
| 221 | |
| 222 | static struct PyModuleDef multiprocessing_module = { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 223 | PyModuleDef_HEAD_INIT, |
| 224 | "_multiprocessing", |
| 225 | NULL, |
| 226 | -1, |
| 227 | module_methods, |
| 228 | NULL, |
| 229 | NULL, |
| 230 | NULL, |
| 231 | NULL |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 232 | }; |
| 233 | |
| 234 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 235 | PyMODINIT_FUNC |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 236 | PyInit__multiprocessing(void) |
| 237 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 238 | PyObject *module, *temp, *value; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 239 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 240 | /* Initialize module */ |
| 241 | module = PyModule_Create(&multiprocessing_module); |
| 242 | if (!module) |
| 243 | return NULL; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 244 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 245 | /* Get copy of BufferTooShort */ |
| 246 | temp = PyImport_ImportModule("multiprocessing"); |
| 247 | if (!temp) |
| 248 | return NULL; |
| 249 | BufferTooShort = PyObject_GetAttrString(temp, "BufferTooShort"); |
| 250 | Py_XDECREF(temp); |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 251 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 252 | #if defined(MS_WINDOWS) || \ |
Mark Dickinson | a614f04 | 2009-11-28 12:48:43 +0000 | [diff] [blame] | 253 | (defined(HAVE_SEM_OPEN) && !defined(POSIX_SEMAPHORES_NOT_ENABLED)) |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 254 | /* Add SemLock type to module */ |
| 255 | if (PyType_Ready(&SemLockType) < 0) |
| 256 | return NULL; |
| 257 | Py_INCREF(&SemLockType); |
Gregory P. Smith | 68e0135 | 2010-10-17 02:14:36 +0000 | [diff] [blame] | 258 | { |
| 259 | PyObject *py_sem_value_max; |
| 260 | /* Some systems define SEM_VALUE_MAX as an unsigned value that |
| 261 | * causes it to be negative when used as an int (NetBSD). */ |
| 262 | if ((int)(SEM_VALUE_MAX) < 0) |
| 263 | py_sem_value_max = PyLong_FromLong(INT_MAX); |
| 264 | else |
| 265 | py_sem_value_max = PyLong_FromLong(SEM_VALUE_MAX); |
| 266 | if (py_sem_value_max == NULL) |
| 267 | return NULL; |
| 268 | PyDict_SetItemString(SemLockType.tp_dict, "SEM_VALUE_MAX", |
| 269 | py_sem_value_max); |
| 270 | } |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 271 | PyModule_AddObject(module, "SemLock", (PyObject*)&SemLockType); |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 272 | #endif |
| 273 | |
| 274 | #ifdef MS_WINDOWS |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 275 | /* Initialize win32 class and add to multiprocessing */ |
| 276 | temp = create_win32_namespace(); |
| 277 | if (!temp) |
| 278 | return NULL; |
| 279 | PyModule_AddObject(module, "win32", temp); |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 280 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 281 | /* Initialize the event handle used to signal Ctrl-C */ |
| 282 | sigint_event = CreateEvent(NULL, TRUE, FALSE, NULL); |
| 283 | if (!sigint_event) { |
| 284 | PyErr_SetFromWindowsErr(0); |
| 285 | return NULL; |
| 286 | } |
| 287 | if (!SetConsoleCtrlHandler(ProcessingCtrlHandler, TRUE)) { |
| 288 | PyErr_SetFromWindowsErr(0); |
| 289 | return NULL; |
| 290 | } |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 291 | #endif |
| 292 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 293 | /* Add configuration macros */ |
| 294 | temp = PyDict_New(); |
| 295 | if (!temp) |
| 296 | return NULL; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 297 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 298 | #define ADD_FLAG(name) \ |
| 299 | value = Py_BuildValue("i", name); \ |
| 300 | if (value == NULL) { Py_DECREF(temp); return NULL; } \ |
| 301 | if (PyDict_SetItemString(temp, #name, value) < 0) { \ |
| 302 | Py_DECREF(temp); Py_DECREF(value); return NULL; } \ |
| 303 | Py_DECREF(value) |
| 304 | |
Mark Dickinson | a614f04 | 2009-11-28 12:48:43 +0000 | [diff] [blame] | 305 | #if defined(HAVE_SEM_OPEN) && !defined(POSIX_SEMAPHORES_NOT_ENABLED) |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 306 | ADD_FLAG(HAVE_SEM_OPEN); |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 307 | #endif |
| 308 | #ifdef HAVE_SEM_TIMEDWAIT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 309 | ADD_FLAG(HAVE_SEM_TIMEDWAIT); |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 310 | #endif |
| 311 | #ifdef HAVE_FD_TRANSFER |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 312 | ADD_FLAG(HAVE_FD_TRANSFER); |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 313 | #endif |
| 314 | #ifdef HAVE_BROKEN_SEM_GETVALUE |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 315 | ADD_FLAG(HAVE_BROKEN_SEM_GETVALUE); |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 316 | #endif |
| 317 | #ifdef HAVE_BROKEN_SEM_UNLINK |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 318 | ADD_FLAG(HAVE_BROKEN_SEM_UNLINK); |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 319 | #endif |
| 320 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 321 | if (PyModule_AddObject(module, "flags", temp) < 0) |
| 322 | return NULL; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 323 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 324 | return module; |
Benjamin Peterson | fa26803 | 2008-06-13 19:28:21 +0000 | [diff] [blame] | 325 | } |