File indexing completed on 2025-01-18 09:30:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_CONTAINER_ALLOC_LIB_EXT_H
0011 #define BOOST_CONTAINER_ALLOC_LIB_EXT_H
0012
0013 #include <stddef.h>
0014
0015 #ifdef _MSC_VER
0016 #pragma warning (push)
0017 #pragma warning (disable : 4127)
0018 #endif
0019
0020 #ifdef __cplusplus
0021 extern "C" {
0022 #endif
0023
0024
0025 typedef struct multialloc_node_impl
0026 {
0027 struct multialloc_node_impl *next_node_ptr;
0028 } boost_cont_memchain_node;
0029
0030
0031
0032 typedef struct multialloc_it_impl
0033 {
0034 boost_cont_memchain_node *node_ptr;
0035 } boost_cont_memchain_it;
0036
0037
0038
0039 typedef struct boost_cont_memchain_impl
0040 {
0041 size_t num_mem;
0042 boost_cont_memchain_node root_node;
0043 boost_cont_memchain_node *last_node_ptr;
0044 } boost_cont_memchain;
0045
0046
0047 #define BOOST_CONTAINER_MEMIT_NEXT(IT) (IT.node_ptr = IT.node_ptr->next_node_ptr)
0048
0049
0050 #define BOOST_CONTAINER_MEMIT_ADDR(IT) ((void*)IT.node_ptr)
0051
0052
0053 #define BOOST_CONTAINER_MEMCHAIN_BEFORE_BEGIN_IT(PMEMCHAIN) { &((PMEMCHAIN)->root_node) }
0054
0055
0056 #define BOOST_CONTAINER_MEMCHAIN_BEGIN_IT(PMEMCHAIN) {(PMEMCHAIN)->root_node.next_node_ptr }
0057
0058
0059 #define BOOST_CONTAINER_MEMCHAIN_LAST_IT(PMEMCHAIN) {(PMEMCHAIN)->last_node_ptr }
0060
0061
0062 #define BOOST_CONTAINER_MEMCHAIN_END_IT(PMEMCHAIN) {(boost_cont_memchain_node *)0 }
0063
0064
0065 #define BOOST_CONTAINER_MEMCHAIN_IS_END_IT(PMEMCHAIN, IT) (!(IT).node_ptr)
0066
0067
0068 #define BOOST_CONTAINER_MEMCHAIN_FIRSTMEM(PMEMCHAIN)((void*)((PMEMCHAIN)->root_node.next_node_ptr))
0069
0070
0071 #define BOOST_CONTAINER_MEMCHAIN_LASTMEM(PMEMCHAIN) ((void*)((PMEMCHAIN)->last_node_ptr))
0072
0073
0074 #define BOOST_CONTAINER_MEMCHAIN_SIZE(PMEMCHAIN) ((PMEMCHAIN)->num_mem)
0075
0076
0077
0078 #define BOOST_CONTAINER_MEMCHAIN_INIT_FROM(PMEMCHAIN, FIRST, LAST, NUM)\
0079 (PMEMCHAIN)->last_node_ptr = (boost_cont_memchain_node *)(LAST), \
0080 (PMEMCHAIN)->root_node.next_node_ptr = (boost_cont_memchain_node *)(FIRST), \
0081 (PMEMCHAIN)->num_mem = (NUM);\
0082
0083
0084
0085
0086 #define BOOST_CONTAINER_MEMCHAIN_INIT(PMEMCHAIN)\
0087 ((PMEMCHAIN)->root_node.next_node_ptr = 0, (PMEMCHAIN)->last_node_ptr = &((PMEMCHAIN)->root_node), (PMEMCHAIN)->num_mem = 0)\
0088
0089
0090
0091 #define BOOST_CONTAINER_MEMCHAIN_EMPTY(PMEMCHAIN)\
0092 ((PMEMCHAIN)->num_mem == 0)\
0093
0094
0095
0096 #define BOOST_CONTAINER_MEMCHAIN_PUSH_BACK(PMEMCHAIN, MEM)\
0097 do{\
0098 boost_cont_memchain *____chain____ = (PMEMCHAIN);\
0099 boost_cont_memchain_node *____tmp_mem____ = (boost_cont_memchain_node *)(MEM);\
0100 ____chain____->last_node_ptr->next_node_ptr = ____tmp_mem____;\
0101 ____tmp_mem____->next_node_ptr = 0;\
0102 ____chain____->last_node_ptr = ____tmp_mem____;\
0103 ++____chain____->num_mem;\
0104 }while(0)\
0105
0106
0107
0108 #define BOOST_CONTAINER_MEMCHAIN_PUSH_FRONT(PMEMCHAIN, MEM)\
0109 do{\
0110 boost_cont_memchain *____chain____ = (PMEMCHAIN);\
0111 boost_cont_memchain_node *____tmp_mem____ = (boost_cont_memchain_node *)(MEM);\
0112 boost_cont_memchain *____root____ = &((PMEMCHAIN)->root_node);\
0113 if(!____chain____->root_node.next_node_ptr){\
0114 ____chain____->last_node_ptr = ____tmp_mem____;\
0115 }\
0116 boost_cont_memchain_node *____old_first____ = ____root____->next_node_ptr;\
0117 ____tmp_mem____->next_node_ptr = ____old_first____;\
0118 ____root____->next_node_ptr = ____tmp_mem____;\
0119 ++____chain____->num_mem;\
0120 }while(0)\
0121
0122
0123
0124
0125 #define BOOST_CONTAINER_MEMCHAIN_ERASE_AFTER(PMEMCHAIN, BEFORE_IT)\
0126 do{\
0127 boost_cont_memchain *____chain____ = (PMEMCHAIN);\
0128 boost_cont_memchain_node *____prev_node____ = (BEFORE_IT).node_ptr;\
0129 boost_cont_memchain_node *____erase_node____ = ____prev_node____->next_node_ptr;\
0130 if(____chain____->last_node_ptr == ____erase_node____){\
0131 ____chain____->last_node_ptr = &____chain____->root_node;\
0132 }\
0133 ____prev_node____->next_node_ptr = ____erase_node____->next_node_ptr;\
0134 --____chain____->num_mem;\
0135 }while(0)\
0136
0137
0138
0139
0140 #define BOOST_CONTAINER_MEMCHAIN_POP_FRONT(PMEMCHAIN)\
0141 do{\
0142 boost_cont_memchain *____chain____ = (PMEMCHAIN);\
0143 boost_cont_memchain_node *____prev_node____ = &____chain____->root_node;\
0144 boost_cont_memchain_node *____erase_node____ = ____prev_node____->next_node_ptr;\
0145 if(____chain____->last_node_ptr == ____erase_node____){\
0146 ____chain____->last_node_ptr = &____chain____->root_node;\
0147 }\
0148 ____prev_node____->next_node_ptr = ____erase_node____->next_node_ptr;\
0149 --____chain____->num_mem;\
0150 }while(0)\
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177 #define BOOST_CONTAINER_MEMCHAIN_INCORPORATE_AFTER(PMEMCHAIN, BEFORE_IT, FIRST, BEFORELAST, NUM)\
0178 do{\
0179 boost_cont_memchain *____chain____ = (PMEMCHAIN);\
0180 boost_cont_memchain_node *____pnode____ = (BEFORE_IT).node_ptr;\
0181 boost_cont_memchain_node *____next____ = ____pnode____->next_node_ptr;\
0182 boost_cont_memchain_node *____first____ = (boost_cont_memchain_node *)(FIRST);\
0183 boost_cont_memchain_node *____blast____ = (boost_cont_memchain_node *)(BEFORELAST);\
0184 size_t ____num____ = (NUM);\
0185 if(!____num____){\
0186 break;\
0187 }\
0188 if(____pnode____ == ____chain____->last_node_ptr){\
0189 ____chain____->last_node_ptr = ____blast____;\
0190 }\
0191 ____pnode____->next_node_ptr = ____first____;\
0192 ____blast____->next_node_ptr = ____next____;\
0193 ____chain____->num_mem += ____num____;\
0194 }while(0)\
0195
0196
0197
0198
0199 #define BOOST_CONTAINER_DL_MULTIALLOC_ALL_CONTIGUOUS ((size_t)(-1))
0200
0201
0202
0203 #define BOOST_CONTAINER_DL_MULTIALLOC_DEFAULT_CONTIGUOUS ((size_t)(0))
0204
0205 typedef struct boost_cont_malloc_stats_impl
0206 {
0207 size_t max_system_bytes;
0208 size_t system_bytes;
0209 size_t in_use_bytes;
0210 } boost_cont_malloc_stats_t;
0211
0212 typedef unsigned int allocation_type;
0213
0214 enum
0215 {
0216
0217 BOOST_CONTAINER_ALLOCATE_NEW = 0X01,
0218 BOOST_CONTAINER_EXPAND_FWD = 0X02,
0219 BOOST_CONTAINER_EXPAND_BWD = 0X04,
0220 BOOST_CONTAINER_SHRINK_IN_PLACE = 0X08,
0221 BOOST_CONTAINER_NOTHROW_ALLOCATION = 0X10,
0222
0223 BOOST_CONTAINER_TRY_SHRINK_IN_PLACE = 0X40,
0224 BOOST_CONTAINER_EXPAND_BOTH = BOOST_CONTAINER_EXPAND_FWD | BOOST_CONTAINER_EXPAND_BWD,
0225 BOOST_CONTAINER_EXPAND_OR_NEW = BOOST_CONTAINER_ALLOCATE_NEW | BOOST_CONTAINER_EXPAND_BOTH
0226 };
0227
0228
0229 #ifndef BOOST_CONTAINER_DLMALLOC_FOOTERS
0230 enum { BOOST_CONTAINER_ALLOCATION_PAYLOAD = sizeof(size_t) };
0231 #else
0232 enum { BOOST_CONTAINER_ALLOCATION_PAYLOAD = sizeof(size_t)*2 };
0233 #endif
0234
0235 typedef struct boost_cont_command_ret_impl
0236 {
0237 void *first;
0238 int second;
0239 }boost_cont_command_ret_t;
0240
0241 size_t boost_cont_size(const void *p);
0242
0243 void* boost_cont_malloc(size_t bytes);
0244
0245 void boost_cont_free(void* mem);
0246
0247 void* boost_cont_memalign(size_t bytes, size_t alignment);
0248
0249 int boost_cont_multialloc_nodes
0250 (size_t n_elements, size_t elem_size, size_t contiguous_elements, boost_cont_memchain *pchain);
0251
0252 int boost_cont_multialloc_arrays
0253 (size_t n_elements, const size_t *sizes, size_t sizeof_element, size_t contiguous_elements, boost_cont_memchain *pchain);
0254
0255 void boost_cont_multidealloc(boost_cont_memchain *pchain);
0256
0257 size_t boost_cont_footprint();
0258
0259 size_t boost_cont_allocated_memory();
0260
0261 size_t boost_cont_chunksize(const void *p);
0262
0263 int boost_cont_all_deallocated();
0264
0265 boost_cont_malloc_stats_t boost_cont_malloc_stats();
0266
0267 size_t boost_cont_in_use_memory();
0268
0269 int boost_cont_trim(size_t pad);
0270
0271 int boost_cont_mallopt(int parameter_number, int parameter_value);
0272
0273 int boost_cont_grow
0274 (void* oldmem, size_t minbytes, size_t maxbytes, size_t *received);
0275
0276 int boost_cont_shrink
0277 (void* oldmem, size_t minbytes, size_t maxbytes, size_t *received, int do_commit);
0278
0279 void* boost_cont_alloc
0280 (size_t minbytes, size_t preferred_bytes, size_t *received_bytes);
0281
0282 int boost_cont_malloc_check();
0283
0284 boost_cont_command_ret_t boost_cont_allocation_command
0285 ( allocation_type command
0286 , size_t sizeof_object
0287 , size_t limit_objects
0288 , size_t preferred_objects
0289 , size_t *received_objects
0290 , void *reuse_ptr
0291 );
0292
0293 void *boost_cont_sync_create();
0294
0295 void boost_cont_sync_destroy(void *sync);
0296
0297 int boost_cont_sync_lock(void *sync);
0298
0299 void boost_cont_sync_unlock(void *sync);
0300
0301 int boost_cont_global_sync_lock();
0302
0303 void boost_cont_global_sync_unlock();
0304
0305 #ifdef __cplusplus
0306 }
0307 #endif
0308
0309 #ifdef _MSC_VER
0310 #pragma warning (pop)
0311 #endif
0312
0313
0314 #endif