summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@kernel.org>2015-04-01 10:49:43 -0700
committerAndy Lutomirski <luto@kernel.org>2015-04-01 10:49:43 -0700
commit74d4e3369594983d779fa4c53b61de5065d88a5a (patch)
tree1b5a347020ca0ad00a09163819cf302f3acf0adc
parent5f8fcc3d10bcecbe92eeef6f4d7ef5064fa0789b (diff)
downloadmisc-tests-74d4e3369594983d779fa4c53b61de5065d88a5a.tar.gz
user_visible_state: Improve portability
-rw-r--r--user_visible_state.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/user_visible_state.c b/user_visible_state.c
index e33a985..704fd3d 100644
--- a/user_visible_state.c
+++ b/user_visible_state.c
@@ -5,11 +5,12 @@
#include <setjmp.h>
#include <string.h>
#include <xmmintrin.h>
+
+#ifdef __linux__
#include <asm/prctl.h>
#include <sys/prctl.h>
-#include <asm/ldt.h>
-
extern int arch_prctl(int, unsigned long);
+#endif
static void sethandler(int sig, void (*handler)(int, siginfo_t *, void *),
int flags)
@@ -182,13 +183,13 @@ static void show_segment(uint16_t index, int ldt)
asm ("lsl %[selector], %[limit]\n\t"
"jnz 1f\n\t"
- "mov $1, %[has_limit]\n\t"
+ "movl $1, %[has_limit]\n\t"
"1:"
: [limit] "=r" (limit), [has_limit] "+rm" (has_limit)
: [selector] "r" (selector));
asm ("larl %[selector], %[ar]\n\t"
"jnz 1f\n\t"
- "mov $1, %[has_ar]\n\t"
+ "movl $1, %[has_ar]\n\t"
"1:"
: [ar] "=r" (ar), [has_ar] "+rm" (has_ar)
: [selector] "r" (selector));
@@ -221,8 +222,10 @@ static void show_segment(uint16_t index, int ldt)
int main()
{
+#ifdef __linux__
// Optional: gives some visibility into how TLS works.
arch_prctl(ARCH_SET_GS, 500);
+#endif
uint16_t gdtlimit = show_gdt_and_idt();
show_ldt();