Skip to content

Commit 3172cbe

Browse files
Restore uint for obmalloc.
1 parent a1ff9b0 commit 3172cbe

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

Include/internal/pycore_obmalloc.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11+
12+
typedef unsigned int pymem_uint; /* assuming >= 16 bits */
13+
14+
#undef uint
15+
#define uint pymem_uint
16+
17+
1118
/* An object allocator for Python.
1219
1320
Here is an introduction to the layers of the Python memory architecture,
@@ -130,7 +137,7 @@ extern "C" {
130137
#endif
131138

132139
/* Return the number of bytes in size class I, as a uint. */
133-
#define INDEX2SIZE(I) (((uint)(I) + 1) << ALIGNMENT_SHIFT)
140+
#define INDEX2SIZE(I) (((pymem_uint)(I) + 1) << ALIGNMENT_SHIFT)
134141

135142
/*
136143
* Max size threshold below which malloc requests are considered to be
@@ -307,7 +314,7 @@ struct arena_object {
307314
#define POOL_ADDR(P) ((poolp)_Py_ALIGN_DOWN((P), POOL_SIZE))
308315

309316
/* Return total number of blocks in pool of size index I, as a uint. */
310-
#define NUMBLOCKS(I) ((uint)(POOL_SIZE - POOL_OVERHEAD) / INDEX2SIZE(I))
317+
#define NUMBLOCKS(I) ((pymem_uint)(POOL_SIZE - POOL_OVERHEAD) / INDEX2SIZE(I))
311318

312319
/*==========================================================================*/
313320

@@ -657,6 +664,9 @@ struct _obmalloc_state {
657664
};
658665

659666

667+
#undef uint
668+
669+
660670
/* Allocate memory directly from the O/S virtual memory system,
661671
* where supported. Otherwise fallback on malloc */
662672
void *_PyObject_VirtualAlloc(size_t size);

Objects/obmalloc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
#include "Python.h"
2-
#include "pycore_pymem.h" // _PyTraceMalloc_Config
32
#include "pycore_code.h" // stats
43
#include "pycore_pystate.h" // _PyInterpreterState_GET
4+
5+
#include "pycore_obmalloc.h"
56
#include "pycore_pymem.h"
67
#include "pycore_pymem_allocators.h"
78

89
#include <stdbool.h>
910

1011

12+
#undef uint
13+
#define uint pymem_uint
14+
15+
1116
/* Defined in tracemalloc.c */
1217
extern void _PyMem_DumpTraceback(int fd, const void *ptr);
1318

1419

1520
/* Python's malloc wrappers (see pymem.h) */
1621

17-
#undef uint
18-
#define uint unsigned int /* assuming >= 16 bits */
19-
2022
static void _PyObject_DebugDumpAddress(const void *p);
2123
static void _PyMem_DebugCheckAddress(const char *func, char api_id, const void *p);
2224

0 commit comments

Comments
 (0)