[3.15] gh-150907: Fix dynamic_annotations.h when built with C++ and Valgrind (GH-150914) (#150962)

gh-150907: Fix dynamic_annotations.h when built with C++ and Valgrind (GH-150914)

Add extern "C++" scope for the C++ template.

Fix test_cppext when Python is built with --with-valgrind.
(cherry picked from commit c32501261a)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Miss Islington (bot) 2026-06-05 14:41:19 +02:00 committed by GitHub
parent d8af158eb6
commit 85e75a73d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View file

@ -461,6 +461,7 @@ int RunningOnValgrind(void);
#if DYNAMIC_ANNOTATIONS_ENABLED != 0 && defined(__cplusplus)
extern "C++" {
/* _Py_ANNOTATE_UNPROTECTED_READ is the preferred way to annotate racey reads.
Instead of doing
@ -476,6 +477,8 @@ int RunningOnValgrind(void);
_Py_ANNOTATE_IGNORE_READS_END();
return res;
}
}
/* Apply _Py_ANNOTATE_BENIGN_RACE_SIZED to a static variable. */
#define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) \
namespace { \

View file

@ -0,0 +1,2 @@
Fix ``dynamic_annotations.h`` header file when built with C++ and Valgrind:
add ``extern "C++" scope`` for the C++ template. Patch by Victor Stinner.