diff options
| author | Hans Wennborg <hans@hanshq.net> | 2014-01-24 00:52:39 +0000 |
|---|---|---|
| committer | Hans Wennborg <hans@hanshq.net> | 2014-01-24 00:52:39 +0000 |
| commit | 74ca0c41059aa918f0de8aeb1fd65a34129fcba5 (patch) | |
| tree | 19b6b0badd7df46dc2a58ff23045759e2f4a149e /clang/lib | |
| parent | 72553fc19b1e57c08d77ccde1a6a6f7bcf22c08f (diff) | |
| download | bcm5719-llvm-74ca0c41059aa918f0de8aeb1fd65a34129fcba5.tar.gz bcm5719-llvm-74ca0c41059aa918f0de8aeb1fd65a34129fcba5.zip | |
Add implementations of __readfs{byte,word,dword,qword} to Intrin.h
Differential Revision: http://llvm-reviews.chandlerc.com/D2606
llvm-svn: 199958
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Headers/Intrin.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/clang/lib/Headers/Intrin.h b/clang/lib/Headers/Intrin.h index 82aadb2e33c..2a93d3d29b1 100644 --- a/clang/lib/Headers/Intrin.h +++ b/clang/lib/Headers/Intrin.h @@ -101,10 +101,16 @@ unsigned long __readcr5(void); unsigned long __readcr8(void); unsigned int __readdr(unsigned int); unsigned int __readeflags(void); +#ifdef __i386__ +static __inline__ unsigned char __readfsbyte(unsigned long); +static __inline__ unsigned long __readfsdword(unsigned long); +static __inline__ unsigned __int64 __readfsqword(unsigned long); +static __inline__ unsigned short __readfsword(unsigned long); +#endif unsigned __int64 __readmsr(unsigned long); unsigned __int64 __readpmc(unsigned long); unsigned long __segmentlimit(unsigned long); @@ -767,6 +773,33 @@ _WriteBarrier(void) { __asm__ volatile ("" : : : "memory"); } /*----------------------------------------------------------------------------*\ +|* readfs +|* (Pointers in address space #257 are relative to the FS segment register.) +\*----------------------------------------------------------------------------*/ +#ifdef __i386__ +#define __ptr_to_addr_space(__addr_space_nbr, __type, __offset) \ + ((volatile __type __attribute__((__address_space__(__addr_space_nbr)))*) \ + (__offset)) + +static __inline__ unsigned char __attribute__((__always_inline__, __nodebug__)) +__readfsbyte(unsigned long __offset) { + return *__ptr_to_addr_space(257, unsigned char, __offset); +} +static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__)) +__readfsdword(unsigned long __offset) { + return *__ptr_to_addr_space(257, unsigned long, __offset); +} +static __inline__ unsigned __int64 __attribute__((__always_inline__, __nodebug__)) +__readfsqword(unsigned long __offset) { + return *__ptr_to_addr_space(257, unsigned __int64, __offset); +} +static __inline__ unsigned short __attribute__((__always_inline__, __nodebug__)) +__readfsword(unsigned long __offset) { + return *__ptr_to_addr_space(257, unsigned short, __offset); +} +#undef __ptr_to_addr_space +#endif +/*----------------------------------------------------------------------------*\ |* Misc \*----------------------------------------------------------------------------*/ static __inline__ void * __attribute__((__always_inline__, __nodebug__)) |

