24 namespace L4 {
namespace Ipc L4_EXPORT {
38 template<
typename ELEM_TYPE,
typename LEN_TYPE = Array_len_default >
41 typedef ELEM_TYPE *ptr_type;
42 typedef LEN_TYPE len_type;
48 : length(length), data(data)
51 template<
typename X>
struct Non_const
54 template<
typename X>
struct Non_const<X const>
58 : length(other.length), data(other.data)
84 template<
typename ELEM_TYPE,
typename LEN_TYPE = Array_len_default>
90 Array(LEN_TYPE length, ELEM_TYPE *data)
91 :
Array_ref<ELEM_TYPE, LEN_TYPE>(length, data)
94 template<
typename X>
struct Non_const
97 template<
typename X>
struct Non_const<X const>
101 Array(
typename Non_const<ELEM_TYPE>::type
const &other)
102 :
Array_ref<ELEM_TYPE, LEN_TYPE>(other.length, other.data)
119 template<
typename ELEM_TYPE,
140 for (LEN_TYPE i = 0; i < length; ++i)
154 template<
typename A,
typename LEN>
155 struct Elem< Array<A, LEN> >
162 enum { Is_optional =
false };
166 template<
typename A,
typename LEN>
175 enum { Is_optional =
false };
179 template<
typename A,
typename LEN>
188 enum { Is_optional =
false };
191 template<
typename A>
struct Class<Array<A> > : Class<A>::type {};
192 template<
typename A>
struct Class<Array_ref<A> > : Class<A>::type {};
196 template<
typename A,
typename LEN,
typename ARRAY,
bool REF>
197 struct Clnt_val_ops_d_in : Clnt_noops<ARRAY>
199 using Clnt_noops<ARRAY>::to_msg;
200 static int to_msg(
char *msg,
unsigned offset,
unsigned limit,
203 offset = align_to<LEN>(offset);
206 *
reinterpret_cast<LEN *
>(msg + offset) = a.length;
207 offset = align_to<A>(offset +
sizeof(LEN));
208 if (
L4_UNLIKELY(!check_size<A>(offset, limit, a.length)))
210 typedef typename L4::Types::Remove_const<A>::type elem_type;
211 elem_type *data =
reinterpret_cast<elem_type*
>(msg + offset);
214 if (!REF || data != a.data)
215 for (LEN i = 0; i < a.length; ++i)
218 return offset + a.length *
sizeof(A);
223 template<
typename A,
typename LEN>
225 Detail::Clnt_val_ops_d_in<A, LEN, Array<A, LEN>, false> {};
227 template<
typename A,
typename LEN>
228 struct Clnt_val_ops<Array_ref<A, LEN>, Dir_in, Cls_data> :
229 Detail::Clnt_val_ops_d_in<A, LEN, Array_ref<A, LEN>, true> {};
231 template<
typename A,
typename LEN,
typename CLASS>
232 struct Svr_val_ops< Array_ref<A, LEN>, Dir_in, CLASS >
233 : Svr_noops< Array_ref<A, LEN> >
237 using Svr_noops<svr_type>::to_svr;
238 static int to_svr(
char *msg,
unsigned offset,
unsigned limit,
239 svr_type &a, Dir_in, Cls_data)
241 offset = align_to<LEN>(offset);
244 a.length = *
reinterpret_cast<LEN *
>(msg + offset);
245 offset = align_to<A>(offset +
sizeof(LEN));
246 if (
L4_UNLIKELY(!check_size<A>(offset, limit, a.length)))
248 a.data =
reinterpret_cast<A*
>(msg + offset);
249 return offset + a.length *
sizeof(A);
253 template<
typename A,
typename LEN>
254 struct Svr_xmit< Array<A, LEN> > : Svr_xmit< Array_ref<A, LEN> > {};
256 template<
typename A,
typename LEN>
257 struct Clnt_val_ops<Array<A, LEN>, Dir_out, Cls_data> : Clnt_noops<Array<A, LEN> >
261 using Clnt_noops<type>::from_msg;
262 static int from_msg(
char *msg,
unsigned offset,
unsigned limit,
long,
263 type &a, Dir_out, Cls_data)
265 offset = align_to<LEN>(offset);
269 LEN l = *
reinterpret_cast<LEN *
>(msg + offset);
271 offset = align_to<A>(offset +
sizeof(LEN));
275 A *data =
reinterpret_cast<A*
>(msg + offset);
282 for (
unsigned i = 0; i < l; ++i)
285 return offset + l *
sizeof(A);
289 template<
typename A,
typename LEN>
290 struct Clnt_val_ops<Array_ref<A, LEN>, Dir_out, Cls_data> :
291 Clnt_noops<Array_ref<A, LEN> >
295 using Clnt_noops<type>::from_msg;
296 static int from_msg(
char *msg,
unsigned offset,
unsigned limit,
long,
297 type &a, Dir_out, Cls_data)
299 offset = align_to<LEN>(offset);
303 LEN l = *
reinterpret_cast<LEN *
>(msg + offset);
305 offset = align_to<A>(offset +
sizeof(LEN));
309 a.data =
reinterpret_cast<A*
>(msg + offset);
311 return offset + l *
sizeof(A);
315 template<
typename A,
typename LEN,
typename CLASS>
316 struct Svr_val_ops<Array_ref<A, LEN>, Dir_out, CLASS> :
317 Svr_noops<Array_ref<typename L4::Types::Remove_const<A>::type, LEN> &>
319 typedef typename L4::Types::Remove_const<A>::type elem_type;
322 using Svr_noops<svr_type>::to_svr;
323 static int to_svr(
char *msg,
unsigned offset,
unsigned limit,
324 svr_type a, Dir_out, Cls_data)
326 offset = align_to<LEN>(offset);
330 offset = align_to<A>(offset +
sizeof(LEN));
331 a.data =
reinterpret_cast<elem_type *
>(msg + offset);
332 a.length = (limit-offset) /
sizeof(A);
336 using Svr_noops<svr_type>::from_svr;
337 static int from_svr(
char *msg,
unsigned offset,
unsigned limit,
long,
338 svr_type a, Dir_out, Cls_data)
340 offset = align_to<LEN>(offset);
344 *
reinterpret_cast<LEN *
>(msg + offset) = a.length;
346 offset = align_to<A>(offset +
sizeof(LEN));
347 if (
L4_UNLIKELY(!check_size<A>(offset, limit, a.length)))
350 return offset + a.length *
sizeof(A);
354 template<
typename A,
typename LEN>
355 struct Svr_xmit<Array<A, LEN> &> : Svr_xmit<Array_ref<A, LEN> &> {};
358 template<
typename A,
typename LEN>
362 template<
typename A,
typename LEN>
svr_type & svr_arg_type
Array_ref<> & at the server side.
Total number of message register (MRs) available.
Array(typename Non_const< ELEM_TYPE >::type const &other)
Make a const array from a non-const array.
unsigned short Array_len_default
Default type for passing length of an array.
Array_in_buf(const_array a)
Make Array_in_buf from a const array.
L4 low-level kernel interface.
Array< A, LEN > & arg_type
Array<> & at the interface.
Array_ref< A, LEN > svr_type
Array_ref<> as server storage type.
void copy_in(const_array a)
copy in data from a source array
#define L4_UNLIKELY(x)
Expression is unlikely to execute.
LEN_TYPE length
The length of the array.
Array_in_buf(array a)
Make Array_in_buf from a non-const array.
unsigned long l4_umword_t
Unsigned machine word.
Server-side copy in buffer for Array.
Array_ref< typename L4::Types::Remove_const< A >::type, LEN > svr_type
Array_ref<> as server storage.
Array(LEN_TYPE length, ELEM_TYPE *data)
Make array from length and data pointer.
Type trait defining a valid RPC parameter type.
Marker type for input values.
Array_ref< A, LEN > & arg_type
Array_ref<> at the interface.
Defines client-side handling of `MTYPE' as RPC argument.
Array reference data type for arrays located in the message.
Defines server-side handling for MTYPE server arguments.
Marker type for data values.
Array data type for dynamically sized arrays in RPCs.
Array_ref< A, LEN > svr_type
Array_ref<> at the server side.
svr_type & svr_arg_type
Array_ref<> & as server argument.
Array< A, LEN > arg_type
Array<> as argument at the interface.