From 828f790a87121d0d74581d90ea62e1a482dcd6d8 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Tue, 28 Jan 2014 22:55:01 +0000 Subject: [PATCH] Intrin.h: implement __rdtsc and __halt git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200343 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Headers/Intrin.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Headers/Intrin.h b/lib/Headers/Intrin.h index 6005adfcd4..992fabf7aa 100644 --- a/lib/Headers/Intrin.h +++ b/lib/Headers/Intrin.h @@ -56,6 +56,7 @@ __int64 __emul(int, int); unsigned __int64 __emulu(unsigned int, unsigned int); void __cdecl __fastfail(unsigned int); unsigned int __getcallerseflags(void); +static __inline__ void __halt(void); unsigned char __inbyte(unsigned short); void __inbytestring(unsigned short, unsigned char *, unsigned long); @@ -92,6 +93,7 @@ static __inline__ unsigned int __popcnt(unsigned int); static __inline__ unsigned short __popcnt16(unsigned short); +static __inline__ unsigned __int64 __rdtsc(void); unsigned __int64 __rdtscp(unsigned int *); unsigned long __readcr0(void); @@ -889,6 +891,16 @@ _xgetbv(unsigned int __xcr_no) { __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no)); return ((unsigned __int64)__edx << 32) | __eax; } +static __inline__ unsigned __int64 __attribute__((__always_inline__, __nodebug__)) +__rdtsc(void) { + unsigned int __eax, __edx; + __asm__ ("rdtsc" : "=a" (__eax), "=d" (__edx)); + return ((unsigned __int64)__edx << 32) | __eax; +} +static __inline__ void __attribute__((__always_inline__, __nodebug__)) +__halt(void) { + __asm__ volatile ("hlt"); +} #ifdef __cplusplus } -- 2.40.0