1 /* Definitions of user-visible names for spin locks. 2 Copyright (C) 1994-2022 Free Software Foundation, Inc. 3 This file is part of the GNU C Library. 4 5 The GNU C Library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 The GNU C Library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with the GNU C Library; if not, see 17 <https://www.gnu.org/licenses/>. */ 18 19 #ifndef _BITS_SPIN_LOCK_INLINE_H 20 #define _BITS_SPIN_LOCK_INLINE_H 1 21 22 #include <features.h> 23 #include <bits/types/__pthread_spinlock_t.h> 24 #include <lock-intern.h> /* This does all the work. */ 25 26 __BEGIN_DECLS 27 28 #if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES 29 30 # ifndef __EBUSY 31 # include <errno.h> 32 # define __EBUSY EBUSY 33 # endif 34 35 # ifndef __PT_SPIN_INLINE 36 # define __PT_SPIN_INLINE __extern_inline 37 # endif 38 39 __PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock); 40 41 __PT_SPIN_INLINE int __pthread_spin_destroy(__pthread_spinlock_t * __lock)42__pthread_spin_destroy (__pthread_spinlock_t *__lock) 43 { 44 return 0; 45 } 46 47 __PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock, 48 int __pshared); 49 50 __PT_SPIN_INLINE int __pthread_spin_init(__pthread_spinlock_t * __lock,int __pshared)51__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared) 52 { 53 *__lock = __PTHREAD_SPIN_LOCK_INITIALIZER; 54 return 0; 55 } 56 57 __PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock); 58 59 __PT_SPIN_INLINE int __pthread_spin_trylock(__pthread_spinlock_t * __lock)60__pthread_spin_trylock (__pthread_spinlock_t *__lock) 61 { 62 return __spin_try_lock ((__spin_lock_t *) __lock) ? 0 : __EBUSY; 63 } 64 65 __PT_SPIN_INLINE int __pthread_spin_lock (__pthread_spinlock_t *__lock); 66 67 __PT_SPIN_INLINE int __pthread_spin_lock(__pthread_spinlock_t * __lock)68__pthread_spin_lock (__pthread_spinlock_t *__lock) 69 { 70 __spin_lock_solid ((__spin_lock_t *) __lock); 71 return 0; 72 } 73 74 __PT_SPIN_INLINE int __pthread_spin_wait (__pthread_spinlock_t *__lock); 75 76 __PT_SPIN_INLINE int __pthread_spin_wait(__pthread_spinlock_t * __lock)77__pthread_spin_wait (__pthread_spinlock_t *__lock) 78 { 79 __spin_lock ((__spin_lock_t *) __lock); 80 return 0; 81 } 82 83 __PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock); 84 85 __PT_SPIN_INLINE int __pthread_spin_unlock(__pthread_spinlock_t * __lock)86__pthread_spin_unlock (__pthread_spinlock_t *__lock) 87 { 88 __spin_unlock ((__spin_lock_t *) __lock); 89 return 0; 90 } 91 92 #endif /* Use extern inlines or force inlines. */ 93 94 __END_DECLS 95 96 #endif /* bits/types/__pthread_spinlock_t.h */ 97