cpython/Modules/_multiprocessing/multiprocessing.h

#ifndef MULTIPROCESSING_H
#define MULTIPROCESSING_H

#ifndef Py_BUILD_CORE_BUILTIN
#define Py_BUILD_CORE_MODULE
#endif

#include "Python.h"
#include "structmember.h"
#include "pythread.h"
#include "pycore_signal.h"        // _PyOS_IsMainThread()

#ifndef MS_WINDOWS
#  include <unistd.h>             // sysconf()
#endif

/*
 * Platform includes and definitions
 */

#ifdef MS_WINDOWS
#  ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#  endif
#  include <windows.h>
#  include <winsock2.h>
#  include <process.h>               /* getpid() */
#  ifdef Py_DEBUG
#    include <crtdbg.h>
#  endif
#define SEM_HANDLE
#define SEM_VALUE_MAX
#define HAVE_MP_SEMAPHORE
#else
#  include <fcntl.h>                 /* O_CREAT and O_EXCL */
#  if defined(HAVE_SEM_OPEN) && !defined(POSIX_SEMAPHORES_NOT_ENABLED)
#define HAVE_MP_SEMAPHORE
#    include <semaphore.h>
     SEM_HANDLE;
#  endif
#endif

/*
 * Issue 3110 - Solaris does not define SEM_VALUE_MAX
 */
#ifndef SEM_VALUE_MAX
    #if defined(HAVE_SYSCONF) && defined(_SC_SEM_VALUE_MAX)
        #define SEM_VALUE_MAX
    #elif defined(_SEM_VALUE_MAX)
        #define SEM_VALUE_MAX
    #elif defined(_POSIX_SEM_VALUE_MAX)
        #define SEM_VALUE_MAX
    #else
        #define SEM_VALUE_MAX
    #endif
#endif


/*
 * Format codes
 */

#if SIZEOF_VOID_P == SIZEOF_LONG
#define F_POINTER
#define T_POINTER
#elif SIZEOF_VOID_P == SIZEOF_LONG_LONG
#define F_POINTER
#define T_POINTER
#else
#  error "can't find format code for unsigned integer of same size as void*"
#endif

#ifdef MS_WINDOWS
#define F_HANDLE
#define T_HANDLE
#define F_SEM_HANDLE
#define T_SEM_HANDLE
#else
#define F_HANDLE
#define T_HANDLE
#define F_SEM_HANDLE
#define T_SEM_HANDLE
#endif

/*
 * Error codes which can be returned by functions called without GIL
 */

#define MP_SUCCESS
#define MP_STANDARD_ERROR
#define MP_MEMORY_ERROR
#define MP_SOCKET_ERROR
#define MP_EXCEPTION_HAS_BEEN_SET

PyObject *_PyMp_SetError(PyObject *Type, int num);

/*
 * Externs - not all will really exist on all platforms
 */

extern PyType_Spec _PyMp_SemLockType_spec;
extern PyObject *_PyMp_sem_unlink(const char *name);

#endif /* MULTIPROCESSING_H */