38 #ifndef included_clib_serialize_h 39 #define included_clib_serialize_h 71 #define SERIALIZE_END_OF_STREAM (1 << 0) 103 #define serialize_error_return(m,args...) \ 104 serialize_error (&(m)->header, clib_error_return (0, args)) 107 serialize_stream_t * s,
110 #define SERIALIZE_FLAG_IS_READ (1 << 0) 111 #define SERIALIZE_FLAG_IS_WRITE (1 << 1) 115 serialize_stream_t * s,
125 if (l == 0 && j <= s->n_buffer_bytes)
170 else if (n_bytes == 2)
172 else if (n_bytes == 4)
174 else if (n_bytes == 8)
186 else if (n_bytes == 2)
187 *(
u16 *) x = clib_net_to_host_unaligned_mem_u16 ((
u16 *) p);
188 else if (n_bytes == 4)
189 *(
u32 *) x = clib_net_to_host_unaligned_mem_u32 ((
u32 *) p);
190 else if (n_bytes == 8)
191 *(
u64 *) x = clib_net_to_host_unaligned_mem_u64 ((
u64 *) p);
247 r += (y / 4) + (p[0] << 6);
256 + (p[0] << (5 + 8*0))
257 + (p[1] << (5 + 8*1))
258 + (p[2] << (5 + 8*2)));
264 r = clib_little_to_host_u64 (r);
272 u64 u = s < 0 ? -(2*s + 1) : 2*s;
281 return (u & 1) ? -s : s;
323 if (n_data_bytes == 1)
325 else if (n_data_bytes == 2)
327 else if (n_data_bytes == 4)
340 if (n_data_bytes == 1)
342 else if (n_data_bytes == 2)
344 else if (n_data_bytes == 4)
367 #define vec_serialize(m,v,f) \ 368 serialize ((m), serialize_vector, (v), sizeof ((v)[0]), (f)) 370 #define vec_unserialize(m,v,f) \ 371 unserialize ((m), unserialize_vector, (v), sizeof ((*(v))[0]), (f)) 373 #define vec_unserialize_aligned(m,v,f) \ 374 unserialize ((m), unserialize_aligned_vector, (v), sizeof ((*(v))[0]), (f)) 379 #define pool_serialize(m,v,f) \ 380 serialize ((m), serialize_pool, (v), sizeof ((v)[0]), (f)) 382 #define pool_unserialize(m,v,f) \ 383 unserialize ((m), unserialize_pool, (v), sizeof ((*(v))[0]), (f)) 385 #define pool_unserialize_aligned(m,v,a,f) \ 386 unserialize ((m), unserialize_aligned_pool, (v), sizeof ((*(v))[0]), (a), (f)) void unserialize_multiple_4(serialize_main_t *m, void *data, uword data_stride, uword n_data)
sll srl srl sll sra u16x4 i
u32 current_overflow_index
serialize_function_t unserialize_16
void serialize_magic(serialize_main_t *m, void *magic, u32 magic_bytes)
void unserialize_open_data(serialize_main_t *m, u8 *data, uword n_data_bytes)
static void(BVT(clib_bihash)*h, BVT(clib_bihash_value)*v)
void unserialize_multiple_1(serialize_main_t *m, void *data, uword data_stride, uword n_data)
void serialize_close(serialize_main_t *m)
serialize_main_header_t header
serialize_function_t serialize_32
always_inline void serialize_likely_small_unsigned_integer(serialize_main_t *m, u64 x)
serialize_stream_t * streams
clib_error_t * unserialize(serialize_main_t *m,...)
serialize_function_t unserialize_64
serialize_function_t unserialize_vec_16
serialize_function_t serialize_pool
void clib_longjmp(clib_longjmp_t *save, uword return_value)
add_epi add_epi sub_epi sub_epi adds_epu subs_epu i16x8 y
void unserialize_close(serialize_main_t *m)
struct serialize_main_header_t serialize_main_header_t
serialize_function_t serialize_64
serialize_function_t unserialize_aligned_vector
serialize_function_t unserialize_f32
serialize_function_t serialize_vector
always_inline void serialize_stream_set_end_of_stream(serialize_stream_t *s)
void * serialize_close_vector(serialize_main_t *m)
always_inline void unserialize_integer(serialize_main_t *m, void *x, u32 n_bytes)
clib_error_t * serialize(serialize_main_t *m,...)
serialize_function_t unserialize_aligned_pool
void serialize_open_vector(serialize_main_t *m, u8 *vector)
void serialize_multiple_1(serialize_main_t *m, void *data, uword data_stride, uword n_data)
static uword pointer_to_uword(const void *p)
always_inline void serialize_error(serialize_main_header_t *m, clib_error_t *error)
#define SERIALIZE_FLAG_IS_READ
always_inline void serialize_likely_small_signed_integer(serialize_main_t *m, i64 s)
void unserialize_multiple_2(serialize_main_t *m, void *data, uword data_stride, uword n_data)
serialize_function_t unserialize_vec_64
serialize_function_t serialize_vec_32
always_inline uword serialize_stream_is_end_of_stream(serialize_stream_t *s)
serialize_function_t serialize_vec_64
serialize_function_t unserialize_32
void serialize_multiple_2(serialize_main_t *m, void *data, uword data_stride, uword n_data)
void serialize_open_unix_file_descriptor(serialize_main_t *m, int fd)
void unserialize_check_magic(serialize_main_t *m, void *magic, u32 magic_bytes)
always_inline void * unserialize_get(serialize_main_t *m, uword n_bytes)
void serialize_bitmap(serialize_main_t *m, uword *b)
u32 opaque[64-4 *sizeof(u32)-1 *sizeof(uword)-2 *sizeof(void *)]
serialize_function_t unserialize_vector
serialize_function_t unserialize_f64
serialize_function_t serialize_16
serialize_function_t unserialize_8
#define SERIALIZE_END_OF_STREAM
clib_error_t * serialize_open_unix_file(serialize_main_t *m, char *file)
serialize_stream_t stream
uword * unserialize_bitmap(serialize_main_t *m)
always_inline void serialize_set_end_of_stream(serialize_main_t *m)
serialize_data_function_t * data_function
always_inline void serialize_integer(serialize_main_t *m, u64 x, u32 n_bytes)
serialize_function_t serialize_heap
uword data_function_opaque
always_inline uword serialize_is_end_of_stream(serialize_main_t *m)
serialize_function_t serialize_vec_16
serialize_function_t unserialize_vec_8
void serialize_cstring(serialize_main_t *m, char *string)
void serialize_multiple_4(serialize_main_t *m, void *data, uword data_stride, uword n_data)
clib_error_t * va_serialize(serialize_main_t *m, va_list *va)
void unserialize_open_vector(serialize_main_t *m, u8 *vector)
void unserialize_cstring(serialize_main_t *m, char **string)
clib_error_t * unserialize_open_unix_file(serialize_main_t *m, char *file)
always_inline i64 unserialize_likely_small_signed_integer(serialize_main_t *m)
serialize_function_t serialize_f32
serialize_function_t serialize_vec_8
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void( serialize_function_t)(serialize_main_t *m, va_list *va)
serialize_main_header_t header
always_inline void * serialize_stream_read_write(serialize_main_header_t *header, serialize_stream_t *s, uword n_bytes, uword flags)
always_inline void unserialize_multiple(serialize_main_t *m, void *data, uword n_data_bytes, uword data_stride, uword n_data)
void serialize_open_data(serialize_main_t *m, u8 *data, uword n_data_bytes)
#define SERIALIZE_FLAG_IS_WRITE
#define clib_mem_unaligned(pointer, type)
serialize_function_t unserialize_heap
serialize_function_t serialize_8
always_inline void serialize_multiple(serialize_main_t *m, void *data, uword n_data_bytes, uword data_stride, uword n_data)
always_inline void * serialize_get(serialize_main_t *m, uword n_bytes)
always_inline u64 unserialize_likely_small_unsigned_integer(serialize_main_t *m)
void unserialize_open_unix_file_descriptor(serialize_main_t *m, int fd)
void( serialize_data_function_t)(struct serialize_main_header_t *h, struct serialize_stream_t *s)
struct serialize_stream_t serialize_stream_t
void * serialize_read_write_not_inline(serialize_main_header_t *m, serialize_stream_t *s, uword n_bytes, uword flags)
serialize_function_t unserialize_pool
clib_longjmp_t error_longjmp
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
serialize_function_t serialize_f64
serialize_function_t unserialize_vec_32