diff options
author | Marcel Moolenaar <marcel@FreeBSD.org> | 2010-07-01 00:48:00 +0000 |
---|---|---|
committer | Marcel Moolenaar <marcel@FreeBSD.org> | 2010-07-01 00:48:00 +0000 |
commit | af448c52e4f7e066d48e1f4755a39f8bdf27ccde (patch) | |
tree | fbffdf6c0ccd19c4a26e7b3cdcbae9eabed775bb /lib/libc/gmon | |
parent | b9c9542267fa6a4f0dfa4c5482c0cccfcca1493c (diff) | |
download | src-af448c52e4f7e066d48e1f4755a39f8bdf27ccde.tar.gz src-af448c52e4f7e066d48e1f4755a39f8bdf27ccde.zip |
Simplify the calculation of s_scale by rewriting the FP expression to
use uintmax_t instead of float and thereby eliminating the need for
a non-FP version.
Tested on: amd64, ia64 & powerpc (book-E)
Suggested by: bde
MFC after: 1 month
Notes
Notes:
svn path=/head/; revision=209620
Diffstat (limited to 'lib/libc/gmon')
-rw-r--r-- | lib/libc/gmon/gmon.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c index 9b1406a7981d..d699a80ad809 100644 --- a/lib/libc/gmon/gmon.c +++ b/lib/libc/gmon/gmon.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include <err.h> #include <fcntl.h> +#include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -58,8 +59,8 @@ extern char *minbrk __asm ("minbrk"); struct gmonparam _gmonparam = { GMON_PROF_OFF }; static int s_scale; -/* see profil(2) where this is describe (incorrectly) */ -#define SCALE_1_TO_1 0x10000L +/* See profil(2) where this is described (incorrectly). */ +#define SCALE_SHIFT 16 #define ERR(s) _write(2, s, sizeof(s)) @@ -110,24 +111,8 @@ monstartup(lowpc, highpc) p->tos[0].link = 0; o = p->highpc - p->lowpc; - if (p->kcountsize < o) { -#if !defined(__powerpc__) - s_scale = ((float)p->kcountsize / o ) * SCALE_1_TO_1; -#else /* avoid floating point */ - int quot = o / p->kcountsize; - - if (quot >= 0x10000) - s_scale = 1; - else if (quot >= 0x100) - s_scale = 0x10000 / quot; - else if (o >= 0x800000) - s_scale = 0x1000000 / (o / (p->kcountsize >> 8)); - else - s_scale = 0x1000000 / ((o << 8) / p->kcountsize); -#endif - } else - s_scale = SCALE_1_TO_1; - + s_scale = (p->kcountsize < o) ? + ((uintmax_t)p->kcountsize << SCALE_SHIFT) / o : (1 << SCALE_SHIFT); moncontrol(1); } |