summaryrefslogtreecommitdiffstats
path: root/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h
blob: c58a8f39ef2ec0dbe1359b08873070cfac4450b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
 * Override settings that were generated in jemalloc_defs.h as necessary.
 */

#undef JEMALLOC_OVERRIDE_VALLOC

#ifndef MALLOC_PRODUCTION
#define	JEMALLOC_DEBUG
#endif

#undef JEMALLOC_DSS

/*
 * The following are architecture-dependent, so conditionally define them for
 * each supported architecture.
 */
#undef JEMALLOC_TLS_MODEL
#undef STATIC_PAGE_SHIFT
#undef LG_SIZEOF_PTR
#undef LG_SIZEOF_INT
#undef LG_SIZEOF_LONG
#undef LG_SIZEOF_INTMAX_T

#ifdef __i386__
#  define LG_SIZEOF_PTR		2
#  define JEMALLOC_TLS_MODEL	__attribute__((tls_model("initial-exec")))
#endif
#ifdef __ia64__
#  define LG_SIZEOF_PTR		3
#endif
#ifdef __sparc64__
#  define LG_SIZEOF_PTR		3
#  define JEMALLOC_TLS_MODEL	__attribute__((tls_model("initial-exec")))
#endif
#ifdef __amd64__
#  define LG_SIZEOF_PTR		3
#  define JEMALLOC_TLS_MODEL	__attribute__((tls_model("initial-exec")))
#endif
#ifdef __arm__
#  define LG_SIZEOF_PTR		2
#endif
#ifdef __aarch64__
#  define LG_SIZEOF_PTR		3
#endif
#ifdef __mips__
#ifdef __mips_n64
#  define LG_SIZEOF_PTR		3
#else
#  define LG_SIZEOF_PTR		2
#endif
#endif
#ifdef __powerpc64__
#  define LG_SIZEOF_PTR		3
#elif defined(__powerpc__)
#  define LG_SIZEOF_PTR		2
#endif
#ifdef __riscv__
#  define LG_SIZEOF_PTR		3
#endif

#ifndef JEMALLOC_TLS_MODEL
#  define JEMALLOC_TLS_MODEL	/* Default. */
#endif

#define	STATIC_PAGE_SHIFT	PAGE_SHIFT
#define	LG_SIZEOF_INT		2
#define	LG_SIZEOF_LONG		LG_SIZEOF_PTR
#define	LG_SIZEOF_INTMAX_T	3

#undef CPU_SPINWAIT
#include <machine/cpu.h>
#include <machine/cpufunc.h>
#define	CPU_SPINWAIT		cpu_spinwait()

/* Disable lazy-lock machinery, mangle isthreaded, and adjust its type. */
#undef JEMALLOC_LAZY_LOCK
extern int __isthreaded;
#define	isthreaded		((bool)__isthreaded)

/* Mangle. */
#undef je_malloc
#undef je_calloc
#undef je_posix_memalign
#undef je_aligned_alloc
#undef je_realloc
#undef je_free
#undef je_malloc_usable_size
#undef je_mallocx
#undef je_rallocx
#undef je_xallocx
#undef je_sallocx
#undef je_dallocx
#undef je_sdallocx
#undef je_nallocx
#undef je_mallctl
#undef je_mallctlnametomib
#undef je_mallctlbymib
#undef je_malloc_stats_print
#undef je_allocm
#undef je_rallocm
#undef je_sallocm
#undef je_dallocm
#undef je_nallocm
#define	je_malloc		__malloc
#define	je_calloc		__calloc
#define	je_posix_memalign	__posix_memalign
#define	je_aligned_alloc	__aligned_alloc
#define	je_realloc		__realloc
#define	je_free			__free
#define	je_malloc_usable_size	__malloc_usable_size
#define	je_mallocx		__mallocx
#define	je_rallocx		__rallocx
#define	je_xallocx		__xallocx
#define	je_sallocx		__sallocx
#define	je_dallocx		__dallocx
#define	je_sdallocx		__sdallocx
#define	je_nallocx		__nallocx
#define	je_mallctl		__mallctl
#define	je_mallctlnametomib	__mallctlnametomib
#define	je_mallctlbymib		__mallctlbymib
#define	je_malloc_stats_print	__malloc_stats_print
#define	je_allocm		__allocm
#define	je_rallocm		__rallocm
#define	je_sallocm		__sallocm
#define	je_dallocm		__dallocm
#define	je_nallocm		__nallocm
#define	open			_open
#define	read			_read
#define	write			_write
#define	close			_close
#define	pthread_mutex_lock	_pthread_mutex_lock
#define	pthread_mutex_unlock	_pthread_mutex_unlock

#ifdef JEMALLOC_C_
/*
 * Define 'weak' symbols so that an application can have its own versions
 * of malloc, calloc, realloc, free, et al.
 */
__weak_reference(__malloc, malloc);
__weak_reference(__calloc, calloc);
__weak_reference(__posix_memalign, posix_memalign);
__weak_reference(__aligned_alloc, aligned_alloc);
__weak_reference(__realloc, realloc);
__weak_reference(__free, free);
__weak_reference(__malloc_usable_size, malloc_usable_size);
__weak_reference(__mallocx, mallocx);
__weak_reference(__rallocx, rallocx);
__weak_reference(__xallocx, xallocx);
__weak_reference(__sallocx, sallocx);
__weak_reference(__dallocx, dallocx);
__weak_reference(__sdallocx, sdallocx);
__weak_reference(__nallocx, nallocx);
__weak_reference(__mallctl, mallctl);
__weak_reference(__mallctlnametomib, mallctlnametomib);
__weak_reference(__mallctlbymib, mallctlbymib);
__weak_reference(__malloc_stats_print, malloc_stats_print);
__weak_reference(__allocm, allocm);
__weak_reference(__rallocm, rallocm);
__weak_reference(__sallocm, sallocm);
__weak_reference(__dallocm, dallocm);
__weak_reference(__nallocm, nallocm);
#endif
OpenPOWER on IntegriCloud