[PATCH] Add implementations of __readfs{byte, word, dword, qword} to Intrin.h

Charles Davis cdavis5x at gmail.com
Thu Jan 23 15:49:41 PST 2014



================
Comment at: lib/Headers/Intrin.h:781-796
@@ +780,18 @@
+
+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);
+}
+
----------------
In MSVC, these intrinsics actually aren't available on x64. (They're not needed anyway on Windows/x64, because it uses `GS` for the TEB instead of `FS` as Windows/i386 does.) For this reason (unless you have some pressing need for `FS`-relative access on a non-Windows x86-64 platform), you might consider putting them inside an `#ifndef __x86_64__` block.


http://llvm-reviews.chandlerc.com/D2606



More information about the cfe-commits mailing list