This is the mail archive of the
libc-ports@sources.redhat.com
mailing list for the libc-ports project.
Update ARM NPTL port - robust mutexes etc
- From: Daniel Jacobowitz <drow at false dot org>
- To: libc-ports at sourceware dot org
- Cc: Glauber de Oliveira Costa <glommer at gmail dot com>, Ladislav Michl <ladis at linux-mips dot org>
- Date: Mon, 27 Feb 2006 10:37:43 -0500
- Subject: Update ARM NPTL port - robust mutexes etc
This brings ARM up to date with changes to these headers in other
ports. Apologies to the folks who've sent similar patches when I
didn't have time to test them.
With the aio_misc.h fix I just posted ARM builds again. Test results
are good although there's been some slippage, to be investigated.
--
Daniel Jacobowitz
CodeSourcery
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.
Index: glibc/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes.h
===================================================================
--- glibc.orig/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes.h 2006-02-26 12:59:51.000000000 -0500
+++ glibc/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes.h 2006-02-26 12:59:54.000000000 -0500
@@ -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: glibc/ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h
===================================================================
--- glibc.orig/ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h 2005-12-22 12:20:32.000000000 -0500
+++ glibc/ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h 2006-02-26 14:25:17.000000000 -0500
@@ -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
@@ -62,6 +62,15 @@
__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
__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);