summaryrefslogtreecommitdiffstats
path: root/lib/libc/gmon/gmon.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/gmon/gmon.c')
-rw-r--r--lib/libc/gmon/gmon.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c
index fe769e8..edf4e2f 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>
@@ -49,8 +50,10 @@ __FBSDID("$FreeBSD$");
#include "libc_private.h"
-#if defined(__i386__) || defined(__sparc64__) || defined(__amd64__) || defined(__powerpc__)
+#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
@@ -58,8 +61,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 +113,8 @@ monstartup(lowpc, highpc)
p->tos[0].link = 0;
o = p->highpc - p->lowpc;
- if (p->kcountsize < o) {
-#ifndef hp300
- 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);
}
OpenPOWER on IntegriCloud