Warning: That file was not part of the compilation database. It may have many parsing errors.

1/* Private libc-internal interface for mutex locks.
2 Copyright (C) 2015-2019 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 License as
7 published by the Free Software Foundation; either version 2.1 of the
8 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; see the file COPYING.LIB. If
17 not, see <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_LIBC_LOCKP_H
20#define _BITS_LIBC_LOCKP_H 1
21
22#include <pthread.h>
23#include <pthread-functions.h>
24
25/* Type for key to thread-specific data. */
26typedef pthread_key_t __libc_key_t;
27
28/* If we check for a weakly referenced symbol and then perform a
29 normal jump to it te code generated for some platforms in case of
30 PIC is unnecessarily slow. What would happen is that the function
31 is first referenced as data and then it is called indirectly
32 through the PLT. We can make this a direct jump. */
33#ifdef __PIC__
34# define __libc_maybe_call(FUNC, ARGS, ELSE) \
35 (__extension__ ({ __typeof (FUNC) *_fn = (FUNC); \
36 _fn != NULL ? (*_fn) ARGS : ELSE; }))
37#else
38# define __libc_maybe_call(FUNC, ARGS, ELSE) \
39 (FUNC != NULL ? FUNC ARGS : ELSE)
40#endif
41
42/* Call thread functions through the function pointer table. */
43#if defined SHARED && IS_IN (libc)
44# define PTFAVAIL(NAME) __libc_pthread_functions_init
45# define __libc_ptf_call(FUNC, ARGS, ELSE) \
46 (__libc_pthread_functions_init ? PTHFCT_CALL (ptr_##FUNC, ARGS) : ELSE)
47# define __libc_ptf_call_always(FUNC, ARGS) \
48 PTHFCT_CALL (ptr_##FUNC, ARGS)
49#elif IS_IN (libpthread)
50# define PTFAVAIL(NAME) 1
51# define __libc_ptf_call(FUNC, ARGS, ELSE) \
52 FUNC ARGS
53# define __libc_ptf_call_always(FUNC, ARGS) \
54 FUNC ARGS
55#else
56# define PTFAVAIL(NAME) (NAME != NULL)
57# define __libc_ptf_call(FUNC, ARGS, ELSE) \
58 __libc_maybe_call (FUNC, ARGS, ELSE)
59# define __libc_ptf_call_always(FUNC, ARGS) \
60 FUNC ARGS
61#endif
62
63/* Create thread-specific key. */
64#define __libc_key_create(KEY, DESTRUCTOR) \
65 __libc_ptf_call (__pthread_key_create, (KEY, DESTRUCTOR), 1)
66
67/* Get thread-specific data. */
68#define __libc_getspecific(KEY) \
69 __libc_ptf_call (__pthread_getspecific, (KEY), NULL)
70
71/* Set thread-specific data. */
72#define __libc_setspecific(KEY, VALUE) \
73 __libc_ptf_call (__pthread_setspecific, (KEY, VALUE), 0)
74
75
76/* Functions that are used by this file and are internal to the GNU C
77 library. */
78
79extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
80 const pthread_mutexattr_t *__mutex_attr);
81
82extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
83
84extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex);
85
86extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
87
88extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
89
90extern int __pthread_mutexattr_init (pthread_mutexattr_t *__attr);
91
92extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *__attr);
93
94extern int __pthread_mutexattr_settype (pthread_mutexattr_t *__attr,
95 int __kind);
96
97extern int __pthread_rwlock_init (pthread_rwlock_t *__rwlock,
98 const pthread_rwlockattr_t *__attr);
99
100extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
101
102extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock);
103
104extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock);
105
106extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock);
107
108extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
109
110extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
111
112extern int __pthread_key_create (pthread_key_t *__key,
113 void (*__destr_function) (void *));
114
115extern int __pthread_setspecific (pthread_key_t __key,
116 const void *__pointer);
117
118extern void *__pthread_getspecific (pthread_key_t __key);
119
120extern int __pthread_once (pthread_once_t *__once_control,
121 void (*__init_routine) (void));
122
123extern int __pthread_atfork (void (*__prepare) (void),
124 void (*__parent) (void),
125 void (*__child) (void));
126
127
128
129/* Make the pthread functions weak so that we can elide them from
130 single-threaded processes. */
131#if !defined(__NO_WEAK_PTHREAD_ALIASES) && !IS_IN (libpthread)
132# ifdef weak_extern
133weak_extern (__pthread_mutex_init)
134weak_extern (__pthread_mutex_destroy)
135weak_extern (__pthread_mutex_lock)
136weak_extern (__pthread_mutex_trylock)
137weak_extern (__pthread_mutex_unlock)
138weak_extern (__pthread_mutexattr_init)
139weak_extern (__pthread_mutexattr_destroy)
140weak_extern (__pthread_mutexattr_settype)
141weak_extern (__pthread_rwlock_init)
142weak_extern (__pthread_rwlock_destroy)
143weak_extern (__pthread_rwlock_rdlock)
144weak_extern (__pthread_rwlock_tryrdlock)
145weak_extern (__pthread_rwlock_wrlock)
146weak_extern (__pthread_rwlock_trywrlock)
147weak_extern (__pthread_rwlock_unlock)
148weak_extern (__pthread_key_create)
149weak_extern (__pthread_setspecific)
150weak_extern (__pthread_getspecific)
151weak_extern (__pthread_once)
152weak_extern (__pthread_initialize)
153weak_extern (__pthread_atfork)
154weak_extern (__pthread_setcancelstate)
155# else
156# pragma weak __pthread_mutex_init
157# pragma weak __pthread_mutex_destroy
158# pragma weak __pthread_mutex_lock
159# pragma weak __pthread_mutex_trylock
160# pragma weak __pthread_mutex_unlock
161# pragma weak __pthread_mutexattr_init
162# pragma weak __pthread_mutexattr_destroy
163# pragma weak __pthread_mutexattr_settype
164# pragma weak __pthread_rwlock_destroy
165# pragma weak __pthread_rwlock_rdlock
166# pragma weak __pthread_rwlock_tryrdlock
167# pragma weak __pthread_rwlock_wrlock
168# pragma weak __pthread_rwlock_trywrlock
169# pragma weak __pthread_rwlock_unlock
170# pragma weak __pthread_key_create
171# pragma weak __pthread_setspecific
172# pragma weak __pthread_getspecific
173# pragma weak __pthread_once
174# pragma weak __pthread_initialize
175# pragma weak __pthread_atfork
176# pragma weak __pthread_setcancelstate
177# endif
178#endif
179
180#endif /* bits/libc-lockP.h */
181

Warning: That file was not part of the compilation database. It may have many parsing errors.