hc
2024-11-01 2f529f9b558ca1c1bd74be7437a84e4711743404
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 * Copyright (C) 2008 Philippe Gerum <rpm@xenomai.org>.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
 */
#ifndef _LIB_COBALT_INTERNAL_H
#define _LIB_COBALT_INTERNAL_H
 
#include <limits.h>
#include <stdbool.h>
#include <time.h>
#include <boilerplate/ancillaries.h>
#include <cobalt/sys/cobalt.h>
#include "current.h"
 
extern void *cobalt_umm_private;
 
extern void *cobalt_umm_shared;
 
static inline int cobalt_is_relaxed(void)
{
   return cobalt_get_current_mode() & XNRELAX;
}
 
static inline int cobalt_should_warn(void)
{
   return (cobalt_get_current_mode() & (XNRELAX|XNWARN)) == XNWARN;
}
 
#ifdef CONFIG_XENO_LAZY_SETSCHED
static inline int cobalt_eager_setsched(void)
{
   return cobalt_is_relaxed();
}
#else
static inline int cobalt_eager_setsched(void)
{
   return 1;
}
#endif
 
static inline
struct cobalt_mutex_state *mutex_get_state(struct cobalt_mutex_shadow *shadow)
{
   if (shadow->attr.pshared)
       return cobalt_umm_shared + shadow->state_offset;
 
   return cobalt_umm_private + shadow->state_offset;
}
 
static inline atomic_t *mutex_get_ownerp(struct cobalt_mutex_shadow *shadow)
{
   return &mutex_get_state(shadow)->owner;
}
 
void cobalt_sigshadow_install_once(void);
 
void cobalt_thread_init(void);
 
int cobalt_thread_probe(pid_t pid);
 
void cobalt_sched_init(void);
 
void cobalt_print_init(void);
 
void cobalt_print_init_atfork(void);
 
void cobalt_ticks_init(unsigned long long freq);
 
void cobalt_mutex_init(void);
 
void cobalt_default_condattr_init(void);
 
int cobalt_xlate_schedparam(int policy,
               const struct sched_param_ex *param_ex,
               struct sched_param *param);
int cobalt_init(void);
 
void *cobalt_lookup_vdso(const char *version, const char *name);
 
extern struct sigaction __cobalt_orig_sigdebug;
 
extern int __cobalt_std_fifo_minpri,
      __cobalt_std_fifo_maxpri;
 
extern int __cobalt_std_rr_minpri,
      __cobalt_std_rr_maxpri;
 
extern int (*__cobalt_vdso_gettime)(clockid_t clk_id,
                   struct timespec *tp);
 
extern unsigned int cobalt_features;
 
struct cobalt_featinfo;
 
/**
 * Arch specific feature initialization
 *
 * @param finfo
 */
void cobalt_arch_check_features(struct cobalt_featinfo *finfo);
 
/**
 * Initialize the feature handling.
 *
 * @param f Feature info that will be cached for future feature checks
 */
void cobalt_features_init(struct cobalt_featinfo *f);
 
/**
 * Check if a given set of features is available / provided by the kernel
 *
 * @param feat_mask A bit mask of features to check availability for. See
 * __xn_feat_* macros for a list of defined features
 *
 * @return true if all features are available, false otherwise
 */
static inline bool cobalt_features_available(unsigned int feat_mask)
{
   return (cobalt_features & feat_mask) == feat_mask;
}
 
#endif /* _LIB_COBALT_INTERNAL_H */