Skip to content

Commit c8d5057

Browse files
committed
Test: Refresh the vendored CPython headers to 3.15.0
VendoredHeaderVersionTest failed once the default became 3.15.0: the tree under src/nativeInterop/cinterop/include, which EmbedApiSurfaceTest and JniCallConventionClassificationTest read as the C API's source of truth, was still 3.14.7. It is now mirrored from the build's own checksum-verified extraction (build/python-standalone/extracted/3.15.0/android-aarch64/prefix/include/python3.15), as 8e40577 did for 3.14.7: 17 headers added, 8 removed (cpython/lock.h became cpython/pylock.h), 138 changed. Both suites pass on the 3.15.0 headers, so the surface did not move. Refs #196
1 parent ce87827 commit c8d5057

161 files changed

Lines changed: 17623 additions & 11508 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎python-multiplatform/src/nativeInterop/cinterop/include/Python.h‎

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
// is not needed.
1010

1111

12-
// Include Python header files
13-
#include "patchlevel.h"
14-
#include "pyconfig.h"
15-
#include "pymacconfig.h"
12+
// Include Python configuration headers
13+
#include "patchlevel.h" // the Python version
14+
#include "pyconfig.h" // information from configure
15+
#include "pymacconfig.h" // overrides for pyconfig
16+
#include "pyabi.h" // feature/ABI selection
1617

1718

1819
// Include standard header files
@@ -22,12 +23,13 @@
2223
#include <limits.h> // INT_MAX
2324
#include <math.h> // HUGE_VAL
2425
#include <stdarg.h> // va_list
26+
#include <string.h> // memcpy()
2527
#include <wchar.h> // wchar_t
2628
#ifdef HAVE_SYS_TYPES_H
2729
# include <sys/types.h> // ssize_t
2830
#endif
2931

30-
// <errno.h>, <stdio.h>, <stdlib.h> and <string.h> headers are no longer used
32+
// <errno.h>, <stdio.h> and <stdlib.h> headers are no longer used
3133
// by Python, but kept for the backward compatibility of existing third party C
3234
// extensions. They are not included by limited C API version 3.11 and newer.
3335
//
@@ -37,7 +39,6 @@
3739
# include <errno.h> // errno
3840
# include <stdio.h> // FILE*
3941
# include <stdlib.h> // getenv()
40-
# include <string.h> // memcpy()
4142
#endif
4243
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030d0000
4344
# include <ctype.h> // tolower()
@@ -46,43 +47,40 @@
4647
# endif
4748
#endif
4849

49-
// gh-111506: The free-threaded build is not compatible with the limited API
50-
// or the stable ABI.
51-
#if defined(Py_LIMITED_API) && defined(Py_GIL_DISABLED)
52-
# error "The limited API is not currently supported in the free-threaded build"
53-
#endif
54-
55-
#if defined(Py_GIL_DISABLED) && defined(_MSC_VER)
56-
# include <intrin.h> // __readgsqword()
57-
#endif
50+
#if !defined(Py_LIMITED_API)
51+
# if defined(Py_GIL_DISABLED)
52+
# if defined(_MSC_VER) || defined(__MINGW32__)
53+
# include <intrin.h> // __readgsqword()
54+
# endif
55+
# endif
56+
#endif // Py_GIL_DISABLED
5857

59-
#if defined(Py_GIL_DISABLED) && defined(__MINGW32__)
60-
# include <intrin.h> // __readgsqword()
58+
#ifdef _MSC_VER
59+
// Ignore MSC warning C4201: "nonstandard extension used: nameless
60+
// struct/union". (Only generated for C standard versions less than C11, which
61+
// we don't *officially* support.)
62+
__pragma(warning(push))
63+
__pragma(warning(disable: 4201))
6164
#endif
6265

63-
// Suppress known warnings in Python header files.
64-
#if defined(_MSC_VER)
65-
// Warning that alignas behaviour has changed. Doesn't affect us, because we
66-
// never relied on the old behaviour.
67-
#pragma warning(push)
68-
#pragma warning(disable: 5274)
69-
#endif
7066

7167
// Include Python header files
7268
#include "pyport.h"
69+
#include "exports.h"
7370
#include "pymacro.h"
7471
#include "pymath.h"
7572
#include "pymem.h"
7673
#include "pytypedefs.h"
7774
#include "pybuffer.h"
7875
#include "pystats.h"
7976
#include "pyatomic.h"
80-
#include "lock.h"
77+
#include "cpython/pylock.h"
8178
#include "critical_section.h"
8279
#include "object.h"
8380
#include "refcount.h"
8481
#include "objimpl.h"
85-
#include "typeslots.h"
82+
#include "slots.h"
83+
#include "slots_generated.h"
8684
#include "pyhash.h"
8785
#include "cpython/pydebug.h"
8886
#include "bytearrayobject.h"
@@ -104,7 +102,7 @@
104102
#include "setobject.h"
105103
#include "methodobject.h"
106104
#include "moduleobject.h"
107-
#include "monitoring.h"
105+
#include "cpython/monitoring.h"
108106
#include "cpython/funcobject.h"
109107
#include "cpython/classobject.h"
110108
#include "fileobject.h"
@@ -120,6 +118,7 @@
120118
#include "cpython/genobject.h"
121119
#include "descrobject.h"
122120
#include "genericaliasobject.h"
121+
#include "cpython/sentinelobject.h"
123122
#include "warnings.h"
124123
#include "weakrefobject.h"
125124
#include "structseq.h"
@@ -147,9 +146,8 @@
147146
#include "cpython/pyfpe.h"
148147
#include "cpython/tracemalloc.h"
149148

150-
// Restore warning filter
151149
#ifdef _MSC_VER
152-
#pragma warning(pop)
150+
__pragma(warning(pop)) // warning(disable: 4201)
153151
#endif
154152

155153
#endif /* !Py_PYTHON_H */

‎python-multiplatform/src/nativeInterop/cinterop/include/cpython/abstract.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/* Like PyObject_CallMethod(), but expect a _Py_Identifier*
88
as the method name. */
9-
PyAPI_FUNC(PyObject*) _PyObject_CallMethodId(
9+
Py_DEPRECATED(3.15) PyAPI_FUNC(PyObject*) _PyObject_CallMethodId(
1010
PyObject *obj,
1111
_Py_Identifier *name,
1212
const char *format, ...);

‎python-multiplatform/src/nativeInterop/cinterop/include/cpython/bytearrayobject.h‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@
55
/* Object layout */
66
typedef struct {
77
PyObject_VAR_HEAD
8-
Py_ssize_t ob_alloc; /* How many bytes allocated in ob_bytes */
8+
/* How many bytes allocated in ob_bytes
9+
10+
In the current implementation this is equivalent to Py_SIZE(ob_bytes_object).
11+
The value is always loaded and stored atomically for thread safety.
12+
There are API compatibilty concerns with removing so keeping for now. */
13+
Py_ssize_t ob_alloc;
914
char *ob_bytes; /* Physical backing buffer */
1015
char *ob_start; /* Logical start inside ob_bytes */
1116
Py_ssize_t ob_exports; /* How many buffer exports */
17+
PyObject *ob_bytes_object; /* PyBytes for zero-copy bytes conversion */
1218
} PyByteArrayObject;
1319

14-
PyAPI_DATA(char) _PyByteArray_empty_string[];
15-
1620
/* Macros and static inline functions, trading safety for speed */
1721
#define _PyByteArray_CAST(op) \
1822
(assert(PyByteArray_Check(op)), _Py_CAST(PyByteArrayObject*, op))
1923

2024
static inline char* PyByteArray_AS_STRING(PyObject *op)
2125
{
22-
PyByteArrayObject *self = _PyByteArray_CAST(op);
23-
if (Py_SIZE(self)) {
24-
return self->ob_start;
25-
}
26-
return _PyByteArray_empty_string;
26+
return _PyByteArray_CAST(op)->ob_start;
2727
}
2828
#define PyByteArray_AS_STRING(self) PyByteArray_AS_STRING(_PyObject_CAST(self))
2929

‎python-multiplatform/src/nativeInterop/cinterop/include/cpython/bytesobject.h‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,46 @@ _PyBytes_Join(PyObject *sep, PyObject *iterable)
4040
{
4141
return PyBytes_Join(sep, iterable);
4242
}
43+
44+
45+
// --- PyBytesWriter API -----------------------------------------------------
46+
47+
typedef struct PyBytesWriter PyBytesWriter;
48+
49+
PyAPI_FUNC(PyBytesWriter *) PyBytesWriter_Create(
50+
Py_ssize_t size);
51+
PyAPI_FUNC(void) PyBytesWriter_Discard(
52+
PyBytesWriter *writer);
53+
PyAPI_FUNC(PyObject*) PyBytesWriter_Finish(
54+
PyBytesWriter *writer);
55+
PyAPI_FUNC(PyObject*) PyBytesWriter_FinishWithSize(
56+
PyBytesWriter *writer,
57+
Py_ssize_t size);
58+
PyAPI_FUNC(PyObject*) PyBytesWriter_FinishWithPointer(
59+
PyBytesWriter *writer,
60+
void *buf);
61+
62+
PyAPI_FUNC(void*) PyBytesWriter_GetData(
63+
PyBytesWriter *writer);
64+
PyAPI_FUNC(Py_ssize_t) PyBytesWriter_GetSize(
65+
PyBytesWriter *writer);
66+
67+
PyAPI_FUNC(int) PyBytesWriter_WriteBytes(
68+
PyBytesWriter *writer,
69+
const void *bytes,
70+
Py_ssize_t size);
71+
PyAPI_FUNC(int) PyBytesWriter_Format(
72+
PyBytesWriter *writer,
73+
const char *format,
74+
...);
75+
76+
PyAPI_FUNC(int) PyBytesWriter_Resize(
77+
PyBytesWriter *writer,
78+
Py_ssize_t size);
79+
PyAPI_FUNC(int) PyBytesWriter_Grow(
80+
PyBytesWriter *writer,
81+
Py_ssize_t size);
82+
PyAPI_FUNC(void*) PyBytesWriter_GrowAndUpdatePointer(
83+
PyBytesWriter *writer,
84+
Py_ssize_t size,
85+
void *buf);

‎python-multiplatform/src/nativeInterop/cinterop/include/cpython/ceval.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ _PyEval_RequestCodeExtraIndex(freefunc f) {
2323

2424
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
2525
PyAPI_FUNC(int) _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *);
26+
PyAPI_FUNC(int) _PyEval_UnpackIndices(PyObject *, PyObject *,
27+
Py_ssize_t,
28+
Py_ssize_t *, Py_ssize_t *);
2629

2730

2831
// Trampoline API
@@ -35,7 +38,7 @@ typedef struct {
3538
PyAPI_FUNC(int) PyUnstable_PerfMapState_Init(void);
3639
PyAPI_FUNC(int) PyUnstable_WritePerfMapEntry(
3740
const void *code_addr,
38-
unsigned int code_size,
41+
size_t code_size,
3942
const char *entry_name);
4043
PyAPI_FUNC(void) PyUnstable_PerfMapState_Fini(void);
4144
PyAPI_FUNC(int) PyUnstable_CopyPerfMapFile(const char* parent_filename);

‎python-multiplatform/src/nativeInterop/cinterop/include/cpython/code.h‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,6 @@ typedef struct _line_offsets {
282282
*/
283283
PyAPI_FUNC(int) _PyCode_CheckLineNumber(int lasti, PyCodeAddressRange *bounds);
284284

285-
/* Create a comparable key used to compare constants taking in account the
286-
* object type. It is used to make sure types are not coerced (e.g., float and
287-
* complex) _and_ to distinguish 0.0 from -0.0 e.g. on IEEE platforms
288-
*
289-
* Return (type(obj), obj, ...): a tuple with variable size (at least 2 items)
290-
* depending on the type and the value. The type is the first item to not
291-
* compare bytes and str which can raise a BytesWarning exception. */
292-
PyAPI_FUNC(PyObject*) _PyCode_ConstantKey(PyObject *obj);
293-
294285
PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts,
295286
PyObject *names, PyObject *lnotab);
296287

‎python-multiplatform/src/nativeInterop/cinterop/include/cpython/complexobject.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ typedef struct {
77
double imag;
88
} Py_complex;
99

10-
// Operations on complex numbers.
10+
/* Operations on complex numbers (soft deprecated
11+
since Python 3.15). */
1112
PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
1213
PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
1314
PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);

‎python-multiplatform/src/nativeInterop/cinterop/include/cpython/critical_section.h‎

Lines changed: 7 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
// Python critical sections
6-
//
7-
// Conceptually, critical sections are a deadlock avoidance layer on top of
8-
// per-object locks. These helpers, in combination with those locks, replace
9-
// our usage of the global interpreter lock to provide thread-safety for
10-
// otherwise thread-unsafe objects, such as dict.
11-
//
12-
// NOTE: These APIs are no-ops in non-free-threaded builds.
13-
//
145
// Straightforward per-object locking could introduce deadlocks that were not
156
// present when running with the GIL. Threads may hold locks for multiple
167
// objects simultaneously because Python operations can nest. If threads were
@@ -43,52 +34,19 @@
4334
// `_PyThreadState_Attach()`, it resumes the top-most (i.e., most recent)
4435
// critical section by reacquiring the associated lock or locks. See
4536
// `_PyCriticalSection_Resume()`.
46-
//
47-
// NOTE: Only the top-most critical section is guaranteed to be active.
48-
// Operations that need to lock two objects at once must use
49-
// `Py_BEGIN_CRITICAL_SECTION2()`. You *CANNOT* use nested critical sections
50-
// to lock more than one object at once, because the inner critical section
51-
// may suspend the outer critical sections. This API does not provide a way
52-
// to lock more than two objects at once (though it could be added later
53-
// if actually needed).
54-
//
55-
// NOTE: Critical sections implicitly behave like reentrant locks because
56-
// attempting to acquire the same lock will suspend any outer (earlier)
57-
// critical sections. However, they are less efficient for this use case than
58-
// purposefully designed reentrant locks.
59-
//
60-
// Example usage:
61-
// Py_BEGIN_CRITICAL_SECTION(op);
62-
// ...
63-
// Py_END_CRITICAL_SECTION();
64-
//
65-
// To lock two objects at once:
66-
// Py_BEGIN_CRITICAL_SECTION2(op1, op2);
67-
// ...
68-
// Py_END_CRITICAL_SECTION2();
69-
70-
typedef struct PyCriticalSection PyCriticalSection;
71-
typedef struct PyCriticalSection2 PyCriticalSection2;
72-
73-
PyAPI_FUNC(void)
74-
PyCriticalSection_Begin(PyCriticalSection *c, PyObject *op);
7537

7638
PyAPI_FUNC(void)
7739
PyCriticalSection_BeginMutex(PyCriticalSection *c, PyMutex *m);
7840

79-
PyAPI_FUNC(void)
80-
PyCriticalSection_End(PyCriticalSection *c);
81-
82-
PyAPI_FUNC(void)
83-
PyCriticalSection2_Begin(PyCriticalSection2 *c, PyObject *a, PyObject *b);
84-
8541
PyAPI_FUNC(void)
8642
PyCriticalSection2_BeginMutex(PyCriticalSection2 *c, PyMutex *m1, PyMutex *m2);
8743

88-
PyAPI_FUNC(void)
89-
PyCriticalSection2_End(PyCriticalSection2 *c);
90-
9144
#ifndef Py_GIL_DISABLED
45+
#undef Py_BEGIN_CRITICAL_SECTION
46+
#undef Py_END_CRITICAL_SECTION
47+
#undef Py_BEGIN_CRITICAL_SECTION2
48+
#undef Py_END_CRITICAL_SECTION2
49+
9250
# define Py_BEGIN_CRITICAL_SECTION(op) \
9351
{
9452
# define Py_BEGIN_CRITICAL_SECTION_MUTEX(mutex) \
@@ -101,54 +59,17 @@ PyCriticalSection2_End(PyCriticalSection2 *c);
10159
{
10260
# define Py_END_CRITICAL_SECTION2() \
10361
}
104-
#else /* !Py_GIL_DISABLED */
105-
106-
// NOTE: the contents of this struct are private and may change betweeen
107-
// Python releases without a deprecation period.
108-
struct PyCriticalSection {
109-
// Tagged pointer to an outer active critical section (or 0).
110-
uintptr_t _cs_prev;
111-
112-
// Mutex used to protect critical section
113-
PyMutex *_cs_mutex;
114-
};
115-
116-
// A critical section protected by two mutexes. Use
117-
// Py_BEGIN_CRITICAL_SECTION2 and Py_END_CRITICAL_SECTION2.
118-
// NOTE: the contents of this struct are private and may change betweeen
119-
// Python releases without a deprecation period.
120-
struct PyCriticalSection2 {
121-
PyCriticalSection _cs_base;
12262

123-
PyMutex *_cs_mutex2;
124-
};
125-
126-
# define Py_BEGIN_CRITICAL_SECTION(op) \
127-
{ \
128-
PyCriticalSection _py_cs; \
129-
PyCriticalSection_Begin(&_py_cs, _PyObject_CAST(op))
63+
#else /* !Py_GIL_DISABLED */
13064

13165
# define Py_BEGIN_CRITICAL_SECTION_MUTEX(mutex) \
13266
{ \
13367
PyCriticalSection _py_cs; \
13468
PyCriticalSection_BeginMutex(&_py_cs, mutex)
13569

136-
# define Py_END_CRITICAL_SECTION() \
137-
PyCriticalSection_End(&_py_cs); \
138-
}
139-
140-
# define Py_BEGIN_CRITICAL_SECTION2(a, b) \
141-
{ \
142-
PyCriticalSection2 _py_cs2; \
143-
PyCriticalSection2_Begin(&_py_cs2, _PyObject_CAST(a), _PyObject_CAST(b))
144-
14570
# define Py_BEGIN_CRITICAL_SECTION2_MUTEX(m1, m2) \
14671
{ \
14772
PyCriticalSection2 _py_cs2; \
14873
PyCriticalSection2_BeginMutex(&_py_cs2, m1, m2)
14974

150-
# define Py_END_CRITICAL_SECTION2() \
151-
PyCriticalSection2_End(&_py_cs2); \
152-
}
153-
154-
#endif
75+
#endif /* !Py_GIL_DISABLED */

0 commit comments

Comments
 (0)