/
pthread_h.c
164 lines (149 loc) · 6.79 KB
/
pthread_h.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
* Copyright (c) 2022 Meta
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "_common.h"
#ifdef CONFIG_POSIX_API
#include <pthread.h>
#else
#include <zephyr/posix/pthread.h>
#endif
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
/**
* @brief existence test for `<pthread.h>`
*
* @see <a href="https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/pthread.h.html">pthread.h</a>
*/
ZTEST(posix_headers, test_pthread_h)
{
zassert_not_equal(-1, PTHREAD_BARRIER_SERIAL_THREAD);
zassert_not_equal(-1, PTHREAD_CANCEL_ASYNCHRONOUS);
zassert_not_equal(-1, PTHREAD_CANCEL_DEFERRED);
zassert_not_equal(-1, PTHREAD_CANCEL_ENABLE);
zassert_not_equal(-1, PTHREAD_CANCEL_DISABLE);
zassert_not_equal((void *)-42, PTHREAD_CANCELED);
zassert_not_equal(-1, PTHREAD_CREATE_DETACHED);
zassert_not_equal(-1, PTHREAD_CREATE_JOINABLE);
/* zassert_not_equal(-1, PTHREAD_EXPLICIT_SCHED); */ /* not implemented */
/* zassert_not_equal(-1, PTHREAD_INHERIT_SCHED); */ /* not implemented */
zassert_not_equal(-1, PTHREAD_MUTEX_DEFAULT);
zassert_not_equal(-1, PTHREAD_MUTEX_ERRORCHECK);
zassert_not_equal(-1, PTHREAD_MUTEX_ERRORCHECK);
zassert_not_equal(-1, PTHREAD_MUTEX_RECURSIVE);
/* zassert_not_equal(-1, PTHREAD_MUTEX_ROBUST); */ /* not implemented */
/* zassert_not_equal(-1, PTHREAD_MUTEX_STALLED); */ /* not implemented */
pthread_once_t once = PTHREAD_ONCE_INIT;
/* zassert_not_equal(-1, PTHREAD_PRIO_INHERIT); */ /* not implemented */
zassert_not_equal(-1, PTHREAD_PRIO_NONE);
/* zassert_not_equal(-1, PTHREAD_PRIO_PROTECT); */ /* not implemented */
zassert_not_equal(-1, PTHREAD_PROCESS_SHARED);
zassert_not_equal(-1, PTHREAD_PROCESS_PRIVATE);
zassert_not_equal(-1, PTHREAD_SCOPE_PROCESS);
zassert_not_equal(-1, PTHREAD_SCOPE_SYSTEM);
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
pthread_mutex_t mu = PTHREAD_MUTEX_INITIALIZER;
/* pthread_rwlock_t lock = PTHREAD_RWLOCK_INITIALIZER; */ /* not implemented */
if (IS_ENABLED(CONFIG_POSIX_API)) {
zassert_not_null(pthread_atfork);
zassert_not_null(pthread_attr_destroy);
zassert_not_null(pthread_attr_getdetachstate);
zassert_not_null(pthread_attr_getguardsize);
/* zassert_not_null(pthread_attr_getinheritsched); */ /* not implemented */
zassert_not_null(pthread_attr_getschedparam);
zassert_not_null(pthread_attr_getschedpolicy);
zassert_not_null(pthread_attr_getscope);
zassert_not_null(pthread_attr_getstack);
zassert_not_null(pthread_attr_getstacksize);
zassert_not_null(pthread_attr_init);
zassert_not_null(pthread_attr_setdetachstate);
zassert_not_null(pthread_attr_setguardsize);
/* zassert_not_null(pthread_attr_setinheritsched); */ /* not implemented */
zassert_not_null(pthread_attr_setschedparam);
zassert_not_null(pthread_attr_setschedpolicy);
zassert_not_null(pthread_attr_setscope);
zassert_not_null(pthread_attr_setstack);
zassert_not_null(pthread_attr_setstacksize);
zassert_not_null(pthread_barrier_destroy);
zassert_not_null(pthread_barrier_init);
zassert_not_null(pthread_barrier_wait);
zassert_not_null(pthread_barrierattr_destroy);
/* zassert_not_null(pthread_barrierattr_getpshared); */ /* not implemented */
zassert_not_null(pthread_barrierattr_init);
/* zassert_not_null(pthread_barrierattr_setpshared); */ /* not implemented */
zassert_not_null(pthread_cancel);
zassert_not_null(pthread_cond_broadcast);
zassert_not_null(pthread_cond_destroy);
zassert_not_null(pthread_cond_init);
zassert_not_null(pthread_cond_signal);
zassert_not_null(pthread_cond_timedwait);
zassert_not_null(pthread_cond_wait);
zassert_not_null(pthread_condattr_destroy);
zassert_not_null(pthread_condattr_getclock);
/* zassert_not_null(pthread_condattr_getpshared); */ /* not implemented */
zassert_not_null(pthread_condattr_init);
zassert_not_null(pthread_condattr_setclock);
/* zassert_not_null(pthread_condattr_setpshared); */ /* not implemented */
zassert_not_null(pthread_create);
zassert_not_null(pthread_detach);
zassert_not_null(pthread_equal);
zassert_not_null(pthread_exit);
zassert_not_null(pthread_getconcurrency);
/* zassert_not_null(pthread_getcpuclockid); */ /* not implemented */
zassert_not_null(pthread_getschedparam);
zassert_not_null(pthread_getspecific);
zassert_not_null(pthread_join);
zassert_not_null(pthread_key_create);
zassert_not_null(pthread_key_delete);
/* zassert_not_null(pthread_mutex_consistent); */ /* not implemented */
zassert_not_null(pthread_mutex_destroy);
/* zassert_not_null(pthread_mutex_getprioceiling); */ /* not implemented */
zassert_not_null(pthread_mutex_init);
zassert_not_null(pthread_mutex_lock);
/* zassert_not_null(pthread_mutex_setprioceiling); */ /* not implemented */
zassert_not_null(pthread_mutex_timedlock);
zassert_not_null(pthread_mutex_trylock);
zassert_not_null(pthread_mutex_unlock);
zassert_not_null(pthread_mutexattr_destroy);
/* zassert_not_null(pthread_mutexattr_getprioceiling); */ /* not implemented */
zassert_not_null(pthread_mutexattr_getprotocol);
/* zassert_not_null(pthread_mutexattr_getpshared); */ /* not implemented */
/* zassert_not_null(pthread_mutexattr_getrobust); */ /* not implemented */
zassert_not_null(pthread_mutexattr_gettype);
zassert_not_null(pthread_mutexattr_init);
/* zassert_not_null(pthread_mutexattr_setprioceiling); */ /* not implemented */
/* zassert_not_null(pthread_mutexattr_setprotocol); */ /* not implemented */
/* zassert_not_null(pthread_mutexattr_setpshared); */ /* not implemented */
/* zassert_not_null(pthread_mutexattr_setrobust); */ /* not implemented */
zassert_not_null(pthread_mutexattr_settype);
zassert_not_null(pthread_once);
zassert_not_null(pthread_rwlock_destroy);
zassert_not_null(pthread_rwlock_init);
zassert_not_null(pthread_rwlock_rdlock);
zassert_not_null(pthread_rwlock_timedrdlock);
zassert_not_null(pthread_rwlock_timedwrlock);
zassert_not_null(pthread_rwlock_tryrdlock);
zassert_not_null(pthread_rwlock_trywrlock);
zassert_not_null(pthread_rwlock_unlock);
zassert_not_null(pthread_rwlock_wrlock);
zassert_not_null(pthread_rwlockattr_destroy);
/* zassert_not_null(pthread_rwlockattr_getpshared); */ /* not implemented */
zassert_not_null(pthread_rwlockattr_init);
/* zassert_not_null(pthread_rwlockattr_setpshared); */ /* not implemented */
zassert_not_null(pthread_self);
zassert_not_null(pthread_setcancelstate);
zassert_not_null(pthread_setcanceltype);
zassert_not_null(pthread_setconcurrency);
zassert_not_null(pthread_setschedparam);
/* zassert_not_null(pthread_setschedprio); */ /* not implemented */
zassert_not_null(pthread_setspecific);
zassert_not_null(pthread_spin_destroy);
zassert_not_null(pthread_spin_init);
zassert_not_null(pthread_spin_lock);
zassert_not_null(pthread_spin_trylock);
zassert_not_null(pthread_spin_unlock);
zassert_not_null(pthread_testcancel);
}
}
#pragma GCC diagnostic pop