summaryrefslogtreecommitdiff
path: root/libpthread/nptl/sysdeps/sh
diff options
context:
space:
mode:
authorAustin Foxley <austinf@cetoncorp.com>2010-02-16 12:27:18 -0800
committerAustin Foxley <austinf@cetoncorp.com>2010-02-16 12:27:18 -0800
commita032a6587011cbdac8c2f7e11f15dc4e592bbb55 (patch)
treeb8d8dfc6abf0168e098223c2134a3e4bd7640942 /libpthread/nptl/sysdeps/sh
parent70f1d42b13a741f603472f405299e5d2938aa728 (diff)
mass sync with glibc nptl
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
Diffstat (limited to 'libpthread/nptl/sysdeps/sh')
-rw-r--r--libpthread/nptl/sysdeps/sh/tcb-offsets.sym4
-rw-r--r--libpthread/nptl/sysdeps/sh/tls.h54
2 files changed, 51 insertions, 7 deletions
diff --git a/libpthread/nptl/sysdeps/sh/tcb-offsets.sym b/libpthread/nptl/sysdeps/sh/tcb-offsets.sym
index 539789a81..753b72b2d 100644
--- a/libpthread/nptl/sysdeps/sh/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/sh/tcb-offsets.sym
@@ -9,3 +9,7 @@ CLEANUP_JMP_BUF offsetof (struct pthread, cleanup_jmp_buf)
MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads)
TLS_PRE_TCB_SIZE sizeof (struct pthread)
MUTEX_FUTEX offsetof (pthread_mutex_t, __data.__lock)
+POINTER_GUARD offsetof (tcbhead_t, pointer_guard)
+#ifndef __ASSUME_PRIVATE_FUTEX
+PRIVATE_FUTEX offsetof (struct pthread, header.private_futex)
+#endif
diff --git a/libpthread/nptl/sysdeps/sh/tls.h b/libpthread/nptl/sysdeps/sh/tls.h
index 5e5ce12b0..2c538eded 100644
--- a/libpthread/nptl/sysdeps/sh/tls.h
+++ b/libpthread/nptl/sysdeps/sh/tls.h
@@ -1,5 +1,5 @@
/* Definition for thread-local data handling. NPTL/SH version.
- Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -24,6 +24,10 @@
# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
+# include <stdlib.h>
+# include <list.h>
+# include <sysdep.h>
+# include <bits/kernel-features.h>
/* Type for the dtv. */
typedef union dtv
@@ -39,7 +43,7 @@ typedef union dtv
typedef struct
{
dtv_t *dtv;
- void *private;
+ uintptr_t pointer_guard;
} tcbhead_t;
# define TLS_MULTIPLE_THREADS_IN_TCB 1
@@ -52,9 +56,9 @@ typedef struct
/* We require TLS support in the tools. */
#define HAVE_TLS_SUPPORT
#define HAVE___THREAD 1
-#define HAVE_TLS_MODEL_ATTRIBUTE 1
+#define HAVE_TLS_MODEL_ATTRIBUTE 1
/* Signal that TLS support is available. */
-# define USE_TLS 1
+# define USE_TLS 1
#ifndef __ASSEMBLER__
@@ -115,9 +119,9 @@ typedef struct
struct pthread *self = thread_self();
do not get optimized away. */
# define THREAD_SELF \
- ({ struct pthread *__thread_self; \
- __asm ("stc gbr,%0" : "=r" (__thread_self)); \
- __thread_self - 1;})
+ ({ struct pthread *__self; \
+ __asm ("stc gbr,%0" : "=r" (__self)); \
+ __self - 1;})
/* Magic for libthread_db to know how to do THREAD_SELF. */
# define DB_THREAD_SELF \
@@ -137,6 +141,42 @@ typedef struct
# define THREAD_SETMEM_NC(descr, member, idx, value) \
descr->member[idx] = (value)
+#define THREAD_GET_POINTER_GUARD() \
+ ({ tcbhead_t *__tcbp; \
+ __asm __volatile ("stc gbr,%0" : "=r" (__tcbp)); \
+ __tcbp->pointer_guard;})
+ #define THREAD_SET_POINTER_GUARD(value) \
+ ({ tcbhead_t *__tcbp; \
+ __asm __volatile ("stc gbr,%0" : "=r" (__tcbp)); \
+ __tcbp->pointer_guard = (value);})
+#define THREAD_COPY_POINTER_GUARD(descr) \
+ ({ tcbhead_t *__tcbp; \
+ __asm __volatile ("stc gbr,%0" : "=r" (__tcbp)); \
+ ((tcbhead_t *) (descr + 1))->pointer_guard = __tcbp->pointer_guard;})
+
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
#endif /* __ASSEMBLER__ */
#endif /* tls.h */