Date: Thu, 1 Jul 2010 00:48:00 +0000 (UTC) From: Marcel Moolenaar <marcel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r209620 - head/lib/libc/gmon Message-ID: <201007010048.o610m06K009652@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marcel Date: Thu Jul 1 00:48:00 2010 New Revision: 209620 URL: http://svn.freebsd.org/changeset/base/209620 Log: 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 Modified: head/lib/libc/gmon/gmon.c Modified: head/lib/libc/gmon/gmon.c ============================================================================== --- head/lib/libc/gmon/gmon.c Thu Jul 1 00:33:50 2010 (r209619) +++ head/lib/libc/gmon/gmon.c Thu Jul 1 00:48:00 2010 (r209620) @@ -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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007010048.o610m06K009652>