@@ -2637,3 +2637,118 @@ These APIs are obsolete since Python 3.13 with the introduction of
26372637 fatal error.
26382638
26392639 The caller does not need to hold an :term:`attached thread state`.
2640+
2641+
2642+ Operating System Thread APIs
2643+ ============================
2644+
2645+ .. c:macro:: PYTHREAD_INVALID_THREAD_ID
2646+
2647+ Sentinel value for an invalid thread ID.
2648+
2649+ This is currently equivalent to ``-1``.
2650+
2651+
2652+ .. c:function:: unsigned long PyThread_start_new_thread(void (*func)(void *), void *arg)
2653+
2654+ Start function *func* in a new thread with argument *arg*.
2655+ The resulting thread is not intended to be joined.
2656+
2657+ *func* must not be ``NULL``, but *arg* may be ``NULL``.
2658+
2659+ On success, this function returns the ID of the new thread; on failure,
2660+ this returns :c:macro:`PYTHREAD_INVALID_THREAD_ID`.
2661+
2662+ The caller does not need to hold an :term:`attached thread state`.
2663+
2664+
2665+ .. c:function:: unsigned long PyThread_get_thread_ident(void)
2666+
2667+ Return the identifier of the current thread, which will never be zero.
2668+
2669+ This function cannot fail, and the caller does not need to hold an
2670+ :term:`attached thread state`.
2671+
2672+ .. seealso::
2673+ :py:func:`threading.get_ident`
2674+
2675+
2676+ .. c:function:: PyObject *PyThread_GetInfo(void)
2677+
2678+ Get general information about the current thread in the form of a
2679+ :ref:`struct sequence <struct-sequence-objects>` object. This information is
2680+ accessible as :py:attr:`sys.thread_info` in Python.
2681+
2682+ On success, this returns a new :term:`strong reference` to the thread
2683+ information; on failure, this returns ``NULL`` with an exception set.
2684+
2685+ The caller must hold an :term:`attached thread state`.
2686+
2687+
2688+ .. c:macro:: PY_HAVE_THREAD_NATIVE_ID
2689+
2690+ This is defined when the system supports native thread IDs.
2691+
2692+
2693+ .. c:function:: unsigned long PyThread_get_thread_native_id(void)
2694+
2695+ Get the native ID of the current thread as it was assigned by the operating
2696+ system's kernel, which will never be less than zero.
2697+
2698+ This function is only available when :c:macro:`PY_HAVE_THREAD_NATIVE_ID` is
2699+ defined.
2700+
2701+ This function cannot fail, and the caller does not need to hold an
2702+ :term:`attached thread state`.
2703+
2704+ .. seealso::
2705+ :py:func:`threading.get_native_id`
2706+
2707+
2708+ .. c:function:: void PyThread_exit_thread(void)
2709+
2710+ Terminate the current thread. This function is generally considered unsafe
2711+ and should be avoided. It is kept solely for backwards compatibility.
2712+
2713+ This function is only safe to call if all functions in the full call
2714+ stack are written to safely allow it.
2715+
2716+ .. warning::
2717+
2718+ If the current system uses POSIX threads (also known as " pthreads" ),
2719+ this calls :man:`pthread_exit(3)`, attempts to unwind the stack and
2720+ call C++ destructors on some libc implementations. However, if a
2721+ ``noexcept`` function is reached, they may terminate the process.
2722+ Other systems, such as macOS, do unwinding.
2723+
2724+ On Windows, this function calls ``_endthreadex``, which kills the thread
2725+ without calling C++ destructors.
2726+
2727+ In any case, there is a risk of corruption on the thread's stack.
2728+
2729+ .. deprecated:: 3.14
2730+
2731+
2732+ .. c:function:: void PyThread_init_thread(void)
2733+
2734+ Initialize ``PyThread*`` APIs. Python executes this function automatically,
2735+ so there's little need to call it from an extension module.
2736+
2737+
2738+ .. c:function:: int PyThread_set_stacksize(size_t size)
2739+
2740+ Set the stack size of the current thread to *size*.
2741+
2742+ This function returns ``0`` on success, ``-1`` if *size* is invalid, or
2743+ ``-2`` if the system does not support changing the stack size. This function
2744+ does not set exceptions.
2745+
2746+ The caller does not need to hold an :term:`attached thread state`.
2747+
2748+
2749+ .. c:function:: size_t PyThread_get_stacksize(void)
2750+
2751+ Return the stack size of the current thread, or ``0`` if the system's
2752+ default stack size is in use.
2753+
2754+ The caller does not need to hold an :term:`attached thread state`.
0 commit comments