• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef Py_INTERNAL_OBMALLOC_INIT_H
2 #define Py_INTERNAL_OBMALLOC_INIT_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6 
7 #ifndef Py_BUILD_CORE
8 #  error "this header requires Py_BUILD_CORE define"
9 #endif
10 
11 
12 /****************************************************/
13 /* the default object allocator's state initializer */
14 
15 #define PTA(pools, x) \
16     ((poolp )((uint8_t *)&(pools.used[2*(x)]) - 2*sizeof(pymem_block *)))
17 #define PT(p, x)   PTA(p, x), PTA(p, x)
18 
19 #define PT_8(p, start) \
20     PT(p, start), \
21     PT(p, start+1), \
22     PT(p, start+2), \
23     PT(p, start+3), \
24     PT(p, start+4), \
25     PT(p, start+5), \
26     PT(p, start+6), \
27     PT(p, start+7)
28 
29 #if NB_SMALL_SIZE_CLASSES <= 8
30 #  define _obmalloc_pools_INIT(p) \
31     { PT_8(p, 0) }
32 #elif NB_SMALL_SIZE_CLASSES <= 16
33 #  define _obmalloc_pools_INIT(p) \
34     { PT_8(p, 0), PT_8(p, 8) }
35 #elif NB_SMALL_SIZE_CLASSES <= 24
36 #  define _obmalloc_pools_INIT(p) \
37     { PT_8(p, 0), PT_8(p, 8), PT_8(p, 16) }
38 #elif NB_SMALL_SIZE_CLASSES <= 32
39 #  define _obmalloc_pools_INIT(p) \
40     { PT_8(p, 0), PT_8(p, 8), PT_8(p, 16), PT_8(p, 24) }
41 #elif NB_SMALL_SIZE_CLASSES <= 40
42 #  define _obmalloc_pools_INIT(p) \
43     { PT_8(p, 0), PT_8(p, 8), PT_8(p, 16), PT_8(p, 24), PT_8(p, 32) }
44 #elif NB_SMALL_SIZE_CLASSES <= 48
45 #  define _obmalloc_pools_INIT(p) \
46     { PT_8(p, 0), PT_8(p, 8), PT_8(p, 16), PT_8(p, 24), PT_8(p, 32), PT_8(p, 40) }
47 #elif NB_SMALL_SIZE_CLASSES <= 56
48 #  define _obmalloc_pools_INIT(p) \
49     { PT_8(p, 0), PT_8(p, 8), PT_8(p, 16), PT_8(p, 24), PT_8(p, 32), PT_8(p, 40), PT_8(p, 48) }
50 #elif NB_SMALL_SIZE_CLASSES <= 64
51 #  define _obmalloc_pools_INIT(p) \
52     { PT_8(p, 0), PT_8(p, 8), PT_8(p, 16), PT_8(p, 24), PT_8(p, 32), PT_8(p, 40), PT_8(p, 48), PT_8(p, 56) }
53 #else
54 #  error "NB_SMALL_SIZE_CLASSES should be less than 64"
55 #endif
56 
57 #define _obmalloc_global_state_INIT \
58     { \
59         .dump_debug_stats = -1, \
60     }
61 
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 #endif  // !Py_INTERNAL_OBMALLOC_INIT_H
67