Set GS register for Fuchsia
Test: Tested with Fuchsia build system and toolchain
Change-Id: I85f9bdb59090df5cf4c21ef585f813730d84ba3f
diff --git a/runtime/arch/x86_64/thread_x86_64.cc b/runtime/arch/x86_64/thread_x86_64.cc
index 19d25f6..5c0446f 100644
--- a/runtime/arch/x86_64/thread_x86_64.cc
+++ b/runtime/arch/x86_64/thread_x86_64.cc
@@ -25,6 +25,10 @@
#include <asm/prctl.h>
#include <sys/prctl.h>
#include <sys/syscall.h>
+#elif defined(__Fuchsia__)
+#include <zircon/process.h>
+#include <zircon/syscalls.h>
+#include <zircon/syscalls/object.h>
#endif
namespace art {
@@ -40,6 +44,13 @@
#if defined(__linux__)
arch_prctl(ARCH_SET_GS, this);
+#elif defined(__Fuchsia__)
+ Thread* thread_ptr = this;
+ zx_status_t status = zx_object_set_property(zx_thread_self(),
+ ZX_PROP_REGISTER_GS,
+ &thread_ptr,
+ sizeof(thread_ptr));
+ CHECK_EQ(status, ZX_OK) << "failed to set GS register";
#else
UNIMPLEMENTED(FATAL) << "Need to set GS";
#endif