summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/condvar.h3
-rw-r--r--Python/thread.c22
-rw-r--r--Python/thread_pthread.h9
3 files changed, 28 insertions, 6 deletions
diff --git a/Python/condvar.h b/Python/condvar.h
index 4ddc531..d54db94 100644
--- a/Python/condvar.h
+++ b/Python/condvar.h
@@ -41,7 +41,8 @@
#define _CONDVAR_IMPL_H_
#include "Python.h"
-#include "pycore_condvar.h"
+#include "pycore_pythread.h" // _POSIX_THREADS
+
#ifdef _POSIX_THREADS
/*
diff --git a/Python/thread.c b/Python/thread.c
index 1ac2db2..bf207ce 100644
--- a/Python/thread.c
+++ b/Python/thread.c
@@ -8,7 +8,7 @@
#include "Python.h"
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_structseq.h" // _PyStructSequence_FiniBuiltin()
-#include "pycore_pythread.h"
+#include "pycore_pythread.h" // _POSIX_THREADS
#ifndef DONT_HAVE_STDIO_H
# include <stdio.h>
@@ -17,6 +17,26 @@
#include <stdlib.h>
+// Define PY_TIMEOUT_MAX constant.
+#ifdef _POSIX_THREADS
+ // PyThread_acquire_lock_timed() uses _PyTime_FromNanoseconds(us * 1000),
+ // convert microseconds to nanoseconds.
+# define PY_TIMEOUT_MAX_VALUE (LLONG_MAX / 1000)
+#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 (0xFFFFFFFELL * 1000)
+# else
+# define PY_TIMEOUT_MAX_VALUE LLONG_MAX
+# endif
+#else
+# define PY_TIMEOUT_MAX_VALUE LLONG_MAX
+#endif
+const long long PY_TIMEOUT_MAX = PY_TIMEOUT_MAX_VALUE;
+
+
static void PyThread__init_thread(void); /* Forward */
#define initialized _PyRuntime.threads.initialized
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index f96c57d..76a1f77 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -1,4 +1,5 @@
-#include "pycore_interp.h" // _PyInterpreterState.threads.stacksize
+#include "pycore_interp.h" // _PyInterpreterState.threads.stacksize
+#include "pycore_pythread.h" // _POSIX_SEMAPHORES
/* Posix threads interface */
@@ -84,10 +85,10 @@
/* On FreeBSD 4.x, _POSIX_SEMAPHORES is defined empty, so
we need to add 0 to make it work there as well. */
#if (_POSIX_SEMAPHORES+0) == -1
-#define HAVE_BROKEN_POSIX_SEMAPHORES
+# define HAVE_BROKEN_POSIX_SEMAPHORES
#else
-#include <semaphore.h>
-#include <errno.h>
+# include <semaphore.h>
+# include <errno.h>
#endif
#endif