cpython/Python/thread.c


/* Thread package.
   This is intended to be usable independently from Python.
   The implementation for system foobar is in a file thread_foobar.h
   which is included by this file dependent on config settings.
   Stuff shared by all thread_*.h files is collected here. */

#include "Python.h"
#include "pycore_ceval.h"         // _PyEval_MakePendingCalls()
#include "pycore_pystate.h"       // _PyInterpreterState_GET()
#include "pycore_structseq.h"     // _PyStructSequence_FiniBuiltin()
#include "pycore_pythread.h"      // _POSIX_THREADS

#ifndef DONT_HAVE_STDIO_H
#  include <stdio.h>
#endif

#include <stdlib.h>


// Define PY_TIMEOUT_MAX constant.
#ifdef _POSIX_THREADS
   // PyThread_acquire_lock_timed() uses (us * 1000) to convert microseconds
   // to nanoseconds.
#define PY_TIMEOUT_MAX_VALUE
#elif defined (NT_THREADS)
   // WaitForSingleObject() accepts timeout in milliseconds in the range
   // [0; 0xFFFFFFFE] (DWORD type). INFINITE value (0xFFFFFFFF) means no
   // timeout. 0xFFFFFFFE milliseconds is around 49.7 days.
#  if 0xFFFFFFFELL < LLONG_MAX / 1000
#define PY_TIMEOUT_MAX_VALUE
#  else
#define PY_TIMEOUT_MAX_VALUE
#  endif
#else
#define PY_TIMEOUT_MAX_VALUE
#endif
const long long PY_TIMEOUT_MAX =;


static void PyThread__init_thread(void); /* Forward */

#define initialized

void
PyThread_init_thread(void)
{}

#if defined(HAVE_PTHREAD_STUBS)
#define PYTHREAD_NAME
#   include "thread_pthread_stubs.h"
#elif defined(_USE_PTHREADS)  /* AKA _PTHREADS */
#   if defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)
#define PYTHREAD_NAME
#   else
#define PYTHREAD_NAME
#   endif
#   include "thread_pthread.h"
#elif defined(NT_THREADS)
#define PYTHREAD_NAME
#   include "thread_nt.h"
#else
#   error "Require native threads. See https://bugs.python.org/issue31370"
#endif


/* return the current thread stack size */
size_t
PyThread_get_stacksize(void)
{}

/* Only platforms defining a THREAD_SET_STACKSIZE() macro
   in thread_<platform>.h support changing the stack size.
   Return 0 if stack size is valid,
      -1 if stack size value is invalid,
      -2 if setting stack size is not supported. */
int
PyThread_set_stacksize(size_t size)
{}


int
PyThread_ParseTimeoutArg(PyObject *arg, int blocking, PY_TIMEOUT_T *timeout_p)
{}

PyLockStatus
PyThread_acquire_lock_timed_with_retries(PyThread_type_lock lock,
                                         PY_TIMEOUT_T timeout)
{}


/* Thread Specific Storage (TSS) API

   Cross-platform components of TSS API implementation.
*/

Py_tss_t *
PyThread_tss_alloc(void)
{}

void
PyThread_tss_free(Py_tss_t *key)
{}

int
PyThread_tss_is_created(Py_tss_t *key)
{}


PyDoc_STRVAR(threadinfo__doc__,
"sys.thread_info\n\
\n\
A named tuple holding information about the thread implementation.");

static PyStructSequence_Field threadinfo_fields[] =;

static PyStructSequence_Desc threadinfo_desc =;

static PyTypeObject ThreadInfoType;

PyObject*
PyThread_GetInfo(void)
{}


void
_PyThread_FiniType(PyInterpreterState *interp)
{}