| 
									
										
										
										
											2008-06-13 19:28:21 +00:00
										 |  |  | #ifndef MULTIPROCESSING_H
 | 
					
						
							|  |  |  | #define MULTIPROCESSING_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PY_SSIZE_T_CLEAN
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "Python.h"
 | 
					
						
							|  |  |  | #include "structmember.h"
 | 
					
						
							|  |  |  | #include "pythread.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Platform includes and definitions | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef MS_WINDOWS
 | 
					
						
							|  |  |  | #  define WIN32_LEAN_AND_MEAN
 | 
					
						
							|  |  |  | #  include <windows.h>
 | 
					
						
							|  |  |  | #  include <winsock2.h>
 | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  | #  include <process.h>               /* getpid() */
 | 
					
						
							| 
									
										
										
										
											2009-04-01 20:51:28 +00:00
										 |  |  | #  ifdef Py_DEBUG
 | 
					
						
							|  |  |  | #    include <crtdbg.h>
 | 
					
						
							|  |  |  | #  endif
 | 
					
						
							| 
									
										
										
										
											2008-06-13 19:28:21 +00:00
										 |  |  | #  define SEM_HANDLE HANDLE
 | 
					
						
							|  |  |  | #  define SEM_VALUE_MAX LONG_MAX
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #  include <fcntl.h>                 /* O_CREAT and O_EXCL */
 | 
					
						
							| 
									
										
										
										
											2009-11-28 12:48:43 +00:00
										 |  |  | #  if defined(HAVE_SEM_OPEN) && !defined(POSIX_SEMAPHORES_NOT_ENABLED)
 | 
					
						
							| 
									
										
										
										
											2008-06-13 19:28:21 +00:00
										 |  |  | #    include <semaphore.h>
 | 
					
						
							|  |  |  |      typedef sem_t *SEM_HANDLE; | 
					
						
							|  |  |  | #  endif
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-03 18:22:19 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Issue 3110 - Solaris does not define SEM_VALUE_MAX | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #ifndef SEM_VALUE_MAX
 | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |     #if defined(HAVE_SYSCONF) && defined(_SC_SEM_VALUE_MAX)
 | 
					
						
							|  |  |  |         # define SEM_VALUE_MAX sysconf(_SC_SEM_VALUE_MAX)
 | 
					
						
							|  |  |  |     #elif defined(_SEM_VALUE_MAX)
 | 
					
						
							|  |  |  |         # define SEM_VALUE_MAX _SEM_VALUE_MAX
 | 
					
						
							|  |  |  |     #elif defined(_POSIX_SEM_VALUE_MAX)
 | 
					
						
							|  |  |  |         # define SEM_VALUE_MAX _POSIX_SEM_VALUE_MAX
 | 
					
						
							|  |  |  |     #else
 | 
					
						
							|  |  |  |         # define SEM_VALUE_MAX INT_MAX
 | 
					
						
							|  |  |  |     #endif
 | 
					
						
							| 
									
										
										
										
											2008-09-03 18:22:19 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												Merged revisions 70908,70939,71009,71022,71036 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
  r70908 | jesse.noller | 2009-03-31 17:20:35 -0500 (Tue, 31 Mar 2009) | 1 line
  Issue 5619: Pass MS CRT debug flags into subprocesses
........
  r70939 | jesse.noller | 2009-03-31 22:45:50 -0500 (Tue, 31 Mar 2009) | 1 line
  Fix multiprocessing.event to match the new threading.Event API
........
  r71009 | jesse.noller | 2009-04-01 19:03:28 -0500 (Wed, 01 Apr 2009) | 1 line
  issue5545: Switch to Autoconf for multiprocessing; special thanks to Martin Lowis for help
........
  r71022 | jesse.noller | 2009-04-01 21:32:55 -0500 (Wed, 01 Apr 2009) | 1 line
  Issue 3110: Additional protection for SEM_VALUE_MAX on platforms, thanks to Martin Loewis
........
  r71036 | jesse.noller | 2009-04-01 23:22:09 -0500 (Wed, 01 Apr 2009) | 1 line
  Issue 3551: Raise ValueError if the size causes ERROR_NO_SYSTEM_RESOURCES
........
											
										 
											2009-04-05 21:24:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-13 19:28:21 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Format codes | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if SIZEOF_VOID_P == SIZEOF_LONG
 | 
					
						
							|  |  |  | #  define F_POINTER "k"
 | 
					
						
							|  |  |  | #  define T_POINTER T_ULONG
 | 
					
						
							| 
									
										
										
										
											2016-09-05 17:44:18 -07:00
										 |  |  | #elif SIZEOF_VOID_P == SIZEOF_LONG_LONG
 | 
					
						
							| 
									
										
										
										
											2008-06-13 19:28:21 +00:00
										 |  |  | #  define F_POINTER "K"
 | 
					
						
							|  |  |  | #  define T_POINTER T_ULONGLONG
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #  error "can't find format code for unsigned integer of same size as void*"
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef MS_WINDOWS
 | 
					
						
							|  |  |  | #  define F_HANDLE F_POINTER
 | 
					
						
							|  |  |  | #  define T_HANDLE T_POINTER
 | 
					
						
							|  |  |  | #  define F_SEM_HANDLE F_HANDLE
 | 
					
						
							|  |  |  | #  define T_SEM_HANDLE T_HANDLE
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #  define F_HANDLE "i"
 | 
					
						
							|  |  |  | #  define T_HANDLE T_INT
 | 
					
						
							|  |  |  | #  define F_SEM_HANDLE F_POINTER
 | 
					
						
							|  |  |  | #  define T_SEM_HANDLE T_POINTER
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Error codes which can be returned by functions called without GIL | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define MP_SUCCESS (0)
 | 
					
						
							|  |  |  | #define MP_STANDARD_ERROR (-1)
 | 
					
						
							|  |  |  | #define MP_MEMORY_ERROR (-1001)
 | 
					
						
							| 
									
										
										
										
											2011-05-09 17:04:27 +02:00
										 |  |  | #define MP_SOCKET_ERROR (-1002)
 | 
					
						
							|  |  |  | #define MP_EXCEPTION_HAS_BEEN_SET (-1003)
 | 
					
						
							| 
									
										
										
										
											2008-06-13 19:28:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-07 18:08:47 +01:00
										 |  |  | PyObject *_PyMp_SetError(PyObject *Type, int num); | 
					
						
							| 
									
										
										
										
											2008-06-13 19:28:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Externs - not all will really exist on all platforms | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-07 18:08:47 +01:00
										 |  |  | extern PyTypeObject _PyMp_SemLockType; | 
					
						
							| 
									
										
										
										
											2020-07-12 10:11:11 -06:00
										 |  |  | extern PyObject *_PyMp_sem_unlink(const char *name); | 
					
						
							| 
									
										
										
										
											2008-06-13 19:28:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif /* MULTIPROCESSING_H */
 |