diff options
Diffstat (limited to 'Include')
-rw-r--r-- | Include/pyport.h | 3 | ||||
-rw-r--r-- | Include/pythread.h | 21 |
2 files changed, 17 insertions, 7 deletions
diff --git a/Include/pyport.h b/Include/pyport.h index 2742e47..0e82543 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -787,6 +787,9 @@ extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler; #include <android/api-level.h> #endif +/* Maximum value of the Windows DWORD type */ +#define PY_DWORD_MAX 4294967295U + /* This macro used to tell whether Python was built with multithreading * enabled. Now multithreading is always enabled, but keep the macro * for compatibility. diff --git a/Include/pythread.h b/Include/pythread.h index d667468..eb61033 100644 --- a/Include/pythread.h +++ b/Include/pythread.h @@ -42,16 +42,23 @@ PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int); and floating-point numbers allowed. */ #define PY_TIMEOUT_T long long -#define PY_TIMEOUT_MAX PY_LLONG_MAX -/* In the NT API, the timeout is a DWORD and is expressed in milliseconds */ -#if defined (NT_THREADS) -#if 0xFFFFFFFFLL * 1000 < PY_TIMEOUT_MAX -#undef PY_TIMEOUT_MAX -#define PY_TIMEOUT_MAX (0xFFFFFFFFLL * 1000) -#endif +#if defined(_POSIX_THREADS) + /* PyThread_acquire_lock_timed() uses _PyTime_FromNanoseconds(us * 1000), + convert microseconds to nanoseconds. */ +# define PY_TIMEOUT_MAX (PY_LLONG_MAX / 1000) +#elif defined (NT_THREADS) + /* In the NT API, the timeout is a DWORD and is expressed in milliseconds */ +# if 0xFFFFFFFFLL * 1000 < PY_LLONG_MAX +# define PY_TIMEOUT_MAX (0xFFFFFFFFLL * 1000) +# else +# define PY_TIMEOUT_MAX PY_LLONG_MAX +# endif +#else +# define PY_TIMEOUT_MAX PY_LLONG_MAX #endif + /* If microseconds == 0, the call is non-blocking: it returns immediately even when the lock can't be acquired. If microseconds > 0, the call waits up to the specified duration. |