xref: /NextBSD/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h (revision c21ffb8d6aca32c9584cfa072f309a5890a21aea)
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 /*
12  * The following are architecture-dependent, so conditionally define them for
13  * each supported architecture.
14  */
15 #undef JEMALLOC_TLS_MODEL
16 #undef STATIC_PAGE_SHIFT
17 #undef LG_SIZEOF_PTR
18 #undef LG_SIZEOF_INT
19 #undef LG_SIZEOF_LONG
20 #undef LG_SIZEOF_INTMAX_T
21 
22 #ifdef __i386__
23 #  define LG_SIZEOF_PTR		2
24 #  define JEMALLOC_TLS_MODEL	__attribute__((tls_model("initial-exec")))
25 #endif
26 #ifdef __ia64__
27 #  define LG_SIZEOF_PTR		3
28 #endif
29 #ifdef __sparc64__
30 #  define LG_SIZEOF_PTR		3
31 #  define JEMALLOC_TLS_MODEL	__attribute__((tls_model("initial-exec")))
32 #endif
33 #ifdef __amd64__
34 #  define LG_SIZEOF_PTR		3
35 #  define JEMALLOC_TLS_MODEL	__attribute__((tls_model("initial-exec")))
36 #endif
37 #ifdef __arm__
38 #  define LG_SIZEOF_PTR		2
39 #endif
40 #ifdef __aarch64__
41 #  define LG_SIZEOF_PTR		3
42 #endif
43 #ifdef __mips__
44 #ifdef __mips_n64
45 #  define LG_SIZEOF_PTR		3
46 #else
47 #  define LG_SIZEOF_PTR		2
48 #endif
49 #endif
50 #ifdef __powerpc64__
51 #  define LG_SIZEOF_PTR		3
52 #elif defined(__powerpc__)
53 #  define LG_SIZEOF_PTR		2
54 #endif
55 
56 #ifndef JEMALLOC_TLS_MODEL
57 #  define JEMALLOC_TLS_MODEL	/* Default. */
58 #endif
59 
60 #define	STATIC_PAGE_SHIFT	PAGE_SHIFT
61 #define	LG_SIZEOF_INT		2
62 #define	LG_SIZEOF_LONG		LG_SIZEOF_PTR
63 #define	LG_SIZEOF_INTMAX_T	3
64 
65 #undef CPU_SPINWAIT
66 #include <machine/cpu.h>
67 #include <machine/cpufunc.h>
68 #define	CPU_SPINWAIT		cpu_spinwait()
69 
70 /* Disable lazy-lock machinery, mangle isthreaded, and adjust its type. */
71 #undef JEMALLOC_LAZY_LOCK
72 extern int __isthreaded;
73 #define	isthreaded		((bool)__isthreaded)
74 
75 /* Mangle. */
76 #undef je_malloc
77 #undef je_calloc
78 #undef je_realloc
79 #undef je_free
80 #undef je_posix_memalign
81 #undef je_aligned_alloc
82 #undef je_malloc_usable_size
83 #undef je_mallocx
84 #undef je_rallocx
85 #undef je_xallocx
86 #undef je_sallocx
87 #undef je_dallocx
88 #undef je_nallocx
89 #undef je_allocm
90 #undef je_rallocm
91 #undef je_sallocm
92 #undef je_dallocm
93 #undef je_nallocm
94 #define	je_malloc		__malloc
95 #define	je_calloc		__calloc
96 #define	je_realloc		__realloc
97 #define	je_free			__free
98 #define	je_posix_memalign	__posix_memalign
99 #define	je_aligned_alloc	__aligned_alloc
100 #define	je_malloc_usable_size	__malloc_usable_size
101 #define	je_mallocx		__mallocx
102 #define	je_rallocx		__rallocx
103 #define	je_xallocx		__xallocx
104 #define	je_sallocx		__sallocx
105 #define	je_dallocx		__dallocx
106 #define	je_nallocx		__nallocx
107 #define	je_allocm		__allocm
108 #define	je_rallocm		__rallocm
109 #define	je_sallocm		__sallocm
110 #define	je_dallocm		__dallocm
111 #define	je_nallocm		__nallocm
112 #define	open			_open
113 #define	read			_read
114 #define	write			_write
115 #define	close			_close
116 #define	pthread_mutex_lock	_pthread_mutex_lock
117 #define	pthread_mutex_unlock	_pthread_mutex_unlock
118 
119 #ifdef JEMALLOC_C_
120 /*
121  * Define 'weak' symbols so that an application can have its own versions
122  * of malloc, calloc, realloc, free, et al.
123  */
124 __weak_reference(__malloc, malloc);
125 __weak_reference(__calloc, calloc);
126 __weak_reference(__realloc, realloc);
127 __weak_reference(__free, free);
128 __weak_reference(__posix_memalign, posix_memalign);
129 __weak_reference(__aligned_alloc, aligned_alloc);
130 __weak_reference(__malloc_usable_size, malloc_usable_size);
131 __weak_reference(__mallocx, mallocx);
132 __weak_reference(__rallocx, rallocx);
133 __weak_reference(__xallocx, xallocx);
134 __weak_reference(__sallocx, sallocx);
135 __weak_reference(__dallocx, dallocx);
136 __weak_reference(__nallocx, nallocx);
137 __weak_reference(__allocm, allocm);
138 __weak_reference(__rallocm, rallocm);
139 __weak_reference(__sallocm, sallocm);
140 __weak_reference(__dallocm, dallocm);
141 __weak_reference(__nallocm, nallocm);
142 #endif
143