bpo-35134: Create Include/cpython/ subdirectory (GH-10624) · python/cpython@e421106 (original) (raw)
`@@ -101,17 +101,6 @@ PyAPI_FUNC(void *) PyObject_Calloc(size_t nelem, size_t elsize);
`
101
101
`PyAPI_FUNC(void *) PyObject_Realloc(void *ptr, size_t new_size);
`
102
102
`PyAPI_FUNC(void) PyObject_Free(void *ptr);
`
103
103
``
104
``
`-
#ifndef Py_LIMITED_API
`
105
``
`-
/* This function returns the number of allocated memory blocks, regardless of size */
`
106
``
`-
PyAPI_FUNC(Py_ssize_t) _Py_GetAllocatedBlocks(void);
`
107
``
`-
#endif /* !Py_LIMITED_API */
`
108
``
-
109
``
`-
/* Macros */
`
110
``
`-
#ifdef WITH_PYMALLOC
`
111
``
`-
#ifndef Py_LIMITED_API
`
112
``
`-
PyAPI_FUNC(int) _PyObject_DebugMallocStats(FILE *out);
`
113
``
`-
#endif /* #ifndef Py_LIMITED_API */
`
114
``
`-
#endif
`
115
104
``
116
105
`/* Macros */
`
117
106
`#define PyObject_MALLOC PyObject_Malloc
`
`@@ -226,24 +215,6 @@ _PyObject_INIT_VAR(PyVarObject *op, PyTypeObject *typeobj, Py_ssize_t size)
`
226
215
` constructor you would start directly with PyObject_Init/InitVar
`
227
216
`*/
`
228
217
``
229
``
`-
#ifndef Py_LIMITED_API
`
230
``
`-
typedef struct {
`
231
``
`-
/* user context passed as the first argument to the 2 functions */
`
232
``
`-
void *ctx;
`
233
``
-
234
``
`-
/* allocate an arena of size bytes */
`
235
``
`-
void* (*alloc) (void *ctx, size_t size);
`
236
``
-
237
``
`-
/* free an arena */
`
238
``
`-
void (*free) (void *ctx, void *ptr, size_t size);
`
239
``
`-
} PyObjectArenaAllocator;
`
240
``
-
241
``
`-
/* Get the arena allocator. */
`
242
``
`-
PyAPI_FUNC(void) PyObject_GetArenaAllocator(PyObjectArenaAllocator *allocator);
`
243
``
-
244
``
`-
/* Set the arena allocator. */
`
245
``
`-
PyAPI_FUNC(void) PyObject_SetArenaAllocator(PyObjectArenaAllocator *allocator);
`
246
``
`-
#endif
`
247
218
``
248
219
``
249
220
`/*
`
`@@ -254,11 +225,6 @@ PyAPI_FUNC(void) PyObject_SetArenaAllocator(PyObjectArenaAllocator *allocator);
`
254
225
`/* C equivalent of gc.collect() which ignores the state of gc.enabled. */
`
255
226
`PyAPI_FUNC(Py_ssize_t) PyGC_Collect(void);
`
256
227
``
257
``
`-
#ifndef Py_LIMITED_API
`
258
``
`-
PyAPI_FUNC(Py_ssize_t) _PyGC_CollectNoFail(void);
`
259
``
`-
PyAPI_FUNC(Py_ssize_t) _PyGC_CollectIfEnabled(void);
`
260
``
`-
#endif
`
261
``
-
262
228
`/* Test if a type has a GC head */
`
263
229
`#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC)
`
264
230
``
`@@ -267,72 +233,7 @@ PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t);
`
267
233
` ( (type *) _PyObject_GC_Resize(_PyVarObject_CAST(op), (n)) )
`
268
234
``
269
235
``
270
``
`-
#ifndef Py_LIMITED_API
`
271
``
`-
/* Test if an object has a GC head */
`
272
``
`-
#define PyObject_IS_GC(o) \
`
273
``
`-
(PyType_IS_GC(Py_TYPE(o)) \
`
274
``
`-
&& (Py_TYPE(o)->tp_is_gc == NULL || Py_TYPE(o)->tp_is_gc(o)))
`
275
``
-
276
``
`-
/* GC information is stored BEFORE the object structure. */
`
277
``
`-
typedef struct {
`
278
``
`-
// Pointer to next object in the list.
`
279
``
`-
// 0 means the object is not tracked
`
280
``
`-
uintptr_t _gc_next;
`
281
``
-
282
``
`-
// Pointer to previous object in the list.
`
283
``
`-
// Lowest two bits are used for flags documented later.
`
284
``
`-
uintptr_t _gc_prev;
`
285
``
`-
} PyGC_Head;
`
286
``
-
287
``
`-
#define _Py_AS_GC(o) ((PyGC_Head *)(o)-1)
`
288
``
-
289
``
`-
/* True if the object is currently tracked by the GC. */
`
290
``
`-
#define _PyObject_GC_IS_TRACKED(o) (_Py_AS_GC(o)->_gc_next != 0)
`
291
``
-
292
``
`-
/* True if the object may be tracked by the GC in the future, or already is.
`
293
``
`-
This can be useful to implement some optimizations. */
`
294
``
`-
#define _PyObject_GC_MAY_BE_TRACKED(obj) \
`
295
``
`-
(PyObject_IS_GC(obj) && \
`
296
``
`-
(!PyTuple_CheckExact(obj) || _PyObject_GC_IS_TRACKED(obj)))
`
297
``
-
298
``
-
299
``
`-
/* Bit flags for _gc_prev */
`
300
``
`-
/* Bit 0 is set when tp_finalize is called */
`
301
``
`-
#define _PyGC_PREV_MASK_FINALIZED (1)
`
302
``
`-
/* Bit 1 is set when the object is in generation which is GCed currently. */
`
303
``
`-
#define _PyGC_PREV_MASK_COLLECTING (2)
`
304
``
`-
/* The (N-2) most significant bits contain the real address. */
`
305
``
`-
#define _PyGC_PREV_SHIFT (2)
`
306
``
`-
#define _PyGC_PREV_MASK (((uintptr_t) -1) << _PyGC_PREV_SHIFT)
`
307
``
-
308
``
`-
// Lowest bit of _gc_next is used for flags only in GC.
`
309
``
`-
// But it is always 0 for normal code.
`
310
``
`-
#define _PyGCHead_NEXT(g) ((PyGC_Head*)(g)->_gc_next)
`
311
``
`-
#define _PyGCHead_SET_NEXT(g, p) ((g)->_gc_next = (uintptr_t)(p))
`
312
``
-
313
``
`-
// Lowest two bits of _gc_prev is used for PyGC_PREV_MASK* flags.
`
314
``
`-
#define _PyGCHead_PREV(g) ((PyGC_Head*)((g)->_gc_prev & _PyGC_PREV_MASK))
`
315
``
`-
#define _PyGCHead_SET_PREV(g, p) do { \
`
316
``
`-
assert(((uintptr_t)p & ~_PyGC_PREV_MASK) == 0); \
`
317
``
`-
(g)->_gc_prev = ((g)->_gc_prev & ~_PyGC_PREV_MASK) \
`
318
``
`-
| ((uintptr_t)(p)); \
`
319
``
`-
} while (0)
`
320
``
-
321
``
`-
#define _PyGCHead_FINALIZED(g) \
`
322
``
`-
(((g)->_gc_prev & _PyGC_PREV_MASK_FINALIZED) != 0)
`
323
``
`-
#define _PyGCHead_SET_FINALIZED(g) \
`
324
``
`-
((g)->_gc_prev |= _PyGC_PREV_MASK_FINALIZED)
`
325
``
-
326
``
`-
#define _PyGC_FINALIZED(o) \
`
327
``
`-
_PyGCHead_FINALIZED(_Py_AS_GC(o))
`
328
``
`-
#define _PyGC_SET_FINALIZED(o) \
`
329
``
`-
_PyGCHead_SET_FINALIZED(_Py_AS_GC(o))
`
330
``
`-
#endif /* !defined(Py_LIMITED_API) */
`
331
236
``
332
``
`-
#ifndef Py_LIMITED_API
`
333
``
`-
PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t size);
`
334
``
`-
PyAPI_FUNC(PyObject *) _PyObject_GC_Calloc(size_t size);
`
335
``
`-
#endif /* !Py_LIMITED_API */
`
336
237
`PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *);
`
337
238
`PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t);
`
338
239
``
`@@ -368,13 +269,10 @@ PyAPI_FUNC(void) PyObject_GC_Del(void *);
`
368
269
` } \
`
369
270
` } while (0)
`
370
271
``
371
``
-
372
``
`-
/* Test if a type supports weak references */
`
373
272
`#ifndef Py_LIMITED_API
`
374
``
`-
#define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0)
`
375
``
-
376
``
`-
#define PyObject_GET_WEAKREFS_LISTPTR(o) \
`
377
``
`-
((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset))
`
``
273
`+
define Py_CPYTHON_OBJIMPL_H
`
``
274
`+
include "cpython/objimpl.h"
`
``
275
`+
undef Py_CPYTHON_OBJIMPL_H
`
378
276
`#endif
`
379
277
``
380
278
`#ifdef __cplusplus
`