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