summaryrefslogtreecommitdiffstats
path: root/Include/pymacro.h
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-01-23 18:08:23 (GMT)
committerGitHub <noreply@github.com>2024-01-23 18:08:23 (GMT)
commit441affc9e7f419ef0b68f734505fa2f79fe653c7 (patch)
tree1c7771190fffc7927ab70f485500521a96de7938 /Include/pymacro.h
parent5f1997896d9c3ecf92e9863177c452b468a6a2c8 (diff)
downloadcpython-441affc9e7f419ef0b68f734505fa2f79fe653c7.zip
cpython-441affc9e7f419ef0b68f734505fa2f79fe653c7.tar.gz
cpython-441affc9e7f419ef0b68f734505fa2f79fe653c7.tar.bz2
gh-111964: Implement stop-the-world pauses (gh-112471)
The `--disable-gil` builds occasionally need to pause all but one thread. Some examples include: * Cyclic garbage collection, where this is often called a "stop the world event" * Before calling `fork()`, to ensure a consistent state for internal data structures * During interpreter shutdown, to ensure that daemon threads aren't accessing Python objects This adds the following functions to implement global and per-interpreter pauses: * `_PyEval_StopTheWorldAll()` and `_PyEval_StartTheWorldAll()` (for the global runtime) * `_PyEval_StopTheWorld()` and `_PyEval_StartTheWorld()` (per-interpreter) (The function names may change.) These functions are no-ops outside of the `--disable-gil` build.
Diffstat (limited to 'Include/pymacro.h')
-rw-r--r--Include/pymacro.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/Include/pymacro.h b/Include/pymacro.h
index 9d264fe..cd6fc4e 100644
--- a/Include/pymacro.h
+++ b/Include/pymacro.h
@@ -160,6 +160,9 @@
Py_FatalError("Unreachable C code path reached")
#endif
+#define _Py_CONTAINER_OF(ptr, type, member) \
+ (type*)((char*)ptr - offsetof(type, member))
+
// Prevent using an expression as a l-value.
// For example, "int x; _Py_RVALUE(x) = 1;" fails with a compiler error.
#define _Py_RVALUE(EXPR) ((void)0, (EXPR))