1 /* Declarations of internal pthread functions used by libc. Hurd version.
2 Copyright (C) 2016-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/>. */
24 /* Attribute to indicate thread creation was issued from C11 thrd_create. */
25 #define ATTR_C11_THREAD ((void*)(uintptr_t)-1)
27 /* These represent the interface used by glibc itself. */
29 extern pthread_t
__pthread_self (void);
30 extern int __pthread_kill (pthread_t threadid
, int signo
);
31 extern struct __pthread
**__pthread_threads
;
33 extern int __pthread_mutex_init (pthread_mutex_t
*__mutex
, const pthread_mutexattr_t
*__attr
);
34 extern int __pthread_mutex_destroy (pthread_mutex_t
*__mutex
);
35 extern int __pthread_mutex_lock (pthread_mutex_t
*__mutex
);
36 extern int __pthread_mutex_trylock (pthread_mutex_t
*_mutex
);
37 extern int __pthread_mutex_timedlock (pthread_mutex_t
*__mutex
,
38 const struct timespec
*__abstime
);
39 extern int __pthread_mutex_unlock (pthread_mutex_t
*__mutex
);
40 extern int __pthread_mutexattr_init (pthread_mutexattr_t
*attr
);
41 extern int __pthread_mutexattr_settype (pthread_mutexattr_t
*attr
, int kind
);
43 extern int __pthread_cond_init (pthread_cond_t
*cond
,
44 const pthread_condattr_t
*cond_attr
);
45 extern int __pthread_cond_signal (pthread_cond_t
*cond
);
46 extern int __pthread_cond_broadcast (pthread_cond_t
*cond
);
47 extern int __pthread_cond_wait (pthread_cond_t
*cond
, pthread_mutex_t
*mutex
);
48 extern int __pthread_cond_timedwait (pthread_cond_t
*cond
,
49 pthread_mutex_t
*mutex
,
50 const struct timespec
*abstime
);
51 extern int __pthread_cond_destroy (pthread_cond_t
*cond
);
53 typedef struct __cthread
*__cthread_t
;
54 typedef int __cthread_key_t
;
55 typedef void * (*__cthread_fn_t
)(void *__arg
);
57 __cthread_t
__cthread_fork (__cthread_fn_t
, void *);
58 int __pthread_create (pthread_t
*newthread
,
59 const pthread_attr_t
*attr
,
60 void *(*start_routine
) (void *), void *arg
);
62 void __cthread_detach (__cthread_t
);
63 int __pthread_detach (pthread_t __threadp
);
64 void __pthread_exit (void *value
) __attribute__ ((__noreturn__
));
65 int __pthread_join (pthread_t
, void **);
66 int __cthread_keycreate (__cthread_key_t
*);
67 int __cthread_getspecific (__cthread_key_t
, void **);
68 int __cthread_setspecific (__cthread_key_t
, void *);
69 int __pthread_key_create (pthread_key_t
*key
, void (*destr
) (void *));
70 void *__pthread_getspecific (pthread_key_t key
);
71 int __pthread_setspecific (pthread_key_t key
, const void *value
);
72 int __pthread_key_delete (pthread_key_t key
);
73 int __pthread_once (pthread_once_t
*once_control
, void (*init_routine
) (void));
75 int __pthread_setcancelstate (int state
, int *oldstate
);
77 int __pthread_getattr_np (pthread_t
, pthread_attr_t
*);
78 int __pthread_attr_getstackaddr (const pthread_attr_t
*__restrict __attr
,
79 void **__restrict __stackaddr
);
80 int __pthread_attr_setstackaddr (pthread_attr_t
*__attr
, void *__stackaddr
);
81 int __pthread_attr_getstacksize (const pthread_attr_t
*__restrict __attr
,
82 size_t *__restrict __stacksize
);
83 int __pthread_attr_setstacksize (pthread_attr_t
*__attr
, size_t __stacksize
);
84 int __pthread_attr_setstack (pthread_attr_t
*__attr
, void *__stackaddr
,
86 int __pthread_attr_getstack (const pthread_attr_t
*, void **, size_t *);
87 struct __pthread_cancelation_handler
**___pthread_get_cleanup_stack (void) attribute_hidden
;
89 #if IS_IN (libpthread)
90 hidden_proto (__pthread_key_create
)
91 hidden_proto (__pthread_getspecific
)
92 hidden_proto (__pthread_setspecific
)
93 hidden_proto (__pthread_mutex_init
)
94 hidden_proto (__pthread_mutex_destroy
)
95 hidden_proto (__pthread_mutex_timedlock
)
98 #define ASSERT_TYPE_SIZE(type, size) \
99 _Static_assert (sizeof (type) == size, \
100 "sizeof (" #type ") != " #size)
102 #endif /* pthreadP.h */