79 u64 *x = va_arg (*va,
u64 *);
83 *x = ((
u64) hi << 32) | (
u64) lo;
89 u32 *x = va_arg (*va,
u32 *);
96 u16 *x = va_arg (*va,
u16 *);
105 u8 *x = va_arg (*va,
u8 *);
114 f64 x = va_arg (*va,
f64);
127 f32 x = va_arg (*va,
f64);
140 f64 *x = va_arg (*va,
f64 *);
153 f32 *x = va_arg (*va,
f32 *);
166 u32 len = s ? strlen (s) : 0;
190 if (len > 0 && len != 0xFFFFFFFF)
206 u8 *s = va_arg (*va,
u8 *);
207 u32 n = va_arg (*va,
u32);
215 u8 *s = va_arg (*va,
u8 *);
216 u32 n = va_arg (*va,
u32);
222 void serialize_vec_##n_bits (serialize_main_t * m, va_list * va) \ 224 u##n_bits * s = va_arg (*va, u##n_bits *); \ 225 u32 n = va_arg (*va, u32); \ 226 u##n_bits * p = serialize_get (m, n * sizeof (s[0])); \ 230 p[0] = clib_host_to_net_u##n_bits (s[0]); \ 231 p[1] = clib_host_to_net_u##n_bits (s[1]); \ 232 p[2] = clib_host_to_net_u##n_bits (s[2]); \ 233 p[3] = clib_host_to_net_u##n_bits (s[3]); \ 241 p[0] = clib_host_to_net_u##n_bits (s[0]); \ 248 void unserialize_vec_##n_bits (serialize_main_t * m, va_list * va) \ 250 u##n_bits * s = va_arg (*va, u##n_bits *); \ 251 u32 n = va_arg (*va, u32); \ 252 u##n_bits * p = unserialize_get (m, n * sizeof (s[0])); \ 256 s[0] = clib_net_to_host_mem_u##n_bits (&p[0]); \ 257 s[1] = clib_net_to_host_mem_u##n_bits (&p[1]); \ 258 s[2] = clib_net_to_host_mem_u##n_bits (&p[2]); \ 259 s[3] = clib_net_to_host_mem_u##n_bits (&p[3]); \ 267 s[0] = clib_net_to_host_mem_u##n_bits (&p[0]); \ 280 #define SERIALIZE_VECTOR_CHUNK_SIZE 64 285 void *vec = va_arg (*va,
void *);
286 u32 elt_bytes = va_arg (*va,
u32);
316 p = v = _vec_resize ((
void *) 0, l, (
uword) l * elt_bytes, header_bytes,
332 void **vec = va_arg (*va,
void **);
333 u32 elt_bytes = va_arg (*va,
u32);
335 u32 align = va_arg (*va,
u32);
347 void **vec = va_arg (*va,
void **);
348 u32 elt_bytes = va_arg (*va,
u32);
364 n_u32s = l *
sizeof (b[0]) /
sizeof (
u32);
368 for (i = 0; i < l; i++)
386 i = (n_u32s *
sizeof (
u32) +
sizeof (b[0]) - 1) /
sizeof (b[0]);
388 for (i = 0; i < n_u32s; i++)
397 b[i / 2] |= (
u64) data << (
u64) 0;
399 b[i / 2] |= (
u64) data << (
u64) 32;
413 void *pool = va_arg (*va,
void *);
414 u32 elt_bytes = va_arg (*va,
u32);
430 serialize (m, f, pool + lo * elt_bytes, hi - lo));
447 v = _vec_resize ((
void *) 0, l, (
uword) l * elt_bytes,
sizeof (p[0]),
467 void **result = va_arg (*va,
void **);
468 u32 elt_bytes = va_arg (*va,
u32);
476 void **result = va_arg (*va,
void **);
477 u32 elt_bytes = va_arg (*va,
u32);
478 u32 align = va_arg (*va,
u32);
488 for (i = 0; i < n; i++)
501 for (i = 0; i < n; i++)
512 void *heap = va_arg (*va,
void *);
524 #define foreach_serialize_heap_header_integer \ 525 _ (head) _ (tail) _ (used_count) _ (max_len) _ (flags) _ (elt_bytes) 527 #define _(f) serialize_integer (m, h->f, sizeof (h->f)); 562 void **result = va_arg (*va,
void **);
576 #define _(f) unserialize_integer (m, &h.f, sizeof (h.f)); 601 heap = *result = _heap_new (vl, h.
elt_bytes);
640 if (l != magic_bytes)
646 if (memcmp (magic, d, magic_bytes))
700 uword cur_bi, n_left_b, n_left_o;
710 if (n_left_o > 0 && n_left_b > 0)
734 while (n_left_o > 0);
736 if (n_left_o > 0 || n_left_b < n_bytes_to_write)
745 return s->
buffer + cur_bi;
754 uword cur_bi, cur_oi, n_left_b, n_left_o, n_left_to_read;
765 if (n_left_o >= n_bytes_to_read)
778 n_left_to_read = n_bytes_to_read;
779 while (n_left_to_read > 0)
785 if (n_left_o + n_left_b < n_bytes_to_read)
791 n_left_o += n_left_b;
792 n_left_to_read -= n_left_b;
810 && n_left_to_read == n_bytes_to_read && n_left_b >= n_left_to_read)
813 return s->
buffer + cur_bi;
821 n_left_o += n_left_to_read;
827 n =
clib_min (n_left_to_read, n_left_b);
939 uword n_left = n_data;
944 p[0] = d[0 * data_stride];
945 p[1] = d[1 * data_stride];
946 p[2] = d[2 * data_stride];
947 p[3] = d[3 * data_stride];
949 d += 4 * data_stride;
959 d += 1 * data_stride;
971 uword n_left = n_data;
977 clib_host_to_net_mem_u16 (d + 0 * data_stride);
979 clib_host_to_net_mem_u16 (d + 1 * data_stride);
981 clib_host_to_net_mem_u16 (d + 2 * data_stride);
983 clib_host_to_net_mem_u16 (d + 3 * data_stride);
985 d += 4 * data_stride;
994 clib_host_to_net_mem_u16 (d + 0 * data_stride);
996 d += 1 * data_stride;
1008 uword n_left = n_data;
1014 clib_host_to_net_mem_u32 (d + 0 * data_stride);
1016 clib_host_to_net_mem_u32 (d + 1 * data_stride);
1018 clib_host_to_net_mem_u32 (d + 2 * data_stride);
1020 clib_host_to_net_mem_u32 (d + 3 * data_stride);
1022 d += 4 * data_stride;
1031 clib_host_to_net_mem_u32 (d + 0 * data_stride);
1033 d += 1 * data_stride;
1045 uword n_left = n_data;
1050 d[0 * data_stride] = p[0];
1051 d[1 * data_stride] = p[1];
1052 d[2 * data_stride] = p[2];
1053 d[3 * data_stride] = p[3];
1055 d += 4 * data_stride;
1065 d += 1 * data_stride;
1077 uword n_left = n_data;
1083 clib_net_to_host_mem_u16 (p + 0);
1085 clib_net_to_host_mem_u16 (p + 1);
1087 clib_net_to_host_mem_u16 (p + 2);
1089 clib_net_to_host_mem_u16 (p + 3);
1091 d += 4 * data_stride;
1100 clib_net_to_host_mem_u16 (p + 0);
1102 d += 1 * data_stride;
1114 uword n_left = n_data;
1120 clib_net_to_host_mem_u32 (p + 0);
1122 clib_net_to_host_mem_u32 (p + 1);
1124 clib_net_to_host_mem_u32 (p + 2);
1126 clib_net_to_host_mem_u32 (p + 3);
1128 d += 4 * data_stride;
1137 clib_net_to_host_mem_u32 (p + 0);
1139 d += 1 * data_stride;
1165 _vec_len (s->
buffer) = 0;
1226 mode = is_read ? O_RDONLY : O_RDWR | O_CREAT | O_TRUNC;
1227 fd = open (file, mode, 0666);
static void serialize_vector_write(serialize_main_header_t *m, serialize_stream_t *s)
void serialize_f32(serialize_main_t *m, va_list *va)
void unserialize_check_magic(serialize_main_t *m, void *magic, u32 magic_bytes)
u32 current_overflow_index
static u64 unserialize_likely_small_unsigned_integer(serialize_main_t *m)
#define serialize_error_return(m, args...)
clib_error_t * serialize_open_clib_file(serialize_main_t *m, char *file)
void serialize_bitmap(serialize_main_t *m, uword *b)
void serialize_multiple_4(serialize_main_t *m, void *data, uword data_stride, uword n_data)
#define vec_serialize(m, v, f)
Fixed length block allocator.
serialize_main_header_t header
#define clib_memcpy_fast(a, b, c)
static void serialize_error(serialize_main_header_t *m, clib_error_t *error)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define vec_unserialize(m, v, f)
static void serialize_stream_set_end_of_stream(serialize_stream_t *s)
void unserialize_32(serialize_main_t *m, va_list *va)
void unserialize_multiple_2(serialize_main_t *m, void *data, uword data_stride, uword n_data)
void serialize_f64(serialize_main_t *m, va_list *va)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
void() serialize_function_t(serialize_main_t *m, va_list *va)
void serialize_open_clib_file_descriptor(serialize_main_t *m, int fd)
uword clib_setjmp(clib_longjmp_t *save, uword return_value_not_taken)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
#define SERIALIZE_VECTOR_CHUNK_SIZE
#define foreach_serialize_heap_header_integer
void * unserialize_vector_ha(serialize_main_t *m, u32 elt_bytes, u32 header_bytes, u32 align, u32 max_length, serialize_function_t *f)
void unserialize_open_data(serialize_main_t *m, u8 *data, uword n_data_bytes)
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
void unserialize_heap(serialize_main_t *m, va_list *va)
static uword serialize_stream_is_end_of_stream(serialize_stream_t *s)
static void * serialize_get(serialize_main_t *m, uword n_bytes)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
void unserialize_aligned_vector(serialize_main_t *m, va_list *va)
static uword heap_is_free(heap_elt_t *e)
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
#define clib_error_create(args...)
static void * serialize_read_not_inline(serialize_main_header_t *m, serialize_stream_t *s, uword n_bytes_to_read, uword flags)
static heap_elt_t * heap_next(heap_elt_t *e)
void serialize_16(serialize_main_t *m, va_list *va)
#define SERIALIZE_FLAG_IS_READ
void unserialize_vec_8(serialize_main_t *m, va_list *va)
serialize_function_t serialize_vec_32
static pool_header_t * pool_header(void *v)
Get pool header from user pool pointer.
void serialize_open_data(serialize_main_t *m, u8 *data, uword n_data_bytes)
static void serialize_likely_small_unsigned_integer(serialize_main_t *m, u64 x)
void serialize_pool(serialize_main_t *m, va_list *va)
void unserialize_multiple_4(serialize_main_t *m, void *data, uword data_stride, uword n_data)
#define clib_error_return_unix(e, args...)
void unserialize_8(serialize_main_t *m, va_list *va)
void serialize_8(serialize_main_t *m, va_list *va)
static void serialize_open_clib_file_descriptor_helper(serialize_main_t *m, int fd, uword is_read)
static void * unserialize_get(serialize_main_t *m, uword n_bytes)
static void serialize_read_write_close(serialize_main_header_t *m, serialize_stream_t *s, uword flags)
vl_api_tunnel_mode_t mode
void unserialize_cstring(serialize_main_t *m, char **s)
void * serialize_read_write_not_inline(serialize_main_header_t *m, serialize_stream_t *s, uword n_bytes, uword flags)
serialize_stream_t stream
static void clib_file_read(serialize_main_header_t *m, serialize_stream_t *s)
clib_error_t * serialize(serialize_main_t *m,...)
void serialize_open_vector(serialize_main_t *m, u8 *vector)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
clib_error_t * unserialize_open_clib_file(serialize_main_t *m, char *file)
static uword heap_offset(heap_elt_t *e)
serialize_data_function_t * data_function
static void unserialize_integer(serialize_main_t *m, void *x, u32 n_bytes)
static void serialize_integer(serialize_main_t *m, u64 x, u32 n_bytes)
void unserialize_close(serialize_main_t *m)
static void serialize_vec_heap_elt(serialize_main_t *m, va_list *va)
uword data_function_opaque
void serialize_multiple_2(serialize_main_t *m, void *data, uword data_stride, uword n_data)
void serialize_magic(serialize_main_t *m, void *magic, u32 magic_bytes)
#define uword_to_pointer(u, type)
void unserialize_16(serialize_main_t *m, va_list *va)
void serialize_vec_8(serialize_main_t *m, va_list *va)
void unserialize_aligned_pool(serialize_main_t *m, va_list *va)
void unserialize_multiple_1(serialize_main_t *m, void *data, uword data_stride, uword n_data)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
static word unix_error_is_fatal(word error)
void serialize_close(serialize_main_t *m)
#define pool_foreach_region(LO, HI, POOL, BODY)
Optimized iteration through pool.
clib_error_t * unserialize(serialize_main_t *m,...)
#define clib_mem_unaligned(pointer, type)
static uword heap_elt_size(void *v, heap_elt_t *e)
static heap_header_t * heap_header(void *v)
void serialize_cstring(serialize_main_t *m, char *s)
static void unserialize_vec_heap_elt(serialize_main_t *m, va_list *va)
void serialize_32(serialize_main_t *m, va_list *va)
template key/value backing page structure
static void * serialize_write_not_inline(serialize_main_header_t *m, serialize_stream_t *s, uword n_bytes_to_write, uword flags)
u32 vl(void *p)
GDB callable function: vl - Return vector length of vector.
void unserialize_f64(serialize_main_t *m, va_list *va)
void unserialize_vector(serialize_main_t *m, va_list *va)
void unserialize_f32(serialize_main_t *m, va_list *va)
uword * unserialize_bitmap(serialize_main_t *m)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void serialize_heap(serialize_main_t *m, va_list *va)
void serialize_vector(serialize_main_t *m, va_list *va)
clib_error_t * va_serialize(serialize_main_t *sm, va_list *va)
void unserialize_pool(serialize_main_t *m, va_list *va)
static void * unserialize_pool_helper(serialize_main_t *m, u32 elt_bytes, u32 align, serialize_function_t *f)
static void clib_file_write(serialize_main_header_t *m, serialize_stream_t *s)
#define SERIALIZE_FLAG_IS_WRITE
static clib_error_t * serialize_open_clib_file_helper(serialize_main_t *m, char *file, uword is_read)
#define vec_foreach(var, vec)
Vector iterator.
f64 end
end of the time range
void unserialize_open_clib_file_descriptor(serialize_main_t *m, int fd)
void * serialize_close_vector(serialize_main_t *m)
void unserialize_64(serialize_main_t *m, va_list *va)
void serialize_64(serialize_main_t *m, va_list *va)
void serialize_multiple_1(serialize_main_t *m, void *data, uword data_stride, uword n_data)
clib_longjmp_t error_longjmp
serialize_function_t unserialize_vec_32