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
|
/**
* @file rtems/assoc.h
*
* RTEMS associativity routines. Mainly used to convert a value from
* one space to another (eg: our errno's to host errno's and vice-versa)
*/
#ifndef _RTEMS_RTEMS_ASSOC_H
#define _RTEMS_RTEMS_ASSOC_H
/**
* @defgroup Associativity Routines
*/
/**@{*/
#include <stdint.h> /* uint32_t */
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
const char *name;
uint32_t local_value;
uint32_t remote_value;
} rtems_assoc_t;
/*
* Flag/marker for optional default value in each table
*/
#define RTEMS_ASSOC_DEFAULT_NAME "(default)"
const rtems_assoc_t *rtems_assoc_ptr_by_name(
const rtems_assoc_t *,
const char *
);
const rtems_assoc_t *rtems_assoc_ptr_by_remote(
const rtems_assoc_t *,
uint32_t
);
uint32_t rtems_assoc_remote_by_local(
const rtems_assoc_t *,
uint32_t
);
uint32_t rtems_assoc_local_by_remote(
const rtems_assoc_t *,
uint32_t
);
uint32_t rtems_assoc_remote_by_name(
const rtems_assoc_t *,
const char *
);
/**
* @brief RTEMS Associate Local by Name
*/
uint32_t rtems_assoc_local_by_name(
const rtems_assoc_t *,
const char *
);
const char *rtems_assoc_name_by_local(
const rtems_assoc_t *,
uint32_t
);
const char *rtems_assoc_name_by_remote(
const rtems_assoc_t *,
uint32_t
);
/**
* @brief RTEMS Assoc Routines
*/
uint32_t rtems_assoc_remote_by_local_bitfield(
const rtems_assoc_t *,
uint32_t
);
char *rtems_assoc_name_by_local_bitfield(
const rtems_assoc_t *,
uint32_t ,
char *
);
char *rtems_assoc_name_by_remote_bitfield(
const rtems_assoc_t *,
uint32_t ,
char *
);
uint32_t rtems_assoc_local_by_remote_bitfield(
const rtems_assoc_t *,
uint32_t
);
const rtems_assoc_t *rtems_assoc_ptr_by_local(
const rtems_assoc_t *ap,
uint32_t local_value
);
#if defined(INSIDE_ASSOC)
#define rtems_assoc_is_default(_ap) \
((_ap)->name && !strcmp((_ap)->name, RTEMS_ASSOC_DEFAULT_NAME))
/*
* what to return if a value is not found
* this is not reentrant, but it really shouldn't be invoked anyway
*/
const char *rtems_assoc_name_bad(
uint32_t bad_value
);
#endif
#ifdef __cplusplus
}
#endif
/**@}*/
#endif /* ! _RTEMS_RTEMS_ASSOC_H */
|