]> pd.if.org Git - pdclib/blob - functions/_dlmalloc/dlmalloc.h
Moved notime and mincoll from opt/ to functions/.
[pdclib] / functions / _dlmalloc / dlmalloc.h
1 #include "_PDCLIB_glue.h"
2 #include <threads.h>
3
4 typedef mtx_t MLOCK_T;
5 #define INITIAL_LOCK(lk) mtx_init(lk, mtx_plain)
6 #define DESTROY_LOCK(lk) mtx_destroy(lk)
7 #define ACQUIRE_LOCK(lk) mtx_lock(lk)
8 #define RELEASE_LOCK(lk) mtx_unlock(lk)
9 #define TRY_LOCK(lk) mtx_trylock(lk)
10 #define NEED_GLOBAL_LOCK_INIT
11 static mtx_t malloc_global_mutex;
12 static once_flag malloc_global_mutex_init_once;
13
14 static void init_malloc_global_mutex(void)
15 {
16         mtx_init(&malloc_global_mutex, mtx_plain);
17 }
18
19 static inline void *MMAP( size_t nbytes )
20 {
21     void *p = _PDCLIB_allocpages( nbytes / _PDCLIB_MALLOC_PAGESIZE );
22     return p ? p : (void*) (~(size_t)0);
23 }
24
25 #define MMAP(s) MMAP(s)
26 #define DIRECT_MMAP(s) MMAP(s)
27 #define MUNMAP(a, s) ((_PDCLIB_freepages((a), (s)/_PDCLIB_MALLOC_PAGESIZE)), 0)
28 #define MREMAP(a, osz, nsz, mv) _PDCLIB_reallocpages((a), (osz)/_PDCLIB_MALLOC_PAGESIZE, (nsz)/_PDCLIB_MALLOC_PAGESIZE, (mv))
29
30 #undef WIN32
31 #undef _WIN32
32 #define DLMALLOC_EXPORT  _PDCLIB_API
33 #define MALLOC_ALIGNMENT _PDCLIB_MALLOC_ALIGN
34 #define MSPACES 0
35 #define USE_LOCKS 2
36 #define USE_SPIN_LOCKS 0
37 #define USE_RECURSIVE_LOCKS 0
38 #define FOOTERS 0
39 #undef USE_DL_PREFIX
40 #define MALLOC_INSPECT_ALL 0
41 #define ABORT abort()
42 #define PROCEED_ON_ERROR 0
43 #define DEBUG 0
44 #define ABORT_ON_ASSERT_FAILURE 0
45 #define MALLOC_FAILURE_ACTION errno = ENOMEM
46 #define HAVE_MORECORE 0
47 #define MORECORE __unnamed__
48 #define MORECORE_CONTIGUOUS 0
49 #define MORECORE_CANNOT_TRIM 0
50 #define NO_SEGMENT_TRAVERSAL 0
51 #define HAVE_MMAP 1
52 #if defined(_PDCLIB_HAVE_REALLOCPAGES)
53         #define HAVE_MREMAP 1
54 #else
55         #define HAVE_MREMAP 0
56 #endif
57 #if defined(_PDCLIB_ALLOCPAGES_CLEARS)
58         #define MMAP_CLEARS 1
59 #else
60         #define MMAP_CLEARS 0
61 #endif
62 #define USE_BUILTIN_FFS 0
63 #define malloc_getpagesize _PDCLIB_MALLOC_PAGESIZE
64 #define USE_DEV_RANDOM 0
65 #define NO_MALLINFO 1
66 #define MALLINFO_FIELD_TYPE size_t
67 #define NO_MALLOC_STATS 1
68 #define DEFAULT_GRANULARITY _PDCLIB_MALLOC_GRANULARITY
69 #define DEFAULT_TRIM_THRESHOLD _PDCLIB_MALLOC_TRIM_THRESHOLD
70 #define DEFAULT_MMAP_THREHOLD _PDCLIB_MALLOC_MMAP_THRESHOLD
71 #define MAX_RELEASE_CHECK_RATE _PDCLIB_MALLOC_RELEASE_CHECK_RATE
72
73 /* C standard says this is so */
74 #define REALLOC_ZERO_BYTES_FREES 1
75 #define LACKS_UNISTD_H
76 #define LACKS_FCNTL_H
77 #define LACKS_SYS_PARAM_H
78 #define LACKS_SYS_MMAN_H
79 #define LACKS_STRINGS_H
80 #define LACKS_SYS_TYPES_H
81 #define LACKS_SCHED_H
82 #include <stdlib.h>
83 #include <errno.h>