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 *));
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);