1 /*
2 * Copyright (C) 2019 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 #if __has_include(<threads.h>)
30
31 #include <threads.h>
32
33 #include "header_checks.h"
34
35 thread_local int t;
36
threads_h()37 static void threads_h() {
38 MACRO(ONCE_FLAG_INIT);
39 MACRO(TSS_DTOR_ITERATIONS);
40
41 TYPE(cnd_t);
42 TYPE(thrd_t);
43 TYPE(tss_t);
44 TYPE(mtx_t);
45
46 TYPE(tss_dtor_t);
47 TYPE(thrd_start_t);
48
49 TYPE(once_flag);
50
51 int enumeration_constants = mtx_plain | mtx_recursive | mtx_timed |
52 thrd_timedout | thrd_success | thrd_busy | thrd_error | thrd_nomem;
53
54 FUNCTION(call_once, void (*f)(once_flag*, void (*)(void)));
55
56 FUNCTION(cnd_broadcast, int (*f)(cnd_t*));
57 FUNCTION(cnd_destroy, void (*f)(cnd_t*));
58 FUNCTION(cnd_init, int (*f)(cnd_t*));
59 FUNCTION(cnd_signal, int (*f)(cnd_t*));
60 FUNCTION(cnd_timedwait, int (*f)(cnd_t*, mtx_t*, const struct timespec*));
61 FUNCTION(cnd_wait, int (*f)(cnd_t*, mtx_t*));
62
63 FUNCTION(mtx_destroy, void (*f)(mtx_t*));
64 FUNCTION(mtx_init, int (*f)(mtx_t*, int));
65 FUNCTION(mtx_lock, int (*f)(mtx_t*));
66 FUNCTION(mtx_timedlock, int (*f)(mtx_t*, const struct timespec*));
67 FUNCTION(mtx_trylock, int (*f)(mtx_t*));
68 FUNCTION(mtx_unlock, int (*f)(mtx_t*));
69
70 FUNCTION(thrd_create, int (*f)(thrd_t*, thrd_start_t, void*));
71 FUNCTION(thrd_current, thrd_t (*f)(void));
72 FUNCTION(thrd_detach, int (*f)(thrd_t));
73 FUNCTION(thrd_equal, int (*f)(thrd_t, thrd_t));
74 FUNCTION(thrd_exit, void (*f)(int));
75 FUNCTION(thrd_join, int (*f)(thrd_t, int*));
76 FUNCTION(thrd_sleep, int (*f)(const struct timespec*, struct timespec*));
77 FUNCTION(thrd_yield, void (*f)(void));
78
79 FUNCTION(tss_create, int (*f)(tss_t*, tss_dtor_t));
80 FUNCTION(tss_delete, void (*f)(tss_t));
81 FUNCTION(tss_get, void* (*f)(tss_t));
82 FUNCTION(tss_set, int (*f)(tss_t, void*));
83 }
84
85 #define DO_NOT_INCLUDE_TIME_H
86 #include "time_h.c"
87
88 #endif
89