27template<
typename ELEM_TYPE,
typename LEN_TYPE = Array_len_default >
30 using ptr_type = ELEM_TYPE *;
31 using len_type = LEN_TYPE;
35 Array_ref() =
default;
36 Array_ref(len_type length, ptr_type data)
37 : length(length), data(data)
40 template<
typename X>
struct Non_const
41 {
using type = Array_ref<X, LEN_TYPE>; };
43 template<
typename X>
struct Non_const<X const>
44 {
using type = Array_ref<X, LEN_TYPE>; };
46 Array_ref(
typename Non_const<ELEM_TYPE>::type
const &other)
47 : length(other.length), data(other.data)
50 Array_ref &operator = (
typename Non_const<ELEM_TYPE>::type
const &other)
52 this->length = other.length;
53 this->data = other.data;
80template<
typename ELEM_TYPE,
typename LEN_TYPE = Array_len_default>
81struct Array : Array_ref<ELEM_TYPE , LEN_TYPE>
86 Array(LEN_TYPE length, ELEM_TYPE *data)
87 : Array_ref<ELEM_TYPE, LEN_TYPE>(length, data)
90 template<
typename X>
struct Non_const
93 template<
typename X>
struct Non_const<X const>
94 {
using type = Array<X, LEN_TYPE>; };
97 Array(
typename Non_const<ELEM_TYPE>::type
const &other)
98 : Array_ref<ELEM_TYPE, LEN_TYPE>(other.length, other.data)
101 Array &operator = (
typename Non_const<ELEM_TYPE>::type
const &other)
103 this->length = other.length;
104 this->data = other.data;
122template<
typename ELEM_TYPE,
124 LEN_TYPE MAX = (L4_UTCB_GENERIC_DATA_SIZE *
143 for (LEN_TYPE i = 0; i <
length; ++i)
157template<
typename A,
typename LEN>
165 static constexpr bool Is_optional =
false;
166 static constexpr bool Is_input =
true;
167 static constexpr bool Is_output =
false;
171template<
typename A,
typename LEN>
180 static constexpr bool Is_optional =
false;
181 static constexpr bool Is_input =
false;
182 static constexpr bool Is_output =
true;
186template<
typename A,
typename LEN>
195 static constexpr bool Is_optional =
false;
196 static constexpr bool Is_input =
false;
197 static constexpr bool Is_output =
true;
202template<
typename A,
typename LEN,
typename ARRAY,
bool REF>
205 static int to_msg_data(
char *msg,
unsigned offset,
unsigned limit,
211 *
reinterpret_cast<LEN *
>(msg + offset) = a.length;
215 using elem_type = L4::Types::Remove_const_t<A>;
216 elem_type *data =
reinterpret_cast<elem_type*
>(msg + offset);
219 if (!REF || data != a.data)
221 for (LEN i = 0; i < a.length; ++i)
225 return offset + a.length *
sizeof(A);
231template<
typename A,
typename LEN>
232struct Clnt_val_ops<Array<A, LEN>> :
233 Detail::Clnt_val_ops_d_in<A, LEN, Array<A, LEN>, false>
235 using type = Array<A, LEN>;
237 static int from_msg_data(
char *msg,
unsigned offset,
unsigned limit, type &a)
243 LEN l = *
reinterpret_cast<LEN *
>(msg + offset);
249 A *data =
reinterpret_cast<A*
>(msg + offset);
256 for (
unsigned i = 0; i < l; ++i)
259 return offset + l *
sizeof(A);
263template<
typename A,
typename LEN>
265 Detail::Clnt_val_ops_d_in<A, LEN, Array_ref<A, LEN>, true>
267 using type = Array_ref<A, LEN>;
269 static int from_msg_data(
char *msg,
unsigned offset,
unsigned limit, type &a)
275 LEN l = *
reinterpret_cast<LEN *
>(msg + offset);
281 a.data =
reinterpret_cast<A*
>(msg + offset);
283 return offset + l *
sizeof(A);
287template<
typename A,
typename LEN>
291 using svr_type = Array_ref<A, LEN>;
292 using elem_type = L4::Types::Remove_const_t<A>;
294 static int to_svr_data(
char *msg,
unsigned offset,
unsigned limit,
300 a.length = *
reinterpret_cast<LEN *
>(msg + offset);
304 a.data =
reinterpret_cast<A*
>(msg + offset);
305 return offset + a.length *
sizeof(A);
308 static int reserve_data(
char *msg,
unsigned offset,
unsigned limit,
316 a.data =
reinterpret_cast<elem_type *
>(msg + offset);
317 a.length = (limit-offset) /
sizeof(A);
321 static int from_svr_data(
char *msg,
unsigned offset,
unsigned limit,
328 *
reinterpret_cast<LEN *
>(msg + offset) = a.length;
336 elem_type *data =
reinterpret_cast<elem_type *
>(msg + offset);
338 for (LEN i = 0; i < a.length; ++i)
341 return offset + a.length *
sizeof(A);
346template<
typename A,
typename LEN>
350template<
typename A,
typename LEN>
unsigned long l4_umword_t
Unsigned machine word.
@ L4_EMSGTOOLONG
Message too long.
@ L4_EMSGTOOSHORT
Message too short.
#define L4_UNLIKELY(x)
Expression is unlikely to execute.
#define L4_EXPORT
Attribute to mark functions, variables, and data types as being exported from a library.
IPC Message related functionality.
constexpr bool check_size(unsigned offset, unsigned limit) noexcept
Check if there is enough space for T from offset to limit.
constexpr unsigned long align_to(unsigned long bytes, unsigned long align) noexcept
Pad bytes to the given alignment align (in bytes).
IPC related functionality.
unsigned short Array_len_default
Default type for passing length of an array.
L4 low-level kernel interface.
void copy_in(const_array a)
copy in data from a source array
Array_in_buf(array a)
Make Array_in_buf from a non-const array.
Array_in_buf(const_array a)
Make Array_in_buf from a const array.
Array reference data type for arrays located in the message.
Array data type for dynamically sized arrays in RPCs.
Array(LEN_TYPE length, ELEM_TYPE *data)
Make array from length and data pointer.
Array(typename Non_const< ELEM_TYPE >::type const &other)
Make a const array from a non-const array.
Empty client side marshalling code.
Defines client-side handling of 'MTYPE' as RPC argument.
static int from_msg_data(char *msg, unsigned offset, unsigned limit, MTYPE &arg) noexcept
Copy data from the message to a T client reference (arg must be MTYPE &).
Array_ref< A, LEN > svr_type
Array_ref<> at the server side.
Array< A, LEN > arg_type
Array<> as argument at the interface.
Array< A, LEN > & arg_type
Array<> & at the interface.
Array_ref< A, LEN > svr_type
Array_ref<> as server storage type.
svr_type & svr_arg_type
Array_ref<> & at the server side.
svr_type & svr_arg_type
Array_ref<> & as server argument.
Array_ref< L4::Types::Remove_const_t< A >, LEN > svr_type
Array_ref<> as server storage.
Array_ref< A, LEN > & arg_type
Array_ref<> at the interface.
Helper struct to describe various aspects of an IPC argument.
Type trait defining a valid RPC parameter type.
Empty server side marshalling code.
Defines server-side handling of 'MTYPE' as RPC argument.
static int to_svr_data(char *msg, unsigned offset, unsigned limit, MTYPE &arg) noexcept
Copy data from the message to a T server reference (arg must be MTYPE &).
static int from_svr_data(char *msg, unsigned offset, unsigned limit, MTYPE const &arg) noexcept
Copy a T into the message (arg must be either MTYPE or MTYPE const &).
static int reserve_data(char *, unsigned offs, unsigned limit, MTYPE &) noexcept
Prepare a T output operand (arg must be MTYPE &).