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