* sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes.h
authorDaniel Jacobowitz <dan@codesourcery.com>
Mon, 27 Feb 2006 15:36:07 +0000 (15:36 +0000)
committerDaniel Jacobowitz <dan@codesourcery.com>
Mon, 27 Feb 2006 15:36:07 +0000 (15:36 +0000)
(struct __pthread_internal_slist): New.
(union pthread_mutex_t): Give struct a tag.  Add __list
in an anonymous union.
(union pthread_cond_t): Use __extension__.
* sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h
(__lll_mutex_lock_outlined, __lll_mutex_timedlock_outlined): Remove
prototypes.
(lll_robust_mutex_dead, __lll_robust_mutex_trylock,
lll_robust_mutex_trylock, __lll_robust_mutex_lock,
lll_robust_mutex_lock, lll_robust_mutex_cond_lock,
__lll_robust_mutex_timedlock, lll_robust_mutex_timedlock,
__lll_robust_mutex_unlock, lll_robust_mutex_unlock): New.
(__lll_robust_lock_wait, __lll_robust_timedlock_wait): New
prototypes.

ChangeLog.arm
sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes.h
sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h

index 0d4f5fd..abc3563 100644 (file)
@@ -1,5 +1,23 @@
 2006-02-27  Daniel Jacobowitz  <dan@codesourcery.com>
 
+       * sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes.h
+       (struct __pthread_internal_slist): New.
+       (union pthread_mutex_t): Give struct a tag.  Add __list
+       in an anonymous union.
+       (union pthread_cond_t): Use __extension__.
+       * sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h
+       (__lll_mutex_lock_outlined, __lll_mutex_timedlock_outlined): Remove
+       prototypes.
+       (lll_robust_mutex_dead, __lll_robust_mutex_trylock,
+       lll_robust_mutex_trylock, __lll_robust_mutex_lock,
+       lll_robust_mutex_lock, lll_robust_mutex_cond_lock,
+       __lll_robust_mutex_timedlock, lll_robust_mutex_timedlock,
+       __lll_robust_mutex_unlock, lll_robust_mutex_unlock): New.
+       (__lll_robust_lock_wait, __lll_robust_timedlock_wait): New
+       prototypes.
+
+2006-02-27  Daniel Jacobowitz  <dan@codesourcery.com>
+
        * sysdeps/unix/sysv/linux/arm/eabi/ftruncate64.c: Don't use
        sysdeps/generic/.
        * sysdeps/unix/sysv/linux/arm/eabi/truncate64.c: Likewise.
index fb0fe3f..ea8d6a2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006 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
@@ -43,11 +43,17 @@ typedef union
 } pthread_attr_t;
 
 
+typedef struct __pthread_internal_slist
+{
+  struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+
 /* Data structures for mutex handling.  The structure of the attribute
    type is not exposed on purpose.  */
 typedef union
 {
-  struct
+  struct __pthread_mutex_s
   {
     int __lock;
     unsigned int __count;
@@ -56,7 +62,11 @@ typedef union
        binary compatibility.  */
     int __kind;
     unsigned int __nusers;
-    int __spins;
+    __extension__ union
+    {
+      int __spins;
+      __pthread_slist_t __list;
+    };
   } __data;
   char __size[__SIZEOF_PTHREAD_MUTEX_T];
   long int __align;
@@ -77,15 +87,15 @@ typedef union
   {
     int __lock;
     unsigned int __futex;
-    unsigned long long int __total_seq;
-    unsigned long long int __wakeup_seq;
-    unsigned long long int __woken_seq;
+    __extension__ unsigned long long int __total_seq;
+    __extension__ unsigned long long int __wakeup_seq;
+    __extension__ unsigned long long int __woken_seq;
     void *__mutex;
     unsigned int __nwaiters;
     unsigned int __broadcast_seq;
   } __data;
   char __size[__SIZEOF_PTHREAD_COND_T];
-  long long int __align;
+  __extension__ long long int __align;
 } pthread_cond_t;
 
 typedef union
index 7f1c291..d1d0d65 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006 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
     __ret;                                                                   \
   })
 
+#define lll_robust_mutex_dead(futexv) \
+  do                                                                         \
+    {                                                                        \
+      int *__futexp = &(futexv);                                             \
+      atomic_or (__futexp, FUTEX_OWNER_DIED);                                \
+      lll_futex_wake (__futexp, 1);                                          \
+    }                                                                        \
+  while (0)
+
 /* Returns non-zero if error happened, zero if success.  */
 #define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val) \
   ({                                                                         \
@@ -125,7 +134,15 @@ __lll_mutex_cond_trylock (int *futex)
 #define lll_mutex_cond_trylock(lock)   __lll_mutex_cond_trylock (&(lock))
 
 
-extern void __lll_mutex_lock_outlined (int *futex) attribute_hidden;
+static inline int __attribute__((always_inline))
+__lll_robust_mutex_trylock(int *futex, int id)
+{
+  return atomic_compare_and_exchange_val_acq (futex, id, 0) != 0;
+}
+#define lll_robust_mutex_trylock(lock, id) \
+  __lll_robust_mutex_trylock (&(lock), id)
+
+extern int __lll_robust_lock_wait (int *futex) attribute_hidden;
 
 static inline void __attribute__((always_inline))
 __lll_mutex_lock (int *futex)
@@ -141,6 +158,18 @@ __lll_mutex_lock (int *futex)
 #define lll_mutex_lock(futex) __lll_mutex_lock (&(futex))
 
 
+static inline int __attribute__ ((always_inline))
+__lll_robust_mutex_lock (int *futex, int id)
+{
+  int result = 0;
+  if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+    result = __lll_robust_lock_wait (futex);
+  return result;
+}
+#define lll_robust_mutex_lock(futex, id) \
+  __lll_robust_mutex_lock (&(futex), id)
+
+
 static inline void __attribute__ ((always_inline))
 __lll_mutex_cond_lock (int *futex)
 {
@@ -155,11 +184,13 @@ __lll_mutex_cond_lock (int *futex)
 #define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex))
 
 
+#define lll_robust_mutex_cond_lock(futex, id) \
+  __lll_robust_mutex_lock (&(futex), (id) | FUTEX_WAITERS)
+
+
 extern int __lll_timedlock_wait (int *futex, const struct timespec *)
        attribute_hidden;
-
-extern int __lll_mutex_timedlock_outlined (int *futex,
-                                          const struct timespec *)
+extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *)
        attribute_hidden;
 
 static inline int __attribute__ ((always_inline))
@@ -176,6 +207,19 @@ __lll_mutex_timedlock (int *futex, const struct timespec *abstime)
   __lll_mutex_timedlock (&(futex), abstime)
 
 
+static inline int __attribute__ ((always_inline))
+__lll_robust_mutex_timedlock (int *futex, const struct timespec *abstime,
+                             int id)
+{
+  int result = 0;
+  if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+    result = __lll_robust_timedlock_wait (futex, abstime);
+  return result;
+}
+#define lll_robust_mutex_timedlock(futex, abstime, id) \
+  __lll_robust_mutex_timedlock (&(futex), abstime, id)
+
+
 static inline void __attribute__ ((always_inline))
 __lll_mutex_unlock (int *futex)
 {
@@ -187,6 +231,17 @@ __lll_mutex_unlock (int *futex)
 
 
 static inline void __attribute__ ((always_inline))
+__lll_robust_mutex_unlock (int *futex, int mask)
+{
+  int val = atomic_exchange_rel (futex, 0);
+  if (__builtin_expect (val & mask, 0))
+    lll_futex_wake (futex, 1);
+}
+#define lll_robust_mutex_unlock(futex) \
+  __lll_robust_mutex_unlock(&(futex), FUTEX_WAITERS)
+
+
+static inline void __attribute__ ((always_inline))
 __lll_mutex_unlock_force (int *futex)
 {
   (void) atomic_exchange_rel (futex, 0);