Skip to content

Commit 1c2fddd

Browse files
authored
Add feature macro PY_HAVE_THREAD_NATIVE_ID to the stable ABI definition (GH-32365)
1 parent 5b4a4b6 commit 1c2fddd

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

Doc/data/stable_abi.dat

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_stable_abi_ctypes.py

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:c:func:`PyThread_get_thread_native_id` is excluded from the stable ABI on
2+
platforms where it doesn't exist (like Solaris).

Misc/stable_abi.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,6 +1787,7 @@ function PyThread_get_stacksize
17871787
function PyThread_get_thread_ident
17881788
added 3.2
17891789
function PyThread_get_thread_native_id
1790+
ifdef PY_HAVE_THREAD_NATIVE_ID
17901791
added 3.2
17911792
function PyThread_init_thread
17921793
added 3.2

Tools/scripts/stable_abi.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,17 @@
4949
'MS_WINDOWS': 'on Windows',
5050
'HAVE_FORK': 'on platforms with fork()',
5151
'USE_STACKCHECK': 'on platforms with USE_STACKCHECK',
52+
'PY_HAVE_THREAD_NATIVE_ID': 'on platforms with native thread IDs',
5253
}
5354

55+
# To generate the DLL definition, we need to know which feature macros are
56+
# defined on Windows. On all platforms.
57+
# Best way to do that is to hardcode the list (and later test in on Windows).
58+
WINDOWS_IFDEFS = frozenset({
59+
'MS_WINDOWS',
60+
'PY_HAVE_THREAD_NATIVE_ID',
61+
})
62+
5463
# The stable ABI manifest (Misc/stable_abi.txt) exists only to fill the
5564
# following dataclasses.
5665
# Feel free to change its syntax (and the `parse_manifest` function)
@@ -232,15 +241,15 @@ def sort_key(item):
232241

233242
for item in sorted(
234243
manifest.select(
235-
{'function'}, include_abi_only=True, ifdef={'MS_WINDOWS'}),
244+
{'function'}, include_abi_only=True, ifdef=WINDOWS_IFDEFS),
236245
key=sort_key):
237246
write(f'EXPORT_FUNC({item.name})')
238247

239248
write()
240249

241250
for item in sorted(
242251
manifest.select(
243-
{'data'}, include_abi_only=True, ifdef={'MS_WINDOWS'}),
252+
{'data'}, include_abi_only=True, ifdef=WINDOWS_IFDEFS),
244253
key=sort_key):
245254
write(f'EXPORT_DATA({item.name})')
246255

0 commit comments

Comments
 (0)