diff options
author | brooks <brooks@FreeBSD.org> | 2016-01-21 18:17:19 +0000 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2016-01-21 18:17:19 +0000 |
commit | 782c60a71700572e664e5dfc8f70a6727d616396 (patch) | |
tree | af44ac3a1bff7ff173cb75ba9104442e7b6966b0 /lib/libc | |
parent | 53785e60ff88af45e981416d6636d29e0afe04f6 (diff) | |
download | FreeBSD-src-782c60a71700572e664e5dfc8f70a6727d616396.zip FreeBSD-src-782c60a71700572e664e5dfc8f70a6727d616396.tar.gz |
Replace the last non-optional use of sbrk() in the tree with mmap().
All gmon want's is a region of memory without the overhead of malloc().
Just mapping some pages with mmap is an easy way to accomplish this.
Approved by: jhb, cem, emaste
Obtained from: CheriBSD (bf33e1e70b368ababde74aa3ac70d108c8a52c69)
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D5005
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gmon/gmon.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c index eebce0a..6ca8f79 100644 --- a/lib/libc/gmon/gmon.c +++ b/lib/libc/gmon/gmon.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/time.h> #include <sys/gmon.h> +#include <sys/mman.h> #include <sys/sysctl.h> #include <err.h> @@ -50,14 +51,6 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" -#if defined(__i386__) || defined(__sparc64__) || defined(__amd64__) || (defined(__powerpc__) && !defined(__powerpc64__)) -extern char *minbrk __asm (".minbrk"); -#elif defined(__powerpc64__) -extern char *minbrk __asm ("_minbrk"); -#else -extern char *minbrk __asm ("minbrk"); -#endif - struct gmonparam _gmonparam = { GMON_PROF_OFF }; static int s_scale; @@ -94,8 +87,9 @@ monstartup(u_long lowpc, u_long highpc) p->tolimit = MAXARCS; p->tossize = p->tolimit * sizeof(struct tostruct); - cp = sbrk(p->kcountsize + p->fromssize + p->tossize); - if (cp == (char *)-1) { + cp = mmap(NULL, p->kcountsize + p->fromssize + p->tossize, + PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); + if (cp == MAP_FAILED) { ERR("monstartup: out of memory\n"); return; } @@ -108,7 +102,6 @@ monstartup(u_long lowpc, u_long highpc) cp += p->kcountsize; p->froms = (u_short *)cp; - minbrk = sbrk(0); p->tos[0].link = 0; o = p->highpc - p->lowpc; |