20 #ifndef _POSIX_THREAD_H
21 #define _POSIX_THREAD_H
23 #include <posix/internal.h>
25 typedef unsigned long long pse51_sigset_t;
42 xnthread_t threadbase;
44 #define thread2pthread(taddr) ({ \
45 xnthread_t *_taddr = (taddr); \
47 ? ((xnthread_get_magic(_taddr) == PSE51_SKIN_MAGIC) \
48 ? ((pthread_t)(((char *)_taddr)- offsetof(struct pse51_thread, \
58 #define link2pthread(laddr) \
59 ((pthread_t)(((char *)laddr) - offsetof(struct pse51_thread, link)))
64 void *(*entry)(
void *arg);
74 unsigned cancelstate : 2;
75 unsigned canceltype : 2;
76 unsigned cancel_request : 1;
77 xnqueue_t cleanup_handlers_q;
83 pse51_sigset_t sigmask;
84 pse51_sigqueue_t pending;
85 pse51_sigqueue_t blocked_received;
88 const void *tsd [PTHREAD_KEYS_MAX];
93 #ifdef CONFIG_XENO_OPT_PERVASIVE
94 struct pse51_hkey hkey;
98 #define PSE51_JOINED_DETACHED XNTHREAD_INFO_SPARE0
100 #define pse51_current_thread() thread2pthread(xnpod_current_thread())
102 static inline void thread_set_errno (
int err)
104 *xnthread_get_errno_location(xnpod_current_thread()) = err;
107 static inline int thread_get_errno (
void)
109 return *xnthread_get_errno_location(xnpod_current_thread());
112 #define thread_name(thread) ((thread)->attr.name)
114 #define thread_exit_status(thread) ((thread)->exit_status)
116 #define thread_getdetachstate(thread) ((thread)->attr.detachstate)
118 #define thread_setdetachstate(thread, state) ((thread)->attr.detachstate=state)
120 #define thread_getcancelstate(thread) ((thread)->cancelstate)
122 #define thread_setcancelstate(thread, state) ((thread)->cancelstate=state)
124 #define thread_setcanceltype(thread, type) ((thread)->canceltype=type)
126 #define thread_getcanceltype(thread) ((thread)->canceltype)
128 #define thread_clrcancel(thread) ((thread)->cancel_request = 0)
130 #define thread_setcancel(thread) ((thread)->cancel_request = 1)
132 #define thread_cleanups(thread) (&(thread)->cleanup_handlers_q)
134 #define thread_gettsd(thread, key) ((thread)->tsd[key])
136 #define thread_settsd(thread, key, value) ((thread)->tsd[key]=(value))
138 void pse51_thread_abort(pthread_t thread,
void *status);
140 static inline void thread_cancellation_point (xnthread_t *thread)
142 pthread_t cur = thread2pthread(thread);
144 if(cur && cur->cancel_request
145 && thread_getcancelstate(cur) == PTHREAD_CANCEL_ENABLE )
146 pse51_thread_abort(cur, PTHREAD_CANCELED);
149 void pse51_threadq_cleanup(pse51_kqueues_t *q);
151 void pse51_thread_pkg_init(u_long rrperiod);
153 void pse51_thread_pkg_cleanup(
void);
156 extern xnticks_t pse51_time_slice;