Path: blob/main/Modules/_multiprocessing/multiprocessing.h
12 views
#ifndef MULTIPROCESSING_H1#define MULTIPROCESSING_H23#include "Python.h"4#include "structmember.h"5#include "pythread.h"67/*8* Platform includes and definitions9*/1011#ifdef MS_WINDOWS12# ifndef WIN32_LEAN_AND_MEAN13# define WIN32_LEAN_AND_MEAN14# endif15# include <windows.h>16# include <winsock2.h>17# include <process.h> /* getpid() */18# ifdef Py_DEBUG19# include <crtdbg.h>20# endif21# define SEM_HANDLE HANDLE22# define SEM_VALUE_MAX LONG_MAX23# define HAVE_MP_SEMAPHORE24#else25# include <fcntl.h> /* O_CREAT and O_EXCL */26# if defined(HAVE_SEM_OPEN) && !defined(POSIX_SEMAPHORES_NOT_ENABLED)27# define HAVE_MP_SEMAPHORE28# include <semaphore.h>29typedef sem_t *SEM_HANDLE;30# endif31#endif3233/*34* Issue 3110 - Solaris does not define SEM_VALUE_MAX35*/36#ifndef SEM_VALUE_MAX37#if defined(HAVE_SYSCONF) && defined(_SC_SEM_VALUE_MAX)38# define SEM_VALUE_MAX sysconf(_SC_SEM_VALUE_MAX)39#elif defined(_SEM_VALUE_MAX)40# define SEM_VALUE_MAX _SEM_VALUE_MAX41#elif defined(_POSIX_SEM_VALUE_MAX)42# define SEM_VALUE_MAX _POSIX_SEM_VALUE_MAX43#else44# define SEM_VALUE_MAX INT_MAX45#endif46#endif474849/*50* Format codes51*/5253#if SIZEOF_VOID_P == SIZEOF_LONG54# define F_POINTER "k"55# define T_POINTER T_ULONG56#elif SIZEOF_VOID_P == SIZEOF_LONG_LONG57# define F_POINTER "K"58# define T_POINTER T_ULONGLONG59#else60# error "can't find format code for unsigned integer of same size as void*"61#endif6263#ifdef MS_WINDOWS64# define F_HANDLE F_POINTER65# define T_HANDLE T_POINTER66# define F_SEM_HANDLE F_HANDLE67# define T_SEM_HANDLE T_HANDLE68#else69# define F_HANDLE "i"70# define T_HANDLE T_INT71# define F_SEM_HANDLE F_POINTER72# define T_SEM_HANDLE T_POINTER73#endif7475/*76* Error codes which can be returned by functions called without GIL77*/7879#define MP_SUCCESS (0)80#define MP_STANDARD_ERROR (-1)81#define MP_MEMORY_ERROR (-1001)82#define MP_SOCKET_ERROR (-1002)83#define MP_EXCEPTION_HAS_BEEN_SET (-1003)8485PyObject *_PyMp_SetError(PyObject *Type, int num);8687/*88* Externs - not all will really exist on all platforms89*/9091extern PyType_Spec _PyMp_SemLockType_spec;92extern PyObject *_PyMp_sem_unlink(const char *name);9394#endif /* MULTIPROCESSING_H */959697