summaryrefslogtreecommitdiff
path: root/sysdeps/mach
diff options
context:
space:
mode:
authorAgustina Arzille <avarzille@riseup.net>2016-10-18 00:20:45 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2017-11-05 18:46:00 +0100
commit8f03a364f803ad878ea3ab226fd2955ed4565495 (patch)
treeda17acc70dae2d60327044fec8463298d1a6aa4e /sysdeps/mach
parentb279c3618db5740e155c110e8dca395132b53ecd (diff)
Make pthread_spinlock use gsync
* pthread/pt-spin-inlines.c (pthread_spin_lock): Define weak alias for __pthread_spin_lock. * sysdeps/mach/bits/spin-lock-inline.h: Include <lock-intern.h> instead of <machine-lock.h>. (__pthread_spin_trylock, __pthread_spin_unlock): Use __spin_lock_t type instead of __lock. (__pthread_spin_lock): Define as inline only, use __spin_lock and __spin_lock_t type. * sysdeps/mach/bits/spin-lock.h: Do not include <machine-lock.h> (__pthread_spinlock_t): Use volatile int instead of __spin_lock_t. (__PTHREAD_SPIN_LOCK_INITIALIZER): Define to 0. * sysdeps/mach/i386/bits/spin-lock-inline.h: Remove file. * sysdeps/mach/i386/bits/spin-lock.h: Remove file. * sysdeps/posix/pt-spin.c (pthread_spin_lock, __pthread_spin_lock): Remove weak aliases, provided by pt-spin-inlines.c
Diffstat (limited to 'sysdeps/mach')
-rw-r--r--sysdeps/mach/bits/spin-lock-inline.h14
-rw-r--r--sysdeps/mach/bits/spin-lock.h7
-rw-r--r--sysdeps/mach/i386/bits/spin-lock-inline.h98
-rw-r--r--sysdeps/mach/i386/bits/spin-lock.h39
-rw-r--r--sysdeps/mach/pt-spin.c8
5 files changed, 10 insertions, 156 deletions
diff --git a/sysdeps/mach/bits/spin-lock-inline.h b/sysdeps/mach/bits/spin-lock-inline.h
index f9f7c29..98e4b3b 100644
--- a/sysdeps/mach/bits/spin-lock-inline.h
+++ b/sysdeps/mach/bits/spin-lock-inline.h
@@ -22,7 +22,7 @@
#include <features.h>
#include <bits/spin-lock.h>
-#include <machine-lock.h> /* This does all the work. */
+#include <lock-intern.h> /* This does all the work. */
__BEGIN_DECLS
@@ -60,17 +60,15 @@ __PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock);
__PT_SPIN_INLINE int
__pthread_spin_trylock (__pthread_spinlock_t *__lock)
{
- return __spin_try_lock (__lock) ? 0 : __EBUSY;
+ return __spin_try_lock ((__spin_lock_t *) __lock) ? 0 : __EBUSY;
}
-__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock);
-extern int _pthread_spin_lock (__pthread_spinlock_t *__lock);
+__PT_SPIN_INLINE int __pthread_spin_lock (__pthread_spinlock_t *__lock);
-__extern_inline int
+__PT_SPIN_INLINE int
__pthread_spin_lock (__pthread_spinlock_t *__lock)
{
- if (__pthread_spin_trylock (__lock))
- return _pthread_spin_lock (__lock);
+ __spin_lock ((__spin_lock_t *) __lock);
return 0;
}
@@ -79,7 +77,7 @@ __PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock);
__PT_SPIN_INLINE int
__pthread_spin_unlock (__pthread_spinlock_t *__lock)
{
- __spin_unlock (__lock);
+ __spin_unlock ((__spin_lock_t *) __lock);
return 0;
}
diff --git a/sysdeps/mach/bits/spin-lock.h b/sysdeps/mach/bits/spin-lock.h
index 537dac9..7574b37 100644
--- a/sysdeps/mach/bits/spin-lock.h
+++ b/sysdeps/mach/bits/spin-lock.h
@@ -21,17 +21,14 @@
#define _BITS_SPIN_LOCK_H 1
#include <features.h>
-#include <machine-lock.h> /* This does all the work. */
__BEGIN_DECLS
/* The type of a spin lock object. */
-typedef __spin_lock_t __pthread_spinlock_t;
+typedef volatile int __pthread_spinlock_t;
/* Initializer for a spin lock object. */
-#ifndef __PTHREAD_SPIN_LOCK_INITIALIZER
-#error __PTHREAD_SPIN_LOCK_INITIALIZER undefined: should be defined by <lock-intern.h>.
-#endif
+#define __PTHREAD_SPIN_LOCK_INITIALIZER 0
__END_DECLS
diff --git a/sysdeps/mach/i386/bits/spin-lock-inline.h b/sysdeps/mach/i386/bits/spin-lock-inline.h
deleted file mode 100644
index e5ed3de..0000000
--- a/sysdeps/mach/i386/bits/spin-lock-inline.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Machine-specific definitions for spin locks. i386 version.
- Copyright (C) 2000, 2005, 2008, 2009 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
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-/*
- * Never include this file directly; use <pthread.h> or <cthreads.h> instead.
- */
-
-#ifndef _BITS_SPIN_LOCK_INLINE_H
-#define _BITS_SPIN_LOCK_INLINE_H 1
-
-#include <features.h>
-#include <bits/spin-lock.h>
-
-__BEGIN_DECLS
-
-#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES
-
-# ifndef __EBUSY
-# include <errno.h>
-# define __EBUSY EBUSY
-# endif
-
-# ifndef __PT_SPIN_INLINE
-# define __PT_SPIN_INLINE __extern_inline
-# endif
-
-__PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock);
-
-__PT_SPIN_INLINE int
-__pthread_spin_destroy (__pthread_spinlock_t *__lock)
-{
- return 0;
-}
-
-__PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock,
- int __pshared);
-
-__PT_SPIN_INLINE int
-__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared)
-{
- *__lock = __PTHREAD_SPIN_LOCK_INITIALIZER;
- return 0;
-}
-
-__PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock);
-
-__PT_SPIN_INLINE int
-__pthread_spin_trylock (__pthread_spinlock_t *__lock)
-{
- int __locked;
- __asm__ __volatile ("xchgl %0, %1"
- : "=&r" (__locked), "=m" (*__lock) : "0" (1) : "memory");
- return __locked ? __EBUSY : 0;
-}
-
-__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock);
-extern int _pthread_spin_lock (__pthread_spinlock_t *__lock);
-
-__extern_inline int
-__pthread_spin_lock (__pthread_spinlock_t *__lock)
-{
- if (__pthread_spin_trylock (__lock))
- return _pthread_spin_lock (__lock);
- return 0;
-}
-
-__PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock);
-
-__PT_SPIN_INLINE int
-__pthread_spin_unlock (__pthread_spinlock_t *__lock)
-{
- int __unlocked;
- __asm__ __volatile ("xchgl %0, %1"
- : "=&r" (__unlocked), "=m" (*__lock) : "0" (0) : "memory");
- return 0;
-}
-
-#endif /* Use extern inlines or force inlines. */
-
-__END_DECLS
-
-#endif /* bits/spin-lock.h */
diff --git a/sysdeps/mach/i386/bits/spin-lock.h b/sysdeps/mach/i386/bits/spin-lock.h
deleted file mode 100644
index 5ae81e1..0000000
--- a/sysdeps/mach/i386/bits/spin-lock.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Machine-specific definitions for spin locks. i386 version.
- Copyright (C) 2000, 2005, 2008, 2009 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
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-/*
- * Never include this file directly; use <pthread.h> or <cthreads.h> instead.
- */
-
-#ifndef _BITS_SPIN_LOCK_H
-#define _BITS_SPIN_LOCK_H 1
-
-#include <features.h>
-
-__BEGIN_DECLS
-
-/* The type of a spin lock object. */
-typedef __volatile int __pthread_spinlock_t;
-
-/* Initializer for a spin lock object. */
-# define __PTHREAD_SPIN_LOCK_INITIALIZER ((__pthread_spinlock_t) 0)
-
-__END_DECLS
-
-#endif /* bits/spin-lock.h */
diff --git a/sysdeps/mach/pt-spin.c b/sysdeps/mach/pt-spin.c
index d9a2a32..0cf1c49 100644
--- a/sysdeps/mach/pt-spin.c
+++ b/sysdeps/mach/pt-spin.c
@@ -17,20 +17,16 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <pthread.h>
#include <machine-lock.h>
/* In glibc. */
-extern void __spin_lock_solid (__pthread_spinlock_t *lock);
+extern void __spin_lock_solid (__spin_lock_t *lock);
/* Lock the spin lock object LOCK. If the lock is held by another
thread spin until it becomes available. */
int
-_pthread_spin_lock (__pthread_spinlock_t *lock)
+_pthread_spin_lock (__spin_lock_t *lock)
{
__spin_lock_solid (lock);
return 0;
}
-
-weak_alias (_pthread_spin_lock, pthread_spin_lock);
-weak_alias (_pthread_spin_lock, __pthread_spin_lock);