Motr  M0
serialize.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #pragma once
24 
25 #ifndef __MOTR_NET_TEST_SERIALIZE_H__
26 #define __MOTR_NET_TEST_SERIALIZE_H__
27 
28 #include "lib/types.h" /* m0_bcount_t */
29 #include "lib/vec.h" /* m0_buvfec */
30 
45 };
46 
49  size_t ntd_offset;
50  size_t ntd_length;
52 };
53 
54 #define TYPE_DESCR(type_name) \
55  static const struct m0_net_test_descr type_name ## _descr[]
56 
57 #define USE_TYPE_DESCR(type_name) \
58  type_name ## _descr, ARRAY_SIZE(type_name ## _descr)
59 
60 #define FIELD_SIZE(type, field) (sizeof ((type *) 0)->field)
61 
63 #define FIELD_DESCR(type, field) { \
64  .ntd_offset = offsetof(type, field), \
65  .ntd_length = FIELD_SIZE(type, field), \
66  .ntd_plain_data = false, \
67 }
68 
69 #define FIELD_DESCR_PLAIN(type, field) { \
70  .ntd_offset = offsetof(type, field), \
71  .ntd_length = FIELD_SIZE(type, field), \
72  .ntd_plain_data = true, \
73 }
74 
83  void *data,
84  m0_bcount_t data_len,
85  bool plain_data,
86  struct m0_bufvec *bv,
87  m0_bcount_t bv_offset);
88 
106  void *obj,
107  const struct m0_net_test_descr descr[],
108  size_t descr_nr,
109  struct m0_bufvec *bv,
110  m0_bcount_t bv_offset);
111 
123  m0_bcount_t addend)
124 {
125  return addend == 0 ? 0 : accumulator + addend;
126 }
127 
132 #endif /* __MOTR_NET_TEST_SERIALIZE_H__ */
133 
134 /*
135  * Local variables:
136  * c-indentation-style: "K&R"
137  * c-basic-offset: 8
138  * tab-width: 8
139  * fill-column: 79
140  * scroll-step: 1
141  * End:
142  */
struct m0_bufvec data
Definition: di.c:40
uint64_t m0_bcount_t
Definition: types.h:77
static m0_bcount_t net_test_len_accumulate(m0_bcount_t accumulator, m0_bcount_t addend)
Definition: serialize.h:122
static struct foo * obj
Definition: tlist.c:302
op
Definition: libdemo.c:64
size_t ntd_offset
Definition: serialize.h:49
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)
Definition: serialize.c:163
size_t ntd_length
Definition: serialize.h:50
m0_net_test_serialize_op
Definition: serialize.h:42
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)
Definition: serialize.c:176
Definition: vec.h:145