diff options
Diffstat (limited to 'sysdeps/generic/bits')
-rw-r--r-- | sysdeps/generic/bits/condition.h | 2 | ||||
-rw-r--r-- | sysdeps/generic/bits/mutex.h | 75 | ||||
-rw-r--r-- | sysdeps/generic/bits/pthread.h | 2 | ||||
-rw-r--r-- | sysdeps/generic/bits/rwlock.h | 31 | ||||
-rw-r--r-- | sysdeps/generic/bits/semaphore.h | 43 |
5 files changed, 49 insertions, 104 deletions
diff --git a/sysdeps/generic/bits/condition.h b/sysdeps/generic/bits/condition.h index a194b05d..f3b09be4 100644 --- a/sysdeps/generic/bits/condition.h +++ b/sysdeps/generic/bits/condition.h @@ -1,5 +1,5 @@ /* Condition type. Generic version. - Copyright (C) 2000 Free Software Foundation, Inc. + Copyright (C) 2000, 2005 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 diff --git a/sysdeps/generic/bits/mutex.h b/sysdeps/generic/bits/mutex.h index ecbcff8b..1aaf80ed 100644 --- a/sysdeps/generic/bits/mutex.h +++ b/sysdeps/generic/bits/mutex.h @@ -1,5 +1,5 @@ /* Mutex type. Generic version. - Copyright (C) 2000,02 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2005 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 @@ -52,8 +52,7 @@ struct __pthread_mutex /* Initializer for a mutex. N.B. this also happens to be compatible with the cthread mutex initializer. */ # define __PTHREAD_MUTEX_INITIALIZER \ - { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, NULL, NULL, NULL, \ - NULL, 0, 0 } + { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0, 0 } # endif #endif /* Not __pthread_mutex_defined. */ @@ -63,76 +62,6 @@ struct __pthread_mutex #include <errno.h> #include <stddef.h> -#ifdef __USE_EXTERN_INLINES - -# ifndef _EXTERN_INLINE -# define _EXTERN_INLINE extern __inline -# endif - -_EXTERN_INLINE int -pthread_mutex_init (struct __pthread_mutex *__mutex, - const pthread_mutexattr_t *attr) -{ - extern int _pthread_mutex_init (struct __pthread_mutex *, - const pthread_mutexattr_t *); - - if (attr) - return _pthread_mutex_init (__mutex, attr); - - *__mutex = (struct __pthread_mutex) __PTHREAD_MUTEX_INITIALIZER; - return 0; -} - -_EXTERN_INLINE int -pthread_mutex_destroy (struct __pthread_mutex *__mutex) -{ - extern int _pthread_mutex_destroy (struct __pthread_mutex *); - - if (__mutex->attr || __mutex->data) - return _pthread_mutex_destroy (__mutex); - - return 0; -} - -_EXTERN_INLINE int -__pthread_mutex_lock (struct __pthread_mutex *__mutex) -{ - extern int _pthread_mutex_lock (struct __pthread_mutex *); - - if (__mutex->attr == NULL - && __mutex->data == NULL - && __pthread_spin_trylock (&__mutex->__held) == 0) - return 0; - - return _pthread_mutex_lock (__mutex); -} - -extern inline int -__pthread_mutex_trylock (struct __pthread_mutex *__mutex) -{ - extern int _pthread_mutex_trylock (struct __pthread_mutex *); - - if (__mutex->attr == NULL - && __mutex->data == NULL) - return __pthread_spin_trylock (&__mutex->__held); - - return _pthread_mutex_trylock (__mutex); -} - -extern inline int -pthread_mutex_lock (struct __pthread_mutex *__mutex) -{ - return __pthread_mutex_lock (__mutex); -} - -extern inline int -pthread_mutex_trylock (struct __pthread_mutex *__mutex) -{ - return __pthread_mutex_trylock (__mutex); -} - -#endif /* Use extern inlines. */ - #endif #endif /* bits/mutex.h */ diff --git a/sysdeps/generic/bits/pthread.h b/sysdeps/generic/bits/pthread.h index 740325d0..3f9df13d 100644 --- a/sysdeps/generic/bits/pthread.h +++ b/sysdeps/generic/bits/pthread.h @@ -24,7 +24,7 @@ typedef int pthread_t; /* Return true if __T1 and __T2 both name the same thread. Otherwise, false. */ -extern inline int +extern __inline int pthread_equal (pthread_t __t1, pthread_t __t2) { return __t1 == __t2; diff --git a/sysdeps/generic/bits/rwlock.h b/sysdeps/generic/bits/rwlock.h index d089b0c6..696f9c25 100644 --- a/sysdeps/generic/bits/rwlock.h +++ b/sysdeps/generic/bits/rwlock.h @@ -1,5 +1,5 @@ /* rwlock type. Generic version. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2005 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 @@ -40,34 +40,7 @@ struct __pthread_rwlock /* Initializer for a rwlock. */ #define __PTHREAD_RWLOCK_INITIALIZER \ - ((struct __pthread_rwlock) \ - { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0 }) + { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0 } -_EXTERN_INLINE int -pthread_rwlock_init (struct __pthread_rwlock *__rwlock, - const struct __pthread_rwlockattr *__attr) -{ - extern int _pthread_rwlock_init (struct __pthread_rwlock *, - const struct __pthread_rwlockattr *); - - if (__attr) - return _pthread_rwlock_init (__rwlock, __attr); - - *__rwlock = __PTHREAD_RWLOCK_INITIALIZER; - return 0; -} - -_EXTERN_INLINE int -pthread_rwlock_destroy (struct __pthread_rwlock *__rwlock) -{ - extern int _pthread_rwlock_destroy (struct __pthread_rwlock *); - - if (__rwlock->__attr - || __rwlock->__data) - return _pthread_rwlock_destroy (__rwlock); - - return 0; -} - #endif /* bits/rwlock.h */ diff --git a/sysdeps/generic/bits/semaphore.h b/sysdeps/generic/bits/semaphore.h new file mode 100644 index 00000000..b53f47e3 --- /dev/null +++ b/sysdeps/generic/bits/semaphore.h @@ -0,0 +1,43 @@ +/* Semaphore type. Generic version. + Copyright (C) 2005 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. */ + +#ifndef _BITS_SEMAPHORE_H +#define _BITS_SEMAPHORE_H 1 + +#ifndef _SEMAPHORE_H +#error Never include <bits/semaphore.h> directly. +#endif + +#include <pthread.h> + +/* User visible part of a semaphore. */ +struct __semaphore + { + __pthread_spinlock_t __lock; + struct __pthread *__queue; + int __pshared; + int __value; + void *__data; + }; + +/* Initializer for a semaphore. */ +#define __SEMAPHORE_INITIALIZER(pshared, value) \ + { __SPIN_LOCK_INITIALIZER, NULL, (pshared), (value), NULL } + +#endif /* bits/mutex.h */ |