Commit Graph

117 Commits

Author SHA1 Message Date
Benjamin Peterson f1c19031fd bpo-38068: Clean up gettimeofday configure logic. (GH-15775)
Assume gettimeofday exists and takes two arguments.
2019-09-10 03:37:59 -07:00
Michael Felt 9670ce76b8 bpo-18049: Define THREAD_STACK_SIZE for AIX to pass default recursion limit test (GH-15081)
* Define THREAD_STACK_SIZE for AIX to pass default recursion limit test
2019-08-03 08:12:26 +02:00
Ronald Oussoren 1a057bab0f
bpo-18049: Sync thread stack size to main thread size on macOS (GH-14748)
This changeset increases the default size of the stack
for threads on macOS to the size of the stack
of the main thread and reenables the relevant
recursion test.
2019-08-01 07:43:07 +02:00
Michael Felt d0eeb936d8 bpo-37077: Add native thread ID (TID) for AIX (GH-13624)
This is the followup  for issue36084



https://bugs.python.org/issue37077
2019-06-13 15:34:46 -07:00
David Carlier 5287022eee bpo-37160: Thread native ID NetBSD support (GH-13835) 2019-06-12 17:37:56 +02:00
David Carlier 0b9956e916 bpo-37087: Adding native ID support for OpenBSD (GH-13654) 2019-06-03 17:43:33 +02:00
Jake Tesler b121f63155 bpo-36084: Add native thread ID (TID) to threading.Thread (GH-13463)
Add native thread ID (TID) to threading.Thread objects
(supported platforms: Windows, FreeBSD, Linux, macOS).
2019-05-22 17:43:16 +02:00
Victor Stinner d12e75734d
Revert "bpo-36084: Add native thread ID to threading.Thread objects (GH-11993)" (GH-13458)
This reverts commit 4959c33d25.
2019-05-21 12:44:57 +02:00
Jake Tesler 4959c33d25 bpo-36084: Add native thread ID to threading.Thread objects (GH-11993) 2019-05-12 19:08:24 +02:00
Zackery Spytz 1a2252ed39 bpo-36594: Fix incorrect use of %p in format strings (GH-12769)
In addition, fix some other minor violations of C99.
2019-05-06 12:56:50 -04:00
Victor Stinner c664b342a4
bpo-36475: Make PyThread_exit_thread with _Py_NO_RETURN (GH-13068) 2019-05-04 11:48:05 -04:00
Inada Naoki 001fee14e0
bpo-12822: use monotonic clock for condvar if possible (GH-11723) 2019-02-20 10:00:09 +09:00
Siddhesh Poyarekar 9eea6eaf23 bpo-33015: Fix UB in pthread PyThread_start_new_thread (GH-6008)
Fix an undefined behaviour in the pthread implementation of
PyThread_start_new_thread(): add a function wrapper to always return
NULL.

Add pythread_callback struct and pythread_wrapper() to thread_pthread.h.
2018-11-30 16:14:25 +01:00
Victor Stinner 50b48572d9
bpo-35081: Add _PyThreadState_GET() internal macro (GH-10266)
If Py_BUILD_CORE is defined, the PyThreadState_GET() macro access
_PyRuntime which comes from the internal pycore_state.h header.
Public headers must not require internal headers.

Move PyThreadState_GET() and _PyInterpreterState_GET_UNSAFE() from
Include/pystate.h to Include/internal/pycore_state.h, and rename
PyThreadState_GET() to _PyThreadState_GET() there.

The PyThreadState_GET() macro of pystate.h is now redefined when
pycore_state.h is included, to use the fast _PyThreadState_GET().

Changes:

* Add _PyThreadState_GET() macro
* Replace "PyThreadState_GET()->interp" with
  _PyInterpreterState_GET_UNSAFE()
* Replace PyThreadState_GET() with _PyThreadState_GET() in internal C
  files (compiled with Py_BUILD_CORE defined), but keep
  PyThreadState_GET() in the public header files.
* _testcapimodule.c: replace PyThreadState_GET() with
  PyThreadState_Get(); the module is not compiled with Py_BUILD_CORE
  defined.
* pycore_state.h now requires Py_BUILD_CORE to be defined.
2018-11-01 01:51:40 +01:00
Victor Stinner 13ff24582c
bpo-32593: Drop FreeBSD 9 and older support (#5232)
Drop support of FreeBSD 9 and older.
2018-01-22 18:32:50 +01:00
Victor Stinner 8c663fd60e
Replace KB unit with KiB (#4293)
kB (*kilo* byte) unit means 1000 bytes, whereas KiB ("kibibyte")
means 1024 bytes. KB was misused: replace kB or KB with KiB when
appropriate.

Same change for MB and GB which become MiB and GiB.

Change the output of Tools/iobench/iobench.py.

Round also the size of the documentation from 5.5 MB to 5 MiB.
2017-11-08 14:44:44 -08:00
Victor Stinner 850a18e03e bpo-30768: Recompute timeout on interrupted lock (GH-4103)
Fix the pthread+semaphore implementation of
PyThread_acquire_lock_timed() when called with timeout > 0 and
intr_flag=0: recompute the timeout if sem_timedwait() is interrupted
by a signal (EINTR).

See also the PEP 475.

The pthread implementation of PyThread_acquire_lock() now fails with
a fatal error if the timeout is larger than PY_TIMEOUT_MAX, as done
in the Windows implementation.

The check prevents any risk of overflow in PyThread_acquire_lock().

Add also PY_DWORD_MAX constant.
2017-10-24 16:53:32 -07:00
Masayuki Yamamoto 731e189014 bpo-25658: Implement PEP 539 for Thread Specific Storage (TSS) API (GH-1362)
See PEP 539 for details.

Highlights of changes:

- Add Thread Specific Storage (TSS) API
- Document the Thread Local Storage (TLS) API as deprecated
- Update code that used TLS API to use TSS API
2017-10-06 20:41:34 +10:00
Benjamin Peterson 288d1daada remove support for BSD/OS (closes bpo-31624) (#3812) 2017-09-28 22:44:27 -07:00
Eric Snow 2ebc5ce42a bpo-30860: Consolidate stateful runtime globals. (#3397)
* group the (stateful) runtime globals into various topical structs
* consolidate the topical structs under a single top-level _PyRuntimeState struct
* add a check-c-globals.py script that helps identify runtime globals

Other globals are excluded (see globals.txt and check-c-globals.py).
2017-09-07 23:51:28 -06:00
Eric Snow 05351c1bd8 Revert "bpo-30860: Consolidate stateful runtime globals." (#3379)
Windows buildbots started failing due to include-related errors.
2017-09-05 21:43:08 -07:00
Eric Snow 76d5abc868 bpo-30860: Consolidate stateful runtime globals. (#2594)
* group the (stateful) runtime globals into various topical structs
* consolidate the topical structs under a single top-level _PyRuntimeState struct
* add a check-c-globals.py script that helps identify runtime globals

Other globals are excluded (see globals.txt and check-c-globals.py).
2017-09-05 18:26:16 -07:00
Masayuki Yamamoto aa0aa0492c bpo-30832: Remove own implementation for thread-local storage (#2537)
* bpo-30832: Remove own implementation for thread-local storage

CPython has provided the own implementation for thread-local storage
(TLS) on Python/thread.c, it's used in the case which a platform has
not supplied native TLS.  However, currently all supported platforms
(NT and pthreads) have provided native TLS and defined the
Py_HAVE_NATIVE_TLS macro with unconditional in any case.

* bpo-30832: replace NT with Windows

* bpo-30832: change to directive chain

* bpo-30832: remove comemnt which making no sense
2017-07-03 13:34:38 +02:00
Antoine Pitrou f84ac420c2 bpo-30765: Avoid blocking when PyThread_acquire_lock() is asked not to (#2403)
* bpo-30765: Avoid blocking when PyThread_acquire_lock() is asked not to lock

This is especially important if PyThread_acquire_lock() is called reentrantly
(for example from a signal handler).

* Update 2017-06-26-14-29-50.bpo-30765.Q5iBmf.rst

* Avoid core logic when taking the mutex failed
2017-06-26 20:41:07 +02:00
Serhiy Storchaka aefa7ebf0f bpo-6532: Make the thread id an unsigned integer. (#781)
* bpo-6532: Make the thread id an unsigned integer.

From C API side the type of results of PyThread_start_new_thread() and
PyThread_get_thread_ident(), the id parameter of
PyThreadState_SetAsyncExc(), and the thread_id field of PyThreadState
changed from "long" to "unsigned long".

* Restore a check in thread_get_ident().
2017-03-23 14:48:39 +01:00
Daniel Birnstiel d7fa6b259e bpo-29859: Fix error messages from return codes for pthread_* calls (GH-741) 2017-03-21 22:06:06 +09:00
Victor Stinner daca3d7e9b Issue #22206: Using pthread, PyThread_create_key() now sets errno to ENOMEM and
returns -1 (error) on integer overflow.
2014-08-17 22:11:06 +02:00
Victor Stinner 590cebe391 Issue #19787: PyThread_set_key_value() now always set the value
In Python 3.3, PyThread_set_key_value() did nothing if the key already exists
(if the current value is a non-NULL pointer).

When _PyGILState_NoteThreadState() is called twice on the same thread with a
different Python thread state, it still keeps the old Python thread state to
keep the old behaviour. Replacing the Python thread state with the new state
introduces new bugs: see issues #10915 and #15751.
2013-12-13 11:08:56 +01:00
Victor Stinner 441adb8c57 Backout changeset 46393019b650
test_capi is failing and the fix is not trivial, I prefer to revert
2013-12-13 04:14:41 +01:00
Victor Stinner cd0cb8ccd3 Close #19787: PyThread_set_key_value() now always set the value. In Python 3.3,
the function did nothing if the key already exists (if the current value is a
non-NULL pointer).

_testcapi.run_in_subinterp() now correctly sets the new Python thread state of
the current thread when a subinterpreter is created.
2013-12-13 03:22:00 +01:00
Victor Stinner 80aa565fb4 Issue #18203: Replace malloc() with PyMem_RawMalloc() to allocate thread locks 2013-07-07 17:17:59 +02:00
Antoine Pitrou 9a00e0a41c Issue #18256: Compilation fix for recent AIX releases. Patch by David Edelsohn. 2013-06-18 22:17:48 +02:00
Christian Heimes 17485bf6f9 Issue #16588: Silence unused-but-set warnings in Python/thread_pthread.h 2012-12-02 08:38:42 +01:00
Christian Heimes 56379c0d8f Issue #16588: Silence unused-but-set warnings in Python/thread_pthread.h 2012-12-02 08:37:00 +01:00
Kristján Valur Jónsson 187aa54516 Signal condition variables with the mutex held. Destroy condition variables
before their mutexes.
2012-06-05 22:17:42 +00:00
Ned Deily 577c830531 Issue #14184: merge 2012-03-13 11:31:36 -07:00
Ned Deily 7ca97d5208 Issue #14184: Increase the default stack size for secondary threads on
Mac OS X to prevent interpreter crashes when compiled on 10.7.
2012-03-13 11:18:18 -07:00
Victor Stinner 87e78ce1c6 Issue #12469: partial revert of 024827a9db64, freebsd6 thread initialization
* Don't create a thread at startup anymore to initialize the pthread library:
   it changes the behaviour of many functions related to signal handling like
   sigwait()
 * Reenable test_sigtimedwait_poll() on FreeBSD 6
2011-07-04 22:53:49 +02:00
Victor Stinner e71db4450c Issue #12392: fix thread initialization on FreeBSD 6
On FreeBSD6, pthread_kill() doesn't work on the main thread before the creation
of the first thread. Create therefore a dummy thread (no-op) a startup to
initialize the pthread library.

Add also a test for this use case, test written by Charles-François Natali.
2011-06-24 20:52:27 +02:00
Ned Deily 61be422bd7 Issue #9670: Increase the default stack size for secondary threads on
Mac OS X and FreeBSD to reduce the chances of a crash instead of a
"maximum recursion depth" RuntimeError exception.
(patch by Ronald Oussoren)
2011-05-28 00:45:52 -07:00
Ned Deily 056f5b9dad Issue #9670: Increase the default stack size for secondary threads on
Mac OS X and FreeBSD to reduce the chances of a crash instead of a
"maximum recursion depth" RuntimeError exception.
(patch by Ronald Oussoren)
2011-05-28 00:36:12 -07:00
Ned Deily 9a7c524dc6 Issue #9670: Increase the default stack size for secondary threads on
Mac OS X and FreeBSD to reduce the chances of a crash instead of a
"maximum recursion depth" RuntimeError exception.
(patch by Ronald Oussoren)
2011-05-28 00:19:56 -07:00
Antoine Pitrou fc20b0c65c Issue #1856: Avoid crashes and lockups when daemon threads run while the
interpreter is shutting down; instead, these threads are now killed when
they try to take the GIL.
2011-05-04 20:04:29 +02:00
Antoine Pitrou 0d5e52d346 Issue #1856: Avoid crashes and lockups when daemon threads run while the
interpreter is shutting down; instead, these threads are now killed when
they try to take the GIL.
2011-05-04 20:02:30 +02:00
Ned Deily 4e6aba6f63 Issue9670: Merge backout from 3.2. 2011-04-09 14:58:04 -07:00
Ned Deily 2604e33f30 Issue9670: Merge backout to 3.2. 2011-04-09 14:53:47 -07:00
Ned Deily 45e47e58ed Issue9670: Back out changeset 378b40d71175; test fails on other platforms
and on OS X with pydebug.
2011-04-09 14:50:59 -07:00
Ned Deily 6e678b4395 Issue #9670: merge with current 2011-04-09 12:47:12 -07:00
Ned Deily 15012a67d2 Issue #9670: merge with 3.2 2011-04-09 12:37:55 -07:00
Ned Deily 517ac72b00 Issue #9670: Increase the default stack size for secondary threads on
Mac OS X and FreeBSD to reduce the chances of a crash instead of a
"maximum recursion depth" RuntimeError exception.
(Patch by Ronald Oussoren)
2011-04-09 12:32:12 -07:00