summaryrefslogtreecommitdiff
path: root/libc/sysdeps/powerpc/sys/platform/ppc.h
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/powerpc/sys/platform/ppc.h')
-rw-r--r--libc/sysdeps/powerpc/sys/platform/ppc.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/libc/sysdeps/powerpc/sys/platform/ppc.h b/libc/sysdeps/powerpc/sys/platform/ppc.h
index 3780f57ba..58948e837 100644
--- a/libc/sysdeps/powerpc/sys/platform/ppc.h
+++ b/libc/sysdeps/powerpc/sys/platform/ppc.h
@@ -19,6 +19,7 @@
#ifndef _SYS_PLATFORM_PPC_H
#define _SYS_PLATFORM_PPC_H 1
+#include <features.h>
#include <stdint.h>
#include <bits/ppc.h>
@@ -26,13 +27,16 @@
static inline uint64_t
__ppc_get_timebase (void)
{
-#ifdef __powerpc64__
+#if __GNUC_PREREQ (4, 8)
+ return __builtin_ppc_get_timebase ();
+#else
+# ifdef __powerpc64__
uint64_t __tb;
/* "volatile" is necessary here, because the user expects this assembly
isn't moved after an optimization. */
__asm__ volatile ("mfspr %0, 268" : "=r" (__tb));
return __tb;
-#else /* not __powerpc64__ */
+# else /* not __powerpc64__ */
uint32_t __tbu, __tbl, __tmp; \
__asm__ volatile ("0:\n\t"
"mftbu %0\n\t"
@@ -42,7 +46,8 @@ __ppc_get_timebase (void)
"bne- 0b"
: "=r" (__tbu), "=r" (__tbl), "=r" (__tmp));
return (((uint64_t) __tbu << 32) | __tbl);
-#endif /* not __powerpc64__ */
+# endif /* not __powerpc64__ */
+#endif
}
#endif /* sys/platform/ppc.h */