32 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_XCODE 58 return x > 0 ?
x - 1 : 0;
105 const struct m0_xcode_field *f = &xt->xct_child[i];
107 field_invariant(xt, f) &&
109 _0C(i == 0 || offset +
110 xt->xct_child[prev].xf_type->xct_sizeof <=
113 m0_forall(j, xt->xct_nr,
115 xt->xct_child[j].xf_name) ==
118 _0C(ergo(xt->xct_aggr == M0_XA_UNION && i > 0,
119 m0_forall(j, xt->xct_nr,
121 (f->xf_tag == xt->xct_child[j].xf_tag) ==
125 _0C(ergo(i == 0 || xt->xct_aggr != M0_XA_UNION,
126 ({ offset = f->xf_offset;
149 const struct m0_xcode_cursor_frame *prev,
153 prev->s_fieldno == 1 && prev->s_elno == 0 &&
159 const struct m0_xcode_cursor_frame *prev;
163 struct m0_xcode_cursor_frame *
top;
200 if (
it->xcu_depth == 0) {
238 if (nob != 0 && *slot ==
NULL) {
276 struct m0_xcode_cursor_frame *
top;
292 result =
ctx->xcx_iter(
it);
320 struct m0_xcode_cursor_frame *prev =
top - 1;
365 ctx->xcx_iter_end(
it);
368 result = result ?: length;
400 void *),
void *datum)
456 if (
top->s_datum != 0) {
486 struct m0_xcode_cursor_frame *prev =
top -1;
493 if (
top->s_datum != 0) {
502 prev->s_datum = (uint64_t)*slot;
509 if (
top->s_obj.xo_ptr ==
NULL) {
535 struct m0_xcode_cursor_frame *sf;
536 struct m0_xcode_cursor_frame *df;
568 &
sit->xcu_stack[0].s_obj) == 0));
585 struct m0_xcode_cursor_frame *
t0;
586 struct m0_xcode_cursor_frame *
t1;
615 char *
addr = (
char *)
obj->xo_ptr;
621 addr +=
f->xf_offset;
623 addr = *((
char **)
addr) + elno * ct->xct_sizeof;
625 addr += elno * ct->xct_sizeof;
638 M0_PRE(0 <= fieldno && fieldno < obj->xo_type->xct_nr);
640 f = &
obj->xo_type->xct_child[fieldno];
690 switch (
f->xf_type->xct_atype) {
723 if (
cur->xo_type ==
xt) {
724 *place =
cur->xo_ptr;
728 return result ?: -ENOENT;
733 size_t magix_field, uint64_t
magix)
737 M0_PRE(magix_field < xt->xct_nr);
748 return ctx->xcx_it.xcu_stack[0].s_obj.xo_ptr;
752 const char *discriminator,
755 *
un = (typeof(*
un)) {
758 .xct_nr = maxbranches + 1
763 .xf_name = discriminator,
771 for (
i = 0;
i <
un->xct_nr; ++
i)
772 un->xct_child[
i].xf_name =
NULL;
773 *
un = (typeof(*
un)) {
791 for (
i = 1;
i <
un->xct_nr; ++
i) {
792 f = &
un->xct_child[
i];
793 if (
f->xf_name ==
NULL)
801 .xf_offset =
un->xct_child[0].xf_type->xct_sizeof
813 for (
i = 1;
i <
un->xct_nr; ++
i) {
814 f = &
un->xct_child[
i];
815 if (
f->xf_name !=
NULL)
821 maxsize =
max_check(maxsize,
f->xf_type->xct_sizeof);
827 un->xct_sizeof =
m0_align(
un->xct_child[0].xf_type->xct_sizeof +
879 uint32_t on, uint32_t off,
885 .fd_aggr_umask = aggr_umask,
928 .xct_sizeof =
sizeof(uint8_t),
936 .xct_sizeof =
sizeof(uint32_t),
944 .xct_sizeof =
sizeof(uint64_t),
950 .xct_name =
"opaque",
951 .xct_sizeof =
sizeof (
void *),
984 #undef M0_TRACE_SUBSYSTEM M0_INTERNAL struct m0_xcode_cursor_frame * m0_xcode_cursor_top(struct m0_xcode_cursor *it)
#define M0_BUFVEC_INIT_BUF(addr_ptr, count_ptr)
struct m0_xcode_obj s_obj
M0_INTERNAL int m0_xcode_encdec(struct m0_xcode_obj *obj, struct m0_bufvec_cursor *cur, enum m0_xcode_what what)
M0_INTERNAL void * m0_xcode_addr(const struct m0_xcode_obj *obj, int fileno, uint64_t elno)
static void ptr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
M0_INTERNAL void * m0_xcode_ctx_top(const struct m0_xcode_ctx *ctx)
const struct m0_xcode_type * xo_type
const struct m0_xcode_type * xf_type
M0_EXTERN ssize_t m0_xcode_alloc_obj(struct m0_xcode_cursor *it, void *(*alloc)(struct m0_xcode_cursor *, size_t))
M0_INTERNAL void m0_xcode_type_iterate(struct m0_xcode_type *xt, void(*t)(struct m0_xcode_type *, void *), void(*f)(struct m0_xcode_type *, struct m0_xcode_field *, void *), void *datum)
M0_INTERNAL void m0_xcode_union_close(struct m0_xcode_type *un)
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
static int ctx_walk(struct m0_xcode_ctx *ctx, enum xcode_op op)
static uint64_t tag(uint8_t code, uint64_t id)
void m0_xc_u16_init(void)
static bool m0_is_po2(uint64_t val)
M0_INTERNAL int m0_xcode_subobj(struct m0_xcode_obj *subobj, const struct m0_xcode_obj *obj, int fieldno, uint64_t elno)
static struct m0_be_emap_cursor it
struct m0_xcode_field xct_child[0]
M0_INTERNAL void m0_xcode_free_obj(struct m0_xcode_obj *obj)
struct m0_xcode_cursor::m0_xcode_cursor_frame xcu_stack[M0_XCODE_DEPTH_MAX]
M0_INTERNAL int m0_xcode_decode(struct m0_xcode_ctx *ctx)
const struct m0_xcode_type_ops * xct_ops
static struct m0_xcode_type ** xt[]
static unsigned alignment_mask(const struct m0_xcode_field *field)
void m0_xc_void_init(void)
const char * m0_xcode_endianness_name[M0_XEND_NR]
M0_INTERNAL int m0_xcode_dup(struct m0_xcode_ctx *dest, struct m0_xcode_ctx *src)
const char * m0_xcode_cursor_flag_name[M0_XCODE_CURSOR_NR]
M0_INTERNAL int m0_xcode_length(struct m0_xcode_ctx *ctx)
static bool is_pointer(const struct m0_xcode_type *xt, const struct m0_xcode_field *field)
M0_INTERNAL void m0_xcode_union_fini(struct m0_xcode_type *un)
M0_INTERNAL bool m0_xcode_is_byte_array(const struct m0_xcode_type *xt)
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL uint64_t m0_xcode_tag(const struct m0_xcode_obj *obj)
static struct m0_addb2_sit * sit
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_copy(struct m0_bufvec_cursor *dcur, struct m0_bufvec_cursor *scur, m0_bcount_t num_bytes)
const struct m0_xcode_type M0_XT_OPAQUE
static int field(struct ff2c_context *ctx, struct ff2c_term *term)
M0_INTERNAL void m0_xcode_union_add(struct m0_xcode_type *un, const char *name, const struct m0_xcode_type *xt, uint64_t tag)
M0_INTERNAL int m0_xcode_cmp(const struct m0_xcode_obj *o0, const struct m0_xcode_obj *o1)
enum m0_xode_atom_type xct_atype
static struct m0_thread t[8]
const struct m0_xcode_type M0_XT_VOID
static long long max(long long a, long long b)
M0_INTERNAL void m0_bufvec_cursor_init(struct m0_bufvec_cursor *cur, const struct m0_bufvec *bvec)
M0_INTERNAL int m0_xcode_obj_enc_to_buf(struct m0_xcode_obj *obj, void **buf, m0_bcount_t *len)
static struct ff2c_term * alloc(void)
void * m0_alloc(size_t size)
M0_INTERNAL void m0_xcode_union_init(struct m0_xcode_type *un, const char *name, const char *discriminator, size_t maxbranches)
M0_INTERNAL int m0_xcode_next(struct m0_xcode_cursor *it)
static void xcode_flags_check(struct m0_xcode_type *xt, struct flags_data *fd)
bool m0_xcode_type_invariant(const struct m0_xcode_type *xt)
static m0_bindex_t offset
static void __xcode_free(struct m0_xcode_cursor *it)
M0_INTERNAL void * m0_xcode_alloc(struct m0_xcode_cursor *it, size_t nob)
const char * m0_xcode_atom_type_name[M0_XAT_NR]
M0_INTERNAL void m0_xcode_bob_type_init(struct m0_bob_type *bt, const struct m0_xcode_type *xt, size_t magix_field, uint64_t magix)
void m0_xc_u64_init(void)
const char * m0_xcode_aggr_name[M0_XA_NR]
M0_INTERNAL void m0_xcode_free(struct m0_xcode_ctx *ctx)
static bool field_invariant(const struct m0_xcode_type *xt, const struct m0_xcode_field *field)
M0_INTERNAL int m0_xcode_data_size(struct m0_xcode_ctx *ctx, const struct m0_xcode_obj *obj)
M0_INTERNAL uint64_t m0_xcode_atom(const struct m0_xcode_obj *obj)
#define m0_forall(var, nr,...)
static void ** allocp(struct m0_xcode_cursor *it, size_t *out)
const struct m0_xcode_type M0_XT_U32
M0_INTERNAL void m0_xcode_cursor_init(struct m0_xcode_cursor *it, const struct m0_xcode_obj *obj)
static long long min(long long a, long long b)
enum m0_xcode_aggr xct_aggr
M0_INTERNAL int m0_xcode_obj_dec_from_buf(struct m0_xcode_obj *obj, void *buf, m0_bcount_t len)
M0_INTERNAL int m0_xcode_find(struct m0_xcode_obj *obj, const struct m0_xcode_type *xt, void **place)
M0_INTERNAL int m0_xcode_encode(struct m0_xcode_ctx *ctx)
const struct m0_xcode_type M0_XT_U8
M0_INTERNAL void m0_xcode_skip(struct m0_xcode_cursor *it)
struct m0t1fs_filedata * fd
void m0_xc_u32_init(void)
static struct m0_fop_type * ft[]
M0_INTERNAL void m0_xcode_ctx_init(struct m0_xcode_ctx *ctx, const struct m0_xcode_obj *obj)
M0_INTERNAL bool m0_xcode_type_flags(struct m0_xcode_type *xt, uint32_t on, uint32_t off, uint64_t aggr_umask)
const struct m0_xcode_type M0_XT_U64
void m0_xc_opaque_init(void)
struct m0_pdclust_src_addr src
static bool at_array(const struct m0_xcode_cursor *it, const struct m0_xcode_cursor_frame *prev, const struct m0_xcode_obj *par)
static uint64_t m0_align(uint64_t val, uint64_t alignment)
#define M0_IMPOSSIBLE(fmt,...)