Xenomai  3.0.8
pthread.h
1 /*
2  * Copyright (C) 2005 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18 #pragma GCC system_header
19 #include_next <pthread.h>
20 
21 #ifndef _COBALT_PTHREAD_H
22 #define _COBALT_PTHREAD_H
23 
24 #include <boilerplate/libc.h>
25 #include <cobalt/wrappers.h>
26 #include <cobalt/uapi/thread.h>
27 
28 typedef struct pthread_attr_ex {
29  pthread_attr_t std;
30  struct {
31  int personality;
32  int sched_policy;
33  struct sched_param_ex sched_param;
34  } nonstd;
35 } pthread_attr_ex_t;
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 COBALT_DECL(int, pthread_attr_init(pthread_attr_t *attr));
42 
43 COBALT_DECL(int, pthread_create(pthread_t *ptid_r,
44  const pthread_attr_t *attr,
45  void *(*start) (void *),
46  void *arg));
47 
48 COBALT_DECL(int, pthread_getschedparam(pthread_t thread,
49  int *policy,
50  struct sched_param *param));
51 
52 COBALT_DECL(int, pthread_setschedparam(pthread_t thread,
53  int policy,
54  const struct sched_param *param));
55 
56 COBALT_DECL(int, pthread_mutex_init(pthread_mutex_t *mutex,
57  const pthread_mutexattr_t *attr));
58 
59 COBALT_DECL(int, pthread_mutex_destroy(pthread_mutex_t *mutex));
60 
61 COBALT_DECL(int, pthread_mutex_lock(pthread_mutex_t *mutex));
62 
63 COBALT_DECL(int, pthread_mutex_timedlock(pthread_mutex_t *mutex,
64  const struct timespec *to));
65 
66 COBALT_DECL(int, pthread_mutex_trylock(pthread_mutex_t *mutex));
67 
68 COBALT_DECL(int, pthread_mutex_unlock(pthread_mutex_t *mutex));
69 
70 COBALT_DECL(int, pthread_cond_init (pthread_cond_t *cond,
71  const pthread_condattr_t *attr));
72 
73 COBALT_DECL(int, pthread_cond_destroy(pthread_cond_t *cond));
74 
75 COBALT_DECL(int, pthread_cond_wait(pthread_cond_t *cond,
76  pthread_mutex_t *mutex));
77 
78 COBALT_DECL(int, pthread_cond_timedwait(pthread_cond_t *cond,
79  pthread_mutex_t *mutex,
80  const struct timespec *abstime));
81 
82 COBALT_DECL(int, pthread_cond_signal(pthread_cond_t *cond));
83 
84 COBALT_DECL(int, pthread_cond_broadcast(pthread_cond_t *cond));
85 
86 COBALT_DECL(int, pthread_kill(pthread_t ptid, int sig));
87 
88 COBALT_DECL(int, pthread_join(pthread_t ptid, void **retval));
89 
90 #ifndef pthread_yield
91 /*
92  * linuxthreads wraps pthread_yield() to sched_yield() via a
93  * preprocessor macro, which confuses the compiler with
94  * COBALT_DECL(). Since Cobalt also routes pthread_yield() to its own
95  * sched_yield() implementation internally, we can live with this
96  * wrapping.
97  */
98 COBALT_DECL(int, pthread_yield(void));
99 #endif
100 
101 int pthread_setmode_np(int clrmask, int setmask,
102  int *mask_r);
103 
104 COBALT_DECL(int, pthread_setname_np(pthread_t thread, const char *name));
105 
106 int pthread_create_ex(pthread_t *ptid_r,
107  const pthread_attr_ex_t *attr_ex,
108  void *(*start)(void *),
109  void *arg);
110 
111 int pthread_getschedparam_ex(pthread_t ptid,
112  int *pol,
113  struct sched_param_ex *par);
114 
115 int pthread_setschedparam_ex(pthread_t ptid,
116  int pol,
117  const struct sched_param_ex *par);
118 
119 int pthread_attr_init_ex(pthread_attr_ex_t *attr_ex);
120 
121 int pthread_attr_destroy_ex(pthread_attr_ex_t *attr_ex);
122 
123 int pthread_attr_setschedpolicy_ex(pthread_attr_ex_t *attr_ex,
124  int policy);
125 
126 int pthread_attr_getschedpolicy_ex(const pthread_attr_ex_t *attr_ex,
127  int *policy);
128 
129 int pthread_attr_setschedparam_ex(pthread_attr_ex_t *attr_ex,
130  const struct sched_param_ex *param_ex);
131 
132 int pthread_attr_getschedparam_ex(const pthread_attr_ex_t *attr_ex,
133  struct sched_param_ex *param_ex);
134 
135 int pthread_attr_getinheritsched_ex(const pthread_attr_ex_t *attr_ex,
136  int *inheritsched);
137 
138 int pthread_attr_setinheritsched_ex(pthread_attr_ex_t *attr_ex,
139  int inheritsched);
140 
141 int pthread_attr_getdetachstate_ex(const pthread_attr_ex_t *attr_ex,
142  int *detachstate);
143 
144 int pthread_attr_setdetachstate_ex(pthread_attr_ex_t *attr_ex,
145  int detachstate);
146 
147 int pthread_attr_setdetachstate_ex(pthread_attr_ex_t *attr_ex,
148  int detachstate);
149 
150 int pthread_attr_getstacksize_ex(const pthread_attr_ex_t *attr_ex,
151  size_t *stacksize);
152 
153 int pthread_attr_setstacksize_ex(pthread_attr_ex_t *attr_ex,
154  size_t stacksize);
155 
156 int pthread_attr_getscope_ex(const pthread_attr_ex_t *attr_ex,
157  int *scope);
158 
159 int pthread_attr_setscope_ex(pthread_attr_ex_t *attr_ex,
160  int scope);
161 
162 int pthread_attr_getpersonality_ex(const pthread_attr_ex_t *attr_ex,
163  int *personality);
164 
165 int pthread_attr_setpersonality_ex(pthread_attr_ex_t *attr_ex,
166  int personality);
167 #ifdef __cplusplus
168 }
169 #endif
170 
171 #endif /* !_COBALT_PTHREAD_H */
int pthread_getschedparam(pthread_t thread, int *__restrict__ policy, struct sched_param *__restrict__ param)
Get the scheduling policy and parameters of the specified thread.
Definition: thread.c:706
int pthread_mutex_lock(pthread_mutex_t *mutex)
Lock a mutex.
Definition: mutex.c:278
int pthread_cond_signal(pthread_cond_t *cond)
Signal a condition variable.
Definition: cond.c:424
int pthread_mutex_trylock(pthread_mutex_t *mutex)
Attempt to lock a mutex.
Definition: mutex.c:459
int pthread_setschedparam_ex(pthread_t ptid, int pol, const struct sched_param_ex *par)
Set extended scheduling policy of thread.
Definition: thread.c:648
int pthread_setmode_np(int clrmask, int setmask, int *mask_r)
Set the mode of the current thread.
Definition: thread.c:424
int pthread_cond_broadcast(pthread_cond_t *cond)
Broadcast a condition variable.
Definition: cond.c:485
int pthread_mutex_unlock(pthread_mutex_t *mutex)
Unlock a mutex.
Definition: mutex.c:544
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
Wait on a condition variable.
Definition: cond.c:249
int pthread_getschedparam_ex(pthread_t thread, int *__restrict__ policy_r, struct sched_param_ex *__restrict__ param_ex)
Get extended scheduling policy of thread.
Definition: thread.c:746
int pthread_cond_destroy(pthread_cond_t *cond)
Destroy a condition variable.
Definition: cond.c:169
int pthread_setname_np(pthread_t thread, const char *name)
Set a thread name.
Definition: thread.c:448
int pthread_kill(pthread_t ptid, int sig)
Send a signal to a thread.
Definition: thread.c:476
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
Wait a bounded time on a condition variable.
Definition: cond.c:345
int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param)
Set the scheduling policy and parameters of the specified thread.
Definition: thread.c:585
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
Initialize a condition variable.
Definition: cond.c:115
int pthread_yield(void)
Yield the processor.
Definition: thread.c:777
int pthread_mutex_destroy(pthread_mutex_t *mutex)
Destroy a mutex.
Definition: mutex.c:179
int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *to)
Attempt, during a bounded time, to lock a mutex.
Definition: mutex.c:374
int pthread_create(pthread_t *ptid_r, const pthread_attr_t *attr, void *(*start)(void *), void *arg)
Create a new thread.
Definition: thread.c:319
int pthread_join(pthread_t ptid, void **retval)
Wait for termination of a specified thread.
Definition: thread.c:524
int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
Initialize a mutex.
Definition: mutex.c:110