bpo-35081: Move Py_BUILD_CORE code to internal/mem.h (GH-10249) · python/cpython@2be00d9 (original) (raw)

10 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@
4 4 extern "C" {
5 5 #endif
6 6
7 +#ifndef Py_BUILD_CORE
8 +# error "Py_BUILD_CORE must be defined to include this header"
9 +#endif
10 +
7 11 #include "objimpl.h"
8 12 #include "pymem.h"
9 13
@@ -145,6 +149,14 @@ PyAPI_FUNC(void) _PyGC_Initialize(struct _gc_runtime_state *);
145 149
146 150 #define _PyGC_generation0 _PyRuntime.gc.generation0
147 151
152 +
153 +/* Set the memory allocator of the specified domain to the default.
154 + Save the old allocator into *old_alloc if it's non-NULL.
155 + Return on success, or return -1 if the domain is unknown. */
156 +PyAPI_FUNC(int) _PyMem_SetDefaultAllocator(
157 +PyMemAllocatorDomain domain,
158 +PyMemAllocatorEx *old_alloc);
159 +
148 160 #ifdef __cplusplus
149 161 }
150 162 #endif
Original file line number Diff line number Diff line change
@@ -198,16 +198,6 @@ PyAPI_FUNC(void) PyMem_SetAllocator(PyMemAllocatorDomain domain,
198 198 PyAPI_FUNC(void) PyMem_SetupDebugHooks(void);
199 199 #endif /* Py_LIMITED_API */
200 200
201 -#ifdef Py_BUILD_CORE
202 -/* Set the memory allocator of the specified domain to the default.
203 - Save the old allocator into *old_alloc if it's non-NULL.
204 - Return on success, or return -1 if the domain is unknown. */
205 -PyAPI_FUNC(int) _PyMem_SetDefaultAllocator(
206 -PyMemAllocatorDomain domain,
207 -PyMemAllocatorEx *old_alloc);
208 -#endif
209 -
210 -
211 201 /* bpo-35053: expose _Py_tracemalloc_config for performance:
212 202 _Py_NewReference() needs an efficient check to test if tracemalloc is
213 203 tracing.
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
2 2
3 3 #include "Python.h"
4 4 #include "osdefs.h"
5 +#include "internal/mem.h"
5 6 #include "internal/pygetopt.h"
6 7 #include "internal/pystate.h"
7 8
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
1 1 #include "Python.h"
2 +#include "internal/mem.h"
2 3
3 4 #include <stdbool.h>
4 5
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
1 1 #include "Python.h"
2 +#include "internal/mem.h"
2 3 #include "internal/pystate.h"
3 4 #include <locale.h>
4 5 #ifdef HAVE_LANGINFO_H
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
5 5 #include "Python-ast.h"
6 6 #undef Yield /* undefine macro conflicting with winbase.h */
7 7 #include "internal/hash.h"
8 +#include "internal/mem.h"
8 9 #include "internal/pystate.h"
9 10 #include "errcode.h"
10 11 #include "marshal.h"
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
2 2
3 3 #include "Python.h"
4 4 #include "osdefs.h"
5 +#include "internal/mem.h"
5 6 #include "internal/pystate.h"
6 7 #include <wchar.h>
7 8
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
6 6 #undef Yield /* undefine macro conflicting with winbase.h */
7 7 #include "internal/context.h"
8 8 #include "internal/hamt.h"
9 +#include "internal/mem.h"
9 10 #include "internal/pystate.h"
10 11 #include "grammar.h"
11 12 #include "node.h"
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
2 2 /* Thread and interpreter state structures and their interfaces */
3 3
4 4 #include "Python.h"
5 +#include "internal/mem.h"
5 6 #include "internal/pystate.h"
6 7
7 8 #define _PyThreadState_SET(value) \
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ Data members:
15 15 */
16 16
17 17 #include "Python.h"
18 +#include "internal/mem.h"
18 19 #include "internal/pystate.h"
19 20 #include "code.h"
20 21 #include "frameobject.h"