bpo-31370: Remove support for threads-less builds (#3385)

* Remove Setup.config
* Always define WITH_THREAD for compatibility.
This commit is contained in:
Antoine Pitrou 2017-09-07 18:56:24 +02:00 committed by Victor Stinner
parent 1f06a680de
commit a6a4dc816d
135 changed files with 2472 additions and 4377 deletions

View file

@ -85,12 +85,10 @@ module signal
thread. XXX This is a hack.
*/
#ifdef WITH_THREAD
#include <sys/types.h> /* For pid_t */
#include "pythread.h"
static unsigned long main_thread;
static pid_t main_pid;
#endif
static volatile struct {
_Py_atomic_int tripped;
@ -316,10 +314,8 @@ signal_handler(int sig_num)
{
int save_errno = errno;
#ifdef WITH_THREAD
/* See NOTES section above */
if (getpid() == main_pid)
#endif
{
trip_signal(sig_num);
}
@ -439,13 +435,11 @@ signal_signal_impl(PyObject *module, int signalnum, PyObject *handler)
return NULL;
}
#endif
#ifdef WITH_THREAD
if (PyThread_get_thread_ident() != main_thread) {
PyErr_SetString(PyExc_ValueError,
"signal only works in main thread");
return NULL;
}
#endif
if (signalnum < 1 || signalnum >= NSIG) {
PyErr_SetString(PyExc_ValueError,
"signal number out of range");
@ -571,13 +565,11 @@ signal_set_wakeup_fd(PyObject *self, PyObject *args)
return NULL;
#endif
#ifdef WITH_THREAD
if (PyThread_get_thread_ident() != main_thread) {
PyErr_SetString(PyExc_ValueError,
"set_wakeup_fd only works in main thread");
return NULL;
}
#endif
#ifdef MS_WINDOWS
is_socket = 0;
@ -1104,7 +1096,7 @@ signal_sigtimedwait_impl(PyObject *module, PyObject *sigset,
#endif /* #ifdef HAVE_SIGTIMEDWAIT */
#if defined(HAVE_PTHREAD_KILL) && defined(WITH_THREAD)
#if defined(HAVE_PTHREAD_KILL)
/*[clinic input]
signal.pthread_kill
@ -1137,7 +1129,7 @@ signal_pthread_kill_impl(PyObject *module, unsigned long thread_id,
Py_RETURN_NONE;
}
#endif /* #if defined(HAVE_PTHREAD_KILL) && defined(WITH_THREAD) */
#endif /* #if defined(HAVE_PTHREAD_KILL) */
@ -1217,10 +1209,8 @@ PyInit__signal(void)
PyObject *m, *d, *x;
int i;
#ifdef WITH_THREAD
main_thread = PyThread_get_thread_ident();
main_pid = getpid();
#endif
/* Create the module and add the functions */
m = PyModule_Create(&signalmodule);
@ -1523,10 +1513,8 @@ PyErr_CheckSignals(void)
if (!_Py_atomic_load(&is_tripped))
return 0;
#ifdef WITH_THREAD
if (PyThread_get_thread_ident() != main_thread)
return 0;
#endif
/*
* The is_tripped variable is meant to speed up the calls to
@ -1599,10 +1587,8 @@ int
PyOS_InterruptOccurred(void)
{
if (_Py_atomic_load_relaxed(&Handlers[SIGINT].tripped)) {
#ifdef WITH_THREAD
if (PyThread_get_thread_ident() != main_thread)
return 0;
#endif
_Py_atomic_store_relaxed(&Handlers[SIGINT].tripped, 0);
return 1;
}
@ -1628,20 +1614,14 @@ _PySignal_AfterFork(void)
* in both processes if they came in just before the fork() but before
* the interpreter had an opportunity to call the handlers. issue9535. */
_clear_pending_signals();
#ifdef WITH_THREAD
main_thread = PyThread_get_thread_ident();
main_pid = getpid();
#endif
}
int
_PyOS_IsMainThread(void)
{
#ifdef WITH_THREAD
return PyThread_get_thread_ident() == main_thread;
#else
return 1;
#endif
}
#ifdef MS_WINDOWS