1 /* Definitions of user-visible names for spin locks.
2 Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
19 #ifndef _BITS_SPIN_LOCK_INLINE_H
20 #define _BITS_SPIN_LOCK_INLINE_H 1
23 #include <bits/types/__pthread_spinlock_t.h>
24 #include <lock-intern.h> /* This does all the work. */
28 #if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES
32 # define __EBUSY EBUSY
35 # ifndef __PT_SPIN_INLINE
36 # define __PT_SPIN_INLINE __extern_inline
39 __PT_SPIN_INLINE
int __pthread_spin_destroy (__pthread_spinlock_t
*__lock
);
42 __pthread_spin_destroy (__pthread_spinlock_t
*__lock
)
47 __PT_SPIN_INLINE
int __pthread_spin_init (__pthread_spinlock_t
*__lock
,
51 __pthread_spin_init (__pthread_spinlock_t
*__lock
, int __pshared
)
53 *__lock
= __PTHREAD_SPIN_LOCK_INITIALIZER
;
57 __PT_SPIN_INLINE
int __pthread_spin_trylock (__pthread_spinlock_t
*__lock
);
60 __pthread_spin_trylock (__pthread_spinlock_t
*__lock
)
62 return __spin_try_lock ((__spin_lock_t
*) __lock
) ? 0 : __EBUSY
;
65 __PT_SPIN_INLINE
int __pthread_spin_lock (__pthread_spinlock_t
*__lock
);
68 __pthread_spin_lock (__pthread_spinlock_t
*__lock
)
70 __spin_lock ((__spin_lock_t
*) __lock
);
74 __PT_SPIN_INLINE
int __pthread_spin_unlock (__pthread_spinlock_t
*__lock
);
77 __pthread_spin_unlock (__pthread_spinlock_t
*__lock
)
79 __spin_unlock ((__spin_lock_t
*) __lock
);
83 #endif /* Use extern inlines or force inlines. */
87 #endif /* bits/types/__pthread_spinlock_t.h */