<p dir="ltr">Why not use the address space technique? David seemed to find that worked well.</p>
<div class="gmail_quote">On Jan 23, 2014 9:18 AM, "Hans Wennborg" <<a href="mailto:hans@chromium.org">hans@chromium.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi whunt, rnk,<br>
<br>
Please take a look. I always worry about getting the mov operands backwards :)<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D2606" target="_blank">http://llvm-reviews.chandlerc.com/D2606</a><br>
<br>
Files:<br>
  lib/Headers/Intrin.h<br>
<br>
Index: lib/Headers/Intrin.h<br>
===================================================================<br>
--- lib/Headers/Intrin.h<br>
+++ lib/Headers/Intrin.h<br>
@@ -101,9 +101,13 @@<br>
 unsigned long __readcr8(void);<br>
 unsigned int __readdr(unsigned int);<br>
 unsigned int __readeflags(void);<br>
+static __inline__<br>
 unsigned char __readfsbyte(unsigned long);<br>
+static __inline__<br>
 unsigned long __readfsdword(unsigned long);<br>
+static __inline__<br>
 unsigned __int64 __readfsqword(unsigned long);<br>
+static __inline__<br>
 unsigned short __readfsword(unsigned long);<br>
 unsigned __int64 __readmsr(unsigned long);<br>
 unsigned __int64 __readpmc(unsigned long);<br>
@@ -767,6 +771,33 @@<br>
   __asm__ volatile ("" : : : "memory");<br>
 }<br>
 /*----------------------------------------------------------------------------*\<br>
+|* readfs<br>
+\*----------------------------------------------------------------------------*/<br>
+static __inline__ unsigned char __attribute__((__always_inline__, __nodebug__))<br>
+__readfsbyte(unsigned long __addr) {<br>
+  unsigned char __result;<br>
+  __asm__ ("mov %%fs:(%1), %0" : "=r" (__result) : "r" (__addr));<br>
+  return __result;<br>
+}<br>
+static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))<br>
+__readfsdword(unsigned long __addr) {<br>
+  unsigned long __result;<br>
+  __asm__ ("mov %%fs:(%1), %0" : "=r" (__result) : "r" (__addr));<br>
+  return __result;<br>
+}<br>
+static __inline__ unsigned __int64 __attribute__((__always_inline__, __nodebug__))<br>
+__readfsqword(unsigned long __addr) {<br>
+  unsigned __int64 __result;<br>
+  __asm__ ("mov %%fs:(%1), %0" : "=r" (__result) : "r" (__addr));<br>
+  return __result;<br>
+}<br>
+static __inline__ unsigned short __attribute__((__always_inline__, __nodebug__))<br>
+__readfsword(unsigned long __addr) {<br>
+  unsigned short __result;<br>
+  __asm__ ("mov %%fs:(%1), %0" : "=r" (__result) : "r" (__addr));<br>
+  return __result;<br>
+}<br>
+/*----------------------------------------------------------------------------*\<br>
 |* Misc<br>
 \*----------------------------------------------------------------------------*/<br>
 static __inline__ void * __attribute__((__always_inline__, __nodebug__))<br>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div>