19 #ifndef _XENO_POSIX_PTHREAD_H
20 #define _XENO_POSIX_PTHREAD_H
22 #if defined(__KERNEL__) || defined(__XENO_SIM__)
24 #include <nucleus/xenomai.h>
27 #include <linux/types.h>
32 #include <posix_overrides.h>
33 #define PTHREAD_STACK_MIN 8192
35 #define PTHREAD_STACK_MIN 1024
38 #define PTHREAD_CREATE_JOINABLE 0
39 #define PTHREAD_CREATE_DETACHED 1
41 #define PTHREAD_INHERIT_SCHED 0
42 #define PTHREAD_EXPLICIT_SCHED 1
44 #define PTHREAD_SCOPE_SYSTEM 0
45 #define PTHREAD_SCOPE_PROCESS 1
47 #define PTHREAD_MUTEX_NORMAL 0
48 #define PTHREAD_MUTEX_RECURSIVE 1
49 #define PTHREAD_MUTEX_ERRORCHECK 2
50 #define PTHREAD_MUTEX_DEFAULT 0
52 #define PTHREAD_PRIO_NONE 0
53 #define PTHREAD_PRIO_INHERIT 1
54 #define PTHREAD_PRIO_PROTECT 2
56 #define PTHREAD_PROCESS_PRIVATE 0
57 #define PTHREAD_PROCESS_SHARED 1
59 #define PTHREAD_CANCEL_ENABLE 0
60 #define PTHREAD_CANCEL_DISABLE 1
62 #define PTHREAD_CANCEL_DEFERRED 2
63 #define PTHREAD_CANCEL_ASYNCHRONOUS 3
65 #define PTHREAD_CANCELED ((void *)-2)
67 #define PTHREAD_DESTRUCTOR_ITERATIONS 4
68 #define PTHREAD_KEYS_MAX 128
70 #define PTHREAD_ONCE_INIT { 0x86860808, 0 }
76 typedef struct pse51_thread *pthread_t;
78 typedef struct pse51_threadattr {
87 struct sched_param_ex schedparam_ex;
90 xnarch_cpumask_t affinity;
97 typedef struct pse51_key *pthread_key_t;
99 typedef struct pse51_once {
106 struct _pthread_fastlock
114 struct _pthread_fastlock __c_lock;
116 char __padding[48 -
sizeof (
struct _pthread_fastlock)
117 - sizeof (long) - sizeof (long long)];
127 struct _pthread_fastlock __m_lock;
134 #pragma GCC system_header
137 #include_next <pthread.h>
138 #include <nucleus/thread.h>
139 #include <nucleus/intr.h>
145 #ifndef PTHREAD_PRIO_NONE
146 #define PTHREAD_PRIO_NONE 0
148 #ifndef PTHREAD_PRIO_INHERIT
149 #define PTHREAD_PRIO_INHERIT 1
151 #ifndef PTHREAD_PRIO_PROTECT
152 #define PTHREAD_PRIO_PROTECT 2
155 #define PTHREAD_WARNSW XNTRAPSW
156 #define PTHREAD_LOCK_SCHED XNLOCK
157 #define PTHREAD_RPIOFF XNRPIOFF
158 #define PTHREAD_PRIMARY XNTHREAD_STATE_SPARE1
160 #define PTHREAD_INOAUTOENA XN_ISR_NOENABLE
161 #define PTHREAD_IPROPAGATE XN_ISR_PROPAGATE
163 #define PTHREAD_IENABLE 0
164 #define PTHREAD_IDISABLE 1
166 struct pse51_mutexattr {
169 unsigned protocol: 2;
173 struct pse51_condattr {
182 pthread_cond_t native_cond;
183 struct __shadow_cond {
185 struct pse51_cond *cond;
189 struct pse51_interrupt;
191 typedef struct pse51_interrupt *pthread_intr_t;
193 #if defined(__KERNEL__) || defined(__XENO_SIM__)
194 typedef struct pse51_mutexattr pthread_mutexattr_t;
196 typedef struct pse51_condattr pthread_condattr_t;
212 int pthread_attr_getstackaddr(
const pthread_attr_t *attr,
215 int pthread_attr_setstackaddr(pthread_attr_t *attr,
237 struct sched_param *par);
240 struct sched_param_ex *par);
243 const struct sched_param *par);
246 const struct sched_param_ex *par);
267 xnarch_cpumask_t *mask);
270 xnarch_cpumask_t mask);
273 const pthread_attr_t *attr,
274 void *(*start) (
void *),
275 void *arg ) __deprecated_in_kernel__;
291 struct sched_param *par);
295 struct sched_param_ex *par);
299 const struct sched_param *par);
303 const struct sched_param_ex *par);
326 const pthread_mutexattr_t *attr);
335 const struct timespec *to);
354 const pthread_condattr_t *attr);
359 pthread_mutex_t *mutex);
362 pthread_mutex_t *mutex,
363 const struct timespec *abstime);
385 void (*destructor)(
void *));
394 int pthread_once(pthread_once_t *once_control,
395 void (*init_routine)(
void));
398 struct timespec *starttp,
399 struct timespec *periodtp);
425 struct sched_param_ex;
431 #ifndef CONFIG_XENO_HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL
439 #ifndef CONFIG_XENO_HAVE_PTHREAD_CONDATTR_SETCLOCK
448 struct timespec *starttp,
449 struct timespec *periodtp);
466 const struct timespec *to);
473 struct sched_param_ex *par);
477 const struct sched_param_ex *par);
479 int __real_pthread_create(pthread_t *tid,
480 const pthread_attr_t *attr,
481 void *(*start) (
void *),
484 int __real_pthread_detach(pthread_t thread);
486 int __real_pthread_getschedparam(pthread_t thread,
488 struct sched_param *param);
490 int __real_pthread_setschedparam(pthread_t thread,
492 const struct sched_param *param);
493 int __real_pthread_yield(
void);
495 int __real_pthread_mutexattr_init(pthread_mutexattr_t *attr);
497 int __real_pthread_mutexattr_destroy(pthread_mutexattr_t *attr);
499 int __real_pthread_mutexattr_gettype(
const pthread_mutexattr_t *attr,
502 int __real_pthread_mutexattr_settype(pthread_mutexattr_t *attr,
int type);
504 #ifdef CONFIG_XENO_HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL
505 int __real_pthread_mutexattr_getprotocol(
const pthread_mutexattr_t *attr,
508 int __real_pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr,
512 int __real_pthread_mutexattr_getpshared(
const pthread_mutexattr_t *attr,
515 int __real_pthread_mutexattr_setpshared(pthread_mutexattr_t *attr,
518 int __real_pthread_mutex_init(pthread_mutex_t *mutex,
519 const pthread_mutexattr_t *attr);
521 int __real_pthread_mutex_destroy(pthread_mutex_t *mutex);
523 int __real_pthread_mutex_lock(pthread_mutex_t *mutex);
525 int __real_pthread_mutex_timedlock(pthread_mutex_t *mutex,
526 const struct timespec *to);
528 int __real_pthread_mutex_trylock(pthread_mutex_t *mutex);
530 int __real_pthread_mutex_unlock(pthread_mutex_t *mutex);
532 int __real_pthread_condattr_init(pthread_condattr_t *attr);
534 int __real_pthread_condattr_destroy(pthread_condattr_t *attr);
536 int __real_pthread_condattr_getclock(
const pthread_condattr_t *attr,
539 int __real_pthread_condattr_setclock(pthread_condattr_t *attr,
542 int __real_pthread_condattr_getpshared(
const pthread_condattr_t *attr,
545 int __real_pthread_condattr_setpshared(pthread_condattr_t *attr,
int pshared);
547 int __real_pthread_cond_init (pthread_cond_t *cond,
548 const pthread_condattr_t *attr);
550 int __real_pthread_cond_destroy(pthread_cond_t *cond);
552 int __real_pthread_cond_wait(pthread_cond_t *cond,
553 pthread_mutex_t *mutex);
555 int __real_pthread_cond_timedwait(pthread_cond_t *cond,
556 pthread_mutex_t *mutex,
557 const struct timespec *abstime);
559 int __real_pthread_cond_signal(pthread_cond_t *cond);
561 int __real_pthread_cond_broadcast(pthread_cond_t *cond);
563 int __real_pthread_kill(pthread_t tid,
int sig);
int pthread_mutex_unlock(pthread_mutex_t *mutex)
Unlock a mutex.
Definition: mutex.c:592
int pthread_set_name_np(pthread_t thread, const char *name)
Set a thread name.
Definition: thread.c:716
int pthread_setschedparam(pthread_t tid, int pol, const struct sched_param *par)
Set the scheduling policy and parameters of the specified thread.
Definition: sched.c:356
int pthread_wait_np(unsigned long *overruns_r)
Wait for current thread next period.
Definition: thread.c:621
int pthread_detach(pthread_t thread)
Detach a running thread.
Definition: thread.c:302
int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clk_id)
Set the clock selection attribute of a condition variable attributes object.
Definition: cond_attr.c:167
int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched)
Set inheritsched attribute.
Definition: thread_attr.c:373
int pthread_key_create(pthread_key_t *key, void(*destructor)(void *))
Create a thread-specific data key.
Definition: tsd.c:96
int pthread_attr_getname_np(const pthread_attr_t *attr, const char **name)
Get name attribute.
Definition: thread_attr.c:817
int pthread_join(pthread_t thread, void **value_ptr)
Wait for termination of a specified thread.
Definition: thread.c:431
int pthread_attr_getaffinity_np(const pthread_attr_t *attr, xnarch_cpumask_t *mask)
Get the processor affinity attribute.
Definition: thread_attr.c:1004
int pthread_condattr_getclock(const pthread_condattr_t *attr, clockid_t *clk_id)
Get the clock selection attribute from a condition variable attributes object.
Definition: cond_attr.c:125
int pthread_intr_wait_np(pthread_intr_t intr, const struct timespec *to)
Wait for the next interruption.
Definition: interrupt.c:52
int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
Get detachstate attribute.
Definition: thread_attr.c:151
int pthread_getschedparam(pthread_t tid, int *pol, struct sched_param *par)
Get the scheduling policy and parameters of the specified thread.
Definition: sched.c:198
int pthread_attr_getschedparam_ex(const pthread_attr_t *attr, struct sched_param_ex *par)
Get schedparam_ex extended attribute.
Definition: thread_attr.c:579
int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type)
Get the mutex type attribute from a mutex attributes object.
Definition: mutex_attr.c:126
int pthread_cond_broadcast(pthread_cond_t *cond)
Broadcast a condition variable.
Definition: cond.c:578
int pthread_cond_destroy(pthread_cond_t *cond)
Destroy a condition variable.
Definition: cond.c:182
int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *par)
Set schedparam attribute.
Definition: thread_attr.c:624
int pthread_mutexattr_init(pthread_mutexattr_t *attr)
Initialize a mutex attributes object.
Definition: mutex_attr.c:56
int pthread_mutex_lock(pthread_mutex_t *mutex)
Lock a mutex.
Definition: mutex.c:488
int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy)
Get schedpolicy attribute.
Definition: thread_attr.c:425
int pthread_equal(pthread_t t1, pthread_t t2)
Compare thread identifiers.
Definition: thread.c:349
int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared)
Set the process-shared attribute of a mutex attributes object.
Definition: mutex_attr.c:391
int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared)
Set the process-shared attribute of a condition variable attributes object.
Definition: cond_attr.c:268
int pthread_key_delete(pthread_key_t key)
Delete a thread-specific data key.
Definition: tsd.c:257
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
Initialize a condition variable.
Definition: cond.c:103
int pthread_attr_destroy(pthread_attr_t *attr)
Destroy a thread attributes object.
Definition: thread_attr.c:100
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
Wait on a condition variable.
Definition: cond.c:409
int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
Destroy a mutex attributes object.
Definition: mutex_attr.c:84
int pthread_attr_setschedparam_ex(pthread_attr_t *attr, const struct sched_param_ex *par)
Set extended schedparam_ex attribute.
Definition: thread_attr.c:675
int pthread_mutex_destroy(pthread_mutex_t *mutex)
Destroy a mutex.
Definition: mutex.c:246
int pthread_mutex_trylock(pthread_mutex_t *mutex)
Attempt to lock a mutex.
Definition: mutex.c:383
int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inheritsched)
Get inheritsched attribute.
Definition: thread_attr.c:330
int pthread_attr_getscope(const pthread_attr_t *attr, int *scope)
Get contention scope attribute.
Definition: thread_attr.c:726
int pthread_attr_init(pthread_attr_t *attr)
Initialize a thread attributes object.
Definition: thread_attr.c:81
int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
Set schedpolicy attribute.
Definition: thread_attr.c:467
int pthread_attr_setname_np(pthread_attr_t *attr, const char *name)
Set name attribute.
Definition: thread_attr.c:862
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:476
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
Set detachstate attribute.
Definition: thread_attr.c:197
int pthread_condattr_destroy(pthread_condattr_t *attr)
Destroy a condition variable attributes object.
Definition: cond_attr.c:83
int pthread_getschedparam_ex(pthread_t tid, int *pol, struct sched_param_ex *par)
Get the extended scheduling policy and parameters of the specified thread.
Definition: sched.c:249
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
Set stacksize attribute.
Definition: thread_attr.c:283
int pthread_attr_setaffinity_np(pthread_attr_t *attr, xnarch_cpumask_t mask)
Set the processor affinity attribute.
Definition: thread_attr.c:1047
int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, int *proto)
Get the protocol attribute from a mutex attributes object.
Definition: mutex_attr.c:234
int pthread_intr_control_np(pthread_intr_t intr, int cmd)
Control the state of an interrupt channel.
Definition: intr.c:226
int pthread_attr_setscope(pthread_attr_t *attr, int scope)
Set contention scope attribute.
Definition: thread_attr.c:768
int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *par)
Get schedparam attribute.
Definition: thread_attr.c:535
int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int *pshared)
Get the process-shared attribute of a mutex attributes object.
Definition: mutex_attr.c:344
int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *to)
Attempt, during a bounded time, to lock a mutex.
Definition: mutex.c:541
int pthread_setcanceltype(int type, int *oldtype)
Set cancelability type of the current thread.
Definition: cancel.c:279
void * pthread_getspecific(pthread_key_t key)
Get the thread-specific value bound to the specified key.
Definition: tsd.c:215
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
Set the mutex type attribute of a mutex attributes object.
Definition: mutex_attr.c:176
void pthread_testcancel(void)
Test if a cancellation request is pending.
Definition: cancel.c:409
int pthread_cancel(pthread_t thread)
Cancel a thread.
Definition: cancel.c:89
void pthread_cleanup_pop(int execute)
Unregister the last registered cleanup handler.
Definition: cancel.c:211
void pthread_cleanup_push(cleanup_routine_t *routine, void *arg)
Register a cleanup handler to be executed at the time of cancellation.
Definition: cancel.c:153
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize)
Get stacksize attribute.
Definition: thread_attr.c:241
int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared)
Get the process-shared attribute from a condition variable attributes object.
Definition: cond_attr.c:221
int pthread_create(pthread_t *tid, const pthread_attr_t *attr, void *(*start)(void *), void *arg) __deprecated_in_kernel__
Create a thread.
Definition: thread.c:165
int pthread_condattr_init(pthread_condattr_t *attr)
Initialize a condition variable attributes object.
Definition: cond_attr.c:55
void pthread_exit(void *value_ptr)
Terminate the current thread.
Definition: thread.c:372
int pthread_intr_attach_np(pthread_intr_t *intr, unsigned irq, xnisr_t isr, xniack_t iack)
Create and attach an interrupt object.
Definition: intr.c:102
int pthread_cond_signal(pthread_cond_t *cond)
Signal a condition variable.
Definition: cond.c:527
pthread_t pthread_self(void)
Get the identifier of the calling thread.
Definition: thread.c:541
int pthread_intr_detach_np(pthread_intr_t intr)
Destroy an interrupt object.
Definition: intr.c:202
int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int proto)
Set the protocol attribute of a mutex attributes object.
Definition: mutex_attr.c:282
int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
Initialize a mutex.
Definition: mutex.c:151
int pthread_setcancelstate(int state, int *oldstate)
Set cancelability state of the current thread.
Definition: cancel.c:352
int pthread_set_mode_np(int clrmask, int setmask)
Set the mode of the current thread.
Definition: thread.c:668
int pthread_attr_setfp_np(pthread_attr_t *attr, int use_fp)
Set the floating point attribute.
Definition: thread_attr.c:960
int pthread_make_periodic_np(pthread_t thread, struct timespec *starttp, struct timespec *periodtp)
Make a thread periodic.
Definition: thread.c:569
int pthread_attr_getfp_np(const pthread_attr_t *attr, int *use_fp)
Get the floating point attribute.
Definition: thread_attr.c:919
int pthread_setschedparam_ex(pthread_t tid, int pol, const struct sched_param_ex *par)
Set the extended scheduling policy and parameters of the specified thread.
Definition: sched.c:434
init_step
Execute an initialization routine.
Definition: once.c:53
int pthread_setspecific(pthread_key_t key, const void *value)
Associate a thread-specific value with the specified key.
Definition: tsd.c:174