diff options
author | Carmelo Amoroso <carmelo.amoroso@st.com> | 2008-07-09 16:47:01 +0000 |
---|---|---|
committer | Carmelo Amoroso <carmelo.amoroso@st.com> | 2008-07-09 16:47:01 +0000 |
commit | 62a21af8006ab04282fdc354c5b4dc765f56d058 (patch) | |
tree | 568761d58289238aa14cced3f0010809d4d28c00 /libc/stdlib/malloc/malloc.h | |
parent | ef250238dc1572caf859c2b64652f9cdfb0d9e42 (diff) | |
download | uClibc-alpine-62a21af8006ab04282fdc354c5b4dc765f56d058.tar.bz2 uClibc-alpine-62a21af8006ab04282fdc354c5b4dc765f56d058.tar.xz |
BIG BIG commit: all left files merged from trunk [rev 22714]. Currenntly NPTL sh4 port build and work fine. All committed to allow Khem Ray working on a working branch to integrate the ARM nptl port. MIPS nptl port not tested but should still building and working fine. There are some other part non yet merged with trunk (misc/internals and some headers file that need some more work). Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libc/stdlib/malloc/malloc.h')
-rw-r--r-- | libc/stdlib/malloc/malloc.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/libc/stdlib/malloc/malloc.h b/libc/stdlib/malloc/malloc.h index b41c4b08e..7277cd2cf 100644 --- a/libc/stdlib/malloc/malloc.h +++ b/libc/stdlib/malloc/malloc.h @@ -11,8 +11,13 @@ * Written by Miles Bader <miles@gnu.org> */ -/* The alignment we guarantee for malloc return values. */ -#define MALLOC_ALIGNMENT (__alignof__ (double)) +/* The alignment we guarantee for malloc return values. We prefer this + to be at least sizeof (size_t) bytes because (a) we have to allocate + that many bytes for the header anyway and (b) guaranteeing word + alignment can be a significant win on targets like m68k and Coldfire, + where __alignof__(double) == 2. */ +#define MALLOC_ALIGNMENT \ + __alignof__ (double __attribute_aligned__ (sizeof (size_t))) /* The system pagesize... */ extern size_t __pagesize; @@ -79,7 +84,6 @@ extern struct heap __malloc_mmb_heap; to stderr, when the variable __malloc_mmb_debug is set to true. */ #ifdef MALLOC_MMB_DEBUGGING # include <stdio.h> -extern int __putc(int c, FILE *stream) attribute_hidden; extern int __malloc_mmb_debug; # define MALLOC_MMB_DEBUG(indent, fmt, args...) \ @@ -98,17 +102,20 @@ extern int __malloc_mmb_debug; /* The size of a malloc allocation is stored in a size_t word - MALLOC_ALIGNMENT bytes prior to the start address of the allocation: + MALLOC_HEADER_SIZE bytes prior to the start address of the allocation: +--------+---------+-------------------+ | SIZE |(unused) | allocation ... | +--------+---------+-------------------+ ^ BASE ^ ADDR - ^ ADDR - MALLOC_ALIGN + ^ ADDR - MALLOC_HEADER_SIZE */ /* The amount of extra space used by the malloc header. */ -#define MALLOC_HEADER_SIZE MALLOC_ALIGNMENT +#define MALLOC_HEADER_SIZE \ + (MALLOC_ALIGNMENT < sizeof (size_t) \ + ? sizeof (size_t) \ + : MALLOC_ALIGNMENT) /* Set up the malloc header, and return the user address of a malloc block. */ #define MALLOC_SETUP(base, size) \ @@ -126,6 +133,7 @@ extern int __malloc_mmb_debug; #ifdef __UCLIBC_HAS_THREADS__ # include <pthread.h> +# include <bits/uClibc_pthread.h> # define MALLOC_USE_LOCKING |