1 /*
2  * Override settings that were generated in jemalloc_defs.h as necessary.
3  */
4 
5 #undef JEMALLOC_OVERRIDE_VALLOC
6 
7 #ifndef MALLOC_PRODUCTION
8 #define	JEMALLOC_DEBUG
9 #endif
10 
11 #undef JEMALLOC_DSS
12 
13 #undef JEMALLOC_BACKGROUND_THREAD
14 
15 /*
16  * The following are architecture-dependent, so conditionally define them for
17  * each supported architecture.
18  */
19 #undef JEMALLOC_TLS_MODEL
20 #undef LG_PAGE
21 #undef LG_VADDR
22 #undef LG_SIZEOF_PTR
23 #undef LG_SIZEOF_INT
24 #undef LG_SIZEOF_LONG
25 #undef LG_SIZEOF_INTMAX_T
26 
27 #ifdef __i386__
28 #  define LG_VADDR		32
29 #  define LG_SIZEOF_PTR		2
30 #  define JEMALLOC_TLS_MODEL	__attribute__((tls_model("initial-exec")))
31 #endif
32 #ifdef __ia64__
33 #  define LG_VADDR		64
34 #  define LG_SIZEOF_PTR		3
35 #endif
36 #ifdef __sparc64__
37 #  define LG_VADDR		64
38 #  define LG_SIZEOF_PTR		3
39 #  define JEMALLOC_TLS_MODEL	__attribute__((tls_model("initial-exec")))
40 #endif
41 #ifdef __amd64__
42 #  define LG_VADDR		48
43 #  define LG_SIZEOF_PTR		3
44 #  define JEMALLOC_TLS_MODEL	__attribute__((tls_model("initial-exec")))
45 #endif
46 #ifdef __arm__
47 #  define LG_VADDR		32
48 #  define LG_SIZEOF_PTR		2
49 #endif
50 #ifdef __aarch64__
51 #  define LG_VADDR		48
52 #  define LG_SIZEOF_PTR		3
53 #endif
54 #ifdef __mips__
55 #ifdef __mips_n64
56 #  define LG_VADDR		64
57 #  define LG_SIZEOF_PTR		3
58 #else
59 #  define LG_VADDR		32
60 #  define LG_SIZEOF_PTR		2
61 #endif
62 #endif
63 #ifdef __powerpc64__
64 #  define LG_VADDR		64
65 #  define LG_SIZEOF_PTR		3
66 #  define JEMALLOC_TLS_MODEL	__attribute__((tls_model("initial-exec")))
67 #elif defined(__powerpc__)
68 #  define LG_VADDR		32
69 #  define LG_SIZEOF_PTR		2
70 #  define JEMALLOC_TLS_MODEL	__attribute__((tls_model("initial-exec")))
71 #endif
72 #ifdef __riscv
73 #  define LG_VADDR		48
74 #  define LG_SIZEOF_PTR		3
75 #endif
76 
77 #if LG_VADDR > 32
78 #  define JEMALLOC_RETAIN
79 #endif
80 
81 #ifndef JEMALLOC_TLS_MODEL
82 #  define JEMALLOC_TLS_MODEL	/* Default. */
83 #endif
84 
85 #define	LG_PAGE			PAGE_SHIFT
86 #define	LG_SIZEOF_INT		2
87 #define	LG_SIZEOF_LONG		LG_SIZEOF_PTR
88 #define	LG_SIZEOF_INTMAX_T	3
89 
90 #undef CPU_SPINWAIT
91 #include <machine/cpu.h>
92 #include <machine/cpufunc.h>
93 #define	CPU_SPINWAIT		cpu_spinwait()
94 
95 /* Disable lazy-lock machinery, mangle isthreaded, and adjust its type. */
96 #undef JEMALLOC_LAZY_LOCK
97 extern int __isthreaded;
98 #define	isthreaded		((bool)__isthreaded)
99 
100 /* Mangle. */
101 #undef je_malloc
102 #undef je_calloc
103 #undef je_posix_memalign
104 #undef je_aligned_alloc
105 #undef je_realloc
106 #undef je_free
107 #undef je_malloc_usable_size
108 #undef je_mallocx
109 #undef je_rallocx
110 #undef je_xallocx
111 #undef je_sallocx
112 #undef je_dallocx
113 #undef je_sdallocx
114 #undef je_nallocx
115 #undef je_mallctl
116 #undef je_mallctlnametomib
117 #undef je_mallctlbymib
118 #undef je_malloc_stats_print
119 #undef je_allocm
120 #undef je_rallocm
121 #undef je_sallocm
122 #undef je_dallocm
123 #undef je_nallocm
124 #define	je_malloc		__malloc
125 #define	je_calloc		__calloc
126 #define	je_posix_memalign	__posix_memalign
127 #define	je_aligned_alloc	__aligned_alloc
128 #define	je_realloc		__realloc
129 #define	je_free			__free
130 #define	je_malloc_usable_size	__malloc_usable_size
131 #define	je_mallocx		__mallocx
132 #define	je_rallocx		__rallocx
133 #define	je_xallocx		__xallocx
134 #define	je_sallocx		__sallocx
135 #define	je_dallocx		__dallocx
136 #define	je_sdallocx		__sdallocx
137 #define	je_nallocx		__nallocx
138 #define	je_mallctl		__mallctl
139 #define	je_mallctlnametomib	__mallctlnametomib
140 #define	je_mallctlbymib		__mallctlbymib
141 #define	je_malloc_stats_print	__malloc_stats_print
142 #define	je_allocm		__allocm
143 #define	je_rallocm		__rallocm
144 #define	je_sallocm		__sallocm
145 #define	je_dallocm		__dallocm
146 #define	je_nallocm		__nallocm
147 #define	open			_open
148 #define	read			_read
149 #define	write			_write
150 #define	close			_close
151 #define	pthread_join		_pthread_join
152 #define	pthread_once		_pthread_once
153 #define	pthread_self		_pthread_self
154 #define	pthread_equal		_pthread_equal
155 #define	pthread_mutex_lock	_pthread_mutex_lock
156 #define	pthread_mutex_trylock	_pthread_mutex_trylock
157 #define	pthread_mutex_unlock	_pthread_mutex_unlock
158 #define	pthread_cond_init	_pthread_cond_init
159 #define	pthread_cond_wait	_pthread_cond_wait
160 #define	pthread_cond_timedwait	_pthread_cond_timedwait
161 #define	pthread_cond_signal	_pthread_cond_signal
162 
163 #ifdef JEMALLOC_C_
164 /*
165  * Define 'weak' symbols so that an application can have its own versions
166  * of malloc, calloc, realloc, free, et al.
167  */
168 __weak_reference(__malloc, malloc);
169 __weak_reference(__calloc, calloc);
170 __weak_reference(__posix_memalign, posix_memalign);
171 __weak_reference(__aligned_alloc, aligned_alloc);
172 __weak_reference(__realloc, realloc);
173 __weak_reference(__free, free);
174 __weak_reference(__malloc_usable_size, malloc_usable_size);
175 __weak_reference(__mallocx, mallocx);
176 __weak_reference(__rallocx, rallocx);
177 __weak_reference(__xallocx, xallocx);
178 __weak_reference(__sallocx, sallocx);
179 __weak_reference(__dallocx, dallocx);
180 __weak_reference(__sdallocx, sdallocx);
181 __weak_reference(__nallocx, nallocx);
182 __weak_reference(__mallctl, mallctl);
183 __weak_reference(__mallctlnametomib, mallctlnametomib);
184 __weak_reference(__mallctlbymib, mallctlbymib);
185 __weak_reference(__malloc_stats_print, malloc_stats_print);
186 __weak_reference(__allocm, allocm);
187 __weak_reference(__rallocm, rallocm);
188 __weak_reference(__sallocm, sallocm);
189 __weak_reference(__dallocm, dallocm);
190 __weak_reference(__nallocm, nallocm);
191 #endif
192