summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2000-06-14 17:11:47 +0000
committerbde <bde@FreeBSD.org>2000-06-14 17:11:47 +0000
commitcc22f14b179a55f7686e798febd938bfef76c982 (patch)
treed6ac99ce66a0b4779f436220a7b5fff21535b50f
parent3fa18b8916fe9b25c5597ac51644d51a66e57238 (diff)
downloadFreeBSD-src-cc22f14b179a55f7686e798febd938bfef76c982.zip
FreeBSD-src-cc22f14b179a55f7686e798febd938bfef76c982.tar.gz
Removed support for generating inline code for MALLOC() and FREE()
in the dysfunctional !KMEMSTATS case. This hasn't compiled since rev.1.31 of kern_malloc.c quietly removed the core of the support for the !KMEMSTATS case. I fixed it to see if it was worth saving and found that (as usual) inlining just wasted space and increased complexity without significantly affecting time, at least for the lmbench2 micro-benchmark on a Celeron. The space bloat was surprisingly large - the text size increased from 1700K to 1840K for a version with the entire malloc() family inlined. Removed even older garbage (kmemxtob() and btokmemx() macros). Attempt to deprecate MALLOC() and FREE(). Given current compilers (gcc-2.x or C99), they don't do anything that (safe) function-like macros or inline functions named malloc() and free() couldn't do. Fixed missing casts of macro args in MALLOC() and FREE().
-rw-r--r--sys/sys/malloc.h49
1 files changed, 4 insertions, 45 deletions
diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h
index ba85d9c..126b226 100644
--- a/sys/sys/malloc.h
+++ b/sys/sys/malloc.h
@@ -39,8 +39,6 @@
#define splmem splhigh
-#define KMEMSTATS
-
/*
* flags to malloc.
*/
@@ -147,55 +145,16 @@ struct kmembuckets {
: (MINBUCKET + 15))
/*
- * Turn virtual addresses into kmem map indices
+ * Turn virtual addresses into kmemusage pointers.
*/
-#define kmemxtob(alloc) (kmembase + (alloc) * PAGE_SIZE)
-#define btokmemx(addr) (((caddr_t)(addr) - kmembase) / PAGE_SIZE)
#define btokup(addr) (&kmemusage[((caddr_t)(addr) - kmembase) >> PAGE_SHIFT])
/*
- * Macro versions for the usual cases of malloc/free
+ * Deprecated macro versions of not-quite-malloc() and free().
*/
-#if defined(KMEMSTATS) || defined(DIAGNOSTIC)
#define MALLOC(space, cast, size, type, flags) \
- (space) = (cast)malloc((u_long)(size), type, flags)
-#define FREE(addr, type) free((addr), type)
-
-#else /* do not collect statistics */
-#define MALLOC(space, cast, size, type, flags) do { \
- register struct kmembuckets *kbp = &bucket[BUCKETINDX(size)]; \
- long s = splmem(); \
- if (kbp->kb_next == NULL) { \
- (space) = (cast)malloc((u_long)(size), type, flags); \
- } else { \
- (space) = (cast)kbp->kb_next; \
- kbp->kb_next = *(caddr_t *)(space); \
- } \
- splx(s); \
-} while (0)
-
-#define FREE(addr, type) do { \
- register struct kmembuckets *kbp; \
- register struct kmemusage *kup = btokup(addr); \
- long s = splmem(); \
- if (1 << kup->ku_indx > MAXALLOCSAVE) { \
- free((addr), type); \
- } else { \
- kbp = &bucket[kup->ku_indx]; \
- if (kbp->kb_next == NULL) \
- kbp->kb_next = (caddr_t)(addr); \
- else \
- *(caddr_t *)(kbp->kb_last) = (caddr_t)(addr); \
- *(caddr_t *)(addr) = NULL; \
- kbp->kb_last = (caddr_t)(addr); \
- } \
- splx(s); \
-} while (0)
-
-extern struct kmemusage *kmemusage;
-extern char *kmembase;
-extern struct kmembuckets bucket[];
-#endif /* do not collect statistics */
+ (space) = (cast)malloc((u_long)(size), (type), (flags))
+#define FREE(addr, type) free((addr), (type))
/*
* XXX this should be declared in <sys/uio.h>, but that tends to fail
OpenPOWER on IntegriCloud