summaryrefslogtreecommitdiffstats
path: root/sys/libkern/mcount.c
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2007-06-13 06:17:48 +0000
committerbde <bde@FreeBSD.org>2007-06-13 06:17:48 +0000
commit43613ee4edc241e9a29308f32f760f4342026e13 (patch)
tree80a49e4eb1222c7a847d72ab2542d790e4d93843 /sys/libkern/mcount.c
parent0630c4e3a422fc62cbc56d28059df823962b557e (diff)
downloadFreeBSD-src-43613ee4edc241e9a29308f32f760f4342026e13.zip
FreeBSD-src-43613ee4edc241e9a29308f32f760f4342026e13.tar.gz
Unbreak high resolution profiling a little: use dummy asms to prevent
timing loops being optimized away. Once apon a time, gcc promised not to optimize away timing loops, but gcc started optimizing away the call to a null function in the timing loop here some time between gcc-3.3.3 and gcc-3.4.6, and it started optimizing away the timing loop itself some time between gcc-3.4.6 and gcc-4.2.
Diffstat (limited to 'sys/libkern/mcount.c')
-rw-r--r--sys/libkern/mcount.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/libkern/mcount.c b/sys/libkern/mcount.c
index d967fe8..e26f6fa 100644
--- a/sys/libkern/mcount.c
+++ b/sys/libkern/mcount.c
@@ -268,18 +268,23 @@ mexitcount(selfpc)
}
}
+#ifndef __GNUCLIKE_ASM
+#error "This file uses null asms to prevent timing loops being optimized away."
+#endif
+
void
empty_loop()
{
int i;
for (i = 0; i < CALIB_SCALE; i++)
- ;
+ __asm __volatile("");
}
void
nullfunc()
{
+ __asm __volatile("");
}
void
OpenPOWER on IntegriCloud