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>
6
12
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>
15
21
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
19
25
20
- #ifdef __FreeBSD__
26
+ # ifdef __FreeBSD__
21
27
/* *
22
28
* Enable testing against the versions that we get from libc or elsewhere.
23
29
* Enabled by default on FreeBSD where all of the jemalloc functions are
24
30
* exported from libc.
25
31
*/
26
- # define TEST_JEMALLOC_MALLOCX
27
- #endif
32
+ # define TEST_JEMALLOC_MALLOCX
33
+ # endif
28
34
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 ))
31
37
32
- #define OUR_ALLOCM_NO_MOVE (one_at_bit<int >(7 ))
38
+ # define OUR_ALLOCM_NO_MOVE (one_at_bit<int >(7 ))
33
39
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
37
43
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
44
50
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
63
69
64
70
using namespace snmalloc ;
65
71
using namespace snmalloc ::bits;
@@ -335,21 +341,22 @@ int main()
335
341
our_dallocm,
336
342
our_nallocm>();
337
343
338
- #ifndef __PIC__
344
+ # ifndef __PIC__
339
345
void * bootstrap = __je_bootstrap_malloc (42 );
340
346
if (bootstrap == nullptr )
341
347
{
342
348
printf (" Failed to allocate from bootstrap malloc\n " );
343
349
}
344
350
__je_bootstrap_free (bootstrap);
345
- #endif
351
+ # endif
346
352
347
353
// These tests are for jemalloc compatibility and so should work with
348
354
// jemalloc's implementation of these functions. If TEST_JEMALLOC is
349
355
// defined then we try
350
- #ifdef TEST_JEMALLOC_MALLOCX
356
+ # ifdef TEST_JEMALLOC_MALLOCX
351
357
test_size<mallocx, dallocx, sallocx, nallocx>();
352
358
test_zeroing<mallocx, dallocx, rallocx>();
353
359
test_xallocx<mallocx, dallocx, xallocx>();
354
- #endif
360
+ # endif
355
361
}
362
+ #endif // SNMALLOC_ENABLE_GWP_ASAN_INTEGRATION
0 commit comments