Motr  M0
Serialization
Collaboration diagram for Serialization:

Data Structures

struct  m0_net_test_descr
 

Macros

#define TYPE_DESCR(type_name)   static const struct m0_net_test_descr type_name ## _descr[]
 
#define USE_TYPE_DESCR(type_name)   type_name ## _descr, ARRAY_SIZE(type_name ## _descr)
 
#define FIELD_SIZE(type, field)   (sizeof ((type *) 0)->field)
 
#define FIELD_DESCR(type, field)
 
#define FIELD_DESCR_PLAIN(type, field)
 

Enumerations

enum  m0_net_test_serialize_op { M0_NET_TEST_SERIALIZE, M0_NET_TEST_DESERIALIZE }
 

Functions

m0_bcount_t m0_net_test_serialize_data (enum m0_net_test_serialize_op op, void *data, m0_bcount_t data_len, bool plain_data, struct m0_bufvec *bv, m0_bcount_t bv_offset)
 
m0_bcount_t m0_net_test_serialize (enum m0_net_test_serialize_op op, void *obj, const struct m0_net_test_descr descr[], size_t descr_nr, struct m0_bufvec *bv, m0_bcount_t bv_offset)
 
static m0_bcount_t net_test_len_accumulate (m0_bcount_t accumulator, m0_bcount_t addend)
 

Detailed Description

See also
Motr Network Benchmark

Macro Definition Documentation

◆ FIELD_DESCR

#define FIELD_DESCR (   type,
  field 
)
Value:
{ \
.ntd_offset = offsetof(type, field), \
.ntd_length = FIELD_SIZE(type, field), \
.ntd_plain_data = false, \
}
static int field(struct ff2c_context *ctx, struct ff2c_term *term)
Definition: parser.c:84
int type
Definition: dir.c:1031
#define FIELD_SIZE(type, field)
Definition: serialize.h:60
#define offsetof(typ, memb)
Definition: misc.h:29

Recommended to use in field declaration order

Definition at line 63 of file serialize.h.

◆ FIELD_DESCR_PLAIN

#define FIELD_DESCR_PLAIN (   type,
  field 
)
Value:
{ \
.ntd_offset = offsetof(type, field), \
.ntd_length = FIELD_SIZE(type, field), \
.ntd_plain_data = true, \
}
static int field(struct ff2c_context *ctx, struct ff2c_term *term)
Definition: parser.c:84
int type
Definition: dir.c:1031
#define FIELD_SIZE(type, field)
Definition: serialize.h:60
#define offsetof(typ, memb)
Definition: misc.h:29

Definition at line 69 of file serialize.h.

◆ FIELD_SIZE

#define FIELD_SIZE (   type,
  field 
)    (sizeof ((type *) 0)->field)

Definition at line 60 of file serialize.h.

◆ TYPE_DESCR

#define TYPE_DESCR (   type_name)    static const struct m0_net_test_descr type_name ## _descr[]

Definition at line 54 of file serialize.h.

◆ USE_TYPE_DESCR

#define USE_TYPE_DESCR (   type_name)    type_name ## _descr, ARRAY_SIZE(type_name ## _descr)

Definition at line 57 of file serialize.h.

Enumeration Type Documentation

◆ m0_net_test_serialize_op

Operation type.

See also
m0_net_test_serialize().
Enumerator
M0_NET_TEST_SERIALIZE 

Serialize operation.

M0_NET_TEST_DESERIALIZE 

Deserialize operation.

Definition at line 42 of file serialize.h.

Function Documentation

◆ m0_net_test_serialize()

m0_bcount_t m0_net_test_serialize ( enum m0_net_test_serialize_op  op,
void *  obj,
const struct m0_net_test_descr  descr[],
size_t  descr_nr,
struct m0_bufvec bv,
m0_bcount_t  bv_offset 
)

Serialize or deserialize data structure with the given description.

Parameters
opOperation. Can be M0_NET_TEST_SERIALIZE or M0_NET_TEST_DESERIALIZE.
objPointer to data structure.
descrArray of data field descriptions.
descr_nrDescribed fields number in descr.
bvm0_bufvec. Can be NULL - in this case bv_offset is ignored.
bv_offsetOffset in bv.
Returns
0 No free space in buffer or descr_nr == 0.
>0 Number of bytes read/written/will be written to/from buffer.
Precondition
op == M0_NET_TEST_SERIALIZE || op == M0_NET_TEST_DESERIALIZE
obj != NULL
descr != NULL
Note
m0_net_test_descr.ntd_length can't be > 8 if m0_net_test_descr.ntd_plain_data is true.

Definition at line 176 of file serialize.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_serialize_data()

m0_bcount_t m0_net_test_serialize_data ( enum m0_net_test_serialize_op  op,
void *  data,
m0_bcount_t  data_len,
bool  plain_data,
struct m0_bufvec bv,
m0_bcount_t  bv_offset 
)

Serialize or deserialize data.

Precondition
data_len > 0
plain_data || data_len == 1 || data_len == 2 || data_len == 4 || data_len == 8
See also
m0_net_test_serialize().

Definition at line 163 of file serialize.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ net_test_len_accumulate()

static m0_bcount_t net_test_len_accumulate ( m0_bcount_t  accumulator,
m0_bcount_t  addend 
)
inlinestatic

Get new len_total value after serializing part of data.

See also
Complex serialization
Parameters
accumulatorTotal serialized length before serializing current part of data.
addendLength of serialized current part of data. 0 means serializing failed.
Returns
0 if addend == 0 accumulator + addend otherwise.

Definition at line 122 of file serialize.h.

Here is the caller graph for this function: