From: Olivier Dion Date: Tue, 3 Sep 2024 18:27:58 +0000 (-0400) Subject: Separate API definition from implementation X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=db4b4886239c80c3775315e256d86c67cfcbdcb1;p=libside.git Separate API definition from implementation The new file `' defines the DSL and expands to its implementation in `'. Introduce the following DSL change: identifiers defined by `side_{arg,}_define_{array,struct,vla,enum,variant,optional}' must not be rereferenced with the `&' operator, but simply by their name. Change-Id: I883de215000e10abfbd27c93fddba3bae3abf5b2 Signed-off-by: Olivier Dion Signed-off-by: Mathieu Desnoyers --- diff --git a/include/Makefile.am b/include/Makefile.am index 4ee3831..cb592e7 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -8,6 +8,7 @@ nobase_include_HEADERS = \ side/abi/type-description.h \ side/abi/type-value.h \ side/abi/visitor.h \ + side/api.h \ side/endian.h \ side/instrumentation-c-api.h \ side/macros.h \ diff --git a/include/side/api.h b/include/side/api.h new file mode 100644 index 0000000..569c1d6 --- /dev/null +++ b/include/side/api.h @@ -0,0 +1,568 @@ +// SPDX-License-Identifier: MIT +// SPDX-FileCopyrightText: 2024 EfficiOS Inc. + +#ifndef _SIDE_API_H +#define _SIDE_API_H + +#include + +/* + * This layer defines the expansion of the libside DSL to the targeted + * language. In this case, the C/C++ API. + * + * This intermediate layer allows to redefine the DSL to something else, + * for example when enabling the static checker. + * + * Most of the macros are defined with the form: + * + * #define X _X + * + * However, it is necessary in some cases to define `X' with the form: + * + * #define X(...) _X(__VA_ARGS__) + * + * because of name collisions with other definitions such as structures and + * unions. For example, `side_arg_variant' is a macro when used as a function + * and is struct type name when used as an object. + */ + +/* Misc. */ +#define side_length _side_length + +/* Attributes. */ +#define SIDE_DEFAULT_ATTR SIDE_PARAM_SELECT_ARG1 + +#define side_attr(_name, ...) _side_attr(_name, SIDE_PARAM(__VA_ARGS__)) +#define side_attr_list _side_attr_list +#define side_attr_bool _side_attr_bool +#define side_attr_u8 _side_attr_u8 +#define side_attr_u16 _side_attr_u16 +#define side_attr_u32 _side_attr_u32 +#define side_attr_u64 _side_attr_u64 +#define side_attr_u128 _side_attr_u128 +#define side_attr_s8 _side_attr_s8 +#define side_attr_s16 _side_attr_s16 +#define side_attr_s32 _side_attr_s32 +#define side_attr_s64 _side_attr_s64 +#define side_attr_s128 _side_attr_s128 +#define side_attr_float_binary16 _side_attr_float_binary16 +#define side_attr_float_binary32 _side_attr_float_binary32 +#define side_attr_float_binary64 _side_attr_float_binary64 +#define side_attr_float_binary128 _side_attr_float_binary128 +#define side_attr_string _side_attr_string +#define side_attr_string16 _side_attr_string16 +#define side_attr_string32 _side_attr_string32 + +/* Fields. */ +#define side_field_list _side_field_list +#define side_arg_list _side_arg_list + +#define side_field_null _side_field_null +#define side_arg_null _side_arg_null + +#define side_field_bool _side_field_bool +#define side_arg_bool _side_arg_bool + +#define side_field_byte _side_field_byte +#define side_arg_byte _side_arg_byte + +#define side_field_string _side_field_string +#define side_arg_string _side_arg_string + +#define side_field_string16 _side_field_string16 +#define side_arg_string16 _side_arg_string16 + +#define side_field_string32 _side_field_string32 +#define side_arg_string32 _side_arg_string32 + +#define side_field_string16_le _side_field_string16_le +#define side_arg_string16_le _side_arg_string16_le + +#define side_field_string32_le _side_field_string32_le +#define side_arg_string32_le _side_arg_string32_le + +#define side_field_string16_be _side_field_string16_be +#define side_arg_string16_be _side_arg_string16_be + +#define side_field_string32_be _side_field_string32_be +#define side_arg_string32_be _side_arg_string32_be + +#define side_field_pointer _side_field_pointer +#define side_arg_pointer _side_arg_pointer + +#define side_field_pointer_le _side_field_pointer_le +#define side_arg_pointer_le _side_arg_pointer_le + +#define side_field_pointer_be _side_field_pointer_be +#define side_arg_pointer_be _side_arg_pointer_be + +#define side_field_float_binary16 _side_field_float_binary16 +#define side_arg_float_binary16 _side_arg_float_binary16 + +#define side_field_float_binary32 _side_field_float_binary32 +#define side_arg_float_binary32 _side_arg_float_binary32 + +#define side_field_float_binary64 _side_field_float_binary64 +#define side_arg_float_binary64 _side_arg_float_binary64 + +#define side_field_float_binary128 _side_field_float_binary128 +#define side_arg_float_binary128 _side_arg_float_binary128 + +#define side_field_float_binary16_le _side_field_float_binary16_le +#define side_arg_float_binary16_le _side_arg_float_binary16_le + +#define side_field_float_binary32_le _side_field_float_binary32_le +#define side_arg_float_binary32_le _side_arg_float_binary32_le + +#define side_field_float_binary64_le _side_field_float_binary64_le +#define side_arg_float_binary64_le _side_arg_float_binary64_le + +#define side_field_float_binary128_le _side_field_float_binary128_le +#define side_arg_float_binary128_le _side_arg_float_binary128_le + +#define side_field_float_binary16_be _side_field_float_binary16_be +#define side_arg_float_binary16_be _side_arg_float_binary16_be + +#define side_field_float_binary32_be _side_field_float_binary32_be +#define side_arg_float_binary32_be _side_arg_float_binary32_be + +#define side_field_float_binary64_be _side_field_float_binary64_be +#define side_arg_float_binary64_be _side_arg_float_binary64_be + +#define side_field_float_binary128_be _side_field_float_binary128_be +#define side_arg_float_binary128_be _side_arg_float_binary128_be + +#define side_field_char _side_field_char +#define side_arg_char _side_arg_char + +#define side_field_uchar _side_field_uchar +#define side_arg_uchar _side_arg_uchar + +#define side_field_schar _side_field_schar +#define side_arg_schar _side_arg_schar + +#define side_field_short _side_field_short +#define side_arg_short _side_arg_short + +#define side_field_ushort _side_field_ushort +#define side_arg_ushort _side_arg_ushort + +#define side_field_int _side_field_int +#define side_arg_int _side_arg_int + +#define side_field_uint _side_field_uint +#define side_arg_uint _side_arg_uint + +#define side_field_long _side_field_long +#define side_arg_long _side_arg_long + +#define side_field_ulong _side_field_ulong +#define side_arg_ulong _side_arg_ulong + +#define side_field_long_long _side_field_long_long +#define side_arg_long_long _side_arg_long_long + +#define side_field_ulong_long _side_field_ulong_long +#define side_arg_ulong_long _side_arg_ulong_long + +#define side_field_float _side_field_float +#define side_arg_float _side_arg_float + +#define side_field_double _side_field_double +#define side_arg_double _side_arg_double + +#define side_field_long_double _side_field_long_double +#define side_arg_long_double _side_arg_long_double + +#define side_field_u8 _side_field_u8 +#define side_arg_u8 _side_arg_u8 + +#define side_field_u16 _side_field_u16 +#define side_arg_u16 _side_arg_u16 + +#define side_field_u32 _side_field_u32 +#define side_arg_u32 _side_arg_u32 + +#define side_field_u64 _side_field_u64 +#define side_arg_u64 _side_arg_u64 + +#define side_field_u128 _side_field_u128 +#define side_arg_u128 _side_arg_u128 + +#define side_field_s8 _side_field_s8 +#define side_arg_s8 _side_arg_s8 + +#define side_field_s16 _side_field_s16 +#define side_arg_s16 _side_arg_s16 + +#define side_field_s32 _side_field_s32 +#define side_arg_s32 _side_arg_s32 + +#define side_field_s64 _side_field_s64 +#define side_arg_s64 _side_arg_s64 + +#define side_field_s128 _side_field_s128 +#define side_arg_s128 _side_arg_s128 + +#define side_field_u16_le _side_field_u16_le +#define side_arg_u16_le _side_arg_u16_le + +#define side_field_u32_le _side_field_u32_le +#define side_arg_u32_le _side_arg_u32_le + +#define side_field_u64_le _side_field_u64_le +#define side_arg_u64_le _side_arg_u64_le + +#define side_field_u128_le _side_field_u128_le +#define side_arg_u128_le _side_arg_u128_le + +#define side_field_s8_le _side_field_s8_le +#define side_arg_s8_le _side_arg_s8_le + +#define side_field_s16_le _side_field_s16_le +#define side_arg_s16_le _side_arg_s16_le + +#define side_field_s32_le _side_field_s32_le +#define side_arg_s32_le _side_arg_s32_le + +#define side_field_s64_le _side_field_s64_le +#define side_arg_s64_le _side_arg_s64_le + +#define side_field_s128_le _side_field_s128_le +#define side_arg_s128_le _side_arg_s128_le + +#define side_field_u16_be _side_field_u16_be +#define side_arg_u16_be _side_arg_u16_be + +#define side_field_u32_be _side_field_u32_be +#define side_arg_u32_be _side_arg_u32_be + +#define side_field_u64_be _side_field_u64_be +#define side_arg_u64_be _side_arg_u64_be + +#define side_field_u128_be _side_field_u128_be +#define side_arg_u128_be _side_arg_u128_be + +#define side_field_s8_be _side_field_s8_be +#define side_arg_s8_be _side_arg_s8_be + +#define side_field_s16_be _side_field_s16_be +#define side_arg_s16_be _side_arg_s16_be + +#define side_field_s32_be _side_field_s32_be +#define side_arg_s32_be _side_arg_s32_be + +#define side_field_s64_be _side_field_s64_be +#define side_arg_s64_be _side_arg_s64_be + +#define side_field_s128_be _side_field_s128_be +#define side_arg_s128_be _side_arg_s128_be + +/* Gather. */ +#define side_field_gather_byte _side_field_gather_byte +#define side_arg_gather_byte _side_arg_gather_byte + +#define side_field_gather_bool _side_field_gather_bool +#define side_field_gather_bool_le _side_field_gather_bool_le +#define side_field_gather_bool_be _side_field_gather_bool_be +#define side_arg_gather_bool _side_arg_gather_bool + +#define side_field_gather_unsigned_integer _side_field_gather_unsigned_integer +#define side_field_gather_unsigned_integer_le _side_field_gather_unsigned_integer_le +#define side_field_gather_unsigned_integer_be _side_field_gather_unsigned_integer_be +#define side_field_gather_signed_integer _side_field_gather_signed_integer +#define side_field_gather_signed_integer_le _side_field_gather_signed_integer_le +#define side_field_gather_signed_integer_be _side_field_gather_signed_integer_be +#define side_arg_gather_integer _side_arg_gather_integer + +#define side_field_gather_pointer _side_field_gather_pointer +#define side_field_gather_pointer_le _side_field_gather_pointer_le +#define side_field_gather_pointer_be _side_field_gather_pointer_be +#define side_arg_gather_pointer _side_arg_gather_pointer + +#define side_field_gather_float _side_field_gather_float +#define side_field_gather_float_le _side_field_gather_float_le +#define side_field_gather_float_be _side_field_gather_float_be +#define side_arg_gather_float _side_arg_gather_float + +#define side_field_gather_string _side_field_gather_string +#define side_field_gather_string16 _side_field_gather_string16 +#define side_field_gather_string16_le _side_field_gather_string16_le +#define side_field_gather_string16_be _side_field_gather_string16_be +#define side_field_gather_string32 _side_field_gather_string32 +#define side_field_gather_string32_le _side_field_gather_string32_le +#define side_field_gather_string32_be _side_field_gather_string32_be +#define side_arg_gather_string _side_arg_gather_string + +#define side_field_gather_enum _side_field_gather_enum +#define side_arg_gather_enum _side_arg_gather_enum + +#define side_field_gather_struct _side_field_gather_struct +#define side_arg_gather_struct _side_arg_gather_struct + +#define side_field_gather_array _side_field_gather_array +#define side_arg_gather_array _side_arg_gather_array + +#define side_field_gather_vla _side_field_gather_vla +#define side_arg_gather_vla _side_arg_gather_vla + +/* Dynamic. */ +#define side_unwrap_dynamic_field(_type, _name, _val) \ + _side_arg_dynamic_field(_name, side_unwrap_dynamic(_type, _val)) + +#define side_unwrap_dynamic(_type, _val) \ + _side_arg_dynamic_##_type(_val) + +#define side_field_dynamic _side_field_dynamic + +#define side_arg_dynamic_null _side_arg_dynamic_null +#define side_arg_dynamic_bool _side_arg_dynamic_bool +#define side_arg_dynamic_byte _side_arg_dynamic_byte +#define side_arg_dynamic_string _side_arg_dynamic_string +#define side_arg_dynamic_string16 _side_arg_dynamic_string16 +#define side_arg_dynamic_string16_le _side_arg_dynamic_string16_le +#define side_arg_dynamic_string16_be _side_arg_dynamic_string16_be +#define side_arg_dynamic_string32 _side_arg_dynamic_string32 +#define side_arg_dynamic_string32_le _side_arg_dynamic_string32_le +#define side_arg_dynamic_string32_be _side_arg_dynamic_string32_be +#define side_arg_dynamic_string _side_arg_dynamic_string +#define side_arg_dynamic_string _side_arg_dynamic_string +#define side_arg_dynamic_string _side_arg_dynamic_string +#define side_arg_dynamic_u8 _side_arg_dynamic_u8 +#define side_arg_dynamic_u16 _side_arg_dynamic_u16 +#define side_arg_dynamic_u32 _side_arg_dynamic_u32 +#define side_arg_dynamic_u64 _side_arg_dynamic_u64 +#define side_arg_dynamic_u128 _side_arg_dynamic_u128 +#define side_arg_dynamic_s8 _side_arg_dynamic_s8 +#define side_arg_dynamic_s16 _side_arg_dynamic_s16 +#define side_arg_dynamic_s32 _side_arg_dynamic_s32 +#define side_arg_dynamic_s64 _side_arg_dynamic_s64 +#define side_arg_dynamic_s128 _side_arg_dynamic_s128 +#define side_arg_dynamic_pointer _side_arg_dynamic_pointer +#define side_arg_dynamic_float_binary16 _side_arg_dynamic_float_binary16 +#define side_arg_dynamic_float_binary32 _side_arg_dynamic_float_binary32 +#define side_arg_dynamic_float_binary64 _side_arg_dynamic_float_binary64 +#define side_arg_dynamic_float_binary128 _side_arg_dynamic_float_binary128 +#define side_arg_dynamic_u16_le _side_arg_dynamic_u16_le +#define side_arg_dynamic_u32_le _side_arg_dynamic_u32_le +#define side_arg_dynamic_u64_le _side_arg_dynamic_u64_le +#define side_arg_dynamic_u128_le _side_arg_dynamic_u128_le +#define side_arg_dynamic_s16_le _side_arg_dynamic_s16_le +#define side_arg_dynamic_s32_le _side_arg_dynamic_s32_le +#define side_arg_dynamic_s64_le _side_arg_dynamic_s64_le +#define side_arg_dynamic_s128_le _side_arg_dynamic_s128_le +#define side_arg_dynamic_pointer_le _side_arg_dynamic_pointer_le +#define side_arg_dynamic_float_binary16_le _side_arg_dynamic_float_binary16_le +#define side_arg_dynamic_float_binary32_le _side_arg_dynamic_float_binary32_le +#define side_arg_dynamic_float_binary64_le _side_arg_dynamic_float_binary64_le +#define side_arg_dynamic_float_binary128_le _side_arg_dynamic_float_binary128_le +#define side_arg_dynamic_u16_be _side_arg_dynamic_u16_be +#define side_arg_dynamic_u32_be _side_arg_dynamic_u32_be +#define side_arg_dynamic_u64_be _side_arg_dynamic_u64_be +#define side_arg_dynamic_u128_be _side_arg_dynamic_u16 +#define side_arg_dynamic_s16_be _side_arg_dynamic_s16_be +#define side_arg_dynamic_s32_be _side_arg_dynamic_s32_be +#define side_arg_dynamic_s64_be _side_arg_dynamic_s64_be +#define side_arg_dynamic_s128_be _side_arg_dynamic_s128_be +#define side_arg_dynamic_pointer_be _side_arg_dynamic_pointer_be +#define side_arg_dynamic_float_binary16_be _side_arg_dynamic_float_binary16_be +#define side_arg_dynamic_float_binary32_be _side_arg_dynamic_float_binary32_be +#define side_arg_dynamic_float_binary64_be _side_arg_dynamic_float_binary64_be +#define side_arg_dynamic_float_binary128_be _side_arg_dynamic_float_binary128_be + +#define side_arg_dynamic_field(_name, _elem) _side_arg_dynamic_field(_name, SIDE_PARAM(_elem)) +#define side_arg_dynamic_define_vec _side_arg_dynamic_define_vec +#define side_arg_dynamic_vla(...) _side_arg_dynamic_vla(__VA_ARGS__) + +#define side_arg_dynamic_define_vla_visitor(_identifier, _dynamic_vla_visitor, _ctx, _attr...) \ + _side_arg_dynamic_define_vla_visitor(_identifier, SIDE_PARAM(_dynamic_vla_visitor), _ctx, \ + SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) + +#define side_arg_dynamic_vla_visitor(...) _side_arg_dynamic_vla_visitor(__VA_ARGS__) + +#define side_arg_dynamic_define_struct(_identifier, _struct_fields, _attr...) \ + _side_arg_dynamic_define_struct(_identifier, SIDE_PARAM(_struct_fields), \ + SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) + +#define side_arg_dynamic_struct(...) _side_arg_dynamic_struct(__VA_ARGS__) + + +#define side_arg_dynamic_define_struct_visitor _side_arg_dynamic_define_struct_visitor +#define side_arg_dynamic_struct_visitor(...) _side_arg_dynamic_struct_visitor(__VA_ARGS__) + +/* Element. */ +#define side_elem _side_elem + +/* Enum. */ +#define side_define_enum_bitmap _side_define_enum_bitmap +#define side_field_enum _side_field_enum +#define side_field_enum_bitmap _side_field_enum_bitmap + +/* Types. */ +#define side_type_null(...) _side_type_null(__VA_ARGS__) +#define side_type_bool(...) _side_type_bool(__VA_ARGS__) +#define side_type_byte(...) _side_type_byte(__VA_ARGS__) +#define side_type_string(...) _side_type_string(__VA_ARGS__) +#define side_type_pointer _side_type_pointer +#define side_type_dynamic _side_type_dynamic + +#define side_type_u8 _side_type_u8 +#define side_type_u16 _side_type_u16 +#define side_type_u32 _side_type_u32 +#define side_type_u64 _side_type_u64 +#define side_type_u128 _side_type_u128 +#define side_type_s8 _side_type_s8 +#define side_type_s16 _side_type_s16 +#define side_type_s32 _side_type_s32 +#define side_type_s64 _side_type_s64 +#define side_type_s128 _side_type_s128 +#define side_type_float_binary16 _side_type_float_binary16 +#define side_type_float_binary32 _side_type_float_binary32 +#define side_type_float_binary64 _side_type_float_binary64 +#define side_type_float_binary128 _side_type_float_binary128 +#define side_type_string16 _side_type_string16 +#define side_type_string32 _side_type_string32 + +#define side_type_u16_le _side_type_u16_le +#define side_type_u32_le _side_type_u32_le +#define side_type_u64_le _side_type_u64_le +#define side_type_u128_le _side_type_u128_le +#define side_type_s16_le _side_type_s16_le +#define side_type_s32_le _side_type_s32_le +#define side_type_s64_le _side_type_s64_le +#define side_type_s128_le _side_type_s128_le +#define side_type_float_binary16_le _side_type_float_binary16_le +#define side_type_float_binary32_le _side_type_float_binary32_le +#define side_type_float_binary64_le _side_type_float_binary64_le +#define side_type_float_binary128_le _side_type_float_binary128_le +#define side_type_string16_le _side_type_string16_le +#define side_type_string32_le _side_type_string32_le + +#define side_type_u16_be _side_type_u16_be +#define side_type_u32_be _side_type_u32_be +#define side_type_u64_be _side_type_u64_be +#define side_type_u128_be _side_type_u128_be +#define side_type_s16_be _side_type_s16_be +#define side_type_s32_be _side_type_s32_be +#define side_type_s64_be _side_type_s64_be +#define side_type_s128_be _side_type_s128_be +#define side_type_float_binary16_be _side_type_float_binary16_be +#define side_type_float_binary32_be _side_type_float_binary32_be +#define side_type_float_binary64_be _side_type_float_binary64_be +#define side_type_float_binary128_be _side_type_float_binary128_be +#define side_type_string16_be _side_type_string16_be +#define side_type_string32_be _side_type_string32_be + +#define side_type_gather_byte(...) _side_type_gather_byte(__VA_ARGS__) +#define side_type_gather_bool(...) _side_type_gather_bool(__VA_ARGS__) +#define side_type_gather_bool_le _side_type_gather_bool_le +#define side_type_gather_bool_be _side_type_gather_bool_be +#define side_type_gather_unsigned_integer _side_type_gather_unsigned_integer +#define side_type_gather_unsigned_integer_le _side_type_gather_unsigned_integer_le +#define side_type_gather_unsigned_integer_be _side_type_gather_unsigned_integer_be +#define side_type_gather_signed_integer _side_type_gather_signed_integer +#define side_type_gather_signed_integer_le _side_type_gather_signed_integer_le +#define side_type_gather_signed_integer_be _side_type_gather_signed_integer_be +#define side_type_gather_pointer _side_type_gather_pointer +#define side_type_gather_pointer_le _side_type_gather_pointer_le +#define side_type_gather_pointer_be _side_type_gather_pointer_be +#define side_type_gather_float(...) _side_type_gather_float(__VA_ARGS__) +#define side_type_gather_float_le _side_type_gather_float_le +#define side_type_gather_float_be _side_type_gather_float_be +#define side_type_gather_string(...) _side_type_gather_string(__VA_ARGS__) +#define side_type_gather_string16 _side_type_gather_string16 +#define side_type_gather_string16_le _side_type_gather_string16_le +#define side_type_gather_string16_be _side_type_gather_string16_be +#define side_type_gather_string32 _side_type_gather_string32 +#define side_type_gather_string32_le _side_type_gather_string32_le +#define side_type_gather_string32_be _side_type_gather_string32_be +#define side_type_gather_struct(...) _side_type_gather_struct(__VA_ARGS__) +#define side_type_gather_array(...) _side_type_gather_array(__VA_ARGS__) +#define side_type_gather_vla(...) _side_type_gather_vla(__VA_ARGS__) + +/* Variant. */ +#define side_define_variant _side_define_variant +#define side_arg_define_variant _side_arg_define_variant +#define side_type_variant(_identifier) _identifier +#define side_field_variant _side_field_variant +#define side_arg_variant(...) _side_arg_variant(__VA_ARGS__) +#define side_option_list _side_option_list +#define side_option _side_option +#define side_option_range _side_option_range + +/* Optional */ +#define side_define_optional _side_define_optional +#define side_type_optional(_identifier) &_identifier +#define side_field_optional _side_field_optional +#define side_field_optional_literal _side_field_optional_literal +#define side_arg_optional(_identifier) _side_arg_optional(_identifier) +#define side_arg_define_optional _side_arg_define_optional + +/* Vec. */ +#define side_arg_define_vec _side_arg_define_vec + +/* Array. */ +#define side_arg_define_array _side_arg_define_vec +#define side_define_array _side_define_array +#define side_type_array(_array) _side_type_array(_array) +#define side_field_array _side_field_array +#define side_arg_array _side_arg_array + +/* VLA. */ +#define side_define_vla _side_define_vla +#define side_arg_define_vla _side_arg_define_vec +#define side_type_vla(_vla) _side_type_vla(_vla) +#define side_field_vla _side_field_vla +#define side_arg_vla _side_arg_vla + +/* Struct. */ +#define side_type_struct(_struct) _side_type_struct(_struct) +#define side_field_struct _side_field_struct +#define side_arg_struct _side_arg_struct +#define side_define_struct _side_define_struct +#define side_arg_define_struct _side_arg_define_vec + +/* Visitor. */ +#define side_visit_dynamic_arg(_what, _expr...) _what(_expr) +#define side_visit_dynamic_field(_what, _name, _expr...) _side_arg_dynamic_field(_name, _what(_expr)) + +#define side_define_static_vla_visitor(_identifier, _elem_type, _length_type, _func, _type, _attr...) \ + static enum side_visitor_status _side_vla_visitor_func_##_identifier(const struct side_tracer_visitor_ctx *_side_tracer_ctx, \ + void *_side_ctx) \ + { \ + return _func(_side_tracer_ctx, (_type *)_side_ctx); \ + } \ + static const struct side_type_vla_visitor _identifier = \ + _side_type_vla_visitor_define(SIDE_PARAM(_elem_type), SIDE_PARAM(_length_type), \ + _side_vla_visitor_func_##_identifier, \ + SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())); + +#define side_arg_define_vla_visitor _side_arg_define_vla_visitor + +#define side_type_vla_visitor(...) _side_type_vla_visitor(__VA_ARGS__) + +#define side_field_vla_visitor _side_field_vla_visitor +#define side_arg_vla_visitor(...) _side_arg_vla_visitor(__VA_ARGS__) + + +/* Event. */ +#define side_event_call(_identifier, _sav) \ + _side_event_call(side_call, _identifier, SIDE_PARAM(_sav)) + +#define side_event_call_variadic(_identifier, _sav, _var_fields, _attr...) \ + _side_event_call_variadic(side_call_variadic, _identifier, \ + SIDE_PARAM(_sav), SIDE_PARAM(_var_fields), \ + SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) + +#define side_event _side_event +#define side_event_variadic _side_event_variadic + +#define side_static_event _side_static_event +#define side_static_event_variadic _side_static_event_variadic +#define side_hidden_event _side_hidden_event +#define side_hidden_event_variadic _side_hidden_event_variadic +#define side_export_event _side_export_event +#define side_export_event_variadic _side_export_event_variadic +#define side_declare_event _side_declare_event + +#endif /* _SIDE_API_H */ diff --git a/include/side/instrumentation-c-api.h b/include/side/instrumentation-c-api.h index df33208..20344b0 100644 --- a/include/side/instrumentation-c-api.h +++ b/include/side/instrumentation-c-api.h @@ -28,7 +28,7 @@ /* Event and type attributes */ -#define side_attr(_key, _value) \ +#define _side_attr(_key, _value) \ { \ .key = { \ .p = SIDE_PTR_INIT(_key), \ @@ -38,7 +38,7 @@ .value = SIDE_PARAM(_value), \ } -#define side_attr_list(...) \ +#define _side_attr_list(...) \ SIDE_COMPOUND_LITERAL(const struct side_attr, __VA_ARGS__) /* @@ -79,24 +79,24 @@ #define _side_allocate_static_side_dynamic_attr_list(...) \ SIDE_COMPOUND_LITERAL(const struct side_attr, __VA_ARGS__) -#define side_attr_null(_val) { .type = SIDE_ATTR_TYPE_NULL } -#define side_attr_bool(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_BOOL), .u = { .bool_value = !!(_val) } } -#define side_attr_u8(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U8), .u = { .integer_value = { .side_u8 = (_val) } } } -#define side_attr_u16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U16), .u = { .integer_value = { .side_u16 = (_val) } } } -#define side_attr_u32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U32), .u = { .integer_value = { .side_u32 = (_val) } } } -#define side_attr_u64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U64), .u = { .integer_value = { .side_u64 = (_val) } } } -#define side_attr_u128(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U128), .u = { .integer_value = { .side_u128 = (_val) } } } -#define side_attr_s8(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S8), .u = { .integer_value = { .side_s8 = (_val) } } } -#define side_attr_s16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S16), .u = { .integer_value = { .side_s16 = (_val) } } } -#define side_attr_s32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S32), .u = { .integer_value = { .side_s32 = (_val) } } } -#define side_attr_s64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S64), .u = { .integer_value = { .side_s64 = (_val) } } } -#define side_attr_s128(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S128), .u = { .integer_value = { .side_s128 = (_val) } } } -#define side_attr_float_binary16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY16), .u = { .float_value = { .side_float_binary16 = (_val) } } } -#define side_attr_float_binary32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY32), .u = { .float_value = { .side_float_binary32 = (_val) } } } -#define side_attr_float_binary64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY64), .u = { .float_value = { .side_float_binary64 = (_val) } } } -#define side_attr_float_binary128(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY128), .u = { .float_value = { .side_float_binary128 = (_val) } } } - -#define _side_attr_string(_val, _byte_order, _unit_size) \ +#define _side_attr_null(_val) { .type = SIDE_ATTR_TYPE_NULL } +#define _side_attr_bool(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_BOOL), .u = { .bool_value = !!(_val) } } +#define _side_attr_u8(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U8), .u = { .integer_value = { .side_u8 = (_val) } } } +#define _side_attr_u16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U16), .u = { .integer_value = { .side_u16 = (_val) } } } +#define _side_attr_u32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U32), .u = { .integer_value = { .side_u32 = (_val) } } } +#define _side_attr_u64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U64), .u = { .integer_value = { .side_u64 = (_val) } } } +#define _side_attr_u128(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_U128), .u = { .integer_value = { .side_u128 = (_val) } } } +#define _side_attr_s8(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S8), .u = { .integer_value = { .side_s8 = (_val) } } } +#define _side_attr_s16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S16), .u = { .integer_value = { .side_s16 = (_val) } } } +#define _side_attr_s32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S32), .u = { .integer_value = { .side_s32 = (_val) } } } +#define _side_attr_s64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S64), .u = { .integer_value = { .side_s64 = (_val) } } } +#define _side_attr_s128(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_S128), .u = { .integer_value = { .side_s128 = (_val) } } } +#define _side_attr_float_binary16(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY16), .u = { .float_value = { .side_float_binary16 = (_val) } } } +#define _side_attr_float_binary32(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY32), .u = { .float_value = { .side_float_binary32 = (_val) } } } +#define _side_attr_float_binary64(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY64), .u = { .float_value = { .side_float_binary64 = (_val) } } } +#define _side_attr_float_binary128(_val) { .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_FLOAT_BINARY128), .u = { .float_value = { .side_float_binary128 = (_val) } } } + +#define __side_attr_string(_val, _byte_order, _unit_size) \ { \ .type = SIDE_ENUM_INIT(SIDE_ATTR_TYPE_STRING), \ .u = { \ @@ -108,18 +108,18 @@ }, \ } -#define side_attr_string(_val) _side_attr_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t)) -#define side_attr_string16(_val) _side_attr_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t)) -#define side_attr_string32(_val) _side_attr_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t)) +#define _side_attr_string(_val) __side_attr_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t)) +#define _side_attr_string16(_val) __side_attr_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t)) +#define _side_attr_string32(_val) __side_attr_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t)) /* Stack-copy enumeration type definitions */ #define side_define_enum(_identifier, _mappings, _attr...) \ const struct side_enum_mappings _identifier = { \ .mappings = SIDE_PTR_INIT(_mappings), \ - .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .attr = SIDE_PTR_INIT(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ } #define side_enum_mapping_list(...) \ @@ -147,12 +147,12 @@ }, \ } -#define side_define_enum_bitmap(_identifier, _mappings, _attr...) \ +#define _side_define_enum_bitmap(_identifier, _mappings, _attr...) \ const struct side_enum_bitmap_mappings _identifier = { \ .mappings = SIDE_PTR_INIT(_mappings), \ - .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .attr = SIDE_PTR_INIT(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ } #define side_enum_bitmap_mapping_list(...) \ @@ -182,24 +182,24 @@ /* Stack-copy field and type definitions */ -#define side_type_null(_attr...) \ +#define _side_type_null(_attr...) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_NULL), \ .u = { \ .side_null = { \ - .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .attr = SIDE_PTR_INIT(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ }, \ }, \ } -#define side_type_bool(_attr...) \ +#define _side_type_bool(_attr...) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_BOOL), \ .u = { \ .side_bool = { \ - .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .attr = SIDE_PTR_INIT(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ .bool_size = sizeof(uint8_t), \ .len_bits = 0, \ .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \ @@ -207,18 +207,18 @@ }, \ } -#define side_type_byte(_attr...) \ +#define _side_type_byte(_attr...) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_BYTE), \ .u = { \ .side_byte = { \ - .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .attr = SIDE_PTR_INIT(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ }, \ }, \ } -#define _side_type_string(_type, _byte_order, _unit_size, _attr) \ +#define __side_type_string(_type, _byte_order, _unit_size, _attr) \ { \ .type = SIDE_ENUM_INIT(_type), \ .u = { \ @@ -231,7 +231,7 @@ }, \ } -#define side_type_dynamic() \ +#define _side_type_dynamic() \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC), \ .u = { } \ @@ -271,58 +271,58 @@ .side_type = _type, \ } -#define side_option_range(_range_begin, _range_end, _type) \ +#define _side_option_range(_range_begin, _range_end, _type) \ { \ .range_begin = _range_begin, \ .range_end = _range_end, \ .side_type = _type, \ } -#define side_option(_value, _type) \ - side_option_range(_value, _value, SIDE_PARAM(_type)) +#define _side_option(_value, _type) \ + _side_option_range(_value, _value, SIDE_PARAM(_type)) /* Host endian */ -#define side_type_u8(_attr...) _side_type_integer(SIDE_TYPE_U8, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_u16(_attr...) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_u32(_attr...) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_u64(_attr...) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_u128(_attr...) _side_type_integer(SIDE_TYPE_U128, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(unsigned __int128), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_s8(_attr...) _side_type_integer(SIDE_TYPE_S8, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int8_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_s16(_attr...) _side_type_integer(SIDE_TYPE_S16, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_s32(_attr...) _side_type_integer(SIDE_TYPE_S32, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_s64(_attr...) _side_type_integer(SIDE_TYPE_S64, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_s128(_attr...) _side_type_integer(SIDE_TYPE_S128, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(__int128), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_pointer(_attr...) _side_type_integer(SIDE_TYPE_POINTER, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uintptr_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_float_binary16(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float16), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_float_binary32(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float32), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_float_binary64(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float64), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_float_binary128(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float128), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_string(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF8, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_string16(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF16, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_string32(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF32, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) - -#define side_field_null(_name, _attr...) _side_field(_name, side_type_null(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_bool(_name, _attr...) _side_field(_name, side_type_bool(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_u8(_name, _attr...) _side_field(_name, side_type_u8(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_u16(_name, _attr...) _side_field(_name, side_type_u16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_u32(_name, _attr...) _side_field(_name, side_type_u32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_u64(_name, _attr...) _side_field(_name, side_type_u64(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_u128(_name, _attr...) _side_field(_name, side_type_u128(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_s8(_name, _attr...) _side_field(_name, side_type_s8(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_s16(_name, _attr...) _side_field(_name, side_type_s16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_s32(_name, _attr...) _side_field(_name, side_type_s32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_s64(_name, _attr...) _side_field(_name, side_type_s64(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_s128(_name, _attr...) _side_field(_name, side_type_s128(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_byte(_name, _attr...) _side_field(_name, side_type_byte(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_pointer(_name, _attr...) _side_field(_name, side_type_pointer(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_float_binary16(_name, _attr...) _side_field(_name, side_type_float_binary16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_float_binary32(_name, _attr...) _side_field(_name, side_type_float_binary32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_float_binary64(_name, _attr...) _side_field(_name, side_type_float_binary64(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_float_binary128(_name, _attr...) _side_field(_name, side_type_float_binary128(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_string(_name, _attr...) _side_field(_name, side_type_string(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_string16(_name, _attr...) _side_field(_name, side_type_string16(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_string32(_name, _attr...) _side_field(_name, side_type_string32(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_dynamic(_name) _side_field(_name, side_type_dynamic()) +#define _side_type_u8(_attr...) _side_type_integer(SIDE_TYPE_U8, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_u16(_attr...) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_u32(_attr...) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_u64(_attr...) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint64_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_u128(_attr...) _side_type_integer(SIDE_TYPE_U128, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(unsigned __int128), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_s8(_attr...) _side_type_integer(SIDE_TYPE_S8, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int8_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_s16(_attr...) _side_type_integer(SIDE_TYPE_S16, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int16_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_s32(_attr...) _side_type_integer(SIDE_TYPE_S32, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int32_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_s64(_attr...) _side_type_integer(SIDE_TYPE_S64, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int64_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_s128(_attr...) _side_type_integer(SIDE_TYPE_S128, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(__int128), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_pointer(_attr...) _side_type_integer(SIDE_TYPE_POINTER, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uintptr_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_float_binary16(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float16), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_float_binary32(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float32), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_float_binary64(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float64), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_float_binary128(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float128), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_string(_attr...) __side_type_string(SIDE_TYPE_STRING_UTF8, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_string16(_attr...) __side_type_string(SIDE_TYPE_STRING_UTF16, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_string32(_attr...) __side_type_string(SIDE_TYPE_STRING_UTF32, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) + +#define _side_field_null(_name, _attr...) _side_field(_name, _side_type_null(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_bool(_name, _attr...) _side_field(_name, _side_type_bool(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_u8(_name, _attr...) _side_field(_name, _side_type_u8(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_u16(_name, _attr...) _side_field(_name, _side_type_u16(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_u32(_name, _attr...) _side_field(_name, _side_type_u32(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_u64(_name, _attr...) _side_field(_name, _side_type_u64(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_u128(_name, _attr...) _side_field(_name, _side_type_u128(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_s8(_name, _attr...) _side_field(_name, _side_type_s8(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_s16(_name, _attr...) _side_field(_name, _side_type_s16(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_s32(_name, _attr...) _side_field(_name, _side_type_s32(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_s64(_name, _attr...) _side_field(_name, _side_type_s64(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_s128(_name, _attr...) _side_field(_name, _side_type_s128(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_byte(_name, _attr...) _side_field(_name, _side_type_byte(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_pointer(_name, _attr...) _side_field(_name, _side_type_pointer(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_float_binary16(_name, _attr...) _side_field(_name, _side_type_float_binary16(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_float_binary32(_name, _attr...) _side_field(_name, _side_type_float_binary32(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_float_binary64(_name, _attr...) _side_field(_name, _side_type_float_binary64(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_float_binary128(_name, _attr...) _side_field(_name, _side_type_float_binary128(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_string(_name, _attr...) _side_field(_name, _side_type_string(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_string16(_name, _attr...) _side_field(_name, _side_type_string16(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_string32(_name, _attr...) _side_field(_name, _side_type_string32(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_dynamic(_name) _side_field(_name, _side_type_dynamic()) /* C native types. */ @@ -339,225 +339,225 @@ */ #ifdef __CHAR_UNSIGNED__ -# define side_field_char(_name, _attr...) side_field_uchar(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_char(_args...) side_arg_uchar(_args) +# define _side_field_char(_name, _attr...) _side_field_uchar(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_char(_args...) _side_arg_uchar(_args) #else -# define side_field_char(_name, _attr...) side_field_schar(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_char(_args...) side_arg_schar(_args) +# define _side_field_char(_name, _attr...) _side_field_schar(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_char(_args...) _side_arg_schar(_args) #endif -#define side_field_schar(_name, _attr...) side_field_s8(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_arg_schar(_args...) side_arg_s8(_args) +#define _side_field_schar(_name, _attr...) _side_field_s8(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_arg_schar(_args...) _side_arg_s8(_args) -#define side_field_uchar(_name, _attr...) side_field_u8(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_arg_uchar(_args...) side_arg_u8(_args) +#define _side_field_uchar(_name, _attr...) _side_field_u8(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_arg_uchar(_args...) _side_arg_u8(_args) #if __SIZEOF_SHORT__ <= 2 -# define side_field_short(_name, _attr...) side_field_s16(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_short(_args...) side_arg_s16(_args) -# define side_field_ushort(_name, _attr...) side_field_u16(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_ushort(_args...) side_arg_u16(_args) +# define _side_field_short(_name, _attr...) _side_field_s16(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_short(_args...) _side_arg_s16(_args) +# define _side_field_ushort(_name, _attr...) _side_field_u16(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_ushort(_args...) _side_arg_u16(_args) #elif __SIZEOF_SHORT__ <= 4 -# define side_field_short(_name, _attr...) side_field_s32(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_short(_args...) side_arg_s32(_args) -# define side_field_ushort(_name, _attr...) side_field_u32(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_ushort(_args...) side_arg_u32(_args) +# define _side_field_short(_name, _attr...) _side_field_s32(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_short(_args...) _side_arg_s32(_args) +# define _side_field_ushort(_name, _attr...) _side_field_u32(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_ushort(_args...) _side_arg_u32(_args) #elif __SIZEOF_SHORT__ <= 8 -# define side_field_short(_name, _attr...) side_field_s64(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_short(_args...) side_arg_s64(_args) -# define side_field_ushort(_name, _attr...) side_field_u64(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_ushort(_args...) side_arg_u64(_args) +# define _side_field_short(_name, _attr...) _side_field_s64(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_short(_args...) _side_arg_s64(_args) +# define _side_field_ushort(_name, _attr...) _side_field_u64(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_ushort(_args...) _side_arg_u64(_args) #else -# define side_field_short(...) \ +# define _side_field_short(...) \ side_static_assert(0, "Type `signed short int' is not supported", type__signed_short_int__is_not_supported) -# define side_arg_short(...) \ +# define _side_arg_short(...) \ side_static_assert(0, "Type `signed short int' is not supported", type__signed_short_int__is_not_supported) -# define side_field_ushort(...) \ +# define _side_field_ushort(...) \ side_static_assert(0, "Type `unsigned short int' is not supported", type__unsigned_short_int__is_not_supported) -# define side_arg_ushort(...) \ +# define _side_arg_ushort(...) \ side_static_assert(0, "Type `unsigned short int' is not supported", type__unsigned_short_int__is_not_supported) #endif #if __SIZEOF_INT__ <= 2 -# define side_field_int(_name, _attr...) side_field_s16(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_int(_args...) side_arg_s16(_args) -# define side_field_uint(_name, _attr...) side_field_u16(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_uint(_args...) side_arg_u16(_args) +# define _side_field_int(_name, _attr...) _side_field_s16(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_int(_args...) _side_arg_s16(_args) +# define _side_field_uint(_name, _attr...) _side_field_u16(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_uint(_args...) _side_arg_u16(_args) #elif __SIZEOF_INT__ <= 4 -# define side_field_int(_name, _attr...) side_field_s32(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_int(_args...) side_arg_s32(_args) -# define side_field_uint(_name, _attr...) side_field_u32(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_uint(_args...) side_arg_u32(_args) +# define _side_field_int(_name, _attr...) _side_field_s32(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_int(_args...) _side_arg_s32(_args) +# define _side_field_uint(_name, _attr...) _side_field_u32(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_uint(_args...) _side_arg_u32(_args) #elif __SIZEOF_INT__ <= 8 -# define side_field_int(_name, _attr...) side_field_s64(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_int(_args...) side_arg_s64(_args) -# define side_field_uint(_name, _attr...) side_field_u64(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_uint(_args...) side_arg_u64(_args) +# define _side_field_int(_name, _attr...) _side_field_s64(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_int(_args...) _side_arg_s64(_args) +# define _side_field_uint(_name, _attr...) _side_field_u64(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_uint(_args...) _side_arg_u64(_args) #else -# define side_field_int(...) \ +# define _side_field_int(...) \ side_static_assert(0, "Type `signed int' is not supported", type__signed_int__is_not_supported) -# define side_arg_int(...) \ +# define _side_arg_int(...) \ side_static_assert(0, "Type `signed int' is not supported", type__signed_int__is_not_supported) -# define side_field_uint(...) \ +# define _side_field_uint(...) \ side_static_assert(0, "Type `unsigned int' is not supported", type__unsigned_int__is_not_supported) -# define side_arg_uint(...) \ +# define _side_arg_uint(...) \ side_static_assert(0, "Type `unsigned int' is not supported", type__unsigned_int__is_not_supported) #endif #if __SIZEOF_LONG__ <= 4 -# define side_field_long(_name, _attr...) side_field_s32(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_long(_args...) side_arg_s32(_args) -# define side_field_ulong(_name, _attr...) side_field_u32(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_ulong(_args...) side_arg_u32(_args) +# define _side_field_long(_name, _attr...) _side_field_s32(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_long(_args...) _side_arg_s32(_args) +# define _side_field_ulong(_name, _attr...) _side_field_u32(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_ulong(_args...) _side_arg_u32(_args) #elif __SIZEOF_LONG__ <= 8 -# define side_field_long(_name, _attr...) side_field_s64(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_long(_args...) side_arg_s64(_args) -# define side_field_ulong(_name, _attr...) side_field_u64(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_ulong(_args...) side_arg_u64(_args) +# define _side_field_long(_name, _attr...) _side_field_s64(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_long(_args...) _side_arg_s64(_args) +# define _side_field_ulong(_name, _attr...) _side_field_u64(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_ulong(_args...) _side_arg_u64(_args) #else -# define side_field_long(...) \ +# define _side_field_long(...) \ side_static_assert(0, "Type `signed long int' is not supported", type__signed_long_int__is_not_supported) -# define side_arg_long(...) \ +# define _side_arg_long(...) \ side_static_assert(0, "Type `signed long int' is not supported", type__signed_long_int__is_not_supported) -# define side_field_ulong(...) \ +# define _side_field_ulong(...) \ side_static_assert(0, "Type `unsigned long int' is not supported", type__unsigned_long_int__is_not_supported) -# define side_arg_ulong(...) \ +# define _side_arg_ulong(...) \ side_static_assert(0, "Type `unsigned long int' is not supported", type__unsigned_long_int__is_not_supported) #endif #if __SIZEOF_LONG_LONG__ <= 8 -# define side_field_long_long(_name, _attr...) side_field_s64(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_long_long(_args...) side_arg_s64(_args) -# define side_field_ulong_long(_name, _attr...) side_field_u64(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_ulong_long(_args...) side_arg_u64(_args) +# define _side_field_long_long(_name, _attr...) _side_field_s64(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_long_long(_args...) _side_arg_s64(_args) +# define _side_field_ulong_long(_name, _attr...) _side_field_u64(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_ulong_long(_args...) _side_arg_u64(_args) #else -# define side_field_long_long(...) \ +# define _side_field_long_long(...) \ side_static_assert(0, "Type `signed long long int' is not supported", type__signed_long_long_int__is_not_supported) -# define side_arg_long_long(...) \ +# define _side_arg_long_long(...) \ side_static_assert(0, "Type `signed long long int' is not supported", type__signed_long_long_int__is_not_supported) -# define side_field_long_long(...) \ +# define _side_field_long_long(...) \ side_static_assert(0, "Type `unsigned long long int' is not supported", type__unsigned_long_long_int__is_not_supported) -# define side_arg_long_long(...) \ +# define _side_arg_long_long(...) \ side_static_assert(0, "Type `unsigned long long int' is not supported", type__unsigned_long_long_int__is_not_supported) #endif #if __SIZEOF_FLOAT__ <= 4 && __HAVE_FLOAT32 -# define side_field_float(_name, _attr...) side_field_float_binary32(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_float(_args...) side_arg_float_binary32(_args) +# define _side_field_float(_name, _attr...) _side_field_float_binary32(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_float(_args...) _side_arg_float_binary32(_args) #elif __SIZEOF_FLOAT__ <= 8 && __HAVE_FLOAT64 -# define side_field_float(_name, _attr...) side_field_float_binary64(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_float(_args...) side_arg_float_binary64(_args) +# define _side_field_float(_name, _attr...) _side_field_float_binary64(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_float(_args...) _side_arg_float_binary64(_args) #elif __SIZEOF_FLOAT__ <= 16 && __HAVE_FLOAT128 -# define side_field_float(_name, _attr...) side_field_float_binary128(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_float(_args...) side_arg_float_binary128(_args) +# define _side_field_float(_name, _attr...) _side_field_float_binary128(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_float(_args...) _side_arg_float_binary128(_args) #else -# define side_field_float(...) \ +# define _side_field_float(...) \ side_static_assert(0, "Type `float' is not supported", type__float__is_not_supported) -# define side_arg_float(...) \ +# define _side_arg_float(...) \ side_static_assert(0, "Type `float' is not supported", type__float__is_not_supported) #endif #if __SIZEOF_DOUBLE__ <= 4 && __HAVE_FLOAT32 -# define side_field_double(_name, _attr...) side_field_float_binary32(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_double(_args...) side_arg_float_binary32(_args) +# define _side_field_double(_name, _attr...) _side_field_float_binary32(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_double(_args...) _side_arg_float_binary32(_args) #elif __SIZEOF_DOUBLE__ <= 8 && __HAVE_FLOAT64 -# define side_field_double(_name, _attr...) side_field_float_binary64(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_double(_args...) side_arg_float_binary64(_args) +# define _side_field_double(_name, _attr...) _side_field_float_binary64(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_double(_args...) _side_arg_float_binary64(_args) #elif __SIZEOF_DOUBLE__ <= 16 && __HAVE_FLOAT128 -# define side_field_double(_name, _attr...) side_field_double_binary128(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_double(_args...) side_arg_float_binary128(_args) +# define _side_field_double(_name, _attr...) _side_field_double_binary128(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_double(_args...) _side_arg_float_binary128(_args) #else -# define side_field_double(...) \ +# define _side_field_double(...) \ side_static_assert(0, "Type `double' is not supported", type__double__is_not_supported) -# define side_arg_double(...) \ +# define _side_arg_double(...) \ side_static_assert(0, "Type `double' is not supported", type__double__is_not_supported) #endif #ifdef __SIZEOF_LONG_DOUBLE__ # if __SIZEOF_LONG_DOUBLE__ <= 4 && __HAVE_FLOAT32 -# define side_field_long_double(_name, _attr...) side_field_float_binary32(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_long_double(_args...) side_arg_float_binary32(_args) +# define _side_field_long_double(_name, _attr...) _side_field_float_binary32(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_long_double(_args...) _side_arg_float_binary32(_args) # elif __SIZEOF_LONG_DOUBLE__ <= 8 && __HAVE_FLOAT64 -# define side_field_long_double(_name, _attr...) side_field_float_binary64(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_long_double(_args...) side_arg_float_binary64(_args) +# define _side_field_long_double(_name, _attr...) _side_field_float_binary64(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_long_double(_args...) _side_arg_float_binary64(_args) # elif __SIZEOF_LONG_DOUBLE__ <= 16 && __HAVE_FLOAT128 -# define side_field_long_double(_name, _attr...) side_field_float_binary128(_name, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -# define side_arg_long_double(_args...) side_arg_float_binary128(_args) +# define _side_field_long_double(_name, _attr...) _side_field_float_binary128(_name, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +# define _side_arg_long_double(_args...) _side_arg_float_binary128(_args) # else -# define side_field_long_double(...) \ +# define _side_field_long_double(...) \ side_static_assert(0, "Type `long double' is not supported", type__long_double__is_not_supported) -# define side_arg_long_double(...) \ +# define _side_arg_long_double(...) \ side_static_assert(0, "Type `long double' is not supported", type__long_double__is_not_supported) # endif #endif /* __SIZEOF_LONG_DOUBLE__ */ /* Little endian */ -#define side_type_u16_le(_attr...) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_u32_le(_attr...) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_u64_le(_attr...) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_u128_le(_attr...) _side_type_integer(SIDE_TYPE_U128, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(unsigned __int128), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_s16_le(_attr...) _side_type_integer(SIDE_TYPE_S16, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(int16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_s32_le(_attr...) _side_type_integer(SIDE_TYPE_S32, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(int32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_s64_le(_attr...) _side_type_integer(SIDE_TYPE_S64, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(int64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_s128_le(_attr...) _side_type_integer(SIDE_TYPE_S128, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(__int128), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_pointer_le(_attr...) _side_type_integer(SIDE_TYPE_POINTER, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uintptr_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_float_binary16_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float16), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_float_binary32_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float32), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_float_binary64_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float64), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_float_binary128_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float128), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_string16_le(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF16, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_string32_le(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF32, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) - -#define side_field_u16_le(_name, _attr...) _side_field(_name, side_type_u16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_u32_le(_name, _attr...) _side_field(_name, side_type_u32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_u64_le(_name, _attr...) _side_field(_name, side_type_u64_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_u128_le(_name, _attr...) _side_field(_name, side_type_u128_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_s16_le(_name, _attr...) _side_field(_name, side_type_s16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_s32_le(_name, _attr...) _side_field(_name, side_type_s32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_s64_le(_name, _attr...) _side_field(_name, side_type_s64_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_s128_le(_name, _attr...) _side_field(_name, side_type_s128_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_pointer_le(_name, _attr...) _side_field(_name, side_type_pointer_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_float_binary16_le(_name, _attr...) _side_field(_name, side_type_float_binary16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_float_binary32_le(_name, _attr...) _side_field(_name, side_type_float_binary32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_float_binary64_le(_name, _attr...) _side_field(_name, side_type_float_binary64_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_float_binary128_le(_name, _attr...) _side_field(_name, side_type_float_binary128_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_string16_le(_name, _attr...) _side_field(_name, side_type_string16_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_string32_le(_name, _attr...) _side_field(_name, side_type_string32_le(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) +#define _side_type_u16_le(_attr...) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_u32_le(_attr...) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_u64_le(_attr...) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint64_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_u128_le(_attr...) _side_type_integer(SIDE_TYPE_U128, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(unsigned __int128), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_s16_le(_attr...) _side_type_integer(SIDE_TYPE_S16, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(int16_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_s32_le(_attr...) _side_type_integer(SIDE_TYPE_S32, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(int32_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_s64_le(_attr...) _side_type_integer(SIDE_TYPE_S64, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(int64_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_s128_le(_attr...) _side_type_integer(SIDE_TYPE_S128, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(__int128), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_pointer_le(_attr...) _side_type_integer(SIDE_TYPE_POINTER, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uintptr_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_float_binary16_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float16), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_float_binary32_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float32), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_float_binary64_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float64), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_float_binary128_le(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float128), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_string16_le(_attr...) __side_type_string(SIDE_TYPE_STRING_UTF16, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_string32_le(_attr...) __side_type_string(SIDE_TYPE_STRING_UTF32, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) + +#define _side_field_u16_le(_name, _attr...) _side_field(_name, _side_type_u16_le(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_u32_le(_name, _attr...) _side_field(_name, _side_type_u32_le(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_u64_le(_name, _attr...) _side_field(_name, _side_type_u64_le(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_u128_le(_name, _attr...) _side_field(_name, _side_type_u128_le(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_s16_le(_name, _attr...) _side_field(_name, _side_type_s16_le(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_s32_le(_name, _attr...) _side_field(_name, _side_type_s32_le(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_s64_le(_name, _attr...) _side_field(_name, _side_type_s64_le(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_s128_le(_name, _attr...) _side_field(_name, _side_type_s128_le(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_pointer_le(_name, _attr...) _side_field(_name, _side_type_pointer_le(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_float_binary16_le(_name, _attr...) _side_field(_name, _side_type_float_binary16_le(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_float_binary32_le(_name, _attr...) _side_field(_name, _side_type_float_binary32_le(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_float_binary64_le(_name, _attr...) _side_field(_name, _side_type_float_binary64_le(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_float_binary128_le(_name, _attr...) _side_field(_name, _side_type_float_binary128_le(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_string16_le(_name, _attr...) _side_field(_name, _side_type_string16_le(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_string32_le(_name, _attr...) _side_field(_name, _side_type_string32_le(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) /* Big endian */ -#define side_type_u16_be(_attr...) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_u32_be(_attr...) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_u64_be(_attr...) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_u128_be(_attr...) _side_type_integer(SIDE_TYPE_U128, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(unsigned __int128), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_s16_be(_attr...) _side_type_integer(SIDE_TYPE_S16, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(int16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_s32_be(_attr...) _side_type_integer(SIDE_TYPE_S32, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(int32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_s64_be(_attr...) _side_type_integer(SIDE_TYPE_S64, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(int64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_s128_be(_attr...) _side_type_integer(SIDE_TYPE_S128, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(__int128), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_pointer_be(_attr...) _side_type_integer(SIDE_TYPE_POINTER, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uintptr_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_float_binary16_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float16), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_float_binary32_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float32), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_float_binary64_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float64), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_float_binary128_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float128), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_string16_be(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF16, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_string32_be(_attr...) _side_type_string(SIDE_TYPE_STRING_UTF32, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) - -#define side_field_u16_be(_name, _attr...) _side_field(_name, side_type_u16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_u32_be(_name, _attr...) _side_field(_name, side_type_u32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_u64_be(_name, _attr...) _side_field(_name, side_type_u64_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_u128_be(_name, _attr...) _side_field(_name, side_type_u128_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_s16_be(_name, _attr...) _side_field(_name, side_type_s16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_s32_be(_name, _attr...) _side_field(_name, side_type_s32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_s64_be(_name, _attr...) _side_field(_name, side_type_s64_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_s128_be(_name, _attr...) _side_field(_name, side_type_s128_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_pointer_be(_name, _attr...) _side_field(_name, side_type_pointer_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_float_binary16_be(_name, _attr...) _side_field(_name, side_type_float_binary16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_float_binary32_be(_name, _attr...) _side_field(_name, side_type_float_binary32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_float_binary64_be(_name, _attr...) _side_field(_name, side_type_float_binary64_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_float_binary128_be(_name, _attr...) _side_field(_name, side_type_float_binary128_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_string16_be(_name, _attr...) _side_field(_name, side_type_string16_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_string32_be(_name, _attr...) _side_field(_name, side_type_string32_be(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) - -#define side_type_enum(_mappings, _elem_type) \ +#define _side_type_u16_be(_attr...) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_u32_be(_attr...) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_u64_be(_attr...) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint64_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_u128_be(_attr...) _side_type_integer(SIDE_TYPE_U128, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(unsigned __int128), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_s16_be(_attr...) _side_type_integer(SIDE_TYPE_S16, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(int16_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_s32_be(_attr...) _side_type_integer(SIDE_TYPE_S32, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(int32_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_s64_be(_attr...) _side_type_integer(SIDE_TYPE_S64, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(int64_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_s128_be(_attr...) _side_type_integer(SIDE_TYPE_S128, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(__int128), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_pointer_be(_attr...) _side_type_integer(SIDE_TYPE_POINTER, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uintptr_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_float_binary16_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float16), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_float_binary32_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float32), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_float_binary64_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float64), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_float_binary128_be(_attr...) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float128), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_string16_be(_attr...) __side_type_string(SIDE_TYPE_STRING_UTF16, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_string32_be(_attr...) __side_type_string(SIDE_TYPE_STRING_UTF32, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) + +#define _side_field_u16_be(_name, _attr...) _side_field(_name, _side_type_u16_be(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_u32_be(_name, _attr...) _side_field(_name, _side_type_u32_be(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_u64_be(_name, _attr...) _side_field(_name, _side_type_u64_be(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_u128_be(_name, _attr...) _side_field(_name, _side_type_u128_be(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_s16_be(_name, _attr...) _side_field(_name, _side_type_s16_be(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_s32_be(_name, _attr...) _side_field(_name, _side_type_s32_be(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_s64_be(_name, _attr...) _side_field(_name, _side_type_s64_be(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_s128_be(_name, _attr...) _side_field(_name, _side_type_s128_be(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_pointer_be(_name, _attr...) _side_field(_name, _side_type_pointer_be(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_float_binary16_be(_name, _attr...) _side_field(_name, _side_type_float_binary16_be(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_float_binary32_be(_name, _attr...) _side_field(_name, _side_type_float_binary32_be(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_float_binary64_be(_name, _attr...) _side_field(_name, _side_type_float_binary64_be(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_float_binary128_be(_name, _attr...) _side_field(_name, _side_type_float_binary128_be(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_string16_be(_name, _attr...) _side_field(_name, _side_type_string16_be(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_string32_be(_name, _attr...) _side_field(_name, _side_type_string32_be(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) + +#define _side_type_enum(_mappings, _elem_type) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_ENUM), \ .u = { \ @@ -567,10 +567,10 @@ }, \ }, \ } -#define side_field_enum(_name, _mappings, _elem_type) \ - _side_field(_name, side_type_enum(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type))) +#define _side_field_enum(_name, _mappings, _elem_type) \ + _side_field(_name, _side_type_enum(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type))) -#define side_type_enum_bitmap(_mappings, _elem_type) \ +#define _side_type_enum_bitmap(_mappings, _elem_type) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_ENUM_BITMAP), \ .u = { \ @@ -580,19 +580,19 @@ }, \ }, \ } -#define side_field_enum_bitmap(_name, _mappings, _elem_type) \ - _side_field(_name, side_type_enum_bitmap(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type))) +#define _side_field_enum_bitmap(_name, _mappings, _elem_type) \ + _side_field(_name, _side_type_enum_bitmap(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type))) -#define side_type_struct(_struct) \ +#define _side_type_struct(_struct) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_STRUCT), \ .u = { \ - .side_struct = SIDE_PTR_INIT(_struct), \ + .side_struct = SIDE_PTR_INIT(&_struct), \ }, \ } -#define side_field_struct(_name, _struct) \ - _side_field(_name, side_type_struct(SIDE_PARAM(_struct))) +#define _side_field_struct(_name, _struct) \ + _side_field(_name, _side_type_struct(SIDE_PARAM(_struct))) #define _side_type_struct_define(_fields, _attr) \ { \ @@ -602,22 +602,19 @@ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ } -#define side_define_struct(_identifier, _fields, _attr...) \ - const struct side_type_struct _identifier = _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) +#define _side_define_struct(_identifier, _fields, _attr...) \ + const struct side_type_struct _identifier = _side_type_struct_define(SIDE_PARAM(_fields), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_struct_literal(_fields, _attr...) \ - SIDE_COMPOUND_LITERAL(const struct side_type_struct, \ - _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) - -#define side_type_variant(_variant) \ +#define _side_type_variant(_variant) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_VARIANT), \ .u = { \ .side_variant = SIDE_PTR_INIT(_variant), \ }, \ } -#define side_field_variant(_name, _variant) \ - _side_field(_name, side_type_variant(SIDE_PARAM(_variant))) + +#define _side_field_variant(_name, _variant) \ + _side_field(_name, _side_type_variant(SIDE_PARAM(&_variant))) #define _side_type_variant_define(_selector, _options, _attr) \ { \ @@ -628,44 +625,44 @@ .selector = _selector, \ } -#define side_define_variant(_identifier, _selector, _options, _attr...) \ +#define _side_define_variant(_identifier, _selector, _options, _attr...) \ const struct side_type_variant _identifier = \ - _side_type_variant_define(SIDE_PARAM(_selector), SIDE_PARAM(_options), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + _side_type_variant_define(SIDE_PARAM(_selector), SIDE_PARAM(_options), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) enum { SIDE_OPTIONAL_DISABLED = 0, SIDE_OPTIONAL_ENABLED = 1, }; -#define side_type_optional(_type) \ - { \ - .type = SIDE_ENUM_INIT(SIDE_TYPE_OPTIONAL), \ - .u = { \ - .side_optional = SIDE_PTR_INIT(_type), \ - }, \ +#define _side_type_optional(_optional) \ + { \ + .type = SIDE_ENUM_INIT(SIDE_TYPE_OPTIONAL), \ + .u = { \ + .side_optional = SIDE_PTR_INIT(_optional), \ + }, \ } -#define side_define_optional(_identifier, _type) \ - const struct side_type _identifier = side_type_optional(SIDE_PARAM(_type)) +#define _side_define_optional(_identifier, _elem_type) \ + const struct side_type _identifier = _side_type_optional(SIDE_PARAM(_elem_type)) -#define side_field_optional(_name, _identifier) \ - _side_field(_name, side_type_optional(_identifier)) +#define _side_field_optional(_name, _identifier) \ + _side_field(_name, _side_type_optional(&(_identifier))) -#define side_field_optional_literal(_name, _type) \ - _side_field(_name, side_type_optional(SIDE_PARAM(_type))) +#define _side_field_optional_literal(_name, _elem_type) \ + _side_field(_name, _side_type_optional(SIDE_PARAM(_elem_type))) -#define side_type_array(_array) \ +#define _side_type_array(_array) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_ARRAY), \ .u = { \ - .side_array = SIDE_PTR_INIT(_array) \ + .side_array = SIDE_PTR_INIT(&_array) \ } \ } -#define side_field_array(_name, _array) \ - _side_field(_name, side_type_array(_array)) +#define _side_field_array(_name, _array) \ + _side_field(_name, _side_type_array(_array)) -#define side_define_array(_identifier, _elem_type, _length, _attr...) \ +#define _side_define_array(_identifier, _elem_type, _length, _attr...) \ const struct side_type_array _identifier = { \ .elem_type = SIDE_PTR_INIT(SIDE_PARAM(_elem_type)), \ .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ @@ -673,18 +670,18 @@ enum { .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ } -#define side_type_vla(_vla) \ +#define _side_type_vla(_vla) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA), \ .u = { \ - .side_vla = SIDE_PTR_INIT(_vla), \ + .side_vla = SIDE_PTR_INIT(&_vla), \ }, \ } -#define side_field_vla(_name, _vla) \ - _side_field(_name, side_type_vla(_vla)) +#define _side_field_vla(_name, _vla) \ + _side_field(_name, _side_type_vla(_vla)) -#define side_define_vla(_identifier, _elem_type, _length_type, _attr...) \ +#define _side_define_vla(_identifier, _elem_type, _length_type, _attr...) \ const struct side_type_vla _identifier = { \ .elem_type = SIDE_PTR_INIT(SIDE_PARAM(_elem_type)), \ .length_type = SIDE_PTR_INIT(SIDE_PARAM(_length_type)), \ @@ -697,30 +694,23 @@ enum { .elem_type = SIDE_PTR_INIT(_elem_type), \ .length_type = SIDE_PTR_INIT(_length_type), \ .visitor = SIDE_PTR_INIT(_visitor), \ - .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .attr = SIDE_PTR_INIT(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ } -#define side_define_vla_visitor(_identifier, _elem_type, _length_type, _visitor, _attr...) \ - const struct side_type_struct _identifier = _side_type_struct_define(SIDE_PARAM(_elem_type), SIDE_PARAM(_length_type), SIDE_PARAM(_visitor), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) - -#define side_vla_visitor_literal(_elem_type, _length_type, _visitor, _attr...) \ - SIDE_COMPOUND_LITERAL(const struct side_type_vla_visitor, \ - _side_type_vla_visitor_define(SIDE_PARAM(_elem_type), SIDE_PARAM(_length_type), SIDE_PARAM(_visitor), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) - -#define side_type_vla_visitor(_vla_visitor) \ +#define _side_type_vla_visitor(_vla_visitor) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA_VISITOR), \ .u = { \ - .side_vla_visitor = SIDE_PTR_INIT(_vla_visitor), \ + .side_vla_visitor = SIDE_PTR_INIT(&_vla_visitor), \ }, \ } -#define side_field_vla_visitor(_name, _vla_visitor) \ - _side_field(_name, side_type_vla_visitor(SIDE_PARAM(_vla_visitor))) +#define _side_field_vla_visitor(_name, _vla_visitor) \ + _side_field(_name, _side_type_vla_visitor(SIDE_PARAM(_vla_visitor))) /* Gather field and type definitions */ -#define side_type_gather_byte(_offset, _access_mode, _attr...) \ +#define _side_type_gather_byte(_offset, _access_mode, _attr...) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BYTE), \ .u = { \ @@ -730,18 +720,18 @@ enum { .offset = _offset, \ .access_mode = SIDE_ENUM_INIT(_access_mode), \ .type = { \ - .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .attr = SIDE_PTR_INIT(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ }, \ }, \ }, \ }, \ }, \ } -#define side_field_gather_byte(_name, _offset, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_byte(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) +#define _side_field_gather_byte(_name, _offset, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_byte(_offset, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) -#define _side_type_gather_bool(_byte_order, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ +#define __side_type_gather_bool(_byte_order, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BOOL), \ .u = { \ @@ -752,8 +742,8 @@ enum { .offset_bits = _offset_bits, \ .access_mode = SIDE_ENUM_INIT(_access_mode), \ .type = { \ - .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .attr = SIDE_PTR_INIT(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ .bool_size = _bool_size, \ .len_bits = _len_bits, \ .byte_order = SIDE_ENUM_INIT(_byte_order), \ @@ -763,19 +753,19 @@ enum { }, \ }, \ } -#define side_type_gather_bool(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ - _side_type_gather_bool(SIDE_TYPE_BYTE_ORDER_HOST, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_gather_bool_le(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ - _side_type_gather_bool(SIDE_TYPE_BYTE_ORDER_LE, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_gather_bool_be(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ - _side_type_gather_bool(SIDE_TYPE_BYTE_ORDER_BE, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) +#define _side_type_gather_bool(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ + __side_type_gather_bool(SIDE_TYPE_BYTE_ORDER_HOST, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_gather_bool_le(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ + __side_type_gather_bool(SIDE_TYPE_BYTE_ORDER_LE, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_gather_bool_be(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ + __side_type_gather_bool(SIDE_TYPE_BYTE_ORDER_BE, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_field_gather_bool(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_bool(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))) -#define side_field_gather_bool_le(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_bool_le(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))) -#define side_field_gather_bool_be(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_bool_be(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())))) +#define _side_field_gather_bool(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_bool(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_gather_bool_le(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_bool_le(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_gather_bool_be(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_bool_be(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) #define _side_type_gather_integer(_type, _signedness, _byte_order, _offset, \ _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ @@ -789,8 +779,8 @@ enum { .offset_bits = _offset_bits, \ .access_mode = SIDE_ENUM_INIT(_access_mode), \ .type = { \ - .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .attr = SIDE_PTR_INIT(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ .integer_size = _integer_size, \ .len_bits = _len_bits, \ .signedness = _signedness, \ @@ -802,61 +792,61 @@ enum { }, \ } -#define side_type_gather_unsigned_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ +#define _side_type_gather_unsigned_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, false, SIDE_TYPE_BYTE_ORDER_HOST, \ - _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_gather_signed_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ + _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_gather_signed_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, true, SIDE_TYPE_BYTE_ORDER_HOST, \ - _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_type_gather_unsigned_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ +#define _side_type_gather_unsigned_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, false, SIDE_TYPE_BYTE_ORDER_LE, \ - _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_gather_signed_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ + _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_gather_signed_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, true, SIDE_TYPE_BYTE_ORDER_LE, \ - _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_type_gather_unsigned_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ +#define _side_type_gather_unsigned_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, false, SIDE_TYPE_BYTE_ORDER_BE, \ - _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_gather_signed_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ + _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_gather_signed_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ _side_type_gather_integer(SIDE_TYPE_GATHER_INTEGER, true, SIDE_TYPE_BYTE_ORDER_BE, \ - _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_field_gather_unsigned_integer(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_unsigned_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_gather_signed_integer(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_signed_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) +#define _side_field_gather_unsigned_integer(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_unsigned_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_gather_signed_integer(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_signed_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) -#define side_field_gather_unsigned_integer_le(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_unsigned_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_gather_signed_integer_le(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_signed_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) +#define _side_field_gather_unsigned_integer_le(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_unsigned_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_gather_signed_integer_le(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_signed_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) -#define side_field_gather_unsigned_integer_be(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_unsigned_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_gather_signed_integer_be(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_signed_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) +#define _side_field_gather_unsigned_integer_be(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_unsigned_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_gather_signed_integer_be(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_signed_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) -#define side_type_gather_pointer(_offset, _access_mode, _attr...) \ +#define _side_type_gather_pointer(_offset, _access_mode, _attr...) \ _side_type_gather_integer(SIDE_TYPE_GATHER_POINTER, false, SIDE_TYPE_BYTE_ORDER_HOST, \ - _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_field_gather_pointer(_name, _offset, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_pointer(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) + _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_field_gather_pointer(_name, _offset, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_pointer(_offset, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) -#define side_type_gather_pointer_le(_offset, _access_mode, _attr...) \ +#define _side_type_gather_pointer_le(_offset, _access_mode, _attr...) \ _side_type_gather_integer(SIDE_TYPE_GATHER_POINTER, false, SIDE_TYPE_BYTE_ORDER_LE, \ - _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_field_gather_pointer_le(_name, _offset, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_pointer_le(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) + _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_field_gather_pointer_le(_name, _offset, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_pointer_le(_offset, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) -#define side_type_gather_pointer_be(_offset, _access_mode, _attr...) \ +#define _side_type_gather_pointer_be(_offset, _access_mode, _attr...) \ _side_type_gather_integer(SIDE_TYPE_GATHER_POINTER, false, SIDE_TYPE_BYTE_ORDER_BE, \ - _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_field_gather_pointer_be(_name, _offset, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_pointer_be(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) + _offset, sizeof(uintptr_t), 0, 0, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_field_gather_pointer_be(_name, _offset, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_pointer_be(_offset, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) -#define _side_type_gather_float(_byte_order, _offset, _float_size, _access_mode, _attr...) \ +#define __side_type_gather_float(_byte_order, _offset, _float_size, _access_mode, _attr...) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_FLOAT), \ .u = { \ @@ -866,8 +856,8 @@ enum { .offset = _offset, \ .access_mode = SIDE_ENUM_INIT(_access_mode), \ .type = { \ - .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .attr = SIDE_PTR_INIT(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ .float_size = _float_size, \ .byte_order = SIDE_ENUM_INIT(_byte_order), \ }, \ @@ -877,21 +867,21 @@ enum { }, \ } -#define side_type_gather_float(_offset, _float_size, _access_mode, _attr...) \ - _side_type_gather_float(SIDE_TYPE_FLOAT_WORD_ORDER_HOST, _offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_gather_float_le(_offset, _float_size, _access_mode, _attr...) \ - _side_type_gather_float(SIDE_TYPE_BYTE_ORDER_LE, _offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_gather_float_be(_offset, _float_size, _access_mode, _attr...) \ - _side_type_gather_float(SIDE_TYPE_BYTE_ORDER_BE, _offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) +#define _side_type_gather_float(_offset, _float_size, _access_mode, _attr...) \ + __side_type_gather_float(SIDE_TYPE_FLOAT_WORD_ORDER_HOST, _offset, _float_size, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_gather_float_le(_offset, _float_size, _access_mode, _attr...) \ + __side_type_gather_float(SIDE_TYPE_BYTE_ORDER_LE, _offset, _float_size, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_gather_float_be(_offset, _float_size, _access_mode, _attr...) \ + __side_type_gather_float(SIDE_TYPE_BYTE_ORDER_BE, _offset, _float_size, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_field_gather_float(_name, _offset, _float_size, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_float(_offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_gather_float_le(_name, _offset, _float_size, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_float_le(_offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_gather_float_be(_name, _offset, _float_size, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_float_be(_offset, _float_size, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) +#define _side_field_gather_float(_name, _offset, _float_size, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_float(_offset, _float_size, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_gather_float_le(_name, _offset, _float_size, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_float_le(_offset, _float_size, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_gather_float_be(_name, _offset, _float_size, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_float_be(_offset, _float_size, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) -#define _side_type_gather_string(_offset, _byte_order, _unit_size, _access_mode, _attr...) \ +#define __side_type_gather_string(_offset, _byte_order, _unit_size, _access_mode, _attr...) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRING), \ .u = { \ @@ -901,8 +891,8 @@ enum { .offset = _offset, \ .access_mode = SIDE_ENUM_INIT(_access_mode), \ .type = { \ - .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .attr = SIDE_PTR_INIT(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ .unit_size = _unit_size, \ .byte_order = SIDE_ENUM_INIT(_byte_order), \ }, \ @@ -911,60 +901,60 @@ enum { }, \ }, \ } -#define side_type_gather_string(_offset, _access_mode, _attr...) \ - _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_field_gather_string(_name, _offset, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_string(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) - -#define side_type_gather_string16(_offset, _access_mode, _attr...) \ - _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_gather_string16_le(_offset, _access_mode, _attr...) \ - _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_gather_string16_be(_offset, _access_mode, _attr...) \ - _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) - -#define side_field_gather_string16(_name, _offset, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_string16(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_gather_string16_le(_name, _offset, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_string16_le(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_gather_string16_be(_name, _offset, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_string16_be(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) - -#define side_type_gather_string32(_offset, _access_mode, _attr...) \ - _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_gather_string32_le(_offset, _access_mode, _attr...) \ - _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) -#define side_type_gather_string32_be(_offset, _access_mode, _attr...) \ - _side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) - -#define side_field_gather_string32(_name, _offset, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_string32(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_gather_string32_le(_name, _offset, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_string32_le(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) -#define side_field_gather_string32_be(_name, _offset, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_string32_be(_offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) - -#define side_type_gather_enum(_mappings, _elem_type) \ +#define _side_type_gather_string(_offset, _access_mode, _attr...) \ + __side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_field_gather_string(_name, _offset, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_string(_offset, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) + +#define _side_type_gather_string16(_offset, _access_mode, _attr...) \ + __side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_gather_string16_le(_offset, _access_mode, _attr...) \ + __side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_gather_string16_be(_offset, _access_mode, _attr...) \ + __side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) + +#define _side_field_gather_string16(_name, _offset, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_string16(_offset, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_gather_string16_le(_name, _offset, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_string16_le(_offset, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_gather_string16_be(_name, _offset, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_string16_be(_offset, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) + +#define _side_type_gather_string32(_offset, _access_mode, _attr...) \ + __side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_gather_string32_le(_offset, _access_mode, _attr...) \ + __side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) +#define _side_type_gather_string32_be(_offset, _access_mode, _attr...) \ + __side_type_gather_string(_offset, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) + +#define _side_field_gather_string32(_name, _offset, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_string32(_offset, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_gather_string32_le(_name, _offset, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_string32_le(_offset, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) +#define _side_field_gather_string32_be(_name, _offset, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_string32_be(_offset, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) + +#define _side_type_gather_enum(_mappings, _elem_type) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_ENUM), \ .u = { \ .side_enum = { \ - .mappings = SIDE_PTR_INIT(_mappings), \ + .mappings = SIDE_PTR_INIT(&_mappings), \ .elem_type = SIDE_PTR_INIT(_elem_type), \ }, \ }, \ } -#define side_field_gather_enum(_name, _mappings, _elem_type) \ - _side_field(_name, side_type_gather_enum(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type))) +#define _side_field_gather_enum(_name, _mappings, _elem_type) \ + _side_field(_name, _side_type_gather_enum(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type))) -#define side_type_gather_struct(_struct_gather, _offset, _size, _access_mode) \ +#define _side_type_gather_struct(_struct_gather, _offset, _size, _access_mode) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRUCT), \ .u = { \ .side_gather = { \ .u = { \ .side_struct = { \ - .type = SIDE_PTR_INIT(_struct_gather), \ + .type = SIDE_PTR_INIT(&_struct_gather), \ .offset = _offset, \ .access_mode = SIDE_ENUM_INIT(_access_mode), \ .size = _size, \ @@ -973,10 +963,10 @@ enum { }, \ }, \ } -#define side_field_gather_struct(_name, _struct_gather, _offset, _size, _access_mode) \ - _side_field(_name, side_type_gather_struct(SIDE_PARAM(_struct_gather), _offset, _size, _access_mode)) +#define _side_field_gather_struct(_name, _struct_gather, _offset, _size, _access_mode) \ + _side_field(_name, _side_type_gather_struct(SIDE_PARAM(_struct_gather), _offset, _size, _access_mode)) -#define side_type_gather_array(_elem_type_gather, _length, _offset, _access_mode, _attr...) \ +#define _side_type_gather_array(_elem_type_gather, _length, _offset, _access_mode, _attr...) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_ARRAY), \ .u = { \ @@ -987,19 +977,19 @@ enum { .access_mode = SIDE_ENUM_INIT(_access_mode), \ .type = { \ .elem_type = SIDE_PTR_INIT(_elem_type_gather), \ - .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .attr = SIDE_PTR_INIT(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ .length = _length, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ }, \ }, \ }, \ }, \ }, \ } -#define side_field_gather_array(_name, _elem_type, _length, _offset, _access_mode, _attr...) \ - _side_field(_name, side_type_gather_array(SIDE_PARAM(_elem_type), _length, _offset, _access_mode, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) +#define _side_field_gather_array(_name, _elem_type, _length, _offset, _access_mode, _attr...) \ + _side_field(_name, _side_type_gather_array(SIDE_PARAM(_elem_type), _length, _offset, _access_mode, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) -#define side_type_gather_vla(_elem_type_gather, _offset, _access_mode, _length_type_gather, _attr...) \ +#define _side_type_gather_vla(_elem_type_gather, _offset, _access_mode, _length_type_gather, _attr...) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_VLA), \ .u = { \ @@ -1011,104 +1001,105 @@ enum { .type = { \ .elem_type = SIDE_PTR_INIT(_elem_type_gather), \ .length_type = SIDE_PTR_INIT(_length_type_gather), \ - .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .attr = SIDE_PTR_INIT(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ }, \ }, \ }, \ }, \ }, \ } -#define side_field_gather_vla(_name, _elem_type_gather, _offset, _access_mode, _length_type_gather, _attr...) \ - _side_field(_name, side_type_gather_vla(SIDE_PARAM(_elem_type_gather), _offset, _access_mode, SIDE_PARAM(_length_type_gather), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list()))) +#define _side_field_gather_vla(_name, _elem_type_gather, _offset, _access_mode, _length_type_gather, _attr...) \ + _side_field(_name, _side_type_gather_vla(SIDE_PARAM(_elem_type_gather), _offset, _access_mode, SIDE_PARAM(_length_type_gather), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list()))) -#define side_elem(...) \ +#define _side_elem(...) \ SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__) -#define side_length(...) \ +#define _side_length(...) \ SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__) -#define side_field_list(...) \ +#define _side_field_list(...) \ SIDE_COMPOUND_LITERAL(const struct side_event_field, __VA_ARGS__) -#define side_option_list(...) \ +#define _side_option_list(...) \ SIDE_COMPOUND_LITERAL(const struct side_variant_option, __VA_ARGS__) /* Stack-copy field arguments */ -#define side_arg_null(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_NULL), .flags = 0, .u = { .side_static = { } } } -#define side_arg_bool(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_BOOL), .flags = 0, .u = { .side_static = { .bool_value = { .side_bool8 = !!(_val) } } } } -#define side_arg_byte(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_BYTE), .flags = 0, .u = { .side_static = { .byte_value = (_val) } } } -#define side_arg_string(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF8), .flags = 0, .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } } -#define side_arg_string16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF16), .flags = 0, .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } } -#define side_arg_string32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF32), .flags = 0, .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } } - -#define side_arg_u8(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U8), .flags = 0, .u = { .side_static = { .integer_value = { .side_u8 = (_val) } } } } -#define side_arg_u16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U16), .flags = 0, .u = { .side_static = { .integer_value = { .side_u16 = (_val) } } } } -#define side_arg_u32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U32), .flags = 0, .u = { .side_static = { .integer_value = { .side_u32 = (_val) } } } } -#define side_arg_u64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U64), .flags = 0, .u = { .side_static = { .integer_value = { .side_u64 = (_val) } } } } -#define side_arg_u128(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U128), .flags = 0, .u = { .side_static = { .integer_value = { .side_u128 = (_val) } } } } -#define side_arg_s8(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S8), .flags = 0, .u = { .side_static = { .integer_value = { .side_s8 = (_val) } } } } -#define side_arg_s16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S16), .flags = 0, .u = { .side_static = { .integer_value = { .side_s16 = (_val) } } } } -#define side_arg_s32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S32), .flags = 0, .u = { .side_static = { .integer_value = { .side_s32 = (_val) } } } } -#define side_arg_s64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S64), .flags = 0, .u = { .side_static = { .integer_value = { .side_s64 = (_val) } } } } -#define side_arg_s128(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S128), .flags = 0, .u = { .side_static = { .integer_value = { .side_s128 = (_val) } } } } -#define side_arg_pointer(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_POINTER), .flags = 0, .u = { .side_static = { .integer_value = { .side_uptr = (uintptr_t) (_val) } } } } -#define side_arg_float_binary16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY16), .flags = 0, .u = { .side_static = { .float_value = { .side_float_binary16 = (_val) } } } } -#define side_arg_float_binary32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY32), .flags = 0, .u = { .side_static = { .float_value = { .side_float_binary32 = (_val) } } } } -#define side_arg_float_binary64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY64), .flags = 0, .u = { .side_static = { .float_value = { .side_float_binary64 = (_val) } } } } -#define side_arg_float_binary128(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY128), .flags = 0, .u = { .side_static = { .float_value = { .side_float_binary128 = (_val) } } } } - -#define side_arg_struct(_side_type) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRUCT), .flags = 0, .u = { .side_static = { .side_struct = SIDE_PTR_INIT(_side_type) } } } - -#define side_arg_define_variant(_identifier, _selector_val, _option) \ +#define _side_arg_null(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_NULL), .flags = 0, .u = { .side_static = { } } } +#define _side_arg_bool(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_BOOL), .flags = 0, .u = { .side_static = { .bool_value = { .side_bool8 = !!(_val) } } } } +#define _side_arg_byte(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_BYTE), .flags = 0, .u = { .side_static = { .byte_value = (_val) } } } +#define _side_arg_string(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF8), .flags = 0, .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } } +#define _side_arg_string16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF16), .flags = 0, .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } } +#define _side_arg_string32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRING_UTF32), .flags = 0, .u = { .side_static = { .string_value = SIDE_PTR_INIT(_val) } } } + +#define _side_arg_u8(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U8), .flags = 0, .u = { .side_static = { .integer_value = { .side_u8 = (_val) } } } } +#define _side_arg_u16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U16), .flags = 0, .u = { .side_static = { .integer_value = { .side_u16 = (_val) } } } } +#define _side_arg_u32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U32), .flags = 0, .u = { .side_static = { .integer_value = { .side_u32 = (_val) } } } } +#define _side_arg_u64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U64), .flags = 0, .u = { .side_static = { .integer_value = { .side_u64 = (_val) } } } } +#define _side_arg_u128(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_U128), .flags = 0, .u = { .side_static = { .integer_value = { .side_u128 = (_val) } } } } +#define _side_arg_s8(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S8), .flags = 0, .u = { .side_static = { .integer_value = { .side_s8 = (_val) } } } } +#define _side_arg_s16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S16), .flags = 0, .u = { .side_static = { .integer_value = { .side_s16 = (_val) } } } } +#define _side_arg_s32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S32), .flags = 0, .u = { .side_static = { .integer_value = { .side_s32 = (_val) } } } } +#define _side_arg_s64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S64), .flags = 0, .u = { .side_static = { .integer_value = { .side_s64 = (_val) } } } } +#define _side_arg_s128(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_S128), .flags = 0, .u = { .side_static = { .integer_value = { .side_s128 = (_val) } } } } +#define _side_arg_pointer(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_POINTER), .flags = 0, .u = { .side_static = { .integer_value = { .side_uptr = (uintptr_t) (_val) } } } } +#define _side_arg_float_binary16(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY16), .flags = 0, .u = { .side_static = { .float_value = { .side_float_binary16 = (_val) } } } } +#define _side_arg_float_binary32(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY32), .flags = 0, .u = { .side_static = { .float_value = { .side_float_binary32 = (_val) } } } } +#define _side_arg_float_binary64(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY64), .flags = 0, .u = { .side_static = { .float_value = { .side_float_binary64 = (_val) } } } } +#define _side_arg_float_binary128(_val) { .type = SIDE_ENUM_INIT(SIDE_TYPE_FLOAT_BINARY128), .flags = 0, .u = { .side_static = { .float_value = { .side_float_binary128 = (_val) } } } } + +#define _side_arg_struct(_side_type) { .type = SIDE_ENUM_INIT(SIDE_TYPE_STRUCT), .flags = 0, .u = { .side_static = { .side_struct = SIDE_PTR_INIT(&_side_type) } } } + +#define _side_arg_define_variant(_identifier, _selector_val, _option) \ const struct side_arg_variant _identifier = { \ .selector = _selector_val, \ .option = _option, \ } -#define side_arg_variant(_side_variant) \ + +#define _side_arg_variant(_side_variant) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_VARIANT), \ .flags = 0, \ .u = { \ .side_static = { \ - .side_variant = SIDE_PTR_INIT(_side_variant), \ + .side_variant = SIDE_PTR_INIT(&_side_variant), \ }, \ }, \ } - -#define side_arg_define_optional(_identifier, _value, _selector) \ +#define _side_arg_define_optional(_identifier, _value, _selector) \ const struct side_arg_optional _identifier = { \ .side_static = _value, \ .selector = _selector, \ } -#define side_arg_optional(_identifier) \ +#define _side_arg_optional(_identifier) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_OPTIONAL), \ .flags = 0, \ .u = { \ .side_static = { \ - .side_optional = SIDE_PTR_INIT(_identifier) \ + .side_optional = SIDE_PTR_INIT(&(_identifier)), \ }, \ }, \ } -#define side_arg_array(_side_type) { .type = SIDE_ENUM_INIT(SIDE_TYPE_ARRAY), .flags = 0, .u = { .side_static = { .side_array = SIDE_PTR_INIT(_side_type) } } } -#define side_arg_vla(_side_type) { .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA), .flags = 0, .u = { .side_static = { .side_vla = SIDE_PTR_INIT(_side_type) } } } -#define side_arg_vla_visitor(_side_vla_visitor) \ +#define _side_arg_array(_side_type) { .type = SIDE_ENUM_INIT(SIDE_TYPE_ARRAY), .flags = 0, .u = { .side_static = { .side_array = SIDE_PTR_INIT(&_side_type) } } } + +#define _side_arg_vla(_side_type) { .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA), .flags = 0, .u = { .side_static = { .side_vla = SIDE_PTR_INIT(&_side_type) } } } +#define _side_arg_vla_visitor(_side_vla_visitor) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_VLA_VISITOR), \ .flags = 0, \ .u = { \ .side_static = { \ - .side_vla_visitor = SIDE_PTR_INIT(_side_vla_visitor), \ + .side_vla_visitor = SIDE_PTR_INIT(&_side_vla_visitor), \ } \ } \ } -#define side_arg_define_vla_visitor(_identifier, _ctx) \ +#define _side_arg_define_vla_visitor(_identifier, _ctx) \ struct side_arg_vla_visitor _identifier = { \ .app_ctx = SIDE_PTR_INIT(_ctx), \ .cached_arg = SIDE_PTR_INIT(NULL), \ @@ -1116,33 +1107,33 @@ enum { /* Gather field arguments */ -#define side_arg_gather_bool(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BOOL), .flags = 0, .u = { .side_static = { .side_bool_gather_ptr = SIDE_PTR_INIT(_ptr) } } } -#define side_arg_gather_byte(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BYTE), .flags = 0, .u = { .side_static = { .side_byte_gather_ptr = SIDE_PTR_INIT(_ptr) } } } -#define side_arg_gather_pointer(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_POINTER), .flags = 0, .u = { .side_static = { .side_integer_gather_ptr = SIDE_PTR_INIT(_ptr) } } } -#define side_arg_gather_integer(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_INTEGER), .flags = 0, .u = { .side_static = { .side_integer_gather_ptr = SIDE_PTR_INIT(_ptr) } } } -#define side_arg_gather_float(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_FLOAT), .flags = 0, .u = { .side_static = { .side_float_gather_ptr = SIDE_PTR_INIT(_ptr) } } } -#define side_arg_gather_string(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRING), .flags = 0, .u = { .side_static = { .side_string_gather_ptr = SIDE_PTR_INIT(_ptr) } } } -#define side_arg_gather_struct(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRUCT), .flags = 0, .u = { .side_static = { .side_struct_gather_ptr = SIDE_PTR_INIT(_ptr) } } } -#define side_arg_gather_array(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_ARRAY), .flags = 0, .u = { .side_static = { .side_array_gather_ptr = SIDE_PTR_INIT(_ptr) } } } -#define side_arg_gather_vla(_ptr, _length_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_VLA), .flags = 0, .u = { .side_static = { .side_vla_gather = { .ptr = SIDE_PTR_INIT(_ptr), .length_ptr = SIDE_PTR_INIT(_length_ptr) } } } } +#define _side_arg_gather_bool(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BOOL), .flags = 0, .u = { .side_static = { .side_bool_gather_ptr = SIDE_PTR_INIT(_ptr) } } } +#define _side_arg_gather_byte(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_BYTE), .flags = 0, .u = { .side_static = { .side_byte_gather_ptr = SIDE_PTR_INIT(_ptr) } } } +#define _side_arg_gather_pointer(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_POINTER), .flags = 0, .u = { .side_static = { .side_integer_gather_ptr = SIDE_PTR_INIT(_ptr) } } } +#define _side_arg_gather_integer(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_INTEGER), .flags = 0, .u = { .side_static = { .side_integer_gather_ptr = SIDE_PTR_INIT(_ptr) } } } +#define _side_arg_gather_float(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_FLOAT), .flags = 0, .u = { .side_static = { .side_float_gather_ptr = SIDE_PTR_INIT(_ptr) } } } +#define _side_arg_gather_string(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRING), .flags = 0, .u = { .side_static = { .side_string_gather_ptr = SIDE_PTR_INIT(_ptr) } } } +#define _side_arg_gather_struct(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_STRUCT), .flags = 0, .u = { .side_static = { .side_struct_gather_ptr = SIDE_PTR_INIT(_ptr) } } } +#define _side_arg_gather_array(_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_ARRAY), .flags = 0, .u = { .side_static = { .side_array_gather_ptr = SIDE_PTR_INIT(_ptr) } } } +#define _side_arg_gather_vla(_ptr, _length_ptr) { .type = SIDE_ENUM_INIT(SIDE_TYPE_GATHER_VLA), .flags = 0, .u = { .side_static = { .side_vla_gather = { .ptr = SIDE_PTR_INIT(_ptr), .length_ptr = SIDE_PTR_INIT(_length_ptr) } } } } /* Dynamic field arguments */ -#define side_arg_dynamic_null(_attr...) \ +#define _side_arg_dynamic_null(_attr...) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_NULL), \ .flags = 0, \ .u = { \ .side_dynamic = { \ .side_null = { \ - .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ }, \ }, \ }, \ } -#define side_arg_dynamic_bool(_val, _attr...) \ +#define _side_arg_dynamic_bool(_val, _attr...) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_BOOL), \ .flags = 0, \ @@ -1150,8 +1141,8 @@ enum { .side_dynamic = { \ .side_bool = { \ .type = { \ - .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ .bool_size = sizeof(uint8_t), \ .len_bits = 0, \ .byte_order = SIDE_ENUM_INIT(SIDE_TYPE_BYTE_ORDER_HOST), \ @@ -1164,7 +1155,7 @@ enum { }, \ } -#define side_arg_dynamic_byte(_val, _attr...) \ +#define _side_arg_dynamic_byte(_val, _attr...) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_BYTE), \ .flags = 0, \ @@ -1172,8 +1163,8 @@ enum { .side_dynamic = { \ .side_byte = { \ .type = { \ - .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ }, \ .value = (_val), \ }, \ @@ -1181,7 +1172,7 @@ enum { }, \ } -#define _side_arg_dynamic_string(_val, _byte_order, _unit_size, _attr...) \ +#define __side_arg_dynamic_string(_val, _byte_order, _unit_size, _attr...) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRING), \ .flags = 0, \ @@ -1189,8 +1180,8 @@ enum { .side_dynamic = { \ .side_string = { \ .type = { \ - .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ .unit_size = _unit_size, \ .byte_order = SIDE_ENUM_INIT(_byte_order), \ }, \ @@ -1199,20 +1190,21 @@ enum { }, \ }, \ } -#define side_arg_dynamic_string(_val, _attr...) \ - _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_string16(_val, _attr...) \ -63u _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_string16_le(_val, _attr...) \ - _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_string16_be(_val, _attr...) \ - _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_string32(_val, _attr...) \ - _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_string32_le(_val, _attr...) \ - _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_string32_be(_val, _attr...) \ - _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) + +#define _side_arg_dynamic_string(_val, _attr...) \ + __side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_string16(_val, _attr...) \ + __side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_string16_le(_val, _attr...) \ + __side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_string16_be(_val, _attr...) \ + __side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_string32(_val, _attr...) \ + __side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_string32_le(_val, _attr...) \ + __side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_string32_be(_val, _attr...) \ + __side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) #define _side_arg_dynamic_integer(_field, _val, _type, _signedness, _byte_order, _integer_size, _len_bits, _attr...) \ { \ @@ -1222,8 +1214,8 @@ enum { .side_dynamic = { \ .side_integer = { \ .type = { \ - .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ .integer_size = _integer_size, \ .len_bits = _len_bits, \ .signedness = _signedness, \ @@ -1237,34 +1229,34 @@ enum { }, \ } -#define side_arg_dynamic_u8(_val, _attr...) \ - _side_arg_dynamic_integer(.side_u8, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_s8(_val, _attr...) \ - _side_arg_dynamic_integer(.side_s8, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int8_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) - -#define _side_arg_dynamic_u16(_val, _byte_order, _attr...) \ - _side_arg_dynamic_integer(.side_u16, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(uint16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define _side_arg_dynamic_u32(_val, _byte_order, _attr...) \ - _side_arg_dynamic_integer(.side_u32, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(uint32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define _side_arg_dynamic_u64(_val, _byte_order, _attr...) \ - _side_arg_dynamic_integer(.side_u64, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(uint64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define _side_arg_dynamic_u128(_val, _byte_order, _attr...) \ - _side_arg_dynamic_integer(.side_u128, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(unsigned __int128), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) - -#define _side_arg_dynamic_s16(_val, _byte_order, _attr...) \ - _side_arg_dynamic_integer(.side_s16, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(int16_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define _side_arg_dynamic_s32(_val, _byte_order, _attr...) \ - _side_arg_dynamic_integer(.side_s32, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(int32_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define _side_arg_dynamic_s64(_val, _byte_order, _attr...) \ - _side_arg_dynamic_integer(.side_s64, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(int64_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define _side_arg_dynamic_s128(_val, _byte_order, _attr...) \ - _side_arg_dynamic_integer(.side_s128, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(__int128), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) - -#define _side_arg_dynamic_pointer(_val, _byte_order, _attr...) \ +#define _side_arg_dynamic_u8(_val, _attr...) \ + _side_arg_dynamic_integer(.side_u8, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_s8(_val, _attr...) \ + _side_arg_dynamic_integer(.side_s8, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int8_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) + +#define __side_arg_dynamic_u16(_val, _byte_order, _attr...) \ + _side_arg_dynamic_integer(.side_u16, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(uint16_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define __side_arg_dynamic_u32(_val, _byte_order, _attr...) \ + _side_arg_dynamic_integer(.side_u32, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(uint32_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define __side_arg_dynamic_u64(_val, _byte_order, _attr...) \ + _side_arg_dynamic_integer(.side_u64, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(uint64_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define __side_arg_dynamic_u128(_val, _byte_order, _attr...) \ + _side_arg_dynamic_integer(.side_u128, _val, SIDE_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(unsigned __int128), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) + +#define __side_arg_dynamic_s16(_val, _byte_order, _attr...) \ + _side_arg_dynamic_integer(.side_s16, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(int16_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define __side_arg_dynamic_s32(_val, _byte_order, _attr...) \ + _side_arg_dynamic_integer(.side_s32, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(int32_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define __side_arg_dynamic_s64(_val, _byte_order, _attr...) \ + _side_arg_dynamic_integer(.side_s64, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(int64_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define __side_arg_dynamic_s128(_val, _byte_order, _attr...) \ + _side_arg_dynamic_integer(.side_s128, _val, SIDE_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(__int128), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) + +#define __side_arg_dynamic_pointer(_val, _byte_order, _attr...) \ _side_arg_dynamic_integer(.side_uptr, (uintptr_t) (_val), SIDE_TYPE_DYNAMIC_POINTER, false, _byte_order, \ - sizeof(uintptr_t), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) + sizeof(uintptr_t), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) -#define _side_arg_dynamic_float(_field, _val, _type, _byte_order, _float_size, _attr...) \ +#define __side_arg_dynamic_float(_field, _val, _type, _byte_order, _float_size, _attr...) \ { \ .type = SIDE_ENUM_INIT(_type), \ .flags = 0, \ @@ -1272,8 +1264,8 @@ enum { .side_dynamic = { \ .side_float = { \ .type = { \ - .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ .float_size = _float_size, \ .byte_order = SIDE_ENUM_INIT(_byte_order), \ }, \ @@ -1285,61 +1277,61 @@ enum { }, \ } -#define _side_arg_dynamic_float_binary16(_val, _byte_order, _attr...) \ - _side_arg_dynamic_float(.side_float_binary16, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float16), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define _side_arg_dynamic_float_binary32(_val, _byte_order, _attr...) \ - _side_arg_dynamic_float(.side_float_binary32, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float32), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define _side_arg_dynamic_float_binary64(_val, _byte_order, _attr...) \ - _side_arg_dynamic_float(.side_float_binary64, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float64), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define _side_arg_dynamic_float_binary128(_val, _byte_order, _attr...) \ - _side_arg_dynamic_float(.side_float_binary128, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float128), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) +#define __side_arg_dynamic_float_binary16(_val, _byte_order, _attr...) \ + __side_arg_dynamic_float(.side_float_binary16, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float16), SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define __side_arg_dynamic_float_binary32(_val, _byte_order, _attr...) \ + __side_arg_dynamic_float(.side_float_binary32, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float32), SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define __side_arg_dynamic_float_binary64(_val, _byte_order, _attr...) \ + __side_arg_dynamic_float(.side_float_binary64, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float64), SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define __side_arg_dynamic_float_binary128(_val, _byte_order, _attr...) \ + __side_arg_dynamic_float(.side_float_binary128, _val, SIDE_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float128), SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) /* Host endian */ -#define side_arg_dynamic_u16(_val, _attr...) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_u32(_val, _attr...) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_u64(_val, _attr...) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_u128(_val, _attr...) _side_arg_dynamic_u128(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_s16(_val, _attr...) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_s32(_val, _attr...) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_s64(_val, _attr...) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_s128(_val, _attr...) _side_arg_dynamic_s128(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_pointer(_val, _attr...) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_float_binary16(_val, _attr...) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_float_binary32(_val, _attr...) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_float_binary64(_val, _attr...) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_float_binary128(_val, _attr...) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_u16(_val, _attr...) __side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_u32(_val, _attr...) __side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_u64(_val, _attr...) __side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_u128(_val, _attr...) __side_arg_dynamic_u128(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_s16(_val, _attr...) __side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_s32(_val, _attr...) __side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_s64(_val, _attr...) __side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_s128(_val, _attr...) __side_arg_dynamic_s128(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_pointer(_val, _attr...) __side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_float_binary16(_val, _attr...) __side_arg_dynamic_float_binary16(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_float_binary32(_val, _attr...) __side_arg_dynamic_float_binary32(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_float_binary64(_val, _attr...) __side_arg_dynamic_float_binary64(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_float_binary128(_val, _attr...) __side_arg_dynamic_float_binary128(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) /* Little endian */ -#define side_arg_dynamic_u16_le(_val, _attr...) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_u32_le(_val, _attr...) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_u64_le(_val, _attr...) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_u128_le(_val, _attr...) _side_arg_dynamic_u128(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_s16_le(_val, _attr...) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_s32_le(_val, _attr...) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_s64_le(_val, _attr...) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_s128_le(_val, _attr...) _side_arg_dynamic_s128(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_pointer_le(_val, _attr...) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_float_binary16_le(_val, _attr...) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_float_binary32_le(_val, _attr...) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_float_binary64_le(_val, _attr...) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_float_binary128_le(_val, _attr...) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_u16_le(_val, _attr...) __side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_u32_le(_val, _attr...) __side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_u64_le(_val, _attr...) __side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_u128_le(_val, _attr...) __side_arg_dynamic_u128(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_s16_le(_val, _attr...) __side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_s32_le(_val, _attr...) __side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_s64_le(_val, _attr...) __side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_s128_le(_val, _attr...) __side_arg_dynamic_s128(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_pointer_le(_val, _attr...) __side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_float_binary16_le(_val, _attr...) __side_arg_dynamic_float_binary16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_float_binary32_le(_val, _attr...) __side_arg_dynamic_float_binary32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_float_binary64_le(_val, _attr...) __side_arg_dynamic_float_binary64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_float_binary128_le(_val, _attr...) __side_arg_dynamic_float_binary128(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) /* Big endian */ -#define side_arg_dynamic_u16_be(_val, _attr...) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_u32_be(_val, _attr...) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_u64_be(_val, _attr...) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_u128_be(_val, _attr...) _side_arg_dynamic_u128(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_s16_be(_val, _attr...) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_s32_be(_val, _attr...) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_s64_be(_val, _attr...) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_s128_be(_val, _attr...) _side_arg_dynamic_s128(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_pointer_be(_val, _attr...) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_float_binary16_be(_val, _attr...) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_float_binary32_be(_val, _attr...) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_float_binary64_be(_val, _attr...) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) -#define side_arg_dynamic_float_binary128_be(_val, _attr...) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) - -#define side_arg_dynamic_vla(_vla) \ +#define _side_arg_dynamic_u16_be(_val, _attr...) __side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_u32_be(_val, _attr...) __side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_u64_be(_val, _attr...) __side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_u128_be(_val, _attr...) _side_arg_dynamic_u128(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_s16_be(_val, _attr...) __side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_s32_be(_val, _attr...) __side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_s64_be(_val, _attr...) __side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_s128_be(_val, _attr...) __side_arg_dynamic_s128(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_pointer_be(_val, _attr...) __side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_float_binary16_be(_val, _attr...) __side_arg_dynamic_float_binary16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_float_binary32_be(_val, _attr...) __side_arg_dynamic_float_binary32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_float_binary64_be(_val, _attr...) __side_arg_dynamic_float_binary64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) +#define _side_arg_dynamic_float_binary128_be(_val, _attr...) __side_arg_dynamic_float_binary128(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) + +#define _side_arg_dynamic_vla(_vla) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_VLA), \ .flags = 0, \ @@ -1350,18 +1342,18 @@ enum { }, \ } -#define side_arg_dynamic_vla_visitor(_dynamic_vla_visitor) \ +#define _side_arg_dynamic_vla_visitor(_dynamic_vla_visitor) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_VLA_VISITOR), \ .flags = 0, \ .u = { \ .side_dynamic = { \ - .side_dynamic_vla_visitor = SIDE_PTR_INIT(_dynamic_vla_visitor), \ + .side_dynamic_vla_visitor = SIDE_PTR_INIT(&_dynamic_vla_visitor), \ }, \ }, \ } -#define side_arg_dynamic_struct(_struct) \ +#define _side_arg_dynamic_struct(_struct) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRUCT), \ .flags = 0, \ @@ -1372,7 +1364,7 @@ enum { }, \ } -#define side_arg_dynamic_struct_visitor(_dynamic_struct_visitor) \ +#define _side_arg_dynamic_struct_visitor(_dynamic_struct_visitor) \ { \ .type = SIDE_ENUM_INIT(SIDE_TYPE_DYNAMIC_STRUCT_VISITOR), \ .flags = 0, \ @@ -1383,50 +1375,50 @@ enum { }, \ } -#define side_arg_dynamic_define_vec(_identifier, _sav, _attr...) \ +#define _side_arg_dynamic_define_vec(_identifier, _sav, _attr...) \ const struct side_arg _identifier##_vec[] = { _sav }; \ const struct side_arg_dynamic_vla _identifier = { \ .sav = SIDE_PTR_INIT(_identifier##_vec), \ - .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ .len = SIDE_ARRAY_SIZE(_identifier##_vec), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ } -#define side_arg_dynamic_define_struct(_identifier, _struct_fields, _attr...) \ +#define _side_arg_dynamic_define_struct(_identifier, _struct_fields, _attr...) \ const struct side_arg_dynamic_field _identifier##_fields[] = { _struct_fields }; \ const struct side_arg_dynamic_struct _identifier = { \ .fields = SIDE_PTR_INIT(_identifier##_fields), \ - .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ .len = SIDE_ARRAY_SIZE(_identifier##_fields), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ } -#define side_arg_dynamic_define_struct_visitor(_identifier, _dynamic_struct_visitor, _ctx, _attr...) \ +#define _side_arg_dynamic_define_struct_visitor(_identifier, _dynamic_struct_visitor, _ctx, _attr...) \ struct side_arg_dynamic_struct_visitor _identifier = { \ .visitor = SIDE_PTR_INIT(_dynamic_struct_visitor), \ .app_ctx = SIDE_PTR_INIT(_ctx), \ - .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ .cached_arg = SIDE_PTR_INIT(NULL), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ } -#define side_arg_dynamic_define_vla_visitor(_identifier, _dynamic_vla_visitor, _ctx, _attr...) \ +#define _side_arg_dynamic_define_vla_visitor(_identifier, _dynamic_vla_visitor, _ctx, _attr...) \ struct side_arg_dynamic_vla_visitor _identifier = { \ .visitor = SIDE_PTR_INIT(_dynamic_vla_visitor), \ .app_ctx = SIDE_PTR_INIT(_ctx), \ - .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ .cached_arg = SIDE_PTR_INIT(NULL), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ } -#define side_arg_define_vec(_identifier, _sav) \ +#define _side_arg_define_vec(_identifier, _sav) \ const struct side_arg _identifier##_vec[] = { _sav }; \ const struct side_arg_vec _identifier = { \ .sav = SIDE_PTR_INIT(_identifier##_vec), \ .len = SIDE_ARRAY_SIZE(_identifier##_vec), \ } -#define side_arg_dynamic_field(_name, _elem) \ +#define _side_arg_dynamic_field(_name, _elem) \ { \ .field_name = SIDE_PTR_INIT(_name), \ .elem = _elem, \ @@ -1437,12 +1429,22 @@ enum { * check, and instrumentation invocation. */ -#define side_arg_list(...) __VA_ARGS__ +#define _side_arg_list(...) __VA_ARGS__ #define side_event_enabled(_identifier) \ side_unlikely(__atomic_load_n(&side_event_state__##_identifier.enabled, \ __ATOMIC_RELAXED)) +#define _side_event(_identifier, _sav) \ + if (side_event_enabled(_identifier)) \ + _side_event_call(side_call, _identifier, SIDE_PARAM(_sav)) + +#define _side_event_variadic(_identifier, _sav, _var, _attr...) \ + if (side_event_enabled(_identifier)) \ + _side_event_call_variadic(side_call_variadic, _identifier, \ + SIDE_PARAM(_sav), SIDE_PARAM(_var), \ + SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list())) + #define _side_event_call(_call, _identifier, _sav) \ { \ const struct side_arg side_sav[] = { _sav }; \ @@ -1453,13 +1455,6 @@ enum { _call(&(side_event_state__##_identifier).parent, &side_arg_vec); \ } -#define side_event_call(_identifier, _sav) \ - _side_event_call(side_call, _identifier, SIDE_PARAM(_sav)) - -#define side_event(_identifier, _sav) \ - if (side_event_enabled(_identifier)) \ - side_event_call(_identifier, SIDE_PARAM(_sav)) - #define _side_event_call_variadic(_call, _identifier, _sav, _var_fields, _attr...) \ { \ const struct side_arg side_sav[] = { _sav }; \ @@ -1470,22 +1465,13 @@ enum { const struct side_arg_dynamic_field side_fields[] = { _var_fields }; \ const struct side_arg_dynamic_struct var_struct = { \ .fields = SIDE_PTR_INIT(side_fields), \ - .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .attr = SIDE_PTR_INIT(SIDE_CAT2(_side_allocate_dynamic_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ .len = SIDE_ARRAY_SIZE(side_fields), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list()))), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_CAT2(_side_allocate_static_, SIDE_DEFAULT_ATTR(_, ##_attr, side_dynamic_attr_list()))), \ }; \ _call(&(side_event_state__##_identifier.parent), &side_arg_vec, &var_struct); \ } -#define side_event_call_variadic(_identifier, _sav, _var_fields, _attr...) \ - _side_event_call_variadic(side_call_variadic, _identifier, SIDE_PARAM(_sav), SIDE_PARAM(_var_fields), \ - SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) - -#define side_event_variadic(_identifier, _sav, _var, _attr...) \ - if (side_event_enabled(_identifier)) \ - side_event_call_variadic(_identifier, SIDE_PARAM(_sav), SIDE_PARAM(_var), \ - SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_dynamic_attr_list())) - #define _side_statedump_event_call(_call, _identifier, _key, _sav) \ { \ const struct side_arg side_sav[] = { _sav }; \ @@ -1517,7 +1503,7 @@ enum { } #define side_statedump_event_call_variadic(_identifier, _key, _sav, _var_fields, _attr...) \ - _side_statedump_event_call_variadic(side_statedump_call_variadic, _identifier, _key, SIDE_PARAM(_sav), SIDE_PARAM(_var_fields), SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + _side_statedump_event_call_variadic(side_statedump_call_variadic, _identifier, _key, SIDE_PARAM(_sav), SIDE_PARAM(_var_fields), SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) /* @@ -1554,13 +1540,13 @@ enum { .provider_name = SIDE_PTR_INIT(_provider), \ .event_name = SIDE_PTR_INIT(_event), \ .fields = SIDE_PTR_INIT(_fields), \ - .attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .attr = SIDE_PTR_INIT(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ .flags = (_flags), \ .nr_side_type_label = _NR_SIDE_TYPE_LABEL, \ .nr_side_attr_type = _NR_SIDE_ATTR_TYPE, \ .loglevel = SIDE_ENUM_INIT(_loglevel), \ .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())), \ .end = {} \ }; \ static const struct side_event_description __attribute__((section("side_event_description_ptr"), used)) \ @@ -1575,68 +1561,68 @@ enum { #define _side_cxx_define_event(_namespace, _linkage, _identifier, _provider, _event, _loglevel, _fields, _flags, _attr...) \ _namespace { \ _side_define_event(extern, _linkage, _identifier, _provider, _event, _loglevel, \ - SIDE_PARAM(_fields), _flags, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())); \ + SIDE_PARAM(_fields), _flags, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())); \ } -#define side_static_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ +#define _side_static_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ _side_cxx_define_event(namespace, , _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \ - 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_static_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ +#define _side_static_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ _side_cxx_define_event(namespace, , _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \ - SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + SIDE_EVENT_FLAG_VARIADIC, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_hidden_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ +#define _side_hidden_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ _side_cxx_define_event(extern "C", __attribute__((visibility("hidden"))), _identifier, _provider, _event, \ - _loglevel, SIDE_PARAM(_fields), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + _loglevel, SIDE_PARAM(_fields), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_hidden_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ +#define _side_hidden_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ _side_cxx_define_event(extern "C", __attribute__((visibility("hidden"))), _identifier, _provider, _event, \ - _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_export_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ +#define _side_export_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ _side_cxx_define_event(extern "C", __attribute__((visibility("default"))), _identifier, _provider, _event, \ - _loglevel, SIDE_PARAM(_fields), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + _loglevel, SIDE_PARAM(_fields), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_export_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ +#define _side_export_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ _side_cxx_define_event(extern "C", __attribute__((visibility("default"))), _identifier, _provider, _event, \ - _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_declare_event(_identifier) \ +#define _side_declare_event(_identifier) \ extern "C" struct side_event_description _identifier; \ extern "C" struct side_event_state_0 side_event_state_##_identifier #else - - -#define side_static_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ +#define _side_static_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ _side_define_event(static, static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \ - 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_static_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ +#define _side_static_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ _side_define_event(static, static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \ - SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + SIDE_EVENT_FLAG_VARIADIC, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_hidden_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ +#define _side_hidden_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ _side_define_event(__attribute__((visibility("hidden"))), __attribute__((visibility("hidden"))), \ - _identifier, _provider, _event, \ - _loglevel, SIDE_PARAM(_fields), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + _identifier, _provider, _event, \ + _loglevel, SIDE_PARAM(_fields), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_hidden_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ +#define _side_hidden_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ _side_define_event(__attribute__((visibility("hidden"))), __attribute__((visibility("hidden"))), \ - _identifier, _provider, _event, \ - _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + _identifier, _provider, _event, \ + _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, \ + SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_export_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ +#define _side_export_event(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ _side_define_event(__attribute__((visibility("default"))), __attribute__((visibility("default"))), \ - _identifier, _provider, _event, \ - _loglevel, SIDE_PARAM(_fields), 0, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + _identifier, _provider, _event, \ + _loglevel, SIDE_PARAM(_fields), 0, SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_export_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ +#define _side_export_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr...) \ _side_define_event(__attribute__((visibility("default"))), __attribute__((visibility("default"))), \ - _identifier, _provider, _event, \ - _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())) + _identifier, _provider, _event, \ + _loglevel, SIDE_PARAM(_fields), SIDE_EVENT_FLAG_VARIADIC, \ + SIDE_DEFAULT_ATTR(_, ##_attr, side_attr_list())) -#define side_declare_event(_identifier) \ +#define _side_declare_event(_identifier) \ extern struct side_event_state_0 side_event_state_##_identifier; \ extern struct side_event_description _identifier #endif /* __cplusplus */ diff --git a/include/side/trace.h b/include/side/trace.h index 4b6ab3f..7863d63 100644 --- a/include/side/trace.h +++ b/include/side/trace.h @@ -38,7 +38,7 @@ #include #include -#include +#include enum side_error { SIDE_ERROR_OK = 0, diff --git a/tests/unit/test.c b/tests/unit/test.c index e93f7e6..43971b3 100644 --- a/tests/unit/test.c +++ b/tests/unit/test.c @@ -69,29 +69,6 @@ void test_event_export(void) side_event(my_provider_event_export, side_arg_list(side_arg_u32(2))); } -side_static_event(my_provider_event_struct_literal, "myprovider", "myeventstructliteral", SIDE_LOGLEVEL_DEBUG, - side_field_list( - side_field_struct("structliteral", - side_struct_literal( - side_field_list( - side_field_u32("x"), - side_field_s64("y"), - ) - ) - ), - side_field_u8("z"), - ) -); - -static -void test_struct_literal(void) -{ - if (side_event_enabled(my_provider_event_struct_literal)) { - side_arg_define_vec(mystruct, side_arg_list(side_arg_u32(21), side_arg_s64(22))); - side_event_call(my_provider_event_struct_literal, side_arg_list(side_arg_struct(&mystruct), side_arg_u8(55))); - } -} - static side_define_struct(mystructdef, side_field_list( side_field_u32("x"), @@ -101,7 +78,7 @@ static side_define_struct(mystructdef, side_static_event(my_provider_event_struct, "myprovider", "myeventstruct", SIDE_LOGLEVEL_DEBUG, side_field_list( - side_field_struct("struct", &mystructdef), + side_field_struct("struct", mystructdef), side_field_u8("z"), ) ); @@ -110,8 +87,8 @@ static void test_struct(void) { if (side_event_enabled(my_provider_event_struct)) { - side_arg_define_vec(mystruct, side_arg_list(side_arg_u32(21), side_arg_s64(22))); - side_event_call(my_provider_event_struct, side_arg_list(side_arg_struct(&mystruct), side_arg_u8(55))); + side_arg_define_struct(mystruct, side_arg_list(side_arg_u32(21), side_arg_s64(22))); + side_event_call(my_provider_event_struct, side_arg_list(side_arg_struct(mystruct), side_arg_u8(55))); } } @@ -122,7 +99,7 @@ static side_define_array(my_array_u32_3, side_static_event(my_provider_event_array, "myprovider", "myarray", SIDE_LOGLEVEL_DEBUG, side_field_list( - side_field_array("arr", &my_array_u32_3), + side_field_array("arr", my_array_u32_3), side_field_s64("v"), ) ); @@ -131,8 +108,8 @@ static void test_array(void) { if (side_event_enabled(my_provider_event_array)) { - side_arg_define_vec(myarray, side_arg_list(side_arg_u32(1), side_arg_u32(2), side_arg_u32(3))); - side_event_call(my_provider_event_array, side_arg_list(side_arg_array(&myarray), side_arg_s64(42))); + side_arg_define_array(myarray, side_arg_list(side_arg_u32(1), side_arg_u32(2), side_arg_u32(3))); + side_event_call(my_provider_event_array, side_arg_list(side_arg_array(myarray), side_arg_s64(42))); } } @@ -143,7 +120,7 @@ static side_define_vla(my_vla_u32, side_static_event(my_provider_event_vla, "myprovider", "myvla", SIDE_LOGLEVEL_DEBUG, side_field_list( - side_field_vla("vla", &my_vla_u32), + side_field_vla("vla", my_vla_u32), side_field_s64("v"), ) ); @@ -152,26 +129,24 @@ static void test_vla(void) { if (side_event_enabled(my_provider_event_vla)) { - side_arg_define_vec(myvla, side_arg_list(side_arg_u32(1), side_arg_u32(2), side_arg_u32(3))); - side_event_call(my_provider_event_vla, side_arg_list(side_arg_vla(&myvla), side_arg_s64(42))); + side_arg_define_vla(myvla, side_arg_list(side_arg_u32(1), side_arg_u32(2), side_arg_u32(3))); + side_event_call(my_provider_event_vla, side_arg_list(side_arg_vla(myvla), side_arg_s64(42))); } } /* 1D array visitor */ - struct app_visitor_ctx { const uint32_t *ptr; uint32_t length; }; static -enum side_visitor_status test_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) +enum side_visitor_status test_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, struct app_visitor_ctx *ctx) { - struct app_visitor_ctx *ctx = (struct app_visitor_ctx *) _ctx; uint32_t length = ctx->length, i; for (i = 0; i < length; i++) { - const struct side_arg elem = side_arg_u32(ctx->ptr[i]); + const struct side_arg elem = side_visit_dynamic_arg(side_arg_u32, ctx->ptr[i]); if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) return SIDE_VISITOR_STATUS_ERROR; @@ -181,15 +156,13 @@ enum side_visitor_status test_visitor(const struct side_tracer_visitor_ctx *trac static uint32_t testarray[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; +side_define_static_vla_visitor(my_vla_visitor_1d, + side_elem(side_type_u32()), side_elem(side_type_u32()), + test_visitor, struct app_visitor_ctx); + side_static_event(my_provider_event_vla_visitor, "myprovider", "myvlavisit", SIDE_LOGLEVEL_DEBUG, side_field_list( - side_field_vla_visitor("vlavisit", - side_vla_visitor_literal( - side_elem(side_type_u32()), - side_elem(side_type_u32()), - test_visitor - ) - ), + side_field_vla_visitor("vlavisit", my_vla_visitor_1d), side_field_s64("v"), ) ); @@ -204,7 +177,7 @@ void test_vla_visitor(void) }; side_arg_define_vla_visitor(side_visitor, &ctx); side_event_call(my_provider_event_vla_visitor, - side_arg_list(side_arg_vla_visitor(&side_visitor), side_arg_s64(42))); + side_arg_list(side_arg_vla_visitor(side_visitor), side_arg_s64(42))); } } @@ -216,13 +189,13 @@ struct app_visitor_2d_inner_ctx { }; static -enum side_visitor_status test_inner_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) +enum side_visitor_status test_inner_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, + struct app_visitor_2d_inner_ctx *ctx) { - struct app_visitor_2d_inner_ctx *ctx = (struct app_visitor_2d_inner_ctx *) _ctx; uint32_t length = ctx->length, i; for (i = 0; i < length; i++) { - const struct side_arg elem = side_arg_u32(ctx->ptr[i]); + const struct side_arg elem = side_visit_dynamic_arg(side_arg_u32, ctx->ptr[i]); if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) return SIDE_VISITOR_STATUS_ERROR; @@ -230,15 +203,19 @@ enum side_visitor_status test_inner_visitor(const struct side_tracer_visitor_ctx return SIDE_VISITOR_STATUS_OK; } +side_define_static_vla_visitor(my_vla_visitor_2d_inner, + side_elem(side_type_u32()), side_elem(side_type_u32()), + test_inner_visitor, struct app_visitor_2d_inner_ctx); + struct app_visitor_2d_outer_ctx { const uint32_t (*ptr)[2]; uint32_t length; }; static -enum side_visitor_status test_outer_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) +enum side_visitor_status test_outer_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, + struct app_visitor_2d_outer_ctx *ctx) { - struct app_visitor_2d_outer_ctx *ctx = (struct app_visitor_2d_outer_ctx *) _ctx; uint32_t length = ctx->length, i; for (i = 0; i < length; i++) { @@ -247,13 +224,17 @@ enum side_visitor_status test_outer_visitor(const struct side_tracer_visitor_ctx .length = 2, }; side_arg_define_vla_visitor(side_inner_visitor, &inner_ctx); - const struct side_arg elem = side_arg_vla_visitor(&side_inner_visitor); + const struct side_arg elem = side_visit_dynamic_arg(side_arg_vla_visitor, side_inner_visitor); if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) return SIDE_VISITOR_STATUS_ERROR; } return SIDE_VISITOR_STATUS_OK; } +side_define_static_vla_visitor(my_vla_visitor_2d_outer, + side_elem(side_type_vla_visitor(my_vla_visitor_2d_inner)), side_elem(side_type_u32()), + test_outer_visitor, struct app_visitor_2d_outer_ctx); + static uint32_t testarray2d[][2] = { { 1, 2 }, { 33, 44 }, @@ -262,21 +243,7 @@ static uint32_t testarray2d[][2] = { side_static_event(my_provider_event_vla_visitor2d, "myprovider", "myvlavisit2d", SIDE_LOGLEVEL_DEBUG, side_field_list( - side_field_vla_visitor("vlavisit2d", - side_vla_visitor_literal( - side_elem( - side_type_vla_visitor( - side_vla_visitor_literal( - side_elem(side_type_u32()), - side_elem(side_type_u32()), - test_inner_visitor - ) - ) - ), - side_elem(side_type_u32()), - test_outer_visitor - ) - ), + side_field_vla_visitor("vlavisit2d", my_vla_visitor_2d_outer), side_field_s64("v"), ) ); @@ -291,7 +258,7 @@ void test_vla_visitor_2d(void) }; side_arg_define_vla_visitor(side_outer_visitor, &ctx); side_event_call(my_provider_event_vla_visitor2d, - side_arg_list(side_arg_vla_visitor(&side_outer_visitor), side_arg_s64(42))); + side_arg_list(side_arg_vla_visitor(side_outer_visitor), side_arg_s64(42))); } } @@ -608,7 +575,7 @@ enum side_visitor_status test_dynamic_vla_visitor(const struct side_tracer_visit uint32_t length = ctx->length, i; for (i = 0; i < length; i++) { - const struct side_arg elem = side_arg_dynamic_u32(ctx->ptr[i]); + const struct side_arg elem = side_visit_dynamic_arg(side_arg_dynamic_u32, ctx->ptr[i]); if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) return SIDE_VISITOR_STATUS_ERROR; } @@ -628,7 +595,7 @@ void test_dynamic_vla_with_visitor(void) side_arg_dynamic_define_vla_visitor(myvlavisitor, test_dynamic_vla_visitor, &ctx); side_event_call(my_provider_event_dynamic_vla_visitor, side_arg_list( - side_arg_dynamic_vla_visitor(&myvlavisitor) + side_arg_dynamic_vla_visitor(myvlavisitor) ) ); } @@ -658,9 +625,7 @@ enum side_visitor_status test_dynamic_struct_visitor(const struct side_tracer_dy uint32_t length = ctx->length, i; for (i = 0; i < length; i++) { - struct side_arg_dynamic_field dynamic_field = - side_arg_dynamic_field(ctx->ptr[i].name, - side_arg_dynamic_u32(ctx->ptr[i].value)); + struct side_arg_dynamic_field dynamic_field = side_visit_dynamic_field(side_arg_dynamic_u32, ctx->ptr[i].name, ctx->ptr[i].value); if (tracer_ctx->write_field(tracer_ctx, &dynamic_field) != SIDE_VISITOR_STATUS_OK) return SIDE_VISITOR_STATUS_ERROR; } @@ -822,7 +787,7 @@ void test_variadic_struct_attr(void) side_event_call_variadic(my_provider_event_variadic_struct_attr, side_arg_list(), side_arg_list( - side_arg_dynamic_field("a", side_arg_dynamic_struct(&mystruct)), + side_arg_dynamic_field("my-field", side_arg_dynamic_struct(&mystruct)), ) ); } @@ -1104,7 +1069,7 @@ static side_define_enum_bitmap(myenum_bitmap, ) ); -static side_define_array(my_array_u32_5, +static side_define_array(my_array_u32_5_for_bitmap, side_elem(side_type_u32()), 5 ); @@ -1125,10 +1090,8 @@ side_static_event(my_provider_event_enum_bitmap, "myprovider", "myeventenumbitma side_field_enum_bitmap("bit_63", &myenum_bitmap, side_elem(side_type_u64())), side_field_enum_bitmap("bits_1+63", &myenum_bitmap, side_elem(side_type_u64())), side_field_enum_bitmap("byte_bit_2", &myenum_bitmap, side_elem(side_type_byte())), - side_field_enum_bitmap("bit_159", &myenum_bitmap, - side_elem(side_type_array(&my_array_u32_5))), - side_field_enum_bitmap("bit_159", &myenum_bitmap, - side_elem(side_type_vla(&my_vla_u32_for_bitmap))), + side_field_enum_bitmap("bit_159", &myenum_bitmap, side_elem(side_type_array(my_array_u32_5_for_bitmap))), + side_field_enum_bitmap("bit_159", &myenum_bitmap, side_elem(side_type_vla(my_vla_u32_for_bitmap))), side_field_enum_bitmap("bit_2_be", &myenum_bitmap, side_elem(side_type_u32_be())), side_field_enum_bitmap("bit_2_le", &myenum_bitmap, side_elem(side_type_u32_le())), ) @@ -1138,7 +1101,7 @@ static void test_enum_bitmap(void) { if (side_event_enabled(my_provider_event_enum_bitmap)) { - side_arg_define_vec(myarray, + side_arg_define_array(myarray, side_arg_list( side_arg_u32(0), side_arg_u32(0), @@ -1147,6 +1110,12 @@ void test_enum_bitmap(void) side_arg_u32(0x80000000), /* bit 159 */ ) ); + side_arg_define_vla(myvla, + side_arg_list( + side_arg_u32(0x80000000) + ) + ); + side_event_call(my_provider_event_enum_bitmap, side_arg_list( side_arg_u32(1U << 0), @@ -1158,8 +1127,8 @@ void test_enum_bitmap(void) side_arg_u64(1ULL << 63), side_arg_u64((1ULL << 1) | (1ULL << 63)), side_arg_byte(1U << 2), - side_arg_array(&myarray), - side_arg_vla(&myarray), + side_arg_array(myarray), + side_arg_vla(myvla), #if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN side_arg_u32(side_bswap_32(1U << 2)), side_arg_u32(1U << 2), @@ -1180,7 +1149,7 @@ static side_define_array(my_array_byte, side_static_event_variadic(my_provider_event_blob, "myprovider", "myeventblob", SIDE_LOGLEVEL_DEBUG, side_field_list( side_field_byte("blobfield"), - side_field_array("arrayblob", &my_array_byte), + side_field_array("arrayblob", my_array_byte), ) ); @@ -1188,7 +1157,7 @@ static void test_blob(void) { if (side_event_enabled(my_provider_event_blob)) { - side_arg_define_vec(myarray, side_arg_list(side_arg_byte(1), side_arg_byte(2), side_arg_byte(3))); + side_arg_define_array(myarray, side_arg_list(side_arg_byte(1), side_arg_byte(2), side_arg_byte(3))); side_arg_dynamic_define_vec(myvla, side_arg_list( side_arg_dynamic_byte(0x22), @@ -1198,7 +1167,7 @@ void test_blob(void) side_event_call_variadic(my_provider_event_blob, side_arg_list( side_arg_byte(0x55), - side_arg_array(&myarray), + side_arg_array(myarray), ), side_arg_list( side_arg_dynamic_field("varblobfield", @@ -1442,7 +1411,7 @@ static side_define_struct(mystructgatherdef, side_field_gather_signed_integer("j", offsetof(struct test, j), side_struct_field_sizeof(struct test, j), 63, 1, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), - side_field_gather_signed_integer("k", offsetof(struct test, k), + side_field_gather_signed_integer("k", offsetof(struct test, k), side_struct_field_sizeof(struct test, k), 1, 63, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), side_field_gather_unsigned_integer_le("test", offsetof(struct test, test), @@ -1459,7 +1428,7 @@ static side_define_struct(mystructgatherdef, side_static_event(my_provider_event_structgather, "myprovider", "myeventstructgather", SIDE_LOGLEVEL_DEBUG, side_field_list( - side_field_gather_struct("structgather", &mystructgatherdef, 0, sizeof(struct test), + side_field_gather_struct("structgather", mystructgatherdef, 0, sizeof(struct test), SIDE_TYPE_GATHER_ACCESS_DIRECT), side_field_gather_signed_integer("intgather", 0, sizeof(int32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), @@ -1530,7 +1499,7 @@ static side_define_struct(mystructgathernest1, side_field_gather_unsigned_integer("b", offsetof(struct testnest1, b), side_struct_field_sizeof(struct testnest1, b), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT), - side_field_gather_struct("nest2", &mystructgathernest2, + side_field_gather_struct("nest2", mystructgathernest2, offsetof(struct testnest1, nest), sizeof(struct testnest2), SIDE_TYPE_GATHER_ACCESS_POINTER), ) @@ -1541,7 +1510,7 @@ static side_define_struct(mystructgathernest0, side_field_gather_unsigned_integer("a", offsetof(struct testnest0, a), side_struct_field_sizeof(struct testnest0, a), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT), - side_field_gather_struct("nest1", &mystructgathernest1, + side_field_gather_struct("nest1", mystructgathernest1, offsetof(struct testnest0, nest), sizeof(struct testnest1), SIDE_TYPE_GATHER_ACCESS_POINTER), ) @@ -1550,7 +1519,7 @@ static side_define_struct(mystructgathernest0, side_static_event(my_provider_event_structgather_nest, "myprovider", "myeventstructgathernest", SIDE_LOGLEVEL_DEBUG, side_field_list( - side_field_gather_struct("nest0", &mystructgathernest0, 0, + side_field_gather_struct("nest0", mystructgathernest0, 0, sizeof(struct testnest0), SIDE_TYPE_GATHER_ACCESS_DIRECT), ) ); @@ -1617,7 +1586,7 @@ static side_define_struct(mystructgatherfloat, side_static_event(my_provider_event_structgatherfloat, "myprovider", "myeventstructgatherfloat", SIDE_LOGLEVEL_DEBUG, side_field_list( - side_field_gather_struct("structgatherfloat", &mystructgatherfloat, 0, + side_field_gather_struct("structgatherfloat", mystructgatherfloat, 0, sizeof(struct testfloat), SIDE_TYPE_GATHER_ACCESS_DIRECT), ) ); @@ -1671,7 +1640,7 @@ static side_define_struct(mystructgatherarray, side_static_event(my_provider_event_structgatherarray, "myprovider", "myeventstructgatherarray", SIDE_LOGLEVEL_DEBUG, side_field_list( - side_field_gather_struct("structgatherarray", &mystructgatherarray, 0, + side_field_gather_struct("structgatherarray", mystructgatherarray, 0, sizeof(struct testarray), SIDE_TYPE_GATHER_ACCESS_DIRECT), side_field_gather_array("array2", side_elem(side_type_gather_unsigned_integer(0, sizeof(uint16_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT)), @@ -1717,7 +1686,7 @@ static side_define_struct(mystructgatherstructnest1, SIDE_TYPE_GATHER_ACCESS_DIRECT), side_field_gather_array("c", side_elem( - side_type_gather_signed_integer(0, sizeof(uint32_t), 0, 0, + side_type_gather_signed_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT) ), TESTSGNESTARRAY_LEN, @@ -1731,13 +1700,13 @@ static side_define_struct(mystructgatherstructnest0, side_field_gather_signed_integer("a", offsetof(struct testgatherstructnest0, a), side_struct_field_sizeof(struct testgatherstructnest0, a), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT), - side_field_gather_struct("structnest0", &mystructgatherstructnest1, + side_field_gather_struct("structnest0", mystructgatherstructnest1, offsetof(struct testgatherstructnest0, nest), sizeof(struct testgatherstructnest1), SIDE_TYPE_GATHER_ACCESS_DIRECT), side_field_gather_array("nestarray", side_elem( - side_type_gather_struct(&mystructgatherstructnest1, + side_type_gather_struct(mystructgatherstructnest1, 0, sizeof(struct testgatherstructnest1), SIDE_TYPE_GATHER_ACCESS_DIRECT) @@ -1751,7 +1720,7 @@ static side_define_struct(mystructgatherstructnest0, side_static_event(my_provider_event_gatherstructnest, "myprovider", "myeventgatherstructnest", SIDE_LOGLEVEL_DEBUG, side_field_list( - side_field_gather_struct("structgather", &mystructgatherstructnest0, 0, + side_field_gather_struct("structgather", mystructgatherstructnest0, 0, sizeof(struct testgatherstructnest0), SIDE_TYPE_GATHER_ACCESS_DIRECT), ) ); @@ -1813,7 +1782,7 @@ static side_define_struct(mystructgathervla, side_static_event(my_provider_event_gathervla, "myprovider", "myeventgathervla", SIDE_LOGLEVEL_DEBUG, side_field_list( - side_field_gather_struct("structgathervla", &mystructgathervla, 0, + side_field_gather_struct("structgathervla", mystructgathervla, 0, sizeof(struct testgathervla), SIDE_TYPE_GATHER_ACCESS_DIRECT), side_field_gather_vla("vla", side_elem(side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT)), @@ -1863,7 +1832,7 @@ static side_define_struct(mystructgathervlaflex, side_static_event(my_provider_event_gathervlaflex, "myprovider", "myeventgathervlaflex", SIDE_LOGLEVEL_DEBUG, side_field_list( - side_field_gather_struct("structgathervlaflex", &mystructgathervlaflex, 0, + side_field_gather_struct("structgathervlaflex", mystructgathervlaflex, 0, sizeof(struct testgathervlaflex), SIDE_TYPE_GATHER_ACCESS_DIRECT) ) ); @@ -2001,37 +1970,37 @@ static side_define_enum(myenumgather, side_static_event(my_provider_event_enum_gather, "myprovider", "myeventenumgather", SIDE_LOGLEVEL_DEBUG, side_field_list( - side_field_gather_enum("5", &myenumgather, + side_field_gather_enum("5", myenumgather, side_elem( side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT) ) ), - side_field_gather_enum("400", &myenumgather, + side_field_gather_enum("400", myenumgather, side_elem( side_type_gather_unsigned_integer(0, sizeof(uint64_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT) ) ), - side_field_gather_enum("200", &myenumgather, + side_field_gather_enum("200", myenumgather, side_elem( side_type_gather_unsigned_integer(0, sizeof(uint8_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT) ) ), - side_field_gather_enum("-100", &myenumgather, + side_field_gather_enum("-100", myenumgather, side_elem( side_type_gather_signed_integer(0, sizeof(int8_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT) ) ), - side_field_gather_enum("6_be", &myenumgather, + side_field_gather_enum("6_be", myenumgather, side_elem( side_type_gather_unsigned_integer_be(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT) ) ), - side_field_gather_enum("6_le", &myenumgather, + side_field_gather_enum("6_le", myenumgather, side_elem( side_type_gather_unsigned_integer_le(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT) @@ -2167,8 +2136,8 @@ static side_define_variant(myvariantdef, side_static_event(my_provider_event_variant, "myprovider", "myeventvariant", SIDE_LOGLEVEL_DEBUG, side_field_list( - side_field_variant("variant1", &myvariantdef), - side_field_variant("variant2", &myvariantdef), + side_field_variant("variant1", myvariantdef), + side_field_variant("variant2", myvariantdef), side_field_u8("z"), ) ); @@ -2182,8 +2151,8 @@ void test_variant(void) side_event_call(my_provider_event_variant, side_arg_list( - side_arg_variant(&myvariant1), - side_arg_variant(&myvariant2), + side_arg_variant(myvariant1), + side_arg_variant(myvariant2), side_arg_u8(55), ) ); @@ -2317,7 +2286,7 @@ static side_define_optional(my_optional, side_elem(side_type_string())); side_static_event(my_provider_event_optional, "myprovider", "myeventoptional", SIDE_LOGLEVEL_DEBUG, side_field_list( - side_field_optional("a", &my_optional), + side_field_optional("a", my_optional), side_field_optional_literal("b", side_elem(side_type_string())), ) ); @@ -2332,19 +2301,72 @@ void test_optional(void) side_event_call(my_provider_event_optional, side_arg_list( - side_arg_optional(&present), - side_arg_optional(&absent), + side_arg_optional(present), + side_arg_optional(absent), ) ); } } +static side_define_struct(my_struct_inner, + side_field_list( + side_field_u32("x"), + ) +); + +static side_define_struct(my_struct_outter, + side_field_list( + side_field_struct("inner", my_struct_inner), + ) +); + +side_static_event(event_nested_struct, "myprovider", "nestedstruct", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_struct("struct", my_struct_outter), + ) +); + +static void test_nested_struct(void) +{ + if (side_event_enabled(event_nested_struct)) { + side_arg_define_struct(my_inner_struct, side_arg_list(side_arg_u32(21))); + side_arg_define_struct(my_outter_struct, side_arg_list(side_arg_struct(my_inner_struct))); + side_event_call(event_nested_struct, side_arg_list(side_arg_struct(my_outter_struct))); + } +} + +static side_define_struct(my_struct_for_vla, + side_field_list( + side_field_u32("x"), + ) +); + +static side_define_vla(my_vla_of_struct, + side_elem(side_type_struct(my_struct_for_vla)), + side_elem(side_type_u32()) +); + +side_static_event(event_vla_of_struct, "myprovider", "nestedstruct", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_vla("vla", my_vla_of_struct), + ) +); + +static void test_vla_of_struct(void) +{ + if (side_event_enabled(event_nested_struct)) { + side_arg_define_struct(mystruct1, side_arg_list(side_arg_u32(21))); + side_arg_define_struct(mystruct2, side_arg_list(side_arg_u32(21))); + side_arg_define_vla(myvla, side_arg_list(side_arg_struct(mystruct1), side_arg_struct(mystruct2))); + side_event_call(event_vla_of_struct, side_arg_list(side_arg_vla(myvla))); + } +} + int main() { test_fields(); test_event_hidden(); test_event_export(); - test_struct_literal(); test_struct(); test_array(); test_vla(); @@ -2394,5 +2416,7 @@ int main() test_integer128(); test_c_native_types(); test_optional(); + test_nested_struct(); + test_vla_of_struct(); return 0; }