mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 08:12:28 +00:00
Make emacs not croak when editing dlmalloc
This commit is contained in:
parent
3c7ae0fc72
commit
fa1e8a3e65
21 changed files with 3019 additions and 2985 deletions
38
third_party/dlmalloc/chunks.inc
vendored
Normal file
38
third_party/dlmalloc/chunks.inc
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
// clang-format off
|
||||
|
||||
/* ------------------- Chunks sizes and alignments ----------------------- */
|
||||
|
||||
#define MCHUNK_SIZE (sizeof(mchunk))
|
||||
|
||||
#if FOOTERS
|
||||
#define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES)
|
||||
#else /* FOOTERS */
|
||||
#define CHUNK_OVERHEAD (SIZE_T_SIZE)
|
||||
#endif /* FOOTERS */
|
||||
|
||||
/* MMapped chunks need a second word of overhead ... */
|
||||
#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES)
|
||||
/* ... and additional padding for fake next-chunk at foot */
|
||||
#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES)
|
||||
|
||||
/* The smallest size we can malloc is an aligned minimal chunk */
|
||||
#define MIN_CHUNK_SIZE\
|
||||
((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)
|
||||
|
||||
/* conversion from malloc headers to user pointers, and back */
|
||||
#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES))
|
||||
#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES))
|
||||
/* chunk associated with aligned address A */
|
||||
#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A)))
|
||||
|
||||
/* Bounds on request (not chunk) sizes. */
|
||||
#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2)
|
||||
#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE)
|
||||
|
||||
/* pad request bytes into a usable size */
|
||||
#define pad_request(req) \
|
||||
(((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)
|
||||
|
||||
/* pad request, checking for minimum (but not maximum) */
|
||||
#define request2size(req) \
|
||||
(((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req))
|
Loading…
Add table
Add a link
Reference in a new issue