aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/mach/hurd
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/mach/hurd')
-rw-r--r--sysdeps/mach/hurd/i386/tls.h21
-rw-r--r--sysdeps/mach/hurd/tls.h20
2 files changed, 21 insertions, 20 deletions
diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h
index 057b2613f3..2ac65df921 100644
--- a/sysdeps/mach/hurd/i386/tls.h
+++ b/sysdeps/mach/hurd/i386/tls.h
@@ -369,6 +369,27 @@ _hurd_tls_new (thread_t child, struct i386_thread_state *state, tcbhead_t *tcb)
return err;
}
+/* Global scope switch support. */
+# define THREAD_GSCOPE_IN_TCB 1
+
+# define THREAD_GSCOPE_FLAG_UNUSED 0
+# define THREAD_GSCOPE_FLAG_USED 1
+# define THREAD_GSCOPE_FLAG_WAIT 2
+
+# define THREAD_GSCOPE_SET_FLAG() \
+ THREAD_SETMEM (THREAD_SELF, gscope_flag, THREAD_GSCOPE_FLAG_USED)
+
+# define THREAD_GSCOPE_RESET_FLAG() \
+ ({ \
+ int __flag; \
+ asm volatile ("xchgl %0, %%gs:%P1" \
+ : "=r" (__flag) \
+ : "i" (offsetof (tcbhead_t, gscope_flag)), \
+ "0" (THREAD_GSCOPE_FLAG_UNUSED)); \
+ if (__flag == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_wake (THREAD_SELF->gscope_flag, LLL_PRIVATE); \
+ })
+
#endif /* !__ASSEMBLER__ */
#endif /* i386/tls.h */
diff --git a/sysdeps/mach/hurd/tls.h b/sysdeps/mach/hurd/tls.h
index f83956d3d7..8e66d5ff53 100644
--- a/sysdeps/mach/hurd/tls.h
+++ b/sysdeps/mach/hurd/tls.h
@@ -52,26 +52,6 @@
# define GET_DTV(descr) \
(((tcbhead_t *) (descr))->dtv)
-/* Global scope switch support. */
-#define THREAD_GSCOPE_IN_TCB 0
-#define THREAD_GSCOPE_GLOBAL
-#define THREAD_GSCOPE_SET_FLAG() \
- atomic_exchange_and_add_acq (&GL(dl_thread_gscope_count), 1)
-#define THREAD_GSCOPE_RESET_FLAG() \
- do \
- if (atomic_exchange_and_add_rel (&GL(dl_thread_gscope_count), -1) == 1) \
- lll_wake (GL(dl_thread_gscope_count), 0); \
- while (0)
-#define THREAD_GSCOPE_WAIT() \
- do \
- { \
- int count; \
- atomic_write_barrier (); \
- while ((count = GL(dl_thread_gscope_count))) \
- lll_wait (GL(dl_thread_gscope_count), count, 0); \
- } \
- while (0)
-
#endif /* !ASSEMBLER */