Xenomai
3.0-rc7
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
setup.h
1
/*
2
* Copyright (C) 2015 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_SETUP_H
19
#define _BOILERPLATE_SETUP_H
20
21
#include <boilerplate/list.h>
22
#include <boilerplate/wrappers.h>
23
#include <string.h>
24
#include <sched.h>
25
26
struct
base_setup_data {
27
cpu_set_t cpu_affinity;
28
int
no_mlock;
29
int
no_sanity;
30
int
verbosity_level;
31
const
char
*arg0;
32
};
33
34
struct
option;
35
36
struct
setup_descriptor {
37
const
char
*name;
38
int (*tune)(void);
39
int (*parse_option)(
int
optnum,
const
char
*optarg);
40
void (*help)(void);
41
int (*init)(void);
42
const
struct
option *options;
43
struct
{
44
int
id;
45
int
opt_start;
46
int
opt_end;
47
struct
pvholder next;
48
} __reserved;
49
};
50
51
/*
52
* We have three pre-defined constructor priorities:
53
*
54
* - One for setup calls (__setup_ctor), which are guaranteed to run
55
* prior to the bootstrap code. You should use setup calls for
56
* implementing initialization hooks which depend on a particular call
57
* order. Each Xenomai interface layer is initialized via a dedicated
58
* setup call.
59
*
60
* - A second priority is assigned to early init calls (__early_ctor),
61
* which are also guaranteed to run prior to the bootstrap
62
* code. Whether such early code runs before OR after any setup code
63
* is __UNSPECIFIED__. By design, such code may not invoke any Xenomai
64
* service, and generally speaking, should have no dependencies on
65
* anything else.
66
*
67
* - The last priority level is used for the bootstrap code
68
* (__bootstrap_ctor), which is guaranteed to run after any
69
* setup/early code, provided such bootstrap code is part of the main
70
* executable.
71
*
72
* The guarantees on the init order don't go beyond what is stated
73
* here, do NOT assume more than this.
74
*/
75
#define __setup_ctor __attribute__ ((constructor(200)))
76
#define __early_ctor __attribute__ ((constructor(210)))
77
#define __bootstrap_ctor __attribute__ ((constructor(220)))
78
79
#define __setup_call(__name, __id) \
80
static __setup_ctor void __declare_ ## __name(void) \
81
{ \
82
__register_setup_call(&(__name), __id); \
83
}
84
85
#define core_setup_call(__name) __setup_call(__name, 0)
86
#define boilerplate_setup_call(__name) __setup_call(__name, 1)
87
#define copperplate_setup_call(__name) __setup_call(__name, 2)
88
#define interface_setup_call(__name) __setup_call(__name, 3)
89
#define post_setup_call(__name) __setup_call(__name, 4)
90
#define user_setup_call(__name) __setup_call(__name, 5)
91
92
#ifdef __cplusplus
93
extern
"C"
{
94
#endif
95
96
void
__register_setup_call(
struct
setup_descriptor *p,
int
id
);
97
98
extern
pid_t __node_id;
99
100
extern
int
__config_done;
101
102
extern
struct
base_setup_data __base_setup_data;
103
104
static
inline
const
char
*get_program_name(
void
)
105
{
106
return
basename(__base_setup_data.arg0 ?:
"program"
);
107
}
108
109
#ifdef __cplusplus
110
}
111
#endif
112
113
#endif
/* !_BOILERPLATE_SETUP_H */
include
boilerplate
setup.h
Generated by
1.8.9.1