[Python-checkins] Add feature macro PY_HAVE_THREAD_NATIVE_ID to the stable ABI definition (GH-32365)

encukou webhook-mailer at python.org
Fri Apr 8 08:35:28 EDT 2022


https://github.com/python/cpython/commit/1c2fddddae5ce27be354b519f8ae51886b4dd9f4
commit: 1c2fddddae5ce27be354b519f8ae51886b4dd9f4
branch: main
author: Petr Viktorin <encukou at gmail.com>
committer: encukou <encukou at gmail.com>
date: 2022年04月08日T14:35:11+02:00
summary:
Add feature macro PY_HAVE_THREAD_NATIVE_ID to the stable ABI definition (GH-32365)
files:
A Misc/NEWS.d/next/C API/2022-04-06-16-29-14.bpo-47169.wVv2bT.rst
M Doc/data/stable_abi.dat
M Lib/test/test_stable_abi_ctypes.py
M Misc/stable_abi.txt
M Tools/scripts/stable_abi.py
diff --git a/Doc/data/stable_abi.dat b/Doc/data/stable_abi.dat
index 7f42f9c12de71..849a2cfd51f24 100644
--- a/Doc/data/stable_abi.dat
+++ b/Doc/data/stable_abi.dat
@@ -625,7 +625,7 @@ function,PyThread_free_lock,3.2,,
 function,PyThread_get_key_value,3.2,,
 function,PyThread_get_stacksize,3.2,,
 function,PyThread_get_thread_ident,3.2,,
-function,PyThread_get_thread_native_id,3.2,,
+function,PyThread_get_thread_native_id,3.2,on platforms with native thread IDs,
 function,PyThread_init_thread,3.2,,
 function,PyThread_release_lock,3.2,,
 function,PyThread_set_key_value,3.2,,
diff --git a/Lib/test/test_stable_abi_ctypes.py b/Lib/test/test_stable_abi_ctypes.py
index a49235b81c1b0..efd3b1b7cd2d2 100644
--- a/Lib/test/test_stable_abi_ctypes.py
+++ b/Lib/test/test_stable_abi_ctypes.py
@@ -615,7 +615,6 @@ def test_available_symbols(self):
 "PyThread_get_key_value",
 "PyThread_get_stacksize",
 "PyThread_get_thread_ident",
- "PyThread_get_thread_native_id",
 "PyThread_init_thread",
 "PyThread_release_lock",
 "PyThread_set_key_value",
diff --git a/Misc/NEWS.d/next/C API/2022-04-06-16-29-14.bpo-47169.wVv2bT.rst b/Misc/NEWS.d/next/C API/2022-04-06-16-29-14.bpo-47169.wVv2bT.rst
new file mode 100644
index 0000000000000..66eac052391e5
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2022-04-06-16-29-14.bpo-47169.wVv2bT.rst	
@@ -0,0 +1,2 @@
+:c:func:`PyThread_get_thread_native_id` is excluded from the stable ABI on
+platforms where it doesn't exist (like Solaris).
diff --git a/Misc/stable_abi.txt b/Misc/stable_abi.txt
index 04d22603cc19b..4864bf319a76f 100644
--- a/Misc/stable_abi.txt
+++ b/Misc/stable_abi.txt
@@ -1787,6 +1787,7 @@ function PyThread_get_stacksize
 function PyThread_get_thread_ident
 added 3.2
 function PyThread_get_thread_native_id
+ ifdef PY_HAVE_THREAD_NATIVE_ID
 added 3.2
 function PyThread_init_thread
 added 3.2
diff --git a/Tools/scripts/stable_abi.py b/Tools/scripts/stable_abi.py
index feca9a2ba5a4c..9b90e344977f4 100755
--- a/Tools/scripts/stable_abi.py
+++ b/Tools/scripts/stable_abi.py
@@ -49,8 +49,17 @@
 'MS_WINDOWS': 'on Windows',
 'HAVE_FORK': 'on platforms with fork()',
 'USE_STACKCHECK': 'on platforms with USE_STACKCHECK',
+ 'PY_HAVE_THREAD_NATIVE_ID': 'on platforms with native thread IDs',
 }
 
+# To generate the DLL definition, we need to know which feature macros are
+# defined on Windows. On all platforms.
+# Best way to do that is to hardcode the list (and later test in on Windows).
+WINDOWS_IFDEFS = frozenset({
+ 'MS_WINDOWS',
+ 'PY_HAVE_THREAD_NATIVE_ID',
+})
+
 # The stable ABI manifest (Misc/stable_abi.txt) exists only to fill the
 # following dataclasses.
 # Feel free to change its syntax (and the `parse_manifest` function)
@@ -232,7 +241,7 @@ def sort_key(item):
 
 for item in sorted(
 manifest.select(
- {'function'}, include_abi_only=True, ifdef={'MS_WINDOWS'}),
+ {'function'}, include_abi_only=True, ifdef=WINDOWS_IFDEFS),
 key=sort_key):
 write(f'EXPORT_FUNC({item.name})')
 
@@ -240,7 +249,7 @@ def sort_key(item):
 
 for item in sorted(
 manifest.select(
- {'data'}, include_abi_only=True, ifdef={'MS_WINDOWS'}),
+ {'data'}, include_abi_only=True, ifdef=WINDOWS_IFDEFS),
 key=sort_key):
 write(f'EXPORT_DATA({item.name})')
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /