18 #ifndef _COBALT_SYS_COBALT_H
19 #define _COBALT_SYS_COBALT_H
21 #include <sys/types.h>
25 #include <semaphore.h>
29 #include <boilerplate/atomic.h>
30 #include <boilerplate/list.h>
31 #include <cobalt/uapi/kernel/synch.h>
32 #include <cobalt/uapi/kernel/vdso.h>
33 #include <cobalt/uapi/corectl.h>
34 #include <cobalt/uapi/mutex.h>
35 #include <cobalt/uapi/event.h>
36 #include <cobalt/uapi/monitor.h>
37 #include <cobalt/uapi/thread.h>
38 #include <cobalt/uapi/cond.h>
39 #include <cobalt/uapi/sem.h>
41 #define report_error(fmt, args...) \
42 __STD(fprintf(stderr, "Xenomai/cobalt: %s(): " fmt "\n", __func__, ##args))
44 #define report_error_cont(fmt, args...) \
45 __STD(fprintf(stderr, " " fmt "\n", ##args))
47 #define cobalt_commit_memory(p) __cobalt_commit_memory(p, sizeof(*p))
49 struct cobalt_tsd_hook {
50 void (*create_tsd)(void);
51 void (*delete_tsd)(void);
59 int cobalt_extend(
unsigned int magic);
61 int cobalt_corectl(
int request,
void *buf,
size_t bufsz);
63 int cobalt_thread_stat(pid_t pid,
64 struct cobalt_threadstat *stat);
66 int cobalt_serial_debug(
const char *fmt, ...);
68 size_t cobalt_get_stacksize(
size_t size);
70 void __cobalt_commit_memory(
void *p,
size_t len);
72 void cobalt_thread_harden(
void);
74 void cobalt_thread_relax(
void);
76 int cobalt_thread_join(pthread_t thread);
78 pid_t cobalt_thread_pid(pthread_t thread);
80 int cobalt_monitor_init(cobalt_monitor_t *mon,
81 clockid_t clk_id,
int flags);
83 int cobalt_monitor_destroy(cobalt_monitor_t *mon);
85 int cobalt_monitor_enter(cobalt_monitor_t *mon);
87 int cobalt_monitor_exit(cobalt_monitor_t *mon);
89 int cobalt_monitor_wait(cobalt_monitor_t *mon,
int event,
90 const struct timespec *ts);
92 void cobalt_monitor_grant(cobalt_monitor_t *mon,
93 struct xnthread_user_window *u_window);
95 int cobalt_monitor_grant_sync(cobalt_monitor_t *mon,
96 struct xnthread_user_window *u_window);
98 void cobalt_monitor_grant_all(cobalt_monitor_t *mon);
100 int cobalt_monitor_grant_all_sync(cobalt_monitor_t *mon);
102 void cobalt_monitor_drain(cobalt_monitor_t *mon);
104 int cobalt_monitor_drain_sync(cobalt_monitor_t *mon);
106 void cobalt_monitor_drain_all(cobalt_monitor_t *mon);
108 int cobalt_monitor_drain_all_sync(cobalt_monitor_t *mon);
110 int cobalt_event_init(cobalt_event_t *event,
114 int cobalt_event_post(cobalt_event_t *event,
117 int cobalt_event_wait(cobalt_event_t *event,
119 unsigned int *bits_r,
121 const struct timespec *timeout);
123 unsigned long cobalt_event_clear(cobalt_event_t *event,
126 int cobalt_event_inquire(cobalt_event_t *event,
127 struct cobalt_event_info *info,
128 pid_t *waitlist,
size_t waitsz);
130 int cobalt_event_destroy(cobalt_event_t *event);
132 int cobalt_sem_inquire(sem_t *sem,
struct cobalt_sem_info *info,
133 pid_t *waitlist,
size_t waitsz);
135 int cobalt_sched_weighted_prio(
int policy,
136 const struct sched_param_ex *param_ex);
138 void cobalt_register_tsd_hook(
struct cobalt_tsd_hook *th);
140 void __libcobalt_init(
void);
142 extern int __cobalt_defer_init;
144 extern int __cobalt_no_shadow;
146 extern int __cobalt_control_bind;
148 extern int __cobalt_main_prio;
150 extern int __cobalt_print_bufsz;