]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/engine/mem.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / tools / build / src / engine / mem.h
1 /*
2 * Copyright 2006. Rene Rivera
3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
6 */
7
8 #ifndef BJAM_MEM_H
9 #define BJAM_MEM_H
10
11 #ifdef OPT_BOEHM_GC
12
13 /* Use Boehm GC memory allocator. */
14 #include <gc.h>
15
16 #define bjam_malloc_x(s) memset(GC_malloc(s),0,s)
17 #define bjam_malloc_atomic_x(s) memset(GC_malloc_atomic(s),0,s)
18 #define bjam_calloc_x(n,s) memset(GC_malloc((n)*(s)),0,(n)*(s))
19 #define bjam_calloc_atomic_x(n,s) memset(GC_malloc_atomic((n)*(s)),0,(n)*(s))
20 #define bjam_realloc_x(p,s) GC_realloc(p,s)
21 #define bjam_free_x(p) GC_free(p)
22 #define bjam_mem_init_x() GC_init(); GC_enable_incremental()
23
24 #define bjam_malloc_raw_x(s) malloc(s)
25 #define bjam_calloc_raw_x(n,s) calloc(n,s)
26 #define bjam_realloc_raw_x(p,s) realloc(p,s)
27 #define bjam_free_raw_x(p) free(p)
28
29 #ifndef BJAM_NEWSTR_NO_ALLOCATE
30 # define BJAM_NEWSTR_NO_ALLOCATE
31 #endif
32
33 #elif defined( OPT_DUMA )
34
35 /* Use Duma memory debugging library. */
36 #include <stdlib.h>
37
38 #define _DUMA_CONFIG_H_
39 #define DUMA_NO_GLOBAL_MALLOC_FREE
40 #define DUMA_EXPLICIT_INIT
41 #define DUMA_NO_THREAD_SAFETY
42 #define DUMA_NO_CPP_SUPPORT
43 /* #define DUMA_NO_LEAKDETECTION */
44 /* #define DUMA_USE_FRAMENO */
45 /* #define DUMA_PREFER_ATEXIT */
46 /* #define DUMA_OLD_DEL_MACRO */
47 /* #define DUMA_NO_HANG_MSG */
48 #define DUMA_PAGE_SIZE 4096
49 #define DUMA_MIN_ALIGNMENT 1
50 /* #define DUMA_GNU_INIT_ATTR 0 */
51 typedef unsigned int DUMA_ADDR;
52 typedef unsigned int DUMA_SIZE;
53 #include <duma.h>
54
55 #define bjam_malloc_x(s) malloc(s)
56 #define bjam_calloc_x(n,s) calloc(n,s)
57 #define bjam_realloc_x(p,s) realloc(p,s)
58 #define bjam_free_x(p) free(p)
59
60 #ifndef BJAM_NEWSTR_NO_ALLOCATE
61 # define BJAM_NEWSTR_NO_ALLOCATE
62 #endif
63
64 #else
65
66 /* Standard C memory allocation. */
67 #include <stdlib.h>
68
69 #define bjam_malloc_x(s) malloc(s)
70 #define bjam_calloc_x(n,s) calloc(n,s)
71 #define bjam_realloc_x(p,s) realloc(p,s)
72 #define bjam_free_x(p) free(p)
73
74 #endif
75
76 #ifndef bjam_malloc_atomic_x
77 #define bjam_malloc_atomic_x(s) bjam_malloc_x(s)
78 #endif
79 #ifndef bjam_calloc_atomic_x
80 #define bjam_calloc_atomic_x(n,s) bjam_calloc_x(n,s)
81 #endif
82 #ifndef bjam_mem_init_x
83 #define bjam_mem_init_x()
84 #endif
85 #ifndef bjam_mem_close_x
86 #define bjam_mem_close_x()
87 #endif
88 #ifndef bjam_malloc_raw_x
89 #define bjam_malloc_raw_x(s) bjam_malloc_x(s)
90 #endif
91 #ifndef bjam_calloc_raw_x
92 #define bjam_calloc_raw_x(n,s) bjam_calloc_x(n,s)
93 #endif
94 #ifndef bjam_realloc_raw_x
95 #define bjam_realloc_raw_x(p,s) bjam_realloc_x(p,s)
96 #endif
97 #ifndef bjam_free_raw_x
98 #define bjam_free_raw_x(p) bjam_free_x(p)
99 #endif
100
101 #ifdef OPT_DEBUG_PROFILE
102 /* Profile tracing of memory allocations. */
103 #include "debug.h"
104
105 #define BJAM_MALLOC(s) (profile_memory(s), bjam_malloc_x(s))
106 #define BJAM_MALLOC_ATOMIC(s) (profile_memory(s), bjam_malloc_atomic_x(s))
107 #define BJAM_CALLOC(n,s) (profile_memory(n*s), bjam_calloc_x(n,s))
108 #define BJAM_CALLOC_ATOMIC(n,s) (profile_memory(n*s), bjam_calloc_atomic_x(n,s))
109 #define BJAM_REALLOC(p,s) (profile_memory(s), bjam_realloc_x(p,s))
110
111 #define BJAM_MALLOC_RAW(s) (profile_memory(s), bjam_malloc_raw_x(s))
112 #define BJAM_CALLOC_RAW(n,s) (profile_memory(n*s), bjam_calloc_raw_x(n,s))
113 #define BJAM_REALLOC_RAW(p,s) (profile_memory(s), bjam_realloc_raw_x(p,s))
114 #else
115 /* No mem tracing. */
116 #define BJAM_MALLOC(s) bjam_malloc_x(s)
117 #define BJAM_MALLOC_ATOMIC(s) bjam_malloc_atomic_x(s)
118 #define BJAM_CALLOC(n,s) bjam_calloc_x(n,s)
119 #define BJAM_CALLOC_ATOMIC(n,s) bjam_calloc_atomic_x(n,s)
120 #define BJAM_REALLOC(p,s) bjam_realloc_x(p,s)
121
122 #define BJAM_MALLOC_RAW(s) bjam_malloc_raw_x(s)
123 #define BJAM_CALLOC_RAW(n,s) bjam_calloc_raw_x(n,s)
124 #define BJAM_REALLOC_RAW(p,s) bjam_realloc_raw_x(p,s)
125 #endif
126
127 #define BJAM_MEM_INIT() bjam_mem_init_x()
128 #define BJAM_MEM_CLOSE() bjam_mem_close_x()
129
130 #define BJAM_FREE(p) bjam_free_x(p)
131 #define BJAM_FREE_RAW(p) bjam_free_raw_x(p)
132
133 #endif