malloc.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * libc/stdlib/malloc-zarg/malloc.h -- small malloc implementation
  3. *
  4. * Copyright (C) 2002 NEC Corporation
  5. * Copyright (C) 2002 Miles Bader <miles@gnu.org>
  6. *
  7. * This file is subject to the terms and conditions of the GNU Lesser
  8. * General Public License. See the file COPYING.LIB in the main
  9. * directory of this archive for more details.
  10. *
  11. * Written by Miles Bader <miles@gnu.org>
  12. */
  13. /* The alignment we guarantee for malloc return values. */
  14. #define MALLOC_ALIGNMENT (sizeof (double))
  15. /* The system pagesize we assume; we really ought to get it with
  16. getpagesize, but gee, how annoying. */
  17. #define MALLOC_PAGE_SIZE 4096
  18. /* The minimum size of block we request from the the system to extend the
  19. heap for small allocations (we may request a bigger block if necessary to
  20. satisfy a particularly big request). */
  21. #define MALLOC_HEAP_EXTEND_SIZE MALLOC_PAGE_SIZE
  22. /* The threshold above which blocks are allocated/freed with mmap/munmap,
  23. rather than using the heap. */
  24. #define MALLOC_MMAP_THRESHOLD (8*MALLOC_PAGE_SIZE)
  25. #if 0
  26. #include <stdio.h>
  27. #define MALLOC_DEBUG(fmt, args...) fprintf (stderr, fmt , ##args)
  28. #else
  29. #define MALLOC_DEBUG(fmt, args...) (void)0
  30. #endif
  31. /* Return SZ rounded up to a multiple MALLOC_PAGE_SIZE. */
  32. #define MALLOC_ROUND_UP_TO_PAGE_SIZE(sz) \
  33. (((sz) + (MALLOC_PAGE_SIZE - 1)) & ~(MALLOC_PAGE_SIZE - 1))
  34. /* The heap used for small allocations. */
  35. extern struct heap __malloc_heap;