summaryrefslogtreecommitdiff
path: root/libc/stdlib/malloc/malloc.h
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-07-18 15:00:07 +0000
committerEric Andersen <andersen@codepoet.org>2002-07-18 15:00:07 +0000
commit35d29fcb08fadaf006561a058746b0fce76a6a74 (patch)
treeb42a59394f8ee7dc7c11f71ae2d45b1e1beb834b /libc/stdlib/malloc/malloc.h
parent3b1e82407a02aed6319c6686c5b06c2051a20cca (diff)
Miles Bader implemented a new mmap based malloc which is much
smarter than the old "malloc-simple", and actually works, unlike the old "malloc". So kill the old "malloc-simple" and the old "malloc" and replace them with Miles' new malloc implementation. Update Config files to match. Thanks Miles!
Diffstat (limited to 'libc/stdlib/malloc/malloc.h')
-rw-r--r--libc/stdlib/malloc/malloc.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/libc/stdlib/malloc/malloc.h b/libc/stdlib/malloc/malloc.h
new file mode 100644
index 000000000..96c8de6c2
--- /dev/null
+++ b/libc/stdlib/malloc/malloc.h
@@ -0,0 +1,45 @@
+/*
+ * libc/stdlib/malloc-zarg/malloc.h -- small malloc implementation
+ *
+ * Copyright (C) 2002 NEC Corporation
+ * Copyright (C) 2002 Miles Bader <miles@gnu.org>
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ *
+ * Written by Miles Bader <miles@gnu.org>
+ */
+
+/* The alignment we guarantee for malloc return values. */
+#define MALLOC_ALIGNMENT (sizeof (double))
+
+/* The system pagesize we assume; we really ought to get it with
+ getpagesize, but gee, how annoying. */
+#define MALLOC_PAGE_SIZE 4096
+
+/* The minimum size of block we request from the the system to extend the
+ heap for small allocations (we may request a bigger block if necessary to
+ satisfy a particularly big request). */
+#define MALLOC_HEAP_EXTEND_SIZE MALLOC_PAGE_SIZE
+
+/* The threshold above which blocks are allocated/freed with mmap/munmap,
+ rather than using the heap. */
+#define MALLOC_MMAP_THRESHOLD (8*MALLOC_PAGE_SIZE)
+
+
+#if 0
+#include <stdio.h>
+#define MALLOC_DEBUG(fmt, args...) fprintf (stderr, fmt , ##args)
+#else
+#define MALLOC_DEBUG(fmt, args...) (void)0
+#endif
+
+
+/* Return SZ rounded up to a multiple MALLOC_PAGE_SIZE. */
+#define MALLOC_ROUND_UP_TO_PAGE_SIZE(sz) \
+ (((sz) + (MALLOC_PAGE_SIZE - 1)) & ~(MALLOC_PAGE_SIZE - 1))
+
+
+/* The heap used for small allocations. */
+extern struct heap __malloc_heap;