1- #include < functional>
2- #include < limits.h>
3- #include < stdio.h>
4- #include < test/helpers.h>
5- #include < test/setup.h>
1+ #if defined(SNMALLOC_ENABLE_GWP_ASAN_INTEGRATION)
2+ int main ()
3+ {
4+ return 0 ;
5+ }
6+ #else
7+ # include < functional>
8+ # include < limits.h>
9+ # include < stdio.h>
10+ # include < test/helpers.h>
11+ # include < test/setup.h>
612
7- #define SNMALLOC_NAME_MANGLE (a ) our_##a
8- #undef SNMALLOC_NO_REALLOCARRAY
9- #undef SNMALLOC_NO_REALLOCARR
10- #define SNMALLOC_BOOTSTRAP_ALLOCATOR
11- #define SNMALLOC_JEMALLOC3_EXPERIMENTAL
12- #define SNMALLOC_JEMALLOC_NONSTANDARD
13- #include < snmalloc/override/jemalloc_compat.cc>
14- #include < snmalloc/override/malloc.cc>
13+ # define SNMALLOC_NAME_MANGLE (a ) our_##a
14+ # undef SNMALLOC_NO_REALLOCARRAY
15+ # undef SNMALLOC_NO_REALLOCARR
16+ # define SNMALLOC_BOOTSTRAP_ALLOCATOR
17+ # define SNMALLOC_JEMALLOC3_EXPERIMENTAL
18+ # define SNMALLOC_JEMALLOC_NONSTANDARD
19+ # include < snmalloc/override/jemalloc_compat.cc>
20+ # include < snmalloc/override/malloc.cc>
1521
16- #if __has_include(<malloc_np.h>)
17- # include < malloc_np.h>
18- #endif
22+ # if __has_include(<malloc_np.h>)
23+ # include < malloc_np.h>
24+ # endif
1925
20- #ifdef __FreeBSD__
26+ # ifdef __FreeBSD__
2127/* *
2228 * Enable testing against the versions that we get from libc or elsewhere.
2329 * Enabled by default on FreeBSD where all of the jemalloc functions are
2430 * exported from libc.
2531 */
26- # define TEST_JEMALLOC_MALLOCX
27- #endif
32+ # define TEST_JEMALLOC_MALLOCX
33+ # endif
2834
29- #define OUR_MALLOCX_LG_ALIGN (la ) (static_cast <int >(la))
30- #define OUR_MALLOCX_ZERO (one_at_bit<int >(6 ))
35+ # define OUR_MALLOCX_LG_ALIGN (la ) (static_cast <int >(la))
36+ # define OUR_MALLOCX_ZERO (one_at_bit<int >(6 ))
3137
32- #define OUR_ALLOCM_NO_MOVE (one_at_bit<int >(7 ))
38+ # define OUR_ALLOCM_NO_MOVE (one_at_bit<int >(7 ))
3339
34- #define OUR_ALLOCM_SUCCESS 0
35- #define OUR_ALLOCM_ERR_OOM 1
36- #define OUR_ALLOCM_ERR_NOT_MOVED 2
40+ # define OUR_ALLOCM_SUCCESS 0
41+ # define OUR_ALLOCM_ERR_OOM 1
42+ # define OUR_ALLOCM_ERR_NOT_MOVED 2
3743
38- #ifndef MALLOCX_LG_ALIGN
39- # define MALLOCX_LG_ALIGN (la ) OUR_MALLOCX_LG_ALIGN(la)
40- #endif
41- #ifndef MALLOCX_ZERO
42- # define MALLOCX_ZERO OUR_MALLOCX_ZERO
43- #endif
44+ # ifndef MALLOCX_LG_ALIGN
45+ # define MALLOCX_LG_ALIGN (la ) OUR_MALLOCX_LG_ALIGN(la)
46+ # endif
47+ # ifndef MALLOCX_ZERO
48+ # define MALLOCX_ZERO OUR_MALLOCX_ZERO
49+ # endif
4450
45- #ifndef ALLOCM_LG_ALIGN
46- # define ALLOCM_LG_ALIGN (la ) OUR_MALLOCX_LG_ALIGN(la)
47- #endif
48- #ifndef ALLOCM_ZERO
49- # define ALLOCM_ZERO OUR_MALLOCX_ZERO
50- #endif
51- #ifndef ALLOCM_NO_MOVE
52- # define ALLOCM_NO_MOVE OUR_ALLOCM_NO_MOVE
53- #endif
54- #ifndef ALLOCM_SUCCESS
55- # define ALLOCM_SUCCESS OUR_ALLOCM_SUCCESS
56- #endif
57- #ifndef ALLOCM_ERR_OOM
58- # define ALLOCM_ERR_OOM OUR_ALLOCM_ERR_OOM
59- #endif
60- #ifndef ALLOCM_ERR_NOT_MOVED
61- # define ALLOCM_ERR_NOT_MOVED OUR_ALLOCM_ERR_NOT_MOVED
62- #endif
51+ # ifndef ALLOCM_LG_ALIGN
52+ # define ALLOCM_LG_ALIGN (la ) OUR_MALLOCX_LG_ALIGN(la)
53+ # endif
54+ # ifndef ALLOCM_ZERO
55+ # define ALLOCM_ZERO OUR_MALLOCX_ZERO
56+ # endif
57+ # ifndef ALLOCM_NO_MOVE
58+ # define ALLOCM_NO_MOVE OUR_ALLOCM_NO_MOVE
59+ # endif
60+ # ifndef ALLOCM_SUCCESS
61+ # define ALLOCM_SUCCESS OUR_ALLOCM_SUCCESS
62+ # endif
63+ # ifndef ALLOCM_ERR_OOM
64+ # define ALLOCM_ERR_OOM OUR_ALLOCM_ERR_OOM
65+ # endif
66+ # ifndef ALLOCM_ERR_NOT_MOVED
67+ # define ALLOCM_ERR_NOT_MOVED OUR_ALLOCM_ERR_NOT_MOVED
68+ # endif
6369
6470using namespace snmalloc ;
6571using namespace snmalloc ::bits;
@@ -335,21 +341,22 @@ int main()
335341 our_dallocm,
336342 our_nallocm>();
337343
338- #ifndef __PIC__
344+ # ifndef __PIC__
339345 void * bootstrap = __je_bootstrap_malloc (42 );
340346 if (bootstrap == nullptr )
341347 {
342348 printf (" Failed to allocate from bootstrap malloc\n " );
343349 }
344350 __je_bootstrap_free (bootstrap);
345- #endif
351+ # endif
346352
347353 // These tests are for jemalloc compatibility and so should work with
348354 // jemalloc's implementation of these functions. If TEST_JEMALLOC is
349355 // defined then we try
350- #ifdef TEST_JEMALLOC_MALLOCX
356+ # ifdef TEST_JEMALLOC_MALLOCX
351357 test_size<mallocx, dallocx, sallocx, nallocx>();
352358 test_zeroing<mallocx, dallocx, rallocx>();
353359 test_xallocx<mallocx, dallocx, xallocx>();
354- #endif
360+ # endif
355361}
362+ #endif // SNMALLOC_ENABLE_GWP_ASAN_INTEGRATION
0 commit comments