19 #ifndef _POSIX_INTERNAL_H
20 #define _POSIX_INTERNAL_H
22 #include <nucleus/xenomai.h>
25 #include <posix/posix.h>
26 #include <posix/registry.h>
29 #include <nucleus/assert.h>
31 #ifndef CONFIG_XENO_OPT_DEBUG_POSIX
32 #define CONFIG_XENO_OPT_DEBUG_POSIX 0
35 #define PSE51_MAGIC(n) (0x8686##n##n)
36 #define PSE51_ANY_MAGIC PSE51_MAGIC(00)
37 #define PSE51_THREAD_MAGIC PSE51_MAGIC(01)
38 #define PSE51_THREAD_ATTR_MAGIC PSE51_MAGIC(02)
39 #define PSE51_MUTEX_MAGIC PSE51_MAGIC(03)
40 #define PSE51_MUTEX_ATTR_MAGIC (PSE51_MAGIC(04) & ((1 << 24) - 1))
41 #define PSE51_COND_MAGIC PSE51_MAGIC(05)
42 #define PSE51_COND_ATTR_MAGIC (PSE51_MAGIC(05) & ((1 << 24) - 1))
43 #define PSE51_SEM_MAGIC PSE51_MAGIC(06)
44 #define PSE51_KEY_MAGIC PSE51_MAGIC(07)
45 #define PSE51_ONCE_MAGIC PSE51_MAGIC(08)
46 #define PSE51_MQ_MAGIC PSE51_MAGIC(09)
47 #define PSE51_MQD_MAGIC PSE51_MAGIC(0A)
48 #define PSE51_INTR_MAGIC PSE51_MAGIC(0B)
49 #define PSE51_NAMED_SEM_MAGIC PSE51_MAGIC(0C)
50 #define PSE51_TIMER_MAGIC PSE51_MAGIC(0D)
51 #define PSE51_SHM_MAGIC PSE51_MAGIC(0E)
53 #define PSE51_MIN_PRIORITY XNSCHED_LOW_PRIO
54 #define PSE51_MAX_PRIORITY XNSCHED_HIGH_PRIO
56 #define ONE_BILLION 1000000000
58 #define pse51_obj_active(h,m,t) \
59 ((h) && ((t *)(h))->magic == (m))
61 #define pse51_obj_deleted(h,m,t) \
62 ((h) && ((t *)(h))->magic == ~(m))
64 #define pse51_mark_deleted(t) ((t)->magic = ~(t)->magic)
75 #ifdef CONFIG_XENO_OPT_PERVASIVE
77 pse51_kqueues_t kqueues;
85 #define ppd2queues(addr) \
86 ((pse51_queues_t *) ((char *) (addr) - offsetof(pse51_queues_t, ppd)))
90 extern int pse51_muxid;
93 extern xntbase_t *pse51_tbase;
95 extern pse51_kqueues_t pse51_global_kqueues;
97 #ifdef CONFIG_XENO_OPT_PERVASIVE
98 static inline pse51_queues_t *pse51_queues(
void)
103 xnlock_get_irqsave(&nklock, s);
107 xnlock_put_irqrestore(&nklock, s);
112 return ppd2queues(ppd);
116 static inline pse51_kqueues_t *pse51_kqueues(
int pshared)
118 #ifdef CONFIG_XENO_OPT_PERVASIVE
122 return &pse51_global_kqueues;
124 return &ppd2queues(ppd)->kqueues;
126 return &pse51_global_kqueues;
130 static inline void ticks2ts(
struct timespec *ts, xnticks_t ticks)
132 ts->tv_sec = xnarch_divrem_billion(xntbase_ticks2ns(pse51_tbase, ticks),
136 static inline xnticks_t ts2ticks_floor(
const struct timespec *ts)
138 xntime_t nsecs = ts->tv_nsec;
140 nsecs += (xntime_t) ts->tv_sec * ONE_BILLION;
141 return xntbase_ns2ticks(pse51_tbase, nsecs);
144 static inline xnticks_t ts2ticks_ceil(
const struct timespec *ts)
146 xntime_t nsecs = ts->tv_nsec;
150 nsecs += (xntime_t) ts->tv_sec * ONE_BILLION;
151 ticks = xnarch_ulldiv(nsecs, xntbase_get_tickval(pse51_tbase), &rem);
152 return rem ? ticks+1 : ticks;
155 static inline xnticks_t tv2ticks_ceil(
const struct timeval *tv)
157 xntime_t nsecs = tv->tv_usec * 1000;
161 nsecs += (xntime_t) tv->tv_sec * ONE_BILLION;
162 ticks = xnarch_ulldiv(nsecs, xntbase_get_tickval(pse51_tbase), &rem);
163 return rem ? ticks+1 : ticks;
166 static inline void ticks2tv(
struct timeval *tv, xnticks_t ticks)
169 tv->tv_sec = xnarch_divrem_billion(xntbase_ticks2ns(pse51_tbase, ticks),
171 tv->tv_usec = nsecs / 1000;
174 static inline xnticks_t clock_get_ticks(clockid_t clock_id)
176 if(clock_id == CLOCK_REALTIME)
179 return xntbase_get_jiffies(pse51_tbase);
182 static inline int clock_flag(
int flag, clockid_t clock_id)
184 switch(flag & TIMER_ABSTIME) {
190 case CLOCK_MONOTONIC:
200 int pse51_mq_select_bind(mqd_t fd,
struct xnselector *selector,
201 unsigned type,
unsigned index);
xnshadow_ppd_t * xnshadow_ppd_get(unsigned muxid)
Return the per-process data attached to the calling process.
Definition: shadow.c:3014
file descriptors events multiplexing header.
static xnticks_t xntbase_get_time(xntbase_t *base)
Get the clock time for a given time base.
Definition: timebase.h:301