Xenomai 3.3.2
Loading...
Searching...
No Matches
ancillaries.h
1/*
2 * Copyright (C) 2013 Philippe Gerum <rpm@xenomai.org>.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 */
18#ifndef _BOILERPLATE_ANCILLARIES_H
19#define _BOILERPLATE_ANCILLARIES_H
20
21#include <stdarg.h>
22#include <time.h>
23#include <pthread.h>
24#include <sched.h>
25#include <string.h>
26
27struct error_frame;
28
29#define ONE_BILLION 1000000000
30
31void __namecpy_requires_character_array_as_destination(void);
32
33#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
34
35#define namecpy(__dst, __src) \
36 ({ \
37 if (!__builtin_types_compatible_p(typeof(__dst), char[])) \
38 __namecpy_requires_character_array_as_destination(); \
39 strncpy((__dst), __src, sizeof(__dst)); \
40 __dst[sizeof(__dst) - 1] = '\0'; \
41 __dst; \
42 })
43
44#define early_panic(__fmt, __args...) \
45 __early_panic(__func__, __fmt, ##__args)
46
47#define panic(__fmt, __args...) \
48 __panic(__func__, __fmt, ##__args)
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54void __printout(const char *name,
55 const char *header,
56 const char *fmt, va_list ap);
57
58void __noreturn __early_panic(const char *fn,
59 const char *fmt, ...);
60
61void __noreturn ___panic(const char *fn,
62 const char *name,
63 const char *fmt, va_list ap);
64
65void __noreturn __panic(const char *fn,
66 const char *fmt, ...);
67
68void __warning(const char *name,
69 const char *fmt, va_list ap);
70
71void early_warning(const char *fmt, ...);
72
73void warning(const char *fmt, ...);
74
75void __notice(const char *name,
76 const char *fmt, va_list ap);
77
78void early_notice(const char *fmt, ...);
79
80void notice(const char *fmt, ...);
81
82void __boilerplate_init(void);
83
84const char *symerror(int errnum);
85
86void error_hook(struct error_frame *ef);
87
88int get_static_cpu_count(void);
89
90int get_online_cpu_set(cpu_set_t *cpuset);
91
92int get_realtime_cpu_set(cpu_set_t *cpuset);
93
94int get_current_cpu(void);
95
96pid_t get_thread_pid(void);
97
98char *lookup_command(const char *cmd);
99
100size_t get_mem_size(const char *arg);
101
102extern const char *config_strings[];
103
104extern pthread_mutex_t __printlock;
105
106#ifdef __cplusplus
107}
108#endif
109
110#endif /* _BOILERPLATE_ANCILLARIES_H */