From: Mathieu Desnoyers Date: Mon, 28 Nov 2022 20:02:10 +0000 (-0500) Subject: Revert "Rename "libside" to "libtgif"" X-Git-Url: http://git.efficios.com/?p=libside.git;a=commitdiff_plain;h=67337c4a0938b84859ffeb93b02cd59c0a8fda61 Revert "Rename "libside" to "libtgif"" This reverts commit d04d49036a407d68a89879b790c3cba6e081bea5. Signed-off-by: Mathieu Desnoyers --- diff --git a/.gitignore b/.gitignore index 19e099e..db9b7f6 100644 --- a/.gitignore +++ b/.gitignore @@ -54,10 +54,10 @@ Module.symvers Mkfile.old dkms.conf -/src/libtgif.pc +/src/libside.pc /src/test /tests/regression/.dirstamp -/tests/regression/tgif-rcu-test +/tests/regression/side-rcu-test #automake /include/config.h diff --git a/configure.ac b/configure.ac index 9b519c2..6142c90 100644 --- a/configure.ac +++ b/configure.ac @@ -4,19 +4,19 @@ dnl dnl Process this file with autoconf to produce a configure script. # Project version information -m4_define([tgif_version_major], [0]) -m4_define([tgif_version_minor], [1]) -m4_define([tgif_version_patch], [0]) -m4_define([tgif_version_dev_stage], [-pre]) -m4_define([tgif_version], tgif_version_major[.]tgif_version_minor[.]tgif_version_patch[]tgif_version_dev_stage) +m4_define([side_version_major], [0]) +m4_define([side_version_minor], [1]) +m4_define([side_version_patch], [0]) +m4_define([side_version_dev_stage], [-pre]) +m4_define([side_version], side_version_major[.]side_version_minor[.]side_version_patch[]side_version_dev_stage) -# Library version information of "libtgif" +# Library version information of "libside" # Following the numbering scheme proposed by libtool for the library version # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html -m4_define([tgif_lib_version_current], [0]) -m4_define([tgif_lib_version_revision], [0]) -m4_define([tgif_lib_version_age], [0]) -m4_define([tgif_lib_version], tgif_lib_version_current[:]tgif_lib_version_revision[:]tgif_lib_version_age) +m4_define([side_lib_version_current], [0]) +m4_define([side_lib_version_revision], [0]) +m4_define([side_lib_version_age], [0]) +m4_define([side_lib_version], side_lib_version_current[:]side_lib_version_revision[:]side_lib_version_age) ## ## @@ -24,7 +24,7 @@ m4_define([tgif_lib_version], tgif_lib_version_current[:]tgif_lib_version_revisi ## ## AC_PREREQ([2.69]) -AC_INIT([libtgif],[tgif_version],[mathieu dot desnoyers at efficios dot com],[],[https://github.com/compudj/libtgif/]) +AC_INIT([libside],[side_version],[mathieu dot desnoyers at efficios dot com],[],[https://github.com/compudj/libside/]) AC_CONFIG_HEADERS([include/config.h]) AC_CONFIG_AUX_DIR([config]) @@ -183,7 +183,7 @@ AE_FEATURE([Werror], [Treat compiler warnings as errors.]) ## ## # Library versions for libtool -AC_SUBST([TGIF_LIBRARY_VERSION], [tgif_lib_version]) +AC_SUBST([SIDE_LIBRARY_VERSION], [side_lib_version]) # The order in which the include folders are searched is important. # The top_builddir should always be searched first in the event that a build @@ -206,7 +206,7 @@ AC_CONFIG_FILES([ Makefile include/Makefile src/Makefile - src/libtgif.pc + src/libside.pc tests/Makefile tests/utils/Makefile ]) @@ -223,7 +223,7 @@ AE_PPRINT_SET_INDENT(1) AE_PPRINT_SET_TS(38) AS_ECHO -AS_ECHO("${AE_PPRINT_COLOR_BLDBLU}libtgif $PACKAGE_VERSION${AE_PPRINT_COLOR_RST}") +AS_ECHO("${AE_PPRINT_COLOR_BLDBLU}libside $PACKAGE_VERSION${AE_PPRINT_COLOR_RST}") AS_ECHO AE_PPRINT_SUBTITLE([Features]) diff --git a/include/Makefile.am b/include/Makefile.am index 7e65b36..d9a7b31 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -2,6 +2,6 @@ # SPDX-FileCopyrightText: 2022 EfficiOS Inc. nobase_include_HEADERS = \ - tgif/endian.h \ - tgif/macros.h \ - tgif/trace.h + side/endian.h \ + side/macros.h \ + side/trace.h diff --git a/include/side/endian.h b/include/side/endian.h new file mode 100644 index 0000000..de8ccd7 --- /dev/null +++ b/include/side/endian.h @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: MIT +/* + * + * Copyright (C) 2012,2022 Mathieu Desnoyers + */ + +/* + * This header defines the following endian macros based on the current + * platform endian headers: + * + * BYTE_ORDER this macro shall have a value equal to one + * of the *_ENDIAN macros in this header. + * FLOAT_WORD_ORDER this macro shall have a value equal to one + * of the *_ENDIAN macros in this header. + * LITTLE_ENDIAN if BYTE_ORDER == LITTLE_ENDIAN, the host + * byte order is from least significant to + * most significant. + * BIG_ENDIAN if BYTE_ORDER == BIG_ENDIAN, the host byte + * order is from most significant to least + * significant. + * + * Direct byte swapping interfaces: + * + * uint16_t bswap_16(uint16_t x); (* swap bytes 16-bit word *) + * uint32_t bswap_32(uint32_t x); (* swap bytes 32-bit word *) + * uint64_t bswap_64(uint32_t x); (* swap bytes 64-bit word *) + */ + +#ifndef _SIDE_ENDIAN_H +#define _SIDE_ENDIAN_H + +#include +#include + +#if (defined(__linux__) || defined(__CYGWIN__)) +#include +#include + +#define side_bswap_16(x) bswap_16(x) +#define side_bswap_32(x) bswap_32(x) +#define side_bswap_64(x) bswap_64(x) + +#define SIDE_BYTE_ORDER __BYTE_ORDER +#define SIDE_LITTLE_ENDIAN __LITTLE_ENDIAN +#define SIDE_BIG_ENDIAN __BIG_ENDIAN + +#ifdef __FLOAT_WORD_ORDER +#define SIDE_FLOAT_WORD_ORDER __FLOAT_WORD_ORDER +#else /* __FLOAT_WORD_ORDER */ +#define SIDE_FLOAT_WORD_ORDER __BYTE_ORDER +#endif /* __FLOAT_WORD_ORDER */ + +#elif defined(__FreeBSD__) + +#include + +#define side_bswap_16(x) bswap16(x) +#define side_bswap_32(x) bswap32(x) +#define side_bswap_64(x) bswap64(x) + +#define SIDE_BYTE_ORDER BYTE_ORDER +#define SIDE_LITTLE_ENDIAN LITTLE_ENDIAN +#define SIDE_BIG_ENDIAN BIG_ENDIAN +#define SIDE_FLOAT_WORD_ORDER BYTE_ORDER + +#else +#error "Please add support for your OS." +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __HAVE_FLOAT128 +static inline +void side_bswap_128p(char *p) +{ + int i; + + for (i = 0; i < 8; i++) + p[i] = p[15 - i]; +} +#endif + +#ifdef __cplusplus +} +#endif + +#if SIDE_BITS_PER_LONG == 64 +# define side_bswap_pointer(x) side_bswap_64(x) +#else +# define side_bswap_pointer(x) side_bswap_32(x) +#endif + +#endif /* _SIDE_ENDIAN_H */ diff --git a/include/side/macros.h b/include/side/macros.h new file mode 100644 index 0000000..796b708 --- /dev/null +++ b/include/side/macros.h @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright 2022 Mathieu Desnoyers + */ + +#ifndef _SIDE_MACROS_H +#define _SIDE_MACROS_H + +#include +#include + +/* Helper macros */ + +#define SIDE_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + +/* + * Compound literals with static storage are needed by SIDE + * instrumentation. + * Compound literals are part of the C99 and C11 standards, but not + * part of the C++ standards. They are supported by most C++ compilers + * though. + * + * Example use: + * static struct mystruct *var = LTTNG_UST_COMPOUND_LITERAL(struct mystruct, { 1, 2, 3 }); + */ +#define SIDE_COMPOUND_LITERAL(type, ...) (type[]) { __VA_ARGS__ } + +#define side_likely(x) __builtin_expect(!!(x), 1) +#define side_unlikely(x) __builtin_expect(!!(x), 0) + +#define SIDE_PARAM(...) __VA_ARGS__ + +/* + * side_container_of - Get the address of an object containing a field. + * + * @ptr: pointer to the field. + * @type: type of the object. + * @member: name of the field within the object. + */ +#define side_container_of(ptr, type, member) \ + __extension__ \ + ({ \ + const __typeof__(((type *) NULL)->member) * __ptr = (ptr); \ + (type *)((char *)__ptr - offsetof(type, member)); \ + }) + +#define side_struct_field_sizeof(_struct, _field) \ + sizeof(((_struct * )NULL)->_field) + +#if defined(__SIZEOF_LONG__) +#define SIDE_BITS_PER_LONG (__SIZEOF_LONG__ * 8) +#elif defined(_LP64) +#define SIDE_BITS_PER_LONG 64 +#else +#define SIDE_BITS_PER_LONG 32 +#endif + +#define SIDE_PACKED __attribute__((packed)) + +#endif /* _SIDE_MACROS_H */ diff --git a/include/side/trace.h b/include/side/trace.h new file mode 100644 index 0000000..235382e --- /dev/null +++ b/include/side/trace.h @@ -0,0 +1,1876 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright 2022 Mathieu Desnoyers + */ + +#ifndef _SIDE_TRACE_H +#define _SIDE_TRACE_H + +#include +#include +#include +#include +#include +#include +#include + +/* + * SIDE stands for "Static Instrumentation Dynamically Enabled" + * + * This is an instrumentation API for Linux user-space, which exposes an + * instrumentation type system and facilities allowing a kernel or + * user-space tracer to consume user-space instrumentation. + * + * This instrumentation API exposes 3 type systems: + * + * * Stack-copy type system: This is the core type system which can + * represent all supported types and into which all other type systems + * can be nested. This type system requires that every type is + * statically or dynamically declared and then registered, thus giving + * tracers a complete description of the events and their associated + * fields before the associated instrumentation is invoked. The + * application needs to copy each argument (side_arg_...()) onto the + * stack when calling the instrumentation. + * + * This is the most expressive of the 3 type systems, althrough not the + * fastest due to the extra copy of the arguments. + * + * * Data-gathering type system: This type system requires every type to + * be statically or dynamically declared and registered, but does not + * require the application to copy its arguments onto the stack. + * Instead, the type description contains all the required information + * to fetch the data from the application memory. The only argument + * required from the instrumentation is the base pointer from which + * the data should be fetched. + * + * This type system can be used as an event field, or nested within + * the stack-copy type system. Nesting of gather-vla within + * gather-array and gather-vla types is not allowed. + * + * This type system is has the least overhead of the 3 type systems. + * + * * Dynamic type system: This type system receives both type + * description and actual data onto the stack at runtime. It has more + * overhead that the 2 other type systems, but does not require a + * prior registration of event field description. This makes it useful + * for seldom used types which are not performance critical, but for + * which registering each individual events would needlessly grow the + * number of events to declare and register. + * + * Another use-case for this type system is for use by dynamically + * typed language runtimes, where the field type is only known when + * the instrumentation is called. + * + * Those dynamic types can be either used as arguments to a variadic + * field list, or as on-stack instrumentation argument for a static + * type SIDE_TYPE_DYNAMIC place holder in the stack-copy type system. + */ + +//TODO: as those structures will be ABI, we need to either consider them +//fixed forever, or think of a scheme that would allow their binary +//representation to be extended if need be. + +struct side_arg; +struct side_arg_vec; +struct side_arg_dynamic; +struct side_arg_dynamic_field; +struct side_arg_dynamic_vla; +struct side_type; +struct side_event_field; +struct side_tracer_visitor_ctx; +struct side_tracer_dynamic_struct_visitor_ctx; +struct side_event_description; +struct side_arg_dynamic_struct; +struct side_events_register_handle; + +enum side_type_label { + /* Stack-copy basic types */ + SIDE_TYPE_NULL, + SIDE_TYPE_BOOL, + SIDE_TYPE_U8, + SIDE_TYPE_U16, + SIDE_TYPE_U32, + SIDE_TYPE_U64, + SIDE_TYPE_S8, + SIDE_TYPE_S16, + SIDE_TYPE_S32, + SIDE_TYPE_S64, + SIDE_TYPE_BYTE, + SIDE_TYPE_POINTER, + SIDE_TYPE_FLOAT_BINARY16, + SIDE_TYPE_FLOAT_BINARY32, + SIDE_TYPE_FLOAT_BINARY64, + SIDE_TYPE_FLOAT_BINARY128, + SIDE_TYPE_STRING_UTF8, + SIDE_TYPE_STRING_UTF16, + SIDE_TYPE_STRING_UTF32, + + /* Stack-copy compound types */ + SIDE_TYPE_STRUCT, + SIDE_TYPE_ARRAY, + SIDE_TYPE_VLA, + SIDE_TYPE_VLA_VISITOR, + + /* Stack-copy enumeration types */ + SIDE_TYPE_ENUM, + SIDE_TYPE_ENUM_BITMAP, + + /* Stack-copy place holder for dynamic types */ + SIDE_TYPE_DYNAMIC, + + /* Gather basic types */ + SIDE_TYPE_GATHER_BOOL, + SIDE_TYPE_GATHER_INTEGER, + SIDE_TYPE_GATHER_BYTE, + SIDE_TYPE_GATHER_POINTER, + SIDE_TYPE_GATHER_FLOAT, + SIDE_TYPE_GATHER_STRING, + + /* Gather compound types */ + SIDE_TYPE_GATHER_STRUCT, + SIDE_TYPE_GATHER_ARRAY, + SIDE_TYPE_GATHER_VLA, + + /* Gather enumeration types */ + SIDE_TYPE_GATHER_ENUM, + + /* Dynamic basic types */ + SIDE_TYPE_DYNAMIC_NULL, + SIDE_TYPE_DYNAMIC_BOOL, + SIDE_TYPE_DYNAMIC_INTEGER, + SIDE_TYPE_DYNAMIC_BYTE, + SIDE_TYPE_DYNAMIC_POINTER, + SIDE_TYPE_DYNAMIC_FLOAT, + SIDE_TYPE_DYNAMIC_STRING, + + /* Dynamic compound types */ + SIDE_TYPE_DYNAMIC_STRUCT, + SIDE_TYPE_DYNAMIC_STRUCT_VISITOR, + SIDE_TYPE_DYNAMIC_VLA, + SIDE_TYPE_DYNAMIC_VLA_VISITOR, +}; + +enum side_attr_type { + SIDE_ATTR_TYPE_NULL, + SIDE_ATTR_TYPE_BOOL, + SIDE_ATTR_TYPE_U8, + SIDE_ATTR_TYPE_U16, + SIDE_ATTR_TYPE_U32, + SIDE_ATTR_TYPE_U64, + SIDE_ATTR_TYPE_S8, + SIDE_ATTR_TYPE_S16, + SIDE_ATTR_TYPE_S32, + SIDE_ATTR_TYPE_S64, + SIDE_ATTR_TYPE_FLOAT_BINARY16, + SIDE_ATTR_TYPE_FLOAT_BINARY32, + SIDE_ATTR_TYPE_FLOAT_BINARY64, + SIDE_ATTR_TYPE_FLOAT_BINARY128, + SIDE_ATTR_TYPE_STRING, +}; + +enum side_loglevel { + SIDE_LOGLEVEL_EMERG = 0, + SIDE_LOGLEVEL_ALERT = 1, + SIDE_LOGLEVEL_CRIT = 2, + SIDE_LOGLEVEL_ERR = 3, + SIDE_LOGLEVEL_WARNING = 4, + SIDE_LOGLEVEL_NOTICE = 5, + SIDE_LOGLEVEL_INFO = 6, + SIDE_LOGLEVEL_DEBUG = 7, +}; + +enum side_visitor_status { + SIDE_VISITOR_STATUS_OK = 0, + SIDE_VISITOR_STATUS_ERROR = -1, +}; + +enum side_error { + SIDE_ERROR_OK = 0, + SIDE_ERROR_INVAL = 1, + SIDE_ERROR_EXIST = 2, + SIDE_ERROR_NOMEM = 3, + SIDE_ERROR_NOENT = 4, + SIDE_ERROR_EXITING = 5, +}; + +enum side_type_label_byte_order { + SIDE_TYPE_BYTE_ORDER_LE = 0, + SIDE_TYPE_BYTE_ORDER_BE = 1, +}; + +#if (SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN) +# define SIDE_TYPE_BYTE_ORDER_HOST SIDE_TYPE_BYTE_ORDER_LE +#else +# define SIDE_TYPE_BYTE_ORDER_HOST SIDE_TYPE_BYTE_ORDER_BE +#endif + +#if (SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN) +# define SIDE_TYPE_FLOAT_WORD_ORDER_HOST SIDE_TYPE_BYTE_ORDER_LE +#else +# define SIDE_TYPE_FLOAT_WORD_ORDER_HOST SIDE_TYPE_BYTE_ORDER_BE +#endif + +enum side_type_gather_access_mode { + SIDE_TYPE_GATHER_ACCESS_DIRECT, + SIDE_TYPE_GATHER_ACCESS_POINTER, /* Pointer dereference */ +}; + +typedef enum side_visitor_status (*side_visitor_func)( + const struct side_tracer_visitor_ctx *tracer_ctx, + void *app_ctx); +typedef enum side_visitor_status (*side_dynamic_struct_visitor_func)( + const struct side_tracer_dynamic_struct_visitor_ctx *tracer_ctx, + void *app_ctx); + +union side_integer_value { + uint8_t side_u8; + uint16_t side_u16; + uint32_t side_u32; + uint64_t side_u64; + int8_t side_s8; + int16_t side_s16; + int32_t side_s32; + int64_t side_s64; + uintptr_t side_uptr; +} SIDE_PACKED; + +union side_bool_value { + uint8_t side_bool8; + uint16_t side_bool16; + uint32_t side_bool32; + uint64_t side_bool64; +} SIDE_PACKED; + +union side_float_value { +#if __HAVE_FLOAT16 + _Float16 side_float_binary16; +#endif +#if __HAVE_FLOAT32 + _Float32 side_float_binary32; +#endif +#if __HAVE_FLOAT64 + _Float64 side_float_binary64; +#endif +#if __HAVE_FLOAT128 + _Float128 side_float_binary128; +#endif +} SIDE_PACKED; + +struct side_type_raw_string { + const void *p; /* pointer to string */ + uint8_t unit_size; /* 1, 2, or 4 bytes */ + uint8_t byte_order; /* enum side_type_label_byte_order */ +} SIDE_PACKED; + +struct side_attr_value { + uint32_t type; /* enum side_attr_type */ + union { + uint8_t bool_value; + struct side_type_raw_string string_value; + union side_integer_value integer_value; + union side_float_value float_value; + } SIDE_PACKED u; +}; + +/* User attributes. */ +struct side_attr { + const struct side_type_raw_string key; + const struct side_attr_value value; +} SIDE_PACKED; + +/* Type descriptions */ +struct side_type_null { + const struct side_attr *attr; + uint32_t nr_attr; +} SIDE_PACKED; + +struct side_type_bool { + const struct side_attr *attr; + uint32_t nr_attr; + uint16_t bool_size; /* bytes */ + uint16_t len_bits; /* bits. 0 for (bool_size * CHAR_BITS) */ + uint8_t byte_order; /* enum side_type_label_byte_order */ +} SIDE_PACKED; + +struct side_type_byte { + const struct side_attr *attr; + uint32_t nr_attr; +} SIDE_PACKED; + +struct side_type_string { + const struct side_attr *attr; + uint32_t nr_attr; + uint8_t unit_size; /* 1, 2, or 4 bytes */ + uint8_t byte_order; /* enum side_type_label_byte_order */ +} SIDE_PACKED; + +struct side_type_integer { + const struct side_attr *attr; + uint32_t nr_attr; + uint16_t integer_size; /* bytes */ + uint16_t len_bits; /* bits. 0 for (integer_size * CHAR_BITS) */ + uint8_t signedness; /* true/false */ + uint8_t byte_order; /* enum side_type_label_byte_order */ +} SIDE_PACKED; + +struct side_type_float { + const struct side_attr *attr; + uint32_t nr_attr; + uint16_t float_size; /* bytes */ + uint8_t byte_order; /* enum side_type_label_byte_order */ +} SIDE_PACKED; + +struct side_enum_mapping { + int64_t range_begin; + int64_t range_end; + struct side_type_raw_string label; +} SIDE_PACKED; + +struct side_enum_mappings { + const struct side_enum_mapping *mappings; + const struct side_attr *attr; + uint32_t nr_mappings; + uint32_t nr_attr; +} SIDE_PACKED; + +struct side_enum_bitmap_mapping { + uint64_t range_begin; + uint64_t range_end; + struct side_type_raw_string label; +} SIDE_PACKED; + +struct side_enum_bitmap_mappings { + const struct side_enum_bitmap_mapping *mappings; + const struct side_attr *attr; + uint32_t nr_mappings; + uint32_t nr_attr; +} SIDE_PACKED; + +struct side_type_struct { + const struct side_event_field *fields; + const struct side_attr *attr; + uint32_t nr_fields; + uint32_t nr_attr; +} SIDE_PACKED; + +struct side_type_array { + const struct side_type *elem_type; + const struct side_attr *attr; + uint32_t length; + uint32_t nr_attr; +} SIDE_PACKED; + +struct side_type_vla { + const struct side_type *elem_type; + const struct side_attr *attr; + uint32_t nr_attr; +} SIDE_PACKED; + +struct side_type_vla_visitor { + const struct side_type *elem_type; + side_visitor_func visitor; + const struct side_attr *attr; + uint32_t nr_attr; +} SIDE_PACKED; + +struct side_type_enum { + const struct side_enum_mappings *mappings; + const struct side_type *elem_type; +} SIDE_PACKED; + +struct side_type_enum_bitmap { + const struct side_enum_bitmap_mappings *mappings; + const struct side_type *elem_type; +} SIDE_PACKED; + +struct side_type_gather_bool { + uint64_t offset; /* bytes */ + uint8_t access_mode; /* enum side_type_gather_access_mode */ + struct side_type_bool type; + uint16_t offset_bits; /* bits */ +} SIDE_PACKED; + +struct side_type_gather_byte { + uint64_t offset; /* bytes */ + uint8_t access_mode; /* enum side_type_gather_access_mode */ + struct side_type_byte type; +} SIDE_PACKED; + +struct side_type_gather_integer { + uint64_t offset; /* bytes */ + uint8_t access_mode; /* enum side_type_gather_access_mode */ + struct side_type_integer type; + uint16_t offset_bits; /* bits */ +} SIDE_PACKED; + +struct side_type_gather_float { + uint64_t offset; /* bytes */ + uint8_t access_mode; /* enum side_type_gather_access_mode */ + struct side_type_float type; +} SIDE_PACKED; + +struct side_type_gather_string { + uint64_t offset; /* bytes */ + uint8_t access_mode; /* enum side_type_gather_access_mode */ + struct side_type_string type; +} SIDE_PACKED; + +struct side_type_gather_enum { + const struct side_enum_mappings *mappings; + const struct side_type *elem_type; +} SIDE_PACKED; + +struct side_type_gather_struct { + uint64_t offset; /* bytes */ + uint8_t access_mode; /* enum side_type_gather_access_mode */ + const struct side_type_struct *type; + uint32_t size; /* bytes */ +} SIDE_PACKED; + +struct side_type_gather_array { + uint64_t offset; /* bytes */ + uint8_t access_mode; /* enum side_type_gather_access_mode */ + struct side_type_array type; +} SIDE_PACKED; + +struct side_type_gather_vla { + const struct side_type *length_type; /* side_length() */ + + uint64_t offset; /* bytes */ + uint8_t access_mode; /* enum side_type_gather_access_mode */ + struct side_type_vla type; +} SIDE_PACKED; + +struct side_type_gather { + union { + struct side_type_gather_bool side_bool; + struct side_type_gather_byte side_byte; + struct side_type_gather_integer side_integer; + struct side_type_gather_float side_float; + struct side_type_gather_string side_string; + struct side_type_gather_enum side_enum; + struct side_type_gather_array side_array; + struct side_type_gather_vla side_vla; + struct side_type_gather_struct side_struct; + } SIDE_PACKED u; +} SIDE_PACKED; + +struct side_type { + uint32_t type; /* enum side_type_label */ + union { + /* Stack-copy basic types */ + struct side_type_null side_null; + struct side_type_bool side_bool; + struct side_type_byte side_byte; + struct side_type_string side_string; + struct side_type_integer side_integer; + struct side_type_float side_float; + + /* Stack-copy compound types */ + struct side_type_array side_array; + struct side_type_vla side_vla; + struct side_type_vla_visitor side_vla_visitor; + const struct side_type_struct *side_struct; + + /* Stack-copy enumeration types */ + struct side_type_enum side_enum; + struct side_type_enum_bitmap side_enum_bitmap; + + /* Gather types */ + struct side_type_gather side_gather; + } SIDE_PACKED u; +} SIDE_PACKED; + +struct side_event_field { + const char *field_name; + struct side_type side_type; +} SIDE_PACKED; + +enum side_event_flags { + SIDE_EVENT_FLAG_VARIADIC = (1 << 0), +}; + +struct side_callback { + union { + void (*call)(const struct side_event_description *desc, + const struct side_arg_vec *side_arg_vec, + void *priv); + void (*call_variadic)(const struct side_event_description *desc, + const struct side_arg_vec *side_arg_vec, + const struct side_arg_dynamic_struct *var_struct, + void *priv); + } SIDE_PACKED u; + void *priv; +} SIDE_PACKED; + +struct side_arg_static { + /* Stack-copy basic types */ + union side_bool_value bool_value; + uint8_t byte_value; + uint64_t string_value; /* const {uint8_t, uint16_t, uint32_t} * */ + union side_integer_value integer_value; + union side_float_value float_value; + + /* Stack-copy compound types */ + const struct side_arg_vec *side_struct; + const struct side_arg_vec *side_array; + const struct side_arg_vec *side_vla; + void *side_vla_app_visitor_ctx; + + /* Gather basic types */ + const void *side_bool_gather_ptr; + const void *side_byte_gather_ptr; + const void *side_integer_gather_ptr; + const void *side_float_gather_ptr; + const void *side_string_gather_ptr; + + /* Gather compound types */ + const void *side_array_gather_ptr; + const void *side_struct_gather_ptr; + struct { + const void *ptr; + const void *length_ptr; + } SIDE_PACKED side_vla_gather; +} SIDE_PACKED; + +struct side_arg_dynamic_vla { + const struct side_arg *sav; + const struct side_attr *attr; + uint32_t len; + uint32_t nr_attr; +} SIDE_PACKED; + +struct side_arg_dynamic_struct { + const struct side_arg_dynamic_field *fields; + const struct side_attr *attr; + uint32_t len; + uint32_t nr_attr; +} SIDE_PACKED; + +struct side_dynamic_struct_visitor { + void *app_ctx; + side_dynamic_struct_visitor_func visitor; + const struct side_attr *attr; + uint32_t nr_attr; +} SIDE_PACKED; + +struct side_dynamic_vla_visitor { + void *app_ctx; + side_visitor_func visitor; + const struct side_attr *attr; + uint32_t nr_attr; +} SIDE_PACKED; + +struct side_arg_dynamic { + /* Dynamic basic types */ + struct side_type_null side_null; + struct { + struct side_type_bool type; + union side_bool_value value; + } SIDE_PACKED side_bool; + struct { + struct side_type_byte type; + uint8_t value; + } SIDE_PACKED side_byte; + struct { + struct side_type_string type; + uint64_t value; /* const char * */ + } SIDE_PACKED side_string; + struct { + struct side_type_integer type; + union side_integer_value value; + } SIDE_PACKED side_integer; + struct { + struct side_type_float type; + union side_float_value value; + } SIDE_PACKED side_float; + + /* Dynamic compound types */ + const struct side_arg_dynamic_struct *side_dynamic_struct; + const struct side_arg_dynamic_vla *side_dynamic_vla; + + struct side_dynamic_struct_visitor side_dynamic_struct_visitor; + struct side_dynamic_vla_visitor side_dynamic_vla_visitor; +} SIDE_PACKED; + +struct side_arg { + uint32_t type; /* enum side_type_label */ + union { + struct side_arg_static side_static; + struct side_arg_dynamic side_dynamic; + } SIDE_PACKED u; +} SIDE_PACKED; + +struct side_arg_vec { + const struct side_arg *sav; + uint32_t len; +} SIDE_PACKED; + +struct side_arg_dynamic_field { + const char *field_name; + const struct side_arg elem; +} SIDE_PACKED; + +/* The visitor pattern is a double-dispatch visitor. */ +struct side_tracer_visitor_ctx { + enum side_visitor_status (*write_elem)( + const struct side_tracer_visitor_ctx *tracer_ctx, + const struct side_arg *elem); + void *priv; /* Private tracer context. */ +} SIDE_PACKED; + +struct side_tracer_dynamic_struct_visitor_ctx { + enum side_visitor_status (*write_field)( + const struct side_tracer_dynamic_struct_visitor_ctx *tracer_ctx, + const struct side_arg_dynamic_field *dynamic_field); + void *priv; /* Private tracer context. */ +} SIDE_PACKED; + +struct side_event_description { + uintptr_t *enabled; + const char *provider_name; + const char *event_name; + const struct side_event_field *fields; + const struct side_attr *attr; + const struct side_callback *callbacks; + uint64_t flags; + uint32_t version; + uint32_t loglevel; /* enum side_loglevel */ + uint32_t nr_fields; + uint32_t nr_attr; + uint32_t nr_callbacks; +} SIDE_PACKED; + +/* Event and type attributes */ + +#define side_attr(_key, _value) \ + { \ + .key = { \ + .p = (_key), \ + .unit_size = sizeof(uint8_t), \ + .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ + }, \ + .value = SIDE_PARAM(_value), \ + } + +#define side_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_ATTR_TYPE_BOOL, .u = { .bool_value = !!(_val) } } +#define side_attr_u8(_val) { .type = SIDE_ATTR_TYPE_U8, .u = { .integer_value = { .side_u8 = (_val) } } } +#define side_attr_u16(_val) { .type = SIDE_ATTR_TYPE_U16, .u = { .integer_value = { .side_u16 = (_val) } } } +#define side_attr_u32(_val) { .type = SIDE_ATTR_TYPE_U32, .u = { .integer_value = { .side_u32 = (_val) } } } +#define side_attr_u64(_val) { .type = SIDE_ATTR_TYPE_U64, .u = { .integer_value = { .side_u64 = (_val) } } } +#define side_attr_s8(_val) { .type = SIDE_ATTR_TYPE_S8, .u = { .integer_value = { .side_s8 = (_val) } } } +#define side_attr_s16(_val) { .type = SIDE_ATTR_TYPE_S16, .u = { .integer_value = { .side_s16 = (_val) } } } +#define side_attr_s32(_val) { .type = SIDE_ATTR_TYPE_S32, .u = { .integer_value = { .side_s32 = (_val) } } } +#define side_attr_s64(_val) { .type = SIDE_ATTR_TYPE_S64, .u = { .integer_value = { .side_s64 = (_val) } } } +#define side_attr_float_binary16(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY16, .u = { .float_value = { .side_float_binary16 = (_val) } } } +#define side_attr_float_binary32(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY32, .u = { .float_value = { .side_float_binary32 = (_val) } } } +#define side_attr_float_binary64(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY64, .u = { .float_value = { .side_float_binary64 = (_val) } } } +#define side_attr_float_binary128(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY128, .u = { .float_value = { .side_float_binary128 = (_val) } } } + +#define _side_attr_string(_val, _byte_order, _unit_size) \ + { \ + .type = SIDE_ATTR_TYPE_STRING, \ + .u = { \ + .string_value = { \ + .p = (const void *) (_val), \ + .unit_size = _unit_size, \ + .byte_order = _byte_order, \ + }, \ + }, \ + } + +#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 = _mappings, \ + .attr = _attr, \ + .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + } + +#define side_enum_mapping_list(...) \ + SIDE_COMPOUND_LITERAL(const struct side_enum_mapping, __VA_ARGS__) + +#define side_enum_mapping_range(_label, _begin, _end) \ + { \ + .range_begin = _begin, \ + .range_end = _end, \ + .label = { \ + .p = (_label), \ + .unit_size = sizeof(uint8_t), \ + .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ + }, \ + } + +#define side_enum_mapping_value(_label, _value) \ + { \ + .range_begin = _value, \ + .range_end = _value, \ + .label = { \ + .p = (_label), \ + .unit_size = sizeof(uint8_t), \ + .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ + }, \ + } + +#define side_define_enum_bitmap(_identifier, _mappings, _attr) \ + const struct side_enum_bitmap_mappings _identifier = { \ + .mappings = _mappings, \ + .attr = _attr, \ + .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + } + +#define side_enum_bitmap_mapping_list(...) \ + SIDE_COMPOUND_LITERAL(const struct side_enum_bitmap_mapping, __VA_ARGS__) + +#define side_enum_bitmap_mapping_range(_label, _begin, _end) \ + { \ + .range_begin = _begin, \ + .range_end = _end, \ + .label = { \ + .p = (_label), \ + .unit_size = sizeof(uint8_t), \ + .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ + }, \ + } + +#define side_enum_bitmap_mapping_value(_label, _value) \ + { \ + .range_begin = _value, \ + .range_end = _value, \ + .label = { \ + .p = (_label), \ + .unit_size = sizeof(uint8_t), \ + .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ + }, \ + } + +/* Stack-copy field and type definitions */ + +#define side_type_null(_attr) \ + { \ + .type = SIDE_TYPE_NULL, \ + .u = { \ + .side_null = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + }, \ + }, \ + } + +#define side_type_bool(_attr) \ + { \ + .type = SIDE_TYPE_BOOL, \ + .u = { \ + .side_bool = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .bool_size = sizeof(uint8_t), \ + .len_bits = 0, \ + .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ + }, \ + }, \ + } + +#define side_type_byte(_attr) \ + { \ + .type = SIDE_TYPE_BYTE, \ + .u = { \ + .side_byte = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + }, \ + }, \ + } + +#define _side_type_string(_type, _byte_order, _unit_size, _attr) \ + { \ + .type = _type, \ + .u = { \ + .side_string = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .unit_size = _unit_size, \ + .byte_order = _byte_order, \ + }, \ + }, \ + } + +#define side_type_dynamic() \ + { \ + .type = SIDE_TYPE_DYNAMIC, \ + } + +#define _side_type_integer(_type, _signedness, _byte_order, _integer_size, _len_bits, _attr) \ + { \ + .type = _type, \ + .u = { \ + .side_integer = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .integer_size = _integer_size, \ + .len_bits = _len_bits, \ + .signedness = _signedness, \ + .byte_order = _byte_order, \ + }, \ + }, \ + } + +#define _side_type_float(_type, _byte_order, _float_size, _attr) \ + { \ + .type = _type, \ + .u = { \ + .side_float = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .float_size = _float_size, \ + .byte_order = _byte_order, \ + }, \ + }, \ + } + +#define _side_field(_name, _type) \ + { \ + .field_name = _name, \ + .side_type = _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(_attr)) +#define side_type_u16(_attr) _side_type_integer(SIDE_TYPE_U16, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), 0, SIDE_PARAM(_attr)) +#define side_type_u32(_attr) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), 0, SIDE_PARAM(_attr)) +#define side_type_u64(_attr) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint64_t), 0, SIDE_PARAM(_attr)) +#define side_type_s8(_attr) _side_type_integer(SIDE_TYPE_S8, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int8_t), 0, SIDE_PARAM(_attr)) +#define side_type_s16(_attr) _side_type_integer(SIDE_TYPE_S16, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int16_t), 0, SIDE_PARAM(_attr)) +#define side_type_s32(_attr) _side_type_integer(SIDE_TYPE_S32, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int32_t), 0, SIDE_PARAM(_attr)) +#define side_type_s64(_attr) _side_type_integer(SIDE_TYPE_S64, true, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(int64_t), 0, SIDE_PARAM(_attr)) +#define side_type_pointer(_attr) _side_type_integer(SIDE_TYPE_POINTER, false, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uintptr_t), 0, SIDE_PARAM(_attr)) +#define side_type_float_binary16(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float16), SIDE_PARAM(_attr)) +#define side_type_float_binary32(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float32), SIDE_PARAM(_attr)) +#define side_type_float_binary64(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float64), SIDE_PARAM(_attr)) +#define side_type_float_binary128(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float128), SIDE_PARAM(_attr)) +#define side_type_string(_attr) _side_type_string(SIDE_TYPE_STRING_UTF8, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), SIDE_PARAM(_attr)) +#define side_type_string16(_attr) _side_type_string(SIDE_TYPE_STRING_UTF16, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), SIDE_PARAM(_attr)) +#define side_type_string32(_attr) _side_type_string(SIDE_TYPE_STRING_UTF32, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), SIDE_PARAM(_attr)) + +#define side_field_null(_name, _attr) _side_field(_name, side_type_null(SIDE_PARAM(_attr))) +#define side_field_bool(_name, _attr) _side_field(_name, side_type_bool(SIDE_PARAM(_attr))) +#define side_field_u8(_name, _attr) _side_field(_name, side_type_u8(SIDE_PARAM(_attr))) +#define side_field_u16(_name, _attr) _side_field(_name, side_type_u16(SIDE_PARAM(_attr))) +#define side_field_u32(_name, _attr) _side_field(_name, side_type_u32(SIDE_PARAM(_attr))) +#define side_field_u64(_name, _attr) _side_field(_name, side_type_u64(SIDE_PARAM(_attr))) +#define side_field_s8(_name, _attr) _side_field(_name, side_type_s8(SIDE_PARAM(_attr))) +#define side_field_s16(_name, _attr) _side_field(_name, side_type_s16(SIDE_PARAM(_attr))) +#define side_field_s32(_name, _attr) _side_field(_name, side_type_s32(SIDE_PARAM(_attr))) +#define side_field_s64(_name, _attr) _side_field(_name, side_type_s64(SIDE_PARAM(_attr))) +#define side_field_byte(_name, _attr) _side_field(_name, side_type_byte(SIDE_PARAM(_attr))) +#define side_field_pointer(_name, _attr) _side_field(_name, side_type_pointer(SIDE_PARAM(_attr))) +#define side_field_float_binary16(_name, _attr) _side_field(_name, side_type_float_binary16(SIDE_PARAM(_attr))) +#define side_field_float_binary32(_name, _attr) _side_field(_name, side_type_float_binary32(SIDE_PARAM(_attr))) +#define side_field_float_binary64(_name, _attr) _side_field(_name, side_type_float_binary64(SIDE_PARAM(_attr))) +#define side_field_float_binary128(_name, _attr) _side_field(_name, side_type_float_binary128(SIDE_PARAM(_attr))) +#define side_field_string(_name, _attr) _side_field(_name, side_type_string(SIDE_PARAM(_attr))) +#define side_field_string16(_name, _attr) _side_field(_name, side_type_string16(SIDE_PARAM(_attr))) +#define side_field_string32(_name, _attr) _side_field(_name, side_type_string32(SIDE_PARAM(_attr))) +#define side_field_dynamic(_name) _side_field(_name, side_type_dynamic()) + +/* 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(_attr)) +#define side_type_u32_le(_attr) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), 0, SIDE_PARAM(_attr)) +#define side_type_u64_le(_attr) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint64_t), 0, SIDE_PARAM(_attr)) +#define side_type_s16_le(_attr) _side_type_integer(SIDE_TYPE_S16, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(int16_t), 0, SIDE_PARAM(_attr)) +#define side_type_s32_le(_attr) _side_type_integer(SIDE_TYPE_S32, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(int32_t), 0, SIDE_PARAM(_attr)) +#define side_type_s64_le(_attr) _side_type_integer(SIDE_TYPE_S64, true, SIDE_TYPE_BYTE_ORDER_LE, sizeof(int64_t), 0, SIDE_PARAM(_attr)) +#define side_type_pointer_le(_attr) _side_type_integer(SIDE_TYPE_POINTER, false, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uintptr_t), 0, SIDE_PARAM(_attr)) +#define side_type_float_binary16_le(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float16), SIDE_PARAM(_attr)) +#define side_type_float_binary32_le(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float32), SIDE_PARAM(_attr)) +#define side_type_float_binary64_le(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float64), SIDE_PARAM(_attr)) +#define side_type_float_binary128_le(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_BYTE_ORDER_LE, sizeof(_Float128), SIDE_PARAM(_attr)) +#define side_type_string16_le(_attr) _side_type_string(SIDE_TYPE_STRING_UTF16, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), SIDE_PARAM(_attr)) +#define side_type_string32_le(_attr) _side_type_string(SIDE_TYPE_STRING_UTF32, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), SIDE_PARAM(_attr)) + +#define side_field_u16_le(_name, _attr) _side_field(_name, side_type_u16_le(SIDE_PARAM(_attr))) +#define side_field_u32_le(_name, _attr) _side_field(_name, side_type_u32_le(SIDE_PARAM(_attr))) +#define side_field_u64_le(_name, _attr) _side_field(_name, side_type_u64_le(SIDE_PARAM(_attr))) +#define side_field_s16_le(_name, _attr) _side_field(_name, side_type_s16_le(SIDE_PARAM(_attr))) +#define side_field_s32_le(_name, _attr) _side_field(_name, side_type_s32_le(SIDE_PARAM(_attr))) +#define side_field_s64_le(_name, _attr) _side_field(_name, side_type_s64_le(SIDE_PARAM(_attr))) +#define side_field_pointer_le(_name, _attr) _side_field(_name, side_type_pointer_le(SIDE_PARAM(_attr))) +#define side_field_float_binary16_le(_name, _attr) _side_field(_name, side_type_float_binary16_le(SIDE_PARAM(_attr))) +#define side_field_float_binary32_le(_name, _attr) _side_field(_name, side_type_float_binary32_le(SIDE_PARAM(_attr))) +#define side_field_float_binary64_le(_name, _attr) _side_field(_name, side_type_float_binary64_le(SIDE_PARAM(_attr))) +#define side_field_float_binary128_le(_name, _attr) _side_field(_name, side_type_float_binary128_le(SIDE_PARAM(_attr))) +#define side_field_string16_le(_name, _attr) _side_field(_name, side_type_string16_le(SIDE_PARAM(_attr))) +#define side_field_string32_le(_name, _attr) _side_field(_name, side_type_string32_le(SIDE_PARAM(_attr))) + +/* 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(_attr)) +#define side_type_u32_be(_attr) _side_type_integer(SIDE_TYPE_U32, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), 0, SIDE_PARAM(_attr)) +#define side_type_u64_be(_attr) _side_type_integer(SIDE_TYPE_U64, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint64_t), 0, SIDE_PARAM(_attr)) +#define side_type_s16_be(_attr) _side_type_integer(SIDE_TYPE_S16, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(int16_t), 0, SIDE_PARAM(_attr)) +#define side_type_s32_be(_attr) _side_type_integer(SIDE_TYPE_S32, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(int32_t), 0, SIDE_PARAM(_attr)) +#define side_type_s64_be(_attr) _side_type_integer(SIDE_TYPE_S64, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(int64_t), 0, SIDE_PARAM(_attr)) +#define side_type_pointer_be(_attr) _side_type_integer(SIDE_TYPE_POINTER, false, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uintptr_t), 0, SIDE_PARAM(_attr)) +#define side_type_float_binary16_be(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float16), SIDE_PARAM(_attr)) +#define side_type_float_binary32_be(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float32), SIDE_PARAM(_attr)) +#define side_type_float_binary64_be(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float64), SIDE_PARAM(_attr)) +#define side_type_float_binary128_be(_attr) _side_type_float(SIDE_TYPE_FLOAT_BINARY128, SIDE_TYPE_BYTE_ORDER_BE, sizeof(_Float128), SIDE_PARAM(_attr)) +#define side_type_string16_be(_attr) _side_type_string(SIDE_TYPE_STRING_UTF16, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), SIDE_PARAM(_attr)) +#define side_type_string32_be(_attr) _side_type_string(SIDE_TYPE_STRING_UTF32, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), SIDE_PARAM(_attr)) + +#define side_field_u16_be(_name, _attr) _side_field(_name, side_type_u16_be(SIDE_PARAM(_attr))) +#define side_field_u32_be(_name, _attr) _side_field(_name, side_type_u32_be(SIDE_PARAM(_attr))) +#define side_field_u64_be(_name, _attr) _side_field(_name, side_type_u64_be(SIDE_PARAM(_attr))) +#define side_field_s16_be(_name, _attr) _side_field(_name, side_type_s16_be(SIDE_PARAM(_attr))) +#define side_field_s32_be(_name, _attr) _side_field(_name, side_type_s32_be(SIDE_PARAM(_attr))) +#define side_field_s64_be(_name, _attr) _side_field(_name, side_type_s64_be(SIDE_PARAM(_attr))) +#define side_field_pointer_be(_name, _attr) _side_field(_name, side_type_pointer_be(SIDE_PARAM(_attr))) +#define side_field_float_binary16_be(_name, _attr) _side_field(_name, side_type_float_binary16_be(SIDE_PARAM(_attr))) +#define side_field_float_binary32_be(_name, _attr) _side_field(_name, side_type_float_binary32_be(SIDE_PARAM(_attr))) +#define side_field_float_binary64_be(_name, _attr) _side_field(_name, side_type_float_binary64_be(SIDE_PARAM(_attr))) +#define side_field_float_binary128_be(_name, _attr) _side_field(_name, side_type_float_binary128_be(SIDE_PARAM(_attr))) +#define side_field_string16_be(_name, _attr) _side_field(_name, side_type_string16_be(SIDE_PARAM(_attr))) +#define side_field_string32_be(_name, _attr) _side_field(_name, side_type_string32_be(SIDE_PARAM(_attr))) + +#define side_type_enum(_mappings, _elem_type) \ + { \ + .type = SIDE_TYPE_ENUM, \ + .u = { \ + .side_enum = { \ + .mappings = _mappings, \ + .elem_type = _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) \ + { \ + .type = SIDE_TYPE_ENUM_BITMAP, \ + .u = { \ + .side_enum_bitmap = { \ + .mappings = _mappings, \ + .elem_type = _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) \ + { \ + .type = SIDE_TYPE_STRUCT, \ + .u = { \ + .side_struct = _struct, \ + }, \ + } +#define side_field_struct(_name, _struct) \ + _side_field(_name, side_type_struct(SIDE_PARAM(_struct))) + +#define _side_type_struct_define(_fields, _attr) \ + { \ + .fields = _fields, \ + .attr = _attr, \ + .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \ + .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(_attr)) + +#define side_struct_literal(_fields, _attr) \ + SIDE_COMPOUND_LITERAL(const struct side_type_struct, \ + _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM(_attr))) + +#define side_type_array(_elem_type, _length, _attr) \ + { \ + .type = SIDE_TYPE_ARRAY, \ + .u = { \ + .side_array = { \ + .elem_type = _elem_type, \ + .attr = _attr, \ + .length = _length, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + }, \ + }, \ + } +#define side_field_array(_name, _elem_type, _length, _attr) \ + _side_field(_name, side_type_array(SIDE_PARAM(_elem_type), _length, SIDE_PARAM(_attr))) + +#define side_type_vla(_elem_type, _attr) \ + { \ + .type = SIDE_TYPE_VLA, \ + .u = { \ + .side_vla = { \ + .elem_type = _elem_type, \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + }, \ + }, \ + } +#define side_field_vla(_name, _elem_type, _attr) \ + _side_field(_name, side_type_vla(SIDE_PARAM(_elem_type), SIDE_PARAM(_attr))) + +#define side_type_vla_visitor(_elem_type, _visitor, _attr) \ + { \ + .type = SIDE_TYPE_VLA_VISITOR, \ + .u = { \ + .side_vla_visitor = { \ + .elem_type = SIDE_PARAM(_elem_type), \ + .visitor = _visitor, \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + }, \ + }, \ + } +#define side_field_vla_visitor(_name, _elem_type, _visitor, _attr) \ + _side_field(_name, side_type_vla_visitor(SIDE_PARAM(_elem_type), _visitor, SIDE_PARAM(_attr))) + +/* Gather field and type definitions */ + +#define side_type_gather_byte(_offset, _access_mode, _attr) \ + { \ + .type = SIDE_TYPE_GATHER_BYTE, \ + .u = { \ + .side_gather = { \ + .u = { \ + .side_byte = { \ + .offset = _offset, \ + .access_mode = _access_mode, \ + .type = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + }, \ + }, \ + }, \ + }, \ + }, \ + } +#define side_field_gather_byte(_name, _offset, _access_mode, _attr) \ + _side_field(_name, side_type_gather_byte(_offset, _access_mode, SIDE_PARAM(_attr))) + +#define _side_type_gather_bool(_byte_order, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr) \ + { \ + .type = SIDE_TYPE_GATHER_BOOL, \ + .u = { \ + .side_gather = { \ + .u = { \ + .side_bool = { \ + .offset = _offset, \ + .access_mode = _access_mode, \ + .type = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .bool_size = _bool_size, \ + .len_bits = _len_bits, \ + .byte_order = _byte_order, \ + }, \ + .offset_bits = _offset_bits, \ + }, \ + }, \ + }, \ + }, \ + } +#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, _attr) +#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, _attr) +#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, _attr) + +#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(_attr))) +#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(_attr))) +#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(_attr))) + +#define _side_type_gather_integer(_type, _signedness, _byte_order, _offset, \ + _integer_size, _offset_bits, _len_bits, _access_mode, _attr) \ + { \ + .type = _type, \ + .u = { \ + .side_gather = { \ + .u = { \ + .side_integer = { \ + .offset = _offset, \ + .access_mode = _access_mode, \ + .type = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .integer_size = _integer_size, \ + .len_bits = _len_bits, \ + .signedness = _signedness, \ + .byte_order = _byte_order, \ + }, \ + .offset_bits = _offset_bits, \ + }, \ + }, \ + }, \ + }, \ + } + +#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(_attr)) +#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(_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(_attr)) +#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(_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(_attr)) +#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(_attr)) + +#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(_attr))) +#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(_attr))) + +#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(_attr))) +#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(_attr))) + +#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(_attr))) +#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(_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(_attr)) +#define side_field_gather_pointer(_name, _offset, _access_mode, _attr) \ + _side_field(_name, side_type_gather_pointer(_offset, _access_mode, SIDE_PARAM(_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(_attr)) +#define side_field_gather_pointer_le(_name, _offset, _access_mode, _attr) \ + _side_field(_name, side_type_gather_pointer_le(_offset, _access_mode, SIDE_PARAM(_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(_attr)) +#define side_field_gather_pointer_be(_name, _offset, _access_mode, _attr) \ + _side_field(_name, side_type_gather_pointer_be(_offset, _access_mode, SIDE_PARAM(_attr))) + +#define _side_type_gather_float(_byte_order, _offset, _float_size, _access_mode, _attr) \ + { \ + .type = SIDE_TYPE_GATHER_FLOAT, \ + .u = { \ + .side_gather = { \ + .u = { \ + .side_float = { \ + .offset = _offset, \ + .access_mode = _access_mode, \ + .type = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .float_size = _float_size, \ + .byte_order = _byte_order, \ + }, \ + }, \ + }, \ + }, \ + }, \ + } + +#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, _attr) +#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, _attr) +#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, _attr) + +#define side_field_gather_float(_name, _offset, _float_size, _access_mode, _attr) \ + _side_field(_name, side_type_gather_float(_offset, _float_size, _access_mode, _attr)) +#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, _attr)) +#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, _attr)) + +#define _side_type_gather_string(_offset, _byte_order, _unit_size, _access_mode, _attr) \ + { \ + .type = SIDE_TYPE_GATHER_STRING, \ + .u = { \ + .side_gather = { \ + .u = { \ + .side_string = { \ + .offset = _offset, \ + .access_mode = _access_mode, \ + .type = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .unit_size = _unit_size, \ + .byte_order = _byte_order, \ + }, \ + }, \ + }, \ + }, \ + }, \ + } +#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(_attr)) +#define side_field_gather_string(_name, _offset, _access_mode, _attr) \ + _side_field(_name, side_type_gather_string(_offset, _access_mode, SIDE_PARAM(_attr))) + +#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(_attr)) +#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(_attr)) +#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(_attr)) + +#define side_field_gather_string16(_name, _offset, _access_mode, _attr) \ + _side_field(_name, side_type_gather_string16(_offset, _access_mode, SIDE_PARAM(_attr))) +#define side_field_gather_string16_le(_name, _offset, _access_mode, _attr) \ + _side_field(_name, side_type_gather_string16_le(_offset, _access_mode, SIDE_PARAM(_attr))) +#define side_field_gather_string16_be(_name, _offset, _access_mode, _attr) \ + _side_field(_name, side_type_gather_string16_be(_offset, _access_mode, SIDE_PARAM(_attr))) + +#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(_attr)) +#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(_attr)) +#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(_attr)) + +#define side_field_gather_string32(_name, _offset, _access_mode, _attr) \ + _side_field(_name, side_type_gather_string32(_offset, _access_mode, SIDE_PARAM(_attr))) +#define side_field_gather_string32_le(_name, _offset, _access_mode, _attr) \ + _side_field(_name, side_type_gather_string32_le(_offset, _access_mode, SIDE_PARAM(_attr))) +#define side_field_gather_string32_be(_name, _offset, _access_mode, _attr) \ + _side_field(_name, side_type_gather_string32_be(_offset, _access_mode, SIDE_PARAM(_attr))) + +#define side_type_gather_enum(_mappings, _elem_type) \ + { \ + .type = SIDE_TYPE_GATHER_ENUM, \ + .u = { \ + .side_enum = { \ + .mappings = _mappings, \ + .elem_type = _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) \ + { \ + .type = SIDE_TYPE_GATHER_STRUCT, \ + .u = { \ + .side_gather = { \ + .u = { \ + .side_struct = { \ + .offset = _offset, \ + .access_mode = _access_mode, \ + .type = _struct_gather, \ + .size = _size, \ + }, \ + }, \ + }, \ + }, \ + } +#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) \ + { \ + .type = SIDE_TYPE_GATHER_ARRAY, \ + .u = { \ + .side_gather = { \ + .u = { \ + .side_array = { \ + .offset = _offset, \ + .access_mode = _access_mode, \ + .type = { \ + .elem_type = _elem_type_gather, \ + .attr = _attr, \ + .length = _length, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + }, \ + }, \ + }, \ + }, \ + }, \ + } +#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(_attr))) + +#define side_type_gather_vla(_elem_type_gather, _offset, _access_mode, _length_type_gather, _attr) \ + { \ + .type = SIDE_TYPE_GATHER_VLA, \ + .u = { \ + .side_gather = { \ + .u = { \ + .side_vla = { \ + .length_type = _length_type_gather, \ + .offset = _offset, \ + .access_mode = _access_mode, \ + .type = { \ + .elem_type = _elem_type_gather, \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + }, \ + }, \ + }, \ + }, \ + }, \ + } +#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(_attr))) + +#define side_elem(...) \ + SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__) + +#define side_length(...) \ + SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__) + +#define side_field_list(...) \ + SIDE_COMPOUND_LITERAL(const struct side_event_field, __VA_ARGS__) + +/* Stack-copy field arguments */ + +#define side_arg_null(_val) { .type = SIDE_TYPE_NULL } +#define side_arg_bool(_val) { .type = SIDE_TYPE_BOOL, .u = { .side_static = { .bool_value = { .side_bool8 = !!(_val) } } } } +#define side_arg_byte(_val) { .type = SIDE_TYPE_BYTE, .u = { .side_static = { .byte_value = (_val) } } } +#define side_arg_string(_val) { .type = SIDE_TYPE_STRING_UTF8, .u = { .side_static = { .string_value = (uintptr_t) (_val) } } } +#define side_arg_string16(_val) { .type = SIDE_TYPE_STRING_UTF16, .u = { .side_static = { .string_value = (uintptr_t) (_val) } } } +#define side_arg_string32(_val) { .type = SIDE_TYPE_STRING_UTF32, .u = { .side_static = { .string_value = (uintptr_t) (_val) } } } + +#define side_arg_u8(_val) { .type = SIDE_TYPE_U8, .u = { .side_static = { .integer_value = { .side_u8 = (_val) } } } } +#define side_arg_u16(_val) { .type = SIDE_TYPE_U16, .u = { .side_static = { .integer_value = { .side_u16 = (_val) } } } } +#define side_arg_u32(_val) { .type = SIDE_TYPE_U32, .u = { .side_static = { .integer_value = { .side_u32 = (_val) } } } } +#define side_arg_u64(_val) { .type = SIDE_TYPE_U64, .u = { .side_static = { .integer_value = { .side_u64 = (_val) } } } } +#define side_arg_s8(_val) { .type = SIDE_TYPE_S8, .u = { .side_static = { .integer_value = { .side_s8 = (_val) } } } } +#define side_arg_s16(_val) { .type = SIDE_TYPE_S16, .u = { .side_static = { .integer_value = { .side_s16 = (_val) } } } } +#define side_arg_s32(_val) { .type = SIDE_TYPE_S32, .u = { .side_static = { .integer_value = { .side_s32 = (_val) } } } } +#define side_arg_s64(_val) { .type = SIDE_TYPE_S64, .u = { .side_static = { .integer_value = { .side_s64 = (_val) } } } } +#define side_arg_pointer(_val) { .type = SIDE_TYPE_POINTER, .u = { .side_static = { .integer_value = { .side_uptr = (uintptr_t) (_val) } } } } +#define side_arg_float_binary16(_val) { .type = SIDE_TYPE_FLOAT_BINARY16, .u = { .side_static = { .float_value = { .side_float_binary16 = (_val) } } } } +#define side_arg_float_binary32(_val) { .type = SIDE_TYPE_FLOAT_BINARY32, .u = { .side_static = { .float_value = { .side_float_binary32 = (_val) } } } } +#define side_arg_float_binary64(_val) { .type = SIDE_TYPE_FLOAT_BINARY64, .u = { .side_static = { .float_value = { .side_float_binary64 = (_val) } } } } +#define side_arg_float_binary128(_val) { .type = SIDE_TYPE_FLOAT_BINARY128, .u = { .side_static = { .float_value = { .side_float_binary128 = (_val) } } } } + +#define side_arg_struct(_side_type) { .type = SIDE_TYPE_STRUCT, .u = { .side_static = { .side_struct = (_side_type) } } } +#define side_arg_array(_side_type) { .type = SIDE_TYPE_ARRAY, .u = { .side_static = { .side_array = (_side_type) } } } +#define side_arg_vla(_side_type) { .type = SIDE_TYPE_VLA, .u = { .side_static = { .side_vla = (_side_type) } } } +#define side_arg_vla_visitor(_ctx) { .type = SIDE_TYPE_VLA_VISITOR, .u = { .side_static = { .side_vla_app_visitor_ctx = (_ctx) } } } + +/* Gather field arguments */ + +#define side_arg_gather_bool(_ptr) { .type = SIDE_TYPE_GATHER_BOOL, .u = { .side_static = { .side_bool_gather_ptr = (_ptr) } } } +#define side_arg_gather_byte(_ptr) { .type = SIDE_TYPE_GATHER_BYTE, .u = { .side_static = { .side_byte_gather_ptr = (_ptr) } } } +#define side_arg_gather_pointer(_ptr) { .type = SIDE_TYPE_GATHER_POINTER, .u = { .side_static = { .side_integer_gather_ptr = (_ptr) } } } +#define side_arg_gather_integer(_ptr) { .type = SIDE_TYPE_GATHER_INTEGER, .u = { .side_static = { .side_integer_gather_ptr = (_ptr) } } } +#define side_arg_gather_float(_ptr) { .type = SIDE_TYPE_GATHER_FLOAT, .u = { .side_static = { .side_float_gather_ptr = (_ptr) } } } +#define side_arg_gather_string(_ptr) { .type = SIDE_TYPE_GATHER_STRING, .u = { .side_static = { .side_string_gather_ptr = (_ptr) } } } +#define side_arg_gather_struct(_ptr) { .type = SIDE_TYPE_GATHER_STRUCT, .u = { .side_static = { .side_struct_gather_ptr = (_ptr) } } } +#define side_arg_gather_array(_ptr) { .type = SIDE_TYPE_GATHER_ARRAY, .u = { .side_static = { .side_array_gather_ptr = (_ptr) } } } +#define side_arg_gather_vla(_ptr, _length_ptr) { .type = SIDE_TYPE_GATHER_VLA, .u = { .side_static = { .side_vla_gather = { .ptr = (_ptr), .length_ptr = (_length_ptr) } } } } + +/* Dynamic field arguments */ + +#define side_arg_dynamic_null(_attr) \ + { \ + .type = SIDE_TYPE_DYNAMIC_NULL, \ + .u = { \ + .side_dynamic = { \ + .side_null = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + }, \ + }, \ + }, \ + } + +#define side_arg_dynamic_bool(_val, _attr) \ + { \ + .type = SIDE_TYPE_DYNAMIC_BOOL, \ + .u = { \ + .side_dynamic = { \ + .side_bool = { \ + .type = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .bool_size = sizeof(uint8_t), \ + .len_bits = 0, \ + .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \ + }, \ + .value = { \ + .side_bool8 = !!(_val), \ + }, \ + }, \ + }, \ + }, \ + } + +#define side_arg_dynamic_byte(_val, _attr) \ + { \ + .type = SIDE_TYPE_DYNAMIC_BYTE, \ + .u = { \ + .side_dynamic = { \ + .side_byte = { \ + .type = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + }, \ + .value = (_val), \ + }, \ + }, \ + }, \ + } +#define _side_arg_dynamic_string(_val, _byte_order, _unit_size, _attr) \ + { \ + .type = SIDE_TYPE_DYNAMIC_STRING, \ + .u = { \ + .side_dynamic = { \ + .side_string = { \ + .type = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .unit_size = _unit_size, \ + .byte_order = _byte_order, \ + }, \ + .value = (uintptr_t) (_val), \ + }, \ + }, \ + }, \ + } +#define side_arg_dynamic_string(_val, _attr) \ + _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), SIDE_PARAM(_attr)) +#define side_arg_dynamic_string16(_val, _attr) \ + _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), SIDE_PARAM(_attr)) +#define side_arg_dynamic_string16_le(_val, _attr) \ + _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), SIDE_PARAM(_attr)) +#define side_arg_dynamic_string16_be(_val, _attr) \ + _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), SIDE_PARAM(_attr)) +#define side_arg_dynamic_string32(_val, _attr) \ + _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), SIDE_PARAM(_attr)) +#define side_arg_dynamic_string32_le(_val, _attr) \ + _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), SIDE_PARAM(_attr)) +#define side_arg_dynamic_string32_be(_val, _attr) \ + _side_arg_dynamic_string(_val, SIDE_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), SIDE_PARAM(_attr)) + +#define _side_arg_dynamic_integer(_field, _val, _type, _signedness, _byte_order, _integer_size, _len_bits, _attr) \ + { \ + .type = _type, \ + .u = { \ + .side_dynamic = { \ + .side_integer = { \ + .type = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .integer_size = _integer_size, \ + .len_bits = _len_bits, \ + .signedness = _signedness, \ + .byte_order = _byte_order, \ + }, \ + .value = { \ + _field = (_val), \ + }, \ + }, \ + }, \ + }, \ + } + +#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(_attr)) +#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(_attr)) + +#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(_attr)) +#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(_attr)) +#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(_attr)) + +#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(_attr)) +#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(_attr)) +#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(_attr)) + +#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(_attr)) + +#define _side_arg_dynamic_float(_field, _val, _type, _byte_order, _float_size, _attr) \ + { \ + .type = _type, \ + .u = { \ + .side_dynamic = { \ + .side_float = { \ + .type = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .float_size = _float_size, \ + .byte_order = _byte_order, \ + }, \ + .value = { \ + _field = (_val), \ + }, \ + }, \ + }, \ + }, \ + } + +#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(_attr)) +#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(_attr)) +#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(_attr)) +#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(_attr)) + +/* Host endian */ +#define side_arg_dynamic_u16(_val, _attr) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr)) +#define side_arg_dynamic_u32(_val, _attr) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr)) +#define side_arg_dynamic_u64(_val, _attr) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr)) +#define side_arg_dynamic_s16(_val, _attr) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr)) +#define side_arg_dynamic_s32(_val, _attr) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr)) +#define side_arg_dynamic_s64(_val, _attr) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr)) +#define side_arg_dynamic_pointer(_val, _attr) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_HOST, SIDE_PARAM(_attr)) +#define side_arg_dynamic_float_binary16(_val, _attr) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM(_attr)) +#define side_arg_dynamic_float_binary32(_val, _attr) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM(_attr)) +#define side_arg_dynamic_float_binary64(_val, _attr) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM(_attr)) +#define side_arg_dynamic_float_binary128(_val, _attr) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_FLOAT_WORD_ORDER_HOST, SIDE_PARAM(_attr)) + +/* Little endian */ +#define side_arg_dynamic_u16_le(_val, _attr) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_u32_le(_val, _attr) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_u64_le(_val, _attr) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_s16_le(_val, _attr) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_s32_le(_val, _attr) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_s64_le(_val, _attr) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_pointer_le(_val, _attr) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_float_binary16_le(_val, _attr) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_float_binary32_le(_val, _attr) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_float_binary64_le(_val, _attr) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_float_binary128_le(_val, _attr) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_BYTE_ORDER_LE, SIDE_PARAM(_attr)) + +/* Big endian */ +#define side_arg_dynamic_u16_be(_val, _attr) _side_arg_dynamic_u16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_u32_be(_val, _attr) _side_arg_dynamic_u32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_u64_be(_val, _attr) _side_arg_dynamic_u64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_s16_be(_val, _attr) _side_arg_dynamic_s16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_s32_be(_val, _attr) _side_arg_dynamic_s32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_s64_be(_val, _attr) _side_arg_dynamic_s64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_pointer_be(_val, _attr) _side_arg_dynamic_pointer(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_float_binary16_be(_val, _attr) _side_arg_dynamic_float_binary16(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_float_binary32_be(_val, _attr) _side_arg_dynamic_float_binary32(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_float_binary64_be(_val, _attr) _side_arg_dynamic_float_binary64(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr)) +#define side_arg_dynamic_float_binary128_be(_val, _attr) _side_arg_dynamic_float_binary128(_val, SIDE_TYPE_BYTE_ORDER_BE, SIDE_PARAM(_attr)) + +#define side_arg_dynamic_vla(_vla) \ + { \ + .type = SIDE_TYPE_DYNAMIC_VLA, \ + .u = { \ + .side_dynamic = { \ + .side_dynamic_vla = (_vla), \ + }, \ + }, \ + } + +#define side_arg_dynamic_vla_visitor(_dynamic_vla_visitor, _ctx, _attr) \ + { \ + .type = SIDE_TYPE_DYNAMIC_VLA_VISITOR, \ + .u = { \ + .side_dynamic = { \ + .side_dynamic_vla_visitor = { \ + .app_ctx = _ctx, \ + .visitor = _dynamic_vla_visitor, \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + }, \ + }, \ + }, \ + } + +#define side_arg_dynamic_struct(_struct) \ + { \ + .type = SIDE_TYPE_DYNAMIC_STRUCT, \ + .u = { \ + .side_dynamic = { \ + .side_dynamic_struct = (_struct), \ + }, \ + }, \ + } + +#define side_arg_dynamic_struct_visitor(_dynamic_struct_visitor, _ctx, _attr) \ + { \ + .type = SIDE_TYPE_DYNAMIC_STRUCT_VISITOR, \ + .u = { \ + .side_dynamic = { \ + .side_dynamic_struct_visitor = { \ + .app_ctx = _ctx, \ + .visitor = _dynamic_struct_visitor, \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_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 = _identifier##_vec, \ + .attr = _attr, \ + .len = SIDE_ARRAY_SIZE(_identifier##_vec), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_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 = _identifier##_fields, \ + .attr = _attr, \ + .len = SIDE_ARRAY_SIZE(_identifier##_fields), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + } + +#define side_arg_define_vec(_identifier, _sav) \ + const struct side_arg _identifier##_vec[] = { _sav }; \ + const struct side_arg_vec _identifier = { \ + .sav = _identifier##_vec, \ + .len = SIDE_ARRAY_SIZE(_identifier##_vec), \ + } + +#define side_arg_dynamic_field(_name, _elem) \ + { \ + .field_name = _name, \ + .elem = _elem, \ + } + +/* + * Event instrumentation description registration, runtime enabled state + * check, and instrumentation invocation. + */ + +#define side_arg_list(...) __VA_ARGS__ + +#define side_event_cond(_identifier) \ + if (side_unlikely(__atomic_load_n(&side_event_enable__##_identifier, \ + __ATOMIC_RELAXED))) + +#define side_event_call(_identifier, _sav) \ + { \ + const struct side_arg side_sav[] = { _sav }; \ + const struct side_arg_vec side_arg_vec = { \ + .sav = side_sav, \ + .len = SIDE_ARRAY_SIZE(side_sav), \ + }; \ + side_call(&(_identifier), &side_arg_vec); \ + } + +#define side_event(_identifier, _sav) \ + side_event_cond(_identifier) \ + side_event_call(_identifier, SIDE_PARAM(_sav)) + +#define side_event_call_variadic(_identifier, _sav, _var_fields, _attr) \ + { \ + const struct side_arg side_sav[] = { _sav }; \ + const struct side_arg_vec side_arg_vec = { \ + .sav = side_sav, \ + .len = SIDE_ARRAY_SIZE(side_sav), \ + }; \ + const struct side_arg_dynamic_field side_fields[] = { _var_fields }; \ + const struct side_arg_dynamic_struct var_struct = { \ + .fields = side_fields, \ + .attr = _attr, \ + .len = SIDE_ARRAY_SIZE(side_fields), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + }; \ + side_call_variadic(&(_identifier), &side_arg_vec, &var_struct); \ + } + +#define side_event_variadic(_identifier, _sav, _var, _attr) \ + side_event_cond(_identifier) \ + side_event_call_variadic(_identifier, SIDE_PARAM(_sav), SIDE_PARAM(_var), SIDE_PARAM(_attr)) + +#define _side_define_event(_linkage, _identifier, _provider, _event, _loglevel, _fields, _attr, _flags) \ + _linkage uintptr_t side_event_enable__##_identifier __attribute__((section("side_event_enable"))); \ + _linkage struct side_event_description __attribute__((section("side_event_description"))) \ + _identifier = { \ + .enabled = &(side_event_enable__##_identifier), \ + .provider_name = _provider, \ + .event_name = _event, \ + .fields = _fields, \ + .attr = _attr, \ + .callbacks = &side_empty_callback, \ + .flags = (_flags), \ + .version = 0, \ + .loglevel = _loglevel, \ + .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .nr_callbacks = 0, \ + }; \ + static const struct side_event_description *side_event_ptr__##_identifier \ + __attribute__((section("side_event_description_ptr"), used)) = &(_identifier); + +#define side_static_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \ + _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \ + SIDE_PARAM(_attr), 0) + +#define side_static_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \ + _side_define_event(static, _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \ + SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC) + +#define side_hidden_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \ + _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \ + _loglevel, SIDE_PARAM(_fields), SIDE_PARAM(_attr), 0) + +#define side_hidden_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \ + _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \ + _loglevel, SIDE_PARAM(_fields), SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC) + +#define side_export_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \ + _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \ + _loglevel, SIDE_PARAM(_fields), SIDE_PARAM(_attr), 0) + +#define side_export_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \ + _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \ + _loglevel, SIDE_PARAM(_fields), SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC) + +#define side_declare_event(_identifier) \ + extern uintptr_t side_event_enable_##_identifier; \ + extern struct side_event_description _identifier + +#ifdef __cplusplus +extern "C" { +#endif + +extern const struct side_callback side_empty_callback; + +void side_call(const struct side_event_description *desc, + const struct side_arg_vec *side_arg_vec); +void side_call_variadic(const struct side_event_description *desc, + const struct side_arg_vec *side_arg_vec, + const struct side_arg_dynamic_struct *var_struct); + +struct side_events_register_handle *side_events_register(struct side_event_description **events, + uint32_t nr_events); +void side_events_unregister(struct side_events_register_handle *handle); + +/* + * Userspace tracer registration API. This allows userspace tracers to + * register event notification callbacks to be notified of the currently + * registered instrumentation, and to register their callbacks to + * specific events. + */ +typedef void (*side_tracer_callback_func)(const struct side_event_description *desc, + const struct side_arg_vec *side_arg_vec, + void *priv); +typedef void (*side_tracer_callback_variadic_func)(const struct side_event_description *desc, + const struct side_arg_vec *side_arg_vec, + const struct side_arg_dynamic_struct *var_struct, + void *priv); + +int side_tracer_callback_register(struct side_event_description *desc, + side_tracer_callback_func call, + void *priv); +int side_tracer_callback_variadic_register(struct side_event_description *desc, + side_tracer_callback_variadic_func call_variadic, + void *priv); +int side_tracer_callback_unregister(struct side_event_description *desc, + side_tracer_callback_func call, + void *priv); +int side_tracer_callback_variadic_unregister(struct side_event_description *desc, + side_tracer_callback_variadic_func call_variadic, + void *priv); + +enum side_tracer_notification { + SIDE_TRACER_NOTIFICATION_INSERT_EVENTS, + SIDE_TRACER_NOTIFICATION_REMOVE_EVENTS, +}; + +/* Callback is invoked with side library internal lock held. */ +struct side_tracer_handle *side_tracer_event_notification_register( + void (*cb)(enum side_tracer_notification notif, + struct side_event_description **events, uint32_t nr_events, void *priv), + void *priv); +void side_tracer_event_notification_unregister(struct side_tracer_handle *handle); + +/* + * Explicit hooks to initialize/finalize the side instrumentation + * library. Those are also library constructor/destructor. + */ +void side_init(void) __attribute__((constructor)); +void side_exit(void) __attribute__((destructor)); + +/* + * The following constructors/destructors perform automatic registration + * of the declared side events. Those may have to be called explicitly + * in a statically linked library. + */ + +/* + * These weak symbols, the constructor, and destructor take care of + * registering only _one_ instance of the side instrumentation per + * shared-ojbect (or for the whole main program). + */ +extern struct side_event_description * __start_side_event_description_ptr[] + __attribute__((weak, visibility("hidden"))); +extern struct side_event_description * __stop_side_event_description_ptr[] + __attribute__((weak, visibility("hidden"))); +int side_event_description_ptr_registered + __attribute__((weak, visibility("hidden"))); +struct side_events_register_handle *side_events_handle + __attribute__((weak, visibility("hidden"))); + +static void +side_event_description_ptr_init(void) + __attribute__((no_instrument_function)) + __attribute__((constructor)); +static void +side_event_description_ptr_init(void) +{ + if (side_event_description_ptr_registered++) + return; + side_events_handle = side_events_register(__start_side_event_description_ptr, + __stop_side_event_description_ptr - __start_side_event_description_ptr); +} + +static void +side_event_description_ptr_exit(void) + __attribute__((no_instrument_function)) + __attribute__((destructor)); +static void +side_event_description_ptr_exit(void) +{ + if (--side_event_description_ptr_registered) + return; + side_events_unregister(side_events_handle); + side_events_handle = NULL; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _SIDE_TRACE_H */ diff --git a/include/tgif/endian.h b/include/tgif/endian.h deleted file mode 100644 index e31afc9..0000000 --- a/include/tgif/endian.h +++ /dev/null @@ -1,95 +0,0 @@ -// SPDX-License-Identifier: MIT -/* - * - * Copyright (C) 2012,2022 Mathieu Desnoyers - */ - -/* - * This header defines the following endian macros based on the current - * platform endian headers: - * - * BYTE_ORDER this macro shall have a value equal to one - * of the *_ENDIAN macros in this header. - * FLOAT_WORD_ORDER this macro shall have a value equal to one - * of the *_ENDIAN macros in this header. - * LITTLE_ENDIAN if BYTE_ORDER == LITTLE_ENDIAN, the host - * byte order is from least significant to - * most significant. - * BIG_ENDIAN if BYTE_ORDER == BIG_ENDIAN, the host byte - * order is from most significant to least - * significant. - * - * Direct byte swapping interfaces: - * - * uint16_t bswap_16(uint16_t x); (* swap bytes 16-bit word *) - * uint32_t bswap_32(uint32_t x); (* swap bytes 32-bit word *) - * uint64_t bswap_64(uint32_t x); (* swap bytes 64-bit word *) - */ - -#ifndef _TGIF_ENDIAN_H -#define _TGIF_ENDIAN_H - -#include -#include - -#if (defined(__linux__) || defined(__CYGWIN__)) -#include -#include - -#define tgif_bswap_16(x) bswap_16(x) -#define tgif_bswap_32(x) bswap_32(x) -#define tgif_bswap_64(x) bswap_64(x) - -#define TGIF_BYTE_ORDER __BYTE_ORDER -#define TGIF_LITTLE_ENDIAN __LITTLE_ENDIAN -#define TGIF_BIG_ENDIAN __BIG_ENDIAN - -#ifdef __FLOAT_WORD_ORDER -#define TGIF_FLOAT_WORD_ORDER __FLOAT_WORD_ORDER -#else /* __FLOAT_WORD_ORDER */ -#define TGIF_FLOAT_WORD_ORDER __BYTE_ORDER -#endif /* __FLOAT_WORD_ORDER */ - -#elif defined(__FreeBSD__) - -#include - -#define tgif_bswap_16(x) bswap16(x) -#define tgif_bswap_32(x) bswap32(x) -#define tgif_bswap_64(x) bswap64(x) - -#define TGIF_BYTE_ORDER BYTE_ORDER -#define TGIF_LITTLE_ENDIAN LITTLE_ENDIAN -#define TGIF_BIG_ENDIAN BIG_ENDIAN -#define TGIF_FLOAT_WORD_ORDER BYTE_ORDER - -#else -#error "Please add support for your OS." -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __HAVE_FLOAT128 -static inline -void tgif_bswap_128p(char *p) -{ - int i; - - for (i = 0; i < 8; i++) - p[i] = p[15 - i]; -} -#endif - -#ifdef __cplusplus -} -#endif - -#if TGIF_BITS_PER_LONG == 64 -# define tgif_bswap_pointer(x) tgif_bswap_64(x) -#else -# define tgif_bswap_pointer(x) tgif_bswap_32(x) -#endif - -#endif /* _TGIF_ENDIAN_H */ diff --git a/include/tgif/macros.h b/include/tgif/macros.h deleted file mode 100644 index 99d7b63..0000000 --- a/include/tgif/macros.h +++ /dev/null @@ -1,60 +0,0 @@ -// SPDX-License-Identifier: MIT -/* - * Copyright 2022 Mathieu Desnoyers - */ - -#ifndef _TGIF_MACROS_H -#define _TGIF_MACROS_H - -#include -#include - -/* Helper macros */ - -#define TGIF_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) - -/* - * Compound literals with static storage are needed by TGIF - * instrumentation. - * Compound literals are part of the C99 and C11 standards, but not - * part of the C++ standards. They are supported by most C++ compilers - * though. - * - * Example use: - * static struct mystruct *var = LTTNG_UST_COMPOUND_LITERAL(struct mystruct, { 1, 2, 3 }); - */ -#define TGIF_COMPOUND_LITERAL(type, ...) (type[]) { __VA_ARGS__ } - -#define tgif_likely(x) __builtin_expect(!!(x), 1) -#define tgif_unlikely(x) __builtin_expect(!!(x), 0) - -#define TGIF_PARAM(...) __VA_ARGS__ - -/* - * tgif_container_of - Get the address of an object containing a field. - * - * @ptr: pointer to the field. - * @type: type of the object. - * @member: name of the field within the object. - */ -#define tgif_container_of(ptr, type, member) \ - __extension__ \ - ({ \ - const __typeof__(((type *) NULL)->member) * __ptr = (ptr); \ - (type *)((char *)__ptr - offsetof(type, member)); \ - }) - -#define tgif_struct_field_sizeof(_struct, _field) \ - sizeof(((_struct * )NULL)->_field) - -#if defined(__SIZEOF_LONG__) -#define TGIF_BITS_PER_LONG (__SIZEOF_LONG__ * 8) -#elif defined(_LP64) -#define TGIF_BITS_PER_LONG 64 -#else -#define TGIF_BITS_PER_LONG 32 -#endif - -#define TGIF_PACKED __attribute__((packed)) - -#endif /* _TGIF_MACROS_H */ diff --git a/include/tgif/trace.h b/include/tgif/trace.h deleted file mode 100644 index 3a2b6ff..0000000 --- a/include/tgif/trace.h +++ /dev/null @@ -1,1876 +0,0 @@ -// SPDX-License-Identifier: MIT -/* - * Copyright 2022 Mathieu Desnoyers - */ - -#ifndef _TGIF_TRACE_H -#define _TGIF_TRACE_H - -#include -#include -#include -#include -#include -#include -#include - -/* - * TGIF stands for "Trace Generation Instrumentation Framework" - * - * This is an instrumentation API for Linux user-space, which exposes an - * instrumentation type system and facilities allowing a kernel or - * user-space tracer to consume user-space instrumentation. - * - * This instrumentation API exposes 3 type systems: - * - * * Stack-copy type system: This is the core type system which can - * represent all supported types and into which all other type systems - * can be nested. This type system requires that every type is - * statically or dynamically declared and then registered, thus giving - * tracers a complete description of the events and their associated - * fields before the associated instrumentation is invoked. The - * application needs to copy each argument (tgif_arg_...()) onto the - * stack when calling the instrumentation. - * - * This is the most expressive of the 3 type systems, althrough not the - * fastest due to the extra copy of the arguments. - * - * * Data-gathering type system: This type system requires every type to - * be statically or dynamically declared and registered, but does not - * require the application to copy its arguments onto the stack. - * Instead, the type description contains all the required information - * to fetch the data from the application memory. The only argument - * required from the instrumentation is the base pointer from which - * the data should be fetched. - * - * This type system can be used as an event field, or nested within - * the stack-copy type system. Nesting of gather-vla within - * gather-array and gather-vla types is not allowed. - * - * This type system is has the least overhead of the 3 type systems. - * - * * Dynamic type system: This type system receives both type - * description and actual data onto the stack at runtime. It has more - * overhead that the 2 other type systems, but does not require a - * prior registration of event field description. This makes it useful - * for seldom used types which are not performance critical, but for - * which registering each individual events would needlessly grow the - * number of events to declare and register. - * - * Another use-case for this type system is for use by dynamically - * typed language runtimes, where the field type is only known when - * the instrumentation is called. - * - * Those dynamic types can be either used as arguments to a variadic - * field list, or as on-stack instrumentation argument for a static - * type TGIF_TYPE_DYNAMIC place holder in the stack-copy type system. - */ - -//TODO: as those structures will be ABI, we need to either contgifr them -//fixed forever, or think of a scheme that would allow their binary -//representation to be extended if need be. - -struct tgif_arg; -struct tgif_arg_vec; -struct tgif_arg_dynamic; -struct tgif_arg_dynamic_field; -struct tgif_arg_dynamic_vla; -struct tgif_type; -struct tgif_event_field; -struct tgif_tracer_visitor_ctx; -struct tgif_tracer_dynamic_struct_visitor_ctx; -struct tgif_event_description; -struct tgif_arg_dynamic_struct; -struct tgif_events_register_handle; - -enum tgif_type_label { - /* Stack-copy basic types */ - TGIF_TYPE_NULL, - TGIF_TYPE_BOOL, - TGIF_TYPE_U8, - TGIF_TYPE_U16, - TGIF_TYPE_U32, - TGIF_TYPE_U64, - TGIF_TYPE_S8, - TGIF_TYPE_S16, - TGIF_TYPE_S32, - TGIF_TYPE_S64, - TGIF_TYPE_BYTE, - TGIF_TYPE_POINTER, - TGIF_TYPE_FLOAT_BINARY16, - TGIF_TYPE_FLOAT_BINARY32, - TGIF_TYPE_FLOAT_BINARY64, - TGIF_TYPE_FLOAT_BINARY128, - TGIF_TYPE_STRING_UTF8, - TGIF_TYPE_STRING_UTF16, - TGIF_TYPE_STRING_UTF32, - - /* Stack-copy compound types */ - TGIF_TYPE_STRUCT, - TGIF_TYPE_ARRAY, - TGIF_TYPE_VLA, - TGIF_TYPE_VLA_VISITOR, - - /* Stack-copy enumeration types */ - TGIF_TYPE_ENUM, - TGIF_TYPE_ENUM_BITMAP, - - /* Stack-copy place holder for dynamic types */ - TGIF_TYPE_DYNAMIC, - - /* Gather basic types */ - TGIF_TYPE_GATHER_BOOL, - TGIF_TYPE_GATHER_INTEGER, - TGIF_TYPE_GATHER_BYTE, - TGIF_TYPE_GATHER_POINTER, - TGIF_TYPE_GATHER_FLOAT, - TGIF_TYPE_GATHER_STRING, - - /* Gather compound types */ - TGIF_TYPE_GATHER_STRUCT, - TGIF_TYPE_GATHER_ARRAY, - TGIF_TYPE_GATHER_VLA, - - /* Gather enumeration types */ - TGIF_TYPE_GATHER_ENUM, - - /* Dynamic basic types */ - TGIF_TYPE_DYNAMIC_NULL, - TGIF_TYPE_DYNAMIC_BOOL, - TGIF_TYPE_DYNAMIC_INTEGER, - TGIF_TYPE_DYNAMIC_BYTE, - TGIF_TYPE_DYNAMIC_POINTER, - TGIF_TYPE_DYNAMIC_FLOAT, - TGIF_TYPE_DYNAMIC_STRING, - - /* Dynamic compound types */ - TGIF_TYPE_DYNAMIC_STRUCT, - TGIF_TYPE_DYNAMIC_STRUCT_VISITOR, - TGIF_TYPE_DYNAMIC_VLA, - TGIF_TYPE_DYNAMIC_VLA_VISITOR, -}; - -enum tgif_attr_type { - TGIF_ATTR_TYPE_NULL, - TGIF_ATTR_TYPE_BOOL, - TGIF_ATTR_TYPE_U8, - TGIF_ATTR_TYPE_U16, - TGIF_ATTR_TYPE_U32, - TGIF_ATTR_TYPE_U64, - TGIF_ATTR_TYPE_S8, - TGIF_ATTR_TYPE_S16, - TGIF_ATTR_TYPE_S32, - TGIF_ATTR_TYPE_S64, - TGIF_ATTR_TYPE_FLOAT_BINARY16, - TGIF_ATTR_TYPE_FLOAT_BINARY32, - TGIF_ATTR_TYPE_FLOAT_BINARY64, - TGIF_ATTR_TYPE_FLOAT_BINARY128, - TGIF_ATTR_TYPE_STRING, -}; - -enum tgif_loglevel { - TGIF_LOGLEVEL_EMERG = 0, - TGIF_LOGLEVEL_ALERT = 1, - TGIF_LOGLEVEL_CRIT = 2, - TGIF_LOGLEVEL_ERR = 3, - TGIF_LOGLEVEL_WARNING = 4, - TGIF_LOGLEVEL_NOTICE = 5, - TGIF_LOGLEVEL_INFO = 6, - TGIF_LOGLEVEL_DEBUG = 7, -}; - -enum tgif_visitor_status { - TGIF_VISITOR_STATUS_OK = 0, - TGIF_VISITOR_STATUS_ERROR = -1, -}; - -enum tgif_error { - TGIF_ERROR_OK = 0, - TGIF_ERROR_INVAL = 1, - TGIF_ERROR_EXIST = 2, - TGIF_ERROR_NOMEM = 3, - TGIF_ERROR_NOENT = 4, - TGIF_ERROR_EXITING = 5, -}; - -enum tgif_type_label_byte_order { - TGIF_TYPE_BYTE_ORDER_LE = 0, - TGIF_TYPE_BYTE_ORDER_BE = 1, -}; - -#if (TGIF_BYTE_ORDER == TGIF_LITTLE_ENDIAN) -# define TGIF_TYPE_BYTE_ORDER_HOST TGIF_TYPE_BYTE_ORDER_LE -#else -# define TGIF_TYPE_BYTE_ORDER_HOST TGIF_TYPE_BYTE_ORDER_BE -#endif - -#if (TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN) -# define TGIF_TYPE_FLOAT_WORD_ORDER_HOST TGIF_TYPE_BYTE_ORDER_LE -#else -# define TGIF_TYPE_FLOAT_WORD_ORDER_HOST TGIF_TYPE_BYTE_ORDER_BE -#endif - -enum tgif_type_gather_access_mode { - TGIF_TYPE_GATHER_ACCESS_DIRECT, - TGIF_TYPE_GATHER_ACCESS_POINTER, /* Pointer dereference */ -}; - -typedef enum tgif_visitor_status (*tgif_visitor_func)( - const struct tgif_tracer_visitor_ctx *tracer_ctx, - void *app_ctx); -typedef enum tgif_visitor_status (*tgif_dynamic_struct_visitor_func)( - const struct tgif_tracer_dynamic_struct_visitor_ctx *tracer_ctx, - void *app_ctx); - -union tgif_integer_value { - uint8_t tgif_u8; - uint16_t tgif_u16; - uint32_t tgif_u32; - uint64_t tgif_u64; - int8_t tgif_s8; - int16_t tgif_s16; - int32_t tgif_s32; - int64_t tgif_s64; - uintptr_t tgif_uptr; -} TGIF_PACKED; - -union tgif_bool_value { - uint8_t tgif_bool8; - uint16_t tgif_bool16; - uint32_t tgif_bool32; - uint64_t tgif_bool64; -} TGIF_PACKED; - -union tgif_float_value { -#if __HAVE_FLOAT16 - _Float16 tgif_float_binary16; -#endif -#if __HAVE_FLOAT32 - _Float32 tgif_float_binary32; -#endif -#if __HAVE_FLOAT64 - _Float64 tgif_float_binary64; -#endif -#if __HAVE_FLOAT128 - _Float128 tgif_float_binary128; -#endif -} TGIF_PACKED; - -struct tgif_type_raw_string { - const void *p; /* pointer to string */ - uint8_t unit_size; /* 1, 2, or 4 bytes */ - uint8_t byte_order; /* enum tgif_type_label_byte_order */ -} TGIF_PACKED; - -struct tgif_attr_value { - uint32_t type; /* enum tgif_attr_type */ - union { - uint8_t bool_value; - struct tgif_type_raw_string string_value; - union tgif_integer_value integer_value; - union tgif_float_value float_value; - } TGIF_PACKED u; -}; - -/* User attributes. */ -struct tgif_attr { - const struct tgif_type_raw_string key; - const struct tgif_attr_value value; -} TGIF_PACKED; - -/* Type descriptions */ -struct tgif_type_null { - const struct tgif_attr *attr; - uint32_t nr_attr; -} TGIF_PACKED; - -struct tgif_type_bool { - const struct tgif_attr *attr; - uint32_t nr_attr; - uint16_t bool_size; /* bytes */ - uint16_t len_bits; /* bits. 0 for (bool_size * CHAR_BITS) */ - uint8_t byte_order; /* enum tgif_type_label_byte_order */ -} TGIF_PACKED; - -struct tgif_type_byte { - const struct tgif_attr *attr; - uint32_t nr_attr; -} TGIF_PACKED; - -struct tgif_type_string { - const struct tgif_attr *attr; - uint32_t nr_attr; - uint8_t unit_size; /* 1, 2, or 4 bytes */ - uint8_t byte_order; /* enum tgif_type_label_byte_order */ -} TGIF_PACKED; - -struct tgif_type_integer { - const struct tgif_attr *attr; - uint32_t nr_attr; - uint16_t integer_size; /* bytes */ - uint16_t len_bits; /* bits. 0 for (integer_size * CHAR_BITS) */ - uint8_t signedness; /* true/false */ - uint8_t byte_order; /* enum tgif_type_label_byte_order */ -} TGIF_PACKED; - -struct tgif_type_float { - const struct tgif_attr *attr; - uint32_t nr_attr; - uint16_t float_size; /* bytes */ - uint8_t byte_order; /* enum tgif_type_label_byte_order */ -} TGIF_PACKED; - -struct tgif_enum_mapping { - int64_t range_begin; - int64_t range_end; - struct tgif_type_raw_string label; -} TGIF_PACKED; - -struct tgif_enum_mappings { - const struct tgif_enum_mapping *mappings; - const struct tgif_attr *attr; - uint32_t nr_mappings; - uint32_t nr_attr; -} TGIF_PACKED; - -struct tgif_enum_bitmap_mapping { - uint64_t range_begin; - uint64_t range_end; - struct tgif_type_raw_string label; -} TGIF_PACKED; - -struct tgif_enum_bitmap_mappings { - const struct tgif_enum_bitmap_mapping *mappings; - const struct tgif_attr *attr; - uint32_t nr_mappings; - uint32_t nr_attr; -} TGIF_PACKED; - -struct tgif_type_struct { - const struct tgif_event_field *fields; - const struct tgif_attr *attr; - uint32_t nr_fields; - uint32_t nr_attr; -} TGIF_PACKED; - -struct tgif_type_array { - const struct tgif_type *elem_type; - const struct tgif_attr *attr; - uint32_t length; - uint32_t nr_attr; -} TGIF_PACKED; - -struct tgif_type_vla { - const struct tgif_type *elem_type; - const struct tgif_attr *attr; - uint32_t nr_attr; -} TGIF_PACKED; - -struct tgif_type_vla_visitor { - const struct tgif_type *elem_type; - tgif_visitor_func visitor; - const struct tgif_attr *attr; - uint32_t nr_attr; -} TGIF_PACKED; - -struct tgif_type_enum { - const struct tgif_enum_mappings *mappings; - const struct tgif_type *elem_type; -} TGIF_PACKED; - -struct tgif_type_enum_bitmap { - const struct tgif_enum_bitmap_mappings *mappings; - const struct tgif_type *elem_type; -} TGIF_PACKED; - -struct tgif_type_gather_bool { - uint64_t offset; /* bytes */ - uint8_t access_mode; /* enum tgif_type_gather_access_mode */ - struct tgif_type_bool type; - uint16_t offset_bits; /* bits */ -} TGIF_PACKED; - -struct tgif_type_gather_byte { - uint64_t offset; /* bytes */ - uint8_t access_mode; /* enum tgif_type_gather_access_mode */ - struct tgif_type_byte type; -} TGIF_PACKED; - -struct tgif_type_gather_integer { - uint64_t offset; /* bytes */ - uint8_t access_mode; /* enum tgif_type_gather_access_mode */ - struct tgif_type_integer type; - uint16_t offset_bits; /* bits */ -} TGIF_PACKED; - -struct tgif_type_gather_float { - uint64_t offset; /* bytes */ - uint8_t access_mode; /* enum tgif_type_gather_access_mode */ - struct tgif_type_float type; -} TGIF_PACKED; - -struct tgif_type_gather_string { - uint64_t offset; /* bytes */ - uint8_t access_mode; /* enum tgif_type_gather_access_mode */ - struct tgif_type_string type; -} TGIF_PACKED; - -struct tgif_type_gather_enum { - const struct tgif_enum_mappings *mappings; - const struct tgif_type *elem_type; -} TGIF_PACKED; - -struct tgif_type_gather_struct { - uint64_t offset; /* bytes */ - uint8_t access_mode; /* enum tgif_type_gather_access_mode */ - const struct tgif_type_struct *type; - uint32_t size; /* bytes */ -} TGIF_PACKED; - -struct tgif_type_gather_array { - uint64_t offset; /* bytes */ - uint8_t access_mode; /* enum tgif_type_gather_access_mode */ - struct tgif_type_array type; -} TGIF_PACKED; - -struct tgif_type_gather_vla { - const struct tgif_type *length_type; /* tgif_length() */ - - uint64_t offset; /* bytes */ - uint8_t access_mode; /* enum tgif_type_gather_access_mode */ - struct tgif_type_vla type; -} TGIF_PACKED; - -struct tgif_type_gather { - union { - struct tgif_type_gather_bool tgif_bool; - struct tgif_type_gather_byte tgif_byte; - struct tgif_type_gather_integer tgif_integer; - struct tgif_type_gather_float tgif_float; - struct tgif_type_gather_string tgif_string; - struct tgif_type_gather_enum tgif_enum; - struct tgif_type_gather_array tgif_array; - struct tgif_type_gather_vla tgif_vla; - struct tgif_type_gather_struct tgif_struct; - } TGIF_PACKED u; -} TGIF_PACKED; - -struct tgif_type { - uint32_t type; /* enum tgif_type_label */ - union { - /* Stack-copy basic types */ - struct tgif_type_null tgif_null; - struct tgif_type_bool tgif_bool; - struct tgif_type_byte tgif_byte; - struct tgif_type_string tgif_string; - struct tgif_type_integer tgif_integer; - struct tgif_type_float tgif_float; - - /* Stack-copy compound types */ - struct tgif_type_array tgif_array; - struct tgif_type_vla tgif_vla; - struct tgif_type_vla_visitor tgif_vla_visitor; - const struct tgif_type_struct *tgif_struct; - - /* Stack-copy enumeration types */ - struct tgif_type_enum tgif_enum; - struct tgif_type_enum_bitmap tgif_enum_bitmap; - - /* Gather types */ - struct tgif_type_gather tgif_gather; - } TGIF_PACKED u; -} TGIF_PACKED; - -struct tgif_event_field { - const char *field_name; - struct tgif_type tgif_type; -} TGIF_PACKED; - -enum tgif_event_flags { - TGIF_EVENT_FLAG_VARIADIC = (1 << 0), -}; - -struct tgif_callback { - union { - void (*call)(const struct tgif_event_description *desc, - const struct tgif_arg_vec *tgif_arg_vec, - void *priv); - void (*call_variadic)(const struct tgif_event_description *desc, - const struct tgif_arg_vec *tgif_arg_vec, - const struct tgif_arg_dynamic_struct *var_struct, - void *priv); - } TGIF_PACKED u; - void *priv; -} TGIF_PACKED; - -struct tgif_arg_static { - /* Stack-copy basic types */ - union tgif_bool_value bool_value; - uint8_t byte_value; - uint64_t string_value; /* const {uint8_t, uint16_t, uint32_t} * */ - union tgif_integer_value integer_value; - union tgif_float_value float_value; - - /* Stack-copy compound types */ - const struct tgif_arg_vec *tgif_struct; - const struct tgif_arg_vec *tgif_array; - const struct tgif_arg_vec *tgif_vla; - void *tgif_vla_app_visitor_ctx; - - /* Gather basic types */ - const void *tgif_bool_gather_ptr; - const void *tgif_byte_gather_ptr; - const void *tgif_integer_gather_ptr; - const void *tgif_float_gather_ptr; - const void *tgif_string_gather_ptr; - - /* Gather compound types */ - const void *tgif_array_gather_ptr; - const void *tgif_struct_gather_ptr; - struct { - const void *ptr; - const void *length_ptr; - } TGIF_PACKED tgif_vla_gather; -} TGIF_PACKED; - -struct tgif_arg_dynamic_vla { - const struct tgif_arg *sav; - const struct tgif_attr *attr; - uint32_t len; - uint32_t nr_attr; -} TGIF_PACKED; - -struct tgif_arg_dynamic_struct { - const struct tgif_arg_dynamic_field *fields; - const struct tgif_attr *attr; - uint32_t len; - uint32_t nr_attr; -} TGIF_PACKED; - -struct tgif_dynamic_struct_visitor { - void *app_ctx; - tgif_dynamic_struct_visitor_func visitor; - const struct tgif_attr *attr; - uint32_t nr_attr; -} TGIF_PACKED; - -struct tgif_dynamic_vla_visitor { - void *app_ctx; - tgif_visitor_func visitor; - const struct tgif_attr *attr; - uint32_t nr_attr; -} TGIF_PACKED; - -struct tgif_arg_dynamic { - /* Dynamic basic types */ - struct tgif_type_null tgif_null; - struct { - struct tgif_type_bool type; - union tgif_bool_value value; - } TGIF_PACKED tgif_bool; - struct { - struct tgif_type_byte type; - uint8_t value; - } TGIF_PACKED tgif_byte; - struct { - struct tgif_type_string type; - uint64_t value; /* const char * */ - } TGIF_PACKED tgif_string; - struct { - struct tgif_type_integer type; - union tgif_integer_value value; - } TGIF_PACKED tgif_integer; - struct { - struct tgif_type_float type; - union tgif_float_value value; - } TGIF_PACKED tgif_float; - - /* Dynamic compound types */ - const struct tgif_arg_dynamic_struct *tgif_dynamic_struct; - const struct tgif_arg_dynamic_vla *tgif_dynamic_vla; - - struct tgif_dynamic_struct_visitor tgif_dynamic_struct_visitor; - struct tgif_dynamic_vla_visitor tgif_dynamic_vla_visitor; -} TGIF_PACKED; - -struct tgif_arg { - uint32_t type; /* enum tgif_type_label */ - union { - struct tgif_arg_static tgif_static; - struct tgif_arg_dynamic tgif_dynamic; - } TGIF_PACKED u; -} TGIF_PACKED; - -struct tgif_arg_vec { - const struct tgif_arg *sav; - uint32_t len; -} TGIF_PACKED; - -struct tgif_arg_dynamic_field { - const char *field_name; - const struct tgif_arg elem; -} TGIF_PACKED; - -/* The visitor pattern is a double-dispatch visitor. */ -struct tgif_tracer_visitor_ctx { - enum tgif_visitor_status (*write_elem)( - const struct tgif_tracer_visitor_ctx *tracer_ctx, - const struct tgif_arg *elem); - void *priv; /* Private tracer context. */ -} TGIF_PACKED; - -struct tgif_tracer_dynamic_struct_visitor_ctx { - enum tgif_visitor_status (*write_field)( - const struct tgif_tracer_dynamic_struct_visitor_ctx *tracer_ctx, - const struct tgif_arg_dynamic_field *dynamic_field); - void *priv; /* Private tracer context. */ -} TGIF_PACKED; - -struct tgif_event_description { - uintptr_t *enabled; - const char *provider_name; - const char *event_name; - const struct tgif_event_field *fields; - const struct tgif_attr *attr; - const struct tgif_callback *callbacks; - uint64_t flags; - uint32_t version; - uint32_t loglevel; /* enum tgif_loglevel */ - uint32_t nr_fields; - uint32_t nr_attr; - uint32_t nr_callbacks; -} TGIF_PACKED; - -/* Event and type attributes */ - -#define tgif_attr(_key, _value) \ - { \ - .key = { \ - .p = (_key), \ - .unit_size = sizeof(uint8_t), \ - .byte_order = TGIF_TYPE_BYTE_ORDER_HOST, \ - }, \ - .value = TGIF_PARAM(_value), \ - } - -#define tgif_attr_list(...) \ - TGIF_COMPOUND_LITERAL(const struct tgif_attr, __VA_ARGS__) - -#define tgif_attr_null(_val) { .type = TGIF_ATTR_TYPE_NULL } -#define tgif_attr_bool(_val) { .type = TGIF_ATTR_TYPE_BOOL, .u = { .bool_value = !!(_val) } } -#define tgif_attr_u8(_val) { .type = TGIF_ATTR_TYPE_U8, .u = { .integer_value = { .tgif_u8 = (_val) } } } -#define tgif_attr_u16(_val) { .type = TGIF_ATTR_TYPE_U16, .u = { .integer_value = { .tgif_u16 = (_val) } } } -#define tgif_attr_u32(_val) { .type = TGIF_ATTR_TYPE_U32, .u = { .integer_value = { .tgif_u32 = (_val) } } } -#define tgif_attr_u64(_val) { .type = TGIF_ATTR_TYPE_U64, .u = { .integer_value = { .tgif_u64 = (_val) } } } -#define tgif_attr_s8(_val) { .type = TGIF_ATTR_TYPE_S8, .u = { .integer_value = { .tgif_s8 = (_val) } } } -#define tgif_attr_s16(_val) { .type = TGIF_ATTR_TYPE_S16, .u = { .integer_value = { .tgif_s16 = (_val) } } } -#define tgif_attr_s32(_val) { .type = TGIF_ATTR_TYPE_S32, .u = { .integer_value = { .tgif_s32 = (_val) } } } -#define tgif_attr_s64(_val) { .type = TGIF_ATTR_TYPE_S64, .u = { .integer_value = { .tgif_s64 = (_val) } } } -#define tgif_attr_float_binary16(_val) { .type = TGIF_ATTR_TYPE_FLOAT_BINARY16, .u = { .float_value = { .tgif_float_binary16 = (_val) } } } -#define tgif_attr_float_binary32(_val) { .type = TGIF_ATTR_TYPE_FLOAT_BINARY32, .u = { .float_value = { .tgif_float_binary32 = (_val) } } } -#define tgif_attr_float_binary64(_val) { .type = TGIF_ATTR_TYPE_FLOAT_BINARY64, .u = { .float_value = { .tgif_float_binary64 = (_val) } } } -#define tgif_attr_float_binary128(_val) { .type = TGIF_ATTR_TYPE_FLOAT_BINARY128, .u = { .float_value = { .tgif_float_binary128 = (_val) } } } - -#define _tgif_attr_string(_val, _byte_order, _unit_size) \ - { \ - .type = TGIF_ATTR_TYPE_STRING, \ - .u = { \ - .string_value = { \ - .p = (const void *) (_val), \ - .unit_size = _unit_size, \ - .byte_order = _byte_order, \ - }, \ - }, \ - } - -#define tgif_attr_string(_val) _tgif_attr_string(_val, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t)) -#define tgif_attr_string16(_val) _tgif_attr_string(_val, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t)) -#define tgif_attr_string32(_val) _tgif_attr_string(_val, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t)) - -/* Stack-copy enumeration type definitions */ - -#define tgif_define_enum(_identifier, _mappings, _attr) \ - const struct tgif_enum_mappings _identifier = { \ - .mappings = _mappings, \ - .attr = _attr, \ - .nr_mappings = TGIF_ARRAY_SIZE(TGIF_PARAM(_mappings)), \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - } - -#define tgif_enum_mapping_list(...) \ - TGIF_COMPOUND_LITERAL(const struct tgif_enum_mapping, __VA_ARGS__) - -#define tgif_enum_mapping_range(_label, _begin, _end) \ - { \ - .range_begin = _begin, \ - .range_end = _end, \ - .label = { \ - .p = (_label), \ - .unit_size = sizeof(uint8_t), \ - .byte_order = TGIF_TYPE_BYTE_ORDER_HOST, \ - }, \ - } - -#define tgif_enum_mapping_value(_label, _value) \ - { \ - .range_begin = _value, \ - .range_end = _value, \ - .label = { \ - .p = (_label), \ - .unit_size = sizeof(uint8_t), \ - .byte_order = TGIF_TYPE_BYTE_ORDER_HOST, \ - }, \ - } - -#define tgif_define_enum_bitmap(_identifier, _mappings, _attr) \ - const struct tgif_enum_bitmap_mappings _identifier = { \ - .mappings = _mappings, \ - .attr = _attr, \ - .nr_mappings = TGIF_ARRAY_SIZE(TGIF_PARAM(_mappings)), \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - } - -#define tgif_enum_bitmap_mapping_list(...) \ - TGIF_COMPOUND_LITERAL(const struct tgif_enum_bitmap_mapping, __VA_ARGS__) - -#define tgif_enum_bitmap_mapping_range(_label, _begin, _end) \ - { \ - .range_begin = _begin, \ - .range_end = _end, \ - .label = { \ - .p = (_label), \ - .unit_size = sizeof(uint8_t), \ - .byte_order = TGIF_TYPE_BYTE_ORDER_HOST, \ - }, \ - } - -#define tgif_enum_bitmap_mapping_value(_label, _value) \ - { \ - .range_begin = _value, \ - .range_end = _value, \ - .label = { \ - .p = (_label), \ - .unit_size = sizeof(uint8_t), \ - .byte_order = TGIF_TYPE_BYTE_ORDER_HOST, \ - }, \ - } - -/* Stack-copy field and type definitions */ - -#define tgif_type_null(_attr) \ - { \ - .type = TGIF_TYPE_NULL, \ - .u = { \ - .tgif_null = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - }, \ - }, \ - } - -#define tgif_type_bool(_attr) \ - { \ - .type = TGIF_TYPE_BOOL, \ - .u = { \ - .tgif_bool = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - .bool_size = sizeof(uint8_t), \ - .len_bits = 0, \ - .byte_order = TGIF_TYPE_BYTE_ORDER_HOST, \ - }, \ - }, \ - } - -#define tgif_type_byte(_attr) \ - { \ - .type = TGIF_TYPE_BYTE, \ - .u = { \ - .tgif_byte = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - }, \ - }, \ - } - -#define _tgif_type_string(_type, _byte_order, _unit_size, _attr) \ - { \ - .type = _type, \ - .u = { \ - .tgif_string = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - .unit_size = _unit_size, \ - .byte_order = _byte_order, \ - }, \ - }, \ - } - -#define tgif_type_dynamic() \ - { \ - .type = TGIF_TYPE_DYNAMIC, \ - } - -#define _tgif_type_integer(_type, _signedness, _byte_order, _integer_size, _len_bits, _attr) \ - { \ - .type = _type, \ - .u = { \ - .tgif_integer = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - .integer_size = _integer_size, \ - .len_bits = _len_bits, \ - .signedness = _signedness, \ - .byte_order = _byte_order, \ - }, \ - }, \ - } - -#define _tgif_type_float(_type, _byte_order, _float_size, _attr) \ - { \ - .type = _type, \ - .u = { \ - .tgif_float = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - .float_size = _float_size, \ - .byte_order = _byte_order, \ - }, \ - }, \ - } - -#define _tgif_field(_name, _type) \ - { \ - .field_name = _name, \ - .tgif_type = _type, \ - } - -/* Host endian */ -#define tgif_type_u8(_attr) _tgif_type_integer(TGIF_TYPE_U8, false, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_u16(_attr) _tgif_type_integer(TGIF_TYPE_U16, false, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_u32(_attr) _tgif_type_integer(TGIF_TYPE_U32, false, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_u64(_attr) _tgif_type_integer(TGIF_TYPE_U64, false, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint64_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_s8(_attr) _tgif_type_integer(TGIF_TYPE_S8, true, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(int8_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_s16(_attr) _tgif_type_integer(TGIF_TYPE_S16, true, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(int16_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_s32(_attr) _tgif_type_integer(TGIF_TYPE_S32, true, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(int32_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_s64(_attr) _tgif_type_integer(TGIF_TYPE_S64, true, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(int64_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_pointer(_attr) _tgif_type_integer(TGIF_TYPE_POINTER, false, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uintptr_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_float_binary16(_attr) _tgif_type_float(TGIF_TYPE_FLOAT_BINARY16, TGIF_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float16), TGIF_PARAM(_attr)) -#define tgif_type_float_binary32(_attr) _tgif_type_float(TGIF_TYPE_FLOAT_BINARY32, TGIF_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float32), TGIF_PARAM(_attr)) -#define tgif_type_float_binary64(_attr) _tgif_type_float(TGIF_TYPE_FLOAT_BINARY64, TGIF_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float64), TGIF_PARAM(_attr)) -#define tgif_type_float_binary128(_attr) _tgif_type_float(TGIF_TYPE_FLOAT_BINARY128, TGIF_TYPE_FLOAT_WORD_ORDER_HOST, sizeof(_Float128), TGIF_PARAM(_attr)) -#define tgif_type_string(_attr) _tgif_type_string(TGIF_TYPE_STRING_UTF8, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), TGIF_PARAM(_attr)) -#define tgif_type_string16(_attr) _tgif_type_string(TGIF_TYPE_STRING_UTF16, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), TGIF_PARAM(_attr)) -#define tgif_type_string32(_attr) _tgif_type_string(TGIF_TYPE_STRING_UTF32, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), TGIF_PARAM(_attr)) - -#define tgif_field_null(_name, _attr) _tgif_field(_name, tgif_type_null(TGIF_PARAM(_attr))) -#define tgif_field_bool(_name, _attr) _tgif_field(_name, tgif_type_bool(TGIF_PARAM(_attr))) -#define tgif_field_u8(_name, _attr) _tgif_field(_name, tgif_type_u8(TGIF_PARAM(_attr))) -#define tgif_field_u16(_name, _attr) _tgif_field(_name, tgif_type_u16(TGIF_PARAM(_attr))) -#define tgif_field_u32(_name, _attr) _tgif_field(_name, tgif_type_u32(TGIF_PARAM(_attr))) -#define tgif_field_u64(_name, _attr) _tgif_field(_name, tgif_type_u64(TGIF_PARAM(_attr))) -#define tgif_field_s8(_name, _attr) _tgif_field(_name, tgif_type_s8(TGIF_PARAM(_attr))) -#define tgif_field_s16(_name, _attr) _tgif_field(_name, tgif_type_s16(TGIF_PARAM(_attr))) -#define tgif_field_s32(_name, _attr) _tgif_field(_name, tgif_type_s32(TGIF_PARAM(_attr))) -#define tgif_field_s64(_name, _attr) _tgif_field(_name, tgif_type_s64(TGIF_PARAM(_attr))) -#define tgif_field_byte(_name, _attr) _tgif_field(_name, tgif_type_byte(TGIF_PARAM(_attr))) -#define tgif_field_pointer(_name, _attr) _tgif_field(_name, tgif_type_pointer(TGIF_PARAM(_attr))) -#define tgif_field_float_binary16(_name, _attr) _tgif_field(_name, tgif_type_float_binary16(TGIF_PARAM(_attr))) -#define tgif_field_float_binary32(_name, _attr) _tgif_field(_name, tgif_type_float_binary32(TGIF_PARAM(_attr))) -#define tgif_field_float_binary64(_name, _attr) _tgif_field(_name, tgif_type_float_binary64(TGIF_PARAM(_attr))) -#define tgif_field_float_binary128(_name, _attr) _tgif_field(_name, tgif_type_float_binary128(TGIF_PARAM(_attr))) -#define tgif_field_string(_name, _attr) _tgif_field(_name, tgif_type_string(TGIF_PARAM(_attr))) -#define tgif_field_string16(_name, _attr) _tgif_field(_name, tgif_type_string16(TGIF_PARAM(_attr))) -#define tgif_field_string32(_name, _attr) _tgif_field(_name, tgif_type_string32(TGIF_PARAM(_attr))) -#define tgif_field_dynamic(_name) _tgif_field(_name, tgif_type_dynamic()) - -/* Little endian */ -#define tgif_type_u16_le(_attr) _tgif_type_integer(TGIF_TYPE_U16, false, TGIF_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_u32_le(_attr) _tgif_type_integer(TGIF_TYPE_U32, false, TGIF_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_u64_le(_attr) _tgif_type_integer(TGIF_TYPE_U64, false, TGIF_TYPE_BYTE_ORDER_LE, sizeof(uint64_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_s16_le(_attr) _tgif_type_integer(TGIF_TYPE_S16, true, TGIF_TYPE_BYTE_ORDER_LE, sizeof(int16_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_s32_le(_attr) _tgif_type_integer(TGIF_TYPE_S32, true, TGIF_TYPE_BYTE_ORDER_LE, sizeof(int32_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_s64_le(_attr) _tgif_type_integer(TGIF_TYPE_S64, true, TGIF_TYPE_BYTE_ORDER_LE, sizeof(int64_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_pointer_le(_attr) _tgif_type_integer(TGIF_TYPE_POINTER, false, TGIF_TYPE_BYTE_ORDER_LE, sizeof(uintptr_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_float_binary16_le(_attr) _tgif_type_float(TGIF_TYPE_FLOAT_BINARY16, TGIF_TYPE_BYTE_ORDER_LE, sizeof(_Float16), TGIF_PARAM(_attr)) -#define tgif_type_float_binary32_le(_attr) _tgif_type_float(TGIF_TYPE_FLOAT_BINARY32, TGIF_TYPE_BYTE_ORDER_LE, sizeof(_Float32), TGIF_PARAM(_attr)) -#define tgif_type_float_binary64_le(_attr) _tgif_type_float(TGIF_TYPE_FLOAT_BINARY64, TGIF_TYPE_BYTE_ORDER_LE, sizeof(_Float64), TGIF_PARAM(_attr)) -#define tgif_type_float_binary128_le(_attr) _tgif_type_float(TGIF_TYPE_FLOAT_BINARY128, TGIF_TYPE_BYTE_ORDER_LE, sizeof(_Float128), TGIF_PARAM(_attr)) -#define tgif_type_string16_le(_attr) _tgif_type_string(TGIF_TYPE_STRING_UTF16, TGIF_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), TGIF_PARAM(_attr)) -#define tgif_type_string32_le(_attr) _tgif_type_string(TGIF_TYPE_STRING_UTF32, TGIF_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), TGIF_PARAM(_attr)) - -#define tgif_field_u16_le(_name, _attr) _tgif_field(_name, tgif_type_u16_le(TGIF_PARAM(_attr))) -#define tgif_field_u32_le(_name, _attr) _tgif_field(_name, tgif_type_u32_le(TGIF_PARAM(_attr))) -#define tgif_field_u64_le(_name, _attr) _tgif_field(_name, tgif_type_u64_le(TGIF_PARAM(_attr))) -#define tgif_field_s16_le(_name, _attr) _tgif_field(_name, tgif_type_s16_le(TGIF_PARAM(_attr))) -#define tgif_field_s32_le(_name, _attr) _tgif_field(_name, tgif_type_s32_le(TGIF_PARAM(_attr))) -#define tgif_field_s64_le(_name, _attr) _tgif_field(_name, tgif_type_s64_le(TGIF_PARAM(_attr))) -#define tgif_field_pointer_le(_name, _attr) _tgif_field(_name, tgif_type_pointer_le(TGIF_PARAM(_attr))) -#define tgif_field_float_binary16_le(_name, _attr) _tgif_field(_name, tgif_type_float_binary16_le(TGIF_PARAM(_attr))) -#define tgif_field_float_binary32_le(_name, _attr) _tgif_field(_name, tgif_type_float_binary32_le(TGIF_PARAM(_attr))) -#define tgif_field_float_binary64_le(_name, _attr) _tgif_field(_name, tgif_type_float_binary64_le(TGIF_PARAM(_attr))) -#define tgif_field_float_binary128_le(_name, _attr) _tgif_field(_name, tgif_type_float_binary128_le(TGIF_PARAM(_attr))) -#define tgif_field_string16_le(_name, _attr) _tgif_field(_name, tgif_type_string16_le(TGIF_PARAM(_attr))) -#define tgif_field_string32_le(_name, _attr) _tgif_field(_name, tgif_type_string32_le(TGIF_PARAM(_attr))) - -/* Big endian */ -#define tgif_type_u16_be(_attr) _tgif_type_integer(TGIF_TYPE_U16, false, TGIF_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_u32_be(_attr) _tgif_type_integer(TGIF_TYPE_U32, false, TGIF_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_u64_be(_attr) _tgif_type_integer(TGIF_TYPE_U64, false, TGIF_TYPE_BYTE_ORDER_BE, sizeof(uint64_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_s16_be(_attr) _tgif_type_integer(TGIF_TYPE_S16, false, TGIF_TYPE_BYTE_ORDER_BE, sizeof(int16_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_s32_be(_attr) _tgif_type_integer(TGIF_TYPE_S32, false, TGIF_TYPE_BYTE_ORDER_BE, sizeof(int32_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_s64_be(_attr) _tgif_type_integer(TGIF_TYPE_S64, false, TGIF_TYPE_BYTE_ORDER_BE, sizeof(int64_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_pointer_be(_attr) _tgif_type_integer(TGIF_TYPE_POINTER, false, TGIF_TYPE_BYTE_ORDER_BE, sizeof(uintptr_t), 0, TGIF_PARAM(_attr)) -#define tgif_type_float_binary16_be(_attr) _tgif_type_float(TGIF_TYPE_FLOAT_BINARY16, TGIF_TYPE_BYTE_ORDER_BE, sizeof(_Float16), TGIF_PARAM(_attr)) -#define tgif_type_float_binary32_be(_attr) _tgif_type_float(TGIF_TYPE_FLOAT_BINARY32, TGIF_TYPE_BYTE_ORDER_BE, sizeof(_Float32), TGIF_PARAM(_attr)) -#define tgif_type_float_binary64_be(_attr) _tgif_type_float(TGIF_TYPE_FLOAT_BINARY64, TGIF_TYPE_BYTE_ORDER_BE, sizeof(_Float64), TGIF_PARAM(_attr)) -#define tgif_type_float_binary128_be(_attr) _tgif_type_float(TGIF_TYPE_FLOAT_BINARY128, TGIF_TYPE_BYTE_ORDER_BE, sizeof(_Float128), TGIF_PARAM(_attr)) -#define tgif_type_string16_be(_attr) _tgif_type_string(TGIF_TYPE_STRING_UTF16, TGIF_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), TGIF_PARAM(_attr)) -#define tgif_type_string32_be(_attr) _tgif_type_string(TGIF_TYPE_STRING_UTF32, TGIF_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), TGIF_PARAM(_attr)) - -#define tgif_field_u16_be(_name, _attr) _tgif_field(_name, tgif_type_u16_be(TGIF_PARAM(_attr))) -#define tgif_field_u32_be(_name, _attr) _tgif_field(_name, tgif_type_u32_be(TGIF_PARAM(_attr))) -#define tgif_field_u64_be(_name, _attr) _tgif_field(_name, tgif_type_u64_be(TGIF_PARAM(_attr))) -#define tgif_field_s16_be(_name, _attr) _tgif_field(_name, tgif_type_s16_be(TGIF_PARAM(_attr))) -#define tgif_field_s32_be(_name, _attr) _tgif_field(_name, tgif_type_s32_be(TGIF_PARAM(_attr))) -#define tgif_field_s64_be(_name, _attr) _tgif_field(_name, tgif_type_s64_be(TGIF_PARAM(_attr))) -#define tgif_field_pointer_be(_name, _attr) _tgif_field(_name, tgif_type_pointer_be(TGIF_PARAM(_attr))) -#define tgif_field_float_binary16_be(_name, _attr) _tgif_field(_name, tgif_type_float_binary16_be(TGIF_PARAM(_attr))) -#define tgif_field_float_binary32_be(_name, _attr) _tgif_field(_name, tgif_type_float_binary32_be(TGIF_PARAM(_attr))) -#define tgif_field_float_binary64_be(_name, _attr) _tgif_field(_name, tgif_type_float_binary64_be(TGIF_PARAM(_attr))) -#define tgif_field_float_binary128_be(_name, _attr) _tgif_field(_name, tgif_type_float_binary128_be(TGIF_PARAM(_attr))) -#define tgif_field_string16_be(_name, _attr) _tgif_field(_name, tgif_type_string16_be(TGIF_PARAM(_attr))) -#define tgif_field_string32_be(_name, _attr) _tgif_field(_name, tgif_type_string32_be(TGIF_PARAM(_attr))) - -#define tgif_type_enum(_mappings, _elem_type) \ - { \ - .type = TGIF_TYPE_ENUM, \ - .u = { \ - .tgif_enum = { \ - .mappings = _mappings, \ - .elem_type = _elem_type, \ - }, \ - }, \ - } -#define tgif_field_enum(_name, _mappings, _elem_type) \ - _tgif_field(_name, tgif_type_enum(TGIF_PARAM(_mappings), TGIF_PARAM(_elem_type))) - -#define tgif_type_enum_bitmap(_mappings, _elem_type) \ - { \ - .type = TGIF_TYPE_ENUM_BITMAP, \ - .u = { \ - .tgif_enum_bitmap = { \ - .mappings = _mappings, \ - .elem_type = _elem_type, \ - }, \ - }, \ - } -#define tgif_field_enum_bitmap(_name, _mappings, _elem_type) \ - _tgif_field(_name, tgif_type_enum_bitmap(TGIF_PARAM(_mappings), TGIF_PARAM(_elem_type))) - -#define tgif_type_struct(_struct) \ - { \ - .type = TGIF_TYPE_STRUCT, \ - .u = { \ - .tgif_struct = _struct, \ - }, \ - } -#define tgif_field_struct(_name, _struct) \ - _tgif_field(_name, tgif_type_struct(TGIF_PARAM(_struct))) - -#define _tgif_type_struct_define(_fields, _attr) \ - { \ - .fields = _fields, \ - .attr = _attr, \ - .nr_fields = TGIF_ARRAY_SIZE(TGIF_PARAM(_fields)), \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - } - -#define tgif_define_struct(_identifier, _fields, _attr) \ - const struct tgif_type_struct _identifier = _tgif_type_struct_define(TGIF_PARAM(_fields), TGIF_PARAM(_attr)) - -#define tgif_struct_literal(_fields, _attr) \ - TGIF_COMPOUND_LITERAL(const struct tgif_type_struct, \ - _tgif_type_struct_define(TGIF_PARAM(_fields), TGIF_PARAM(_attr))) - -#define tgif_type_array(_elem_type, _length, _attr) \ - { \ - .type = TGIF_TYPE_ARRAY, \ - .u = { \ - .tgif_array = { \ - .elem_type = _elem_type, \ - .attr = _attr, \ - .length = _length, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - }, \ - }, \ - } -#define tgif_field_array(_name, _elem_type, _length, _attr) \ - _tgif_field(_name, tgif_type_array(TGIF_PARAM(_elem_type), _length, TGIF_PARAM(_attr))) - -#define tgif_type_vla(_elem_type, _attr) \ - { \ - .type = TGIF_TYPE_VLA, \ - .u = { \ - .tgif_vla = { \ - .elem_type = _elem_type, \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - }, \ - }, \ - } -#define tgif_field_vla(_name, _elem_type, _attr) \ - _tgif_field(_name, tgif_type_vla(TGIF_PARAM(_elem_type), TGIF_PARAM(_attr))) - -#define tgif_type_vla_visitor(_elem_type, _visitor, _attr) \ - { \ - .type = TGIF_TYPE_VLA_VISITOR, \ - .u = { \ - .tgif_vla_visitor = { \ - .elem_type = TGIF_PARAM(_elem_type), \ - .visitor = _visitor, \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - }, \ - }, \ - } -#define tgif_field_vla_visitor(_name, _elem_type, _visitor, _attr) \ - _tgif_field(_name, tgif_type_vla_visitor(TGIF_PARAM(_elem_type), _visitor, TGIF_PARAM(_attr))) - -/* Gather field and type definitions */ - -#define tgif_type_gather_byte(_offset, _access_mode, _attr) \ - { \ - .type = TGIF_TYPE_GATHER_BYTE, \ - .u = { \ - .tgif_gather = { \ - .u = { \ - .tgif_byte = { \ - .offset = _offset, \ - .access_mode = _access_mode, \ - .type = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - }, \ - }, \ - }, \ - }, \ - }, \ - } -#define tgif_field_gather_byte(_name, _offset, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_byte(_offset, _access_mode, TGIF_PARAM(_attr))) - -#define _tgif_type_gather_bool(_byte_order, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr) \ - { \ - .type = TGIF_TYPE_GATHER_BOOL, \ - .u = { \ - .tgif_gather = { \ - .u = { \ - .tgif_bool = { \ - .offset = _offset, \ - .access_mode = _access_mode, \ - .type = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - .bool_size = _bool_size, \ - .len_bits = _len_bits, \ - .byte_order = _byte_order, \ - }, \ - .offset_bits = _offset_bits, \ - }, \ - }, \ - }, \ - }, \ - } -#define tgif_type_gather_bool(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_type_gather_bool(TGIF_TYPE_BYTE_ORDER_HOST, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr) -#define tgif_type_gather_bool_le(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_type_gather_bool(TGIF_TYPE_BYTE_ORDER_LE, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr) -#define tgif_type_gather_bool_be(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_type_gather_bool(TGIF_TYPE_BYTE_ORDER_BE, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr) - -#define tgif_field_gather_bool(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_bool(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, TGIF_PARAM(_attr))) -#define tgif_field_gather_bool_le(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_bool_le(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, TGIF_PARAM(_attr))) -#define tgif_field_gather_bool_be(_name, _offset, _bool_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_bool_be(_offset, _bool_size, _offset_bits, _len_bits, _access_mode, TGIF_PARAM(_attr))) - -#define _tgif_type_gather_integer(_type, _signedness, _byte_order, _offset, \ - _integer_size, _offset_bits, _len_bits, _access_mode, _attr) \ - { \ - .type = _type, \ - .u = { \ - .tgif_gather = { \ - .u = { \ - .tgif_integer = { \ - .offset = _offset, \ - .access_mode = _access_mode, \ - .type = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - .integer_size = _integer_size, \ - .len_bits = _len_bits, \ - .signedness = _signedness, \ - .byte_order = _byte_order, \ - }, \ - .offset_bits = _offset_bits, \ - }, \ - }, \ - }, \ - }, \ - } - -#define tgif_type_gather_unsigned_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_type_gather_integer(TGIF_TYPE_GATHER_INTEGER, false, TGIF_TYPE_BYTE_ORDER_HOST, \ - _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, TGIF_PARAM(_attr)) -#define tgif_type_gather_signed_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_type_gather_integer(TGIF_TYPE_GATHER_INTEGER, true, TGIF_TYPE_BYTE_ORDER_HOST, \ - _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, TGIF_PARAM(_attr)) - -#define tgif_type_gather_unsigned_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_type_gather_integer(TGIF_TYPE_GATHER_INTEGER, false, TGIF_TYPE_BYTE_ORDER_LE, \ - _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, TGIF_PARAM(_attr)) -#define tgif_type_gather_signed_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_type_gather_integer(TGIF_TYPE_GATHER_INTEGER, true, TGIF_TYPE_BYTE_ORDER_LE, \ - _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, TGIF_PARAM(_attr)) - -#define tgif_type_gather_unsigned_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_type_gather_integer(TGIF_TYPE_GATHER_INTEGER, false, TGIF_TYPE_BYTE_ORDER_BE, \ - _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, TGIF_PARAM(_attr)) -#define tgif_type_gather_signed_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_type_gather_integer(TGIF_TYPE_GATHER_INTEGER, true, TGIF_TYPE_BYTE_ORDER_BE, \ - _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, TGIF_PARAM(_attr)) - -#define tgif_field_gather_unsigned_integer(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_unsigned_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, TGIF_PARAM(_attr))) -#define tgif_field_gather_signed_integer(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_signed_integer(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, TGIF_PARAM(_attr))) - -#define tgif_field_gather_unsigned_integer_le(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_unsigned_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, TGIF_PARAM(_attr))) -#define tgif_field_gather_signed_integer_le(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_signed_integer_le(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, TGIF_PARAM(_attr))) - -#define tgif_field_gather_unsigned_integer_be(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_unsigned_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, TGIF_PARAM(_attr))) -#define tgif_field_gather_signed_integer_be(_name, _integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_signed_integer_be(_integer_offset, _integer_size, _offset_bits, _len_bits, _access_mode, TGIF_PARAM(_attr))) - -#define tgif_type_gather_pointer(_offset, _access_mode, _attr) \ - _tgif_type_gather_integer(TGIF_TYPE_GATHER_POINTER, false, TGIF_TYPE_BYTE_ORDER_HOST, \ - _offset, sizeof(uintptr_t), 0, 0, _access_mode, TGIF_PARAM(_attr)) -#define tgif_field_gather_pointer(_name, _offset, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_pointer(_offset, _access_mode, TGIF_PARAM(_attr))) - -#define tgif_type_gather_pointer_le(_offset, _access_mode, _attr) \ - _tgif_type_gather_integer(TGIF_TYPE_GATHER_POINTER, false, TGIF_TYPE_BYTE_ORDER_LE, \ - _offset, sizeof(uintptr_t), 0, 0, _access_mode, TGIF_PARAM(_attr)) -#define tgif_field_gather_pointer_le(_name, _offset, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_pointer_le(_offset, _access_mode, TGIF_PARAM(_attr))) - -#define tgif_type_gather_pointer_be(_offset, _access_mode, _attr) \ - _tgif_type_gather_integer(TGIF_TYPE_GATHER_POINTER, false, TGIF_TYPE_BYTE_ORDER_BE, \ - _offset, sizeof(uintptr_t), 0, 0, _access_mode, TGIF_PARAM(_attr)) -#define tgif_field_gather_pointer_be(_name, _offset, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_pointer_be(_offset, _access_mode, TGIF_PARAM(_attr))) - -#define _tgif_type_gather_float(_byte_order, _offset, _float_size, _access_mode, _attr) \ - { \ - .type = TGIF_TYPE_GATHER_FLOAT, \ - .u = { \ - .tgif_gather = { \ - .u = { \ - .tgif_float = { \ - .offset = _offset, \ - .access_mode = _access_mode, \ - .type = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - .float_size = _float_size, \ - .byte_order = _byte_order, \ - }, \ - }, \ - }, \ - }, \ - }, \ - } - -#define tgif_type_gather_float(_offset, _float_size, _access_mode, _attr) \ - _tgif_type_gather_float(TGIF_TYPE_FLOAT_WORD_ORDER_HOST, _offset, _float_size, _access_mode, _attr) -#define tgif_type_gather_float_le(_offset, _float_size, _access_mode, _attr) \ - _tgif_type_gather_float(TGIF_TYPE_BYTE_ORDER_LE, _offset, _float_size, _access_mode, _attr) -#define tgif_type_gather_float_be(_offset, _float_size, _access_mode, _attr) \ - _tgif_type_gather_float(TGIF_TYPE_BYTE_ORDER_BE, _offset, _float_size, _access_mode, _attr) - -#define tgif_field_gather_float(_name, _offset, _float_size, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_float(_offset, _float_size, _access_mode, _attr)) -#define tgif_field_gather_float_le(_name, _offset, _float_size, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_float_le(_offset, _float_size, _access_mode, _attr)) -#define tgif_field_gather_float_be(_name, _offset, _float_size, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_float_be(_offset, _float_size, _access_mode, _attr)) - -#define _tgif_type_gather_string(_offset, _byte_order, _unit_size, _access_mode, _attr) \ - { \ - .type = TGIF_TYPE_GATHER_STRING, \ - .u = { \ - .tgif_gather = { \ - .u = { \ - .tgif_string = { \ - .offset = _offset, \ - .access_mode = _access_mode, \ - .type = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - .unit_size = _unit_size, \ - .byte_order = _byte_order, \ - }, \ - }, \ - }, \ - }, \ - }, \ - } -#define tgif_type_gather_string(_offset, _access_mode, _attr) \ - _tgif_type_gather_string(_offset, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), _access_mode, TGIF_PARAM(_attr)) -#define tgif_field_gather_string(_name, _offset, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_string(_offset, _access_mode, TGIF_PARAM(_attr))) - -#define tgif_type_gather_string16(_offset, _access_mode, _attr) \ - _tgif_type_gather_string(_offset, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), _access_mode, TGIF_PARAM(_attr)) -#define tgif_type_gather_string16_le(_offset, _access_mode, _attr) \ - _tgif_type_gather_string(_offset, TGIF_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), _access_mode, TGIF_PARAM(_attr)) -#define tgif_type_gather_string16_be(_offset, _access_mode, _attr) \ - _tgif_type_gather_string(_offset, TGIF_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), _access_mode, TGIF_PARAM(_attr)) - -#define tgif_field_gather_string16(_name, _offset, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_string16(_offset, _access_mode, TGIF_PARAM(_attr))) -#define tgif_field_gather_string16_le(_name, _offset, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_string16_le(_offset, _access_mode, TGIF_PARAM(_attr))) -#define tgif_field_gather_string16_be(_name, _offset, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_string16_be(_offset, _access_mode, TGIF_PARAM(_attr))) - -#define tgif_type_gather_string32(_offset, _access_mode, _attr) \ - _tgif_type_gather_string(_offset, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), _access_mode, TGIF_PARAM(_attr)) -#define tgif_type_gather_string32_le(_offset, _access_mode, _attr) \ - _tgif_type_gather_string(_offset, TGIF_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), _access_mode, TGIF_PARAM(_attr)) -#define tgif_type_gather_string32_be(_offset, _access_mode, _attr) \ - _tgif_type_gather_string(_offset, TGIF_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), _access_mode, TGIF_PARAM(_attr)) - -#define tgif_field_gather_string32(_name, _offset, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_string32(_offset, _access_mode, TGIF_PARAM(_attr))) -#define tgif_field_gather_string32_le(_name, _offset, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_string32_le(_offset, _access_mode, TGIF_PARAM(_attr))) -#define tgif_field_gather_string32_be(_name, _offset, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_string32_be(_offset, _access_mode, TGIF_PARAM(_attr))) - -#define tgif_type_gather_enum(_mappings, _elem_type) \ - { \ - .type = TGIF_TYPE_GATHER_ENUM, \ - .u = { \ - .tgif_enum = { \ - .mappings = _mappings, \ - .elem_type = _elem_type, \ - }, \ - }, \ - } -#define tgif_field_gather_enum(_name, _mappings, _elem_type) \ - _tgif_field(_name, tgif_type_gather_enum(TGIF_PARAM(_mappings), TGIF_PARAM(_elem_type))) - -#define tgif_type_gather_struct(_struct_gather, _offset, _size, _access_mode) \ - { \ - .type = TGIF_TYPE_GATHER_STRUCT, \ - .u = { \ - .tgif_gather = { \ - .u = { \ - .tgif_struct = { \ - .offset = _offset, \ - .access_mode = _access_mode, \ - .type = _struct_gather, \ - .size = _size, \ - }, \ - }, \ - }, \ - }, \ - } -#define tgif_field_gather_struct(_name, _struct_gather, _offset, _size, _access_mode) \ - _tgif_field(_name, tgif_type_gather_struct(TGIF_PARAM(_struct_gather), _offset, _size, _access_mode)) - -#define tgif_type_gather_array(_elem_type_gather, _length, _offset, _access_mode, _attr) \ - { \ - .type = TGIF_TYPE_GATHER_ARRAY, \ - .u = { \ - .tgif_gather = { \ - .u = { \ - .tgif_array = { \ - .offset = _offset, \ - .access_mode = _access_mode, \ - .type = { \ - .elem_type = _elem_type_gather, \ - .attr = _attr, \ - .length = _length, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - }, \ - }, \ - }, \ - }, \ - }, \ - } -#define tgif_field_gather_array(_name, _elem_type, _length, _offset, _access_mode, _attr) \ - _tgif_field(_name, tgif_type_gather_array(TGIF_PARAM(_elem_type), _length, _offset, _access_mode, TGIF_PARAM(_attr))) - -#define tgif_type_gather_vla(_elem_type_gather, _offset, _access_mode, _length_type_gather, _attr) \ - { \ - .type = TGIF_TYPE_GATHER_VLA, \ - .u = { \ - .tgif_gather = { \ - .u = { \ - .tgif_vla = { \ - .length_type = _length_type_gather, \ - .offset = _offset, \ - .access_mode = _access_mode, \ - .type = { \ - .elem_type = _elem_type_gather, \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - }, \ - }, \ - }, \ - }, \ - }, \ - } -#define tgif_field_gather_vla(_name, _elem_type_gather, _offset, _access_mode, _length_type_gather, _attr) \ - _tgif_field(_name, tgif_type_gather_vla(TGIF_PARAM(_elem_type_gather), _offset, _access_mode, TGIF_PARAM(_length_type_gather), TGIF_PARAM(_attr))) - -#define tgif_elem(...) \ - TGIF_COMPOUND_LITERAL(const struct tgif_type, __VA_ARGS__) - -#define tgif_length(...) \ - TGIF_COMPOUND_LITERAL(const struct tgif_type, __VA_ARGS__) - -#define tgif_field_list(...) \ - TGIF_COMPOUND_LITERAL(const struct tgif_event_field, __VA_ARGS__) - -/* Stack-copy field arguments */ - -#define tgif_arg_null(_val) { .type = TGIF_TYPE_NULL } -#define tgif_arg_bool(_val) { .type = TGIF_TYPE_BOOL, .u = { .tgif_static = { .bool_value = { .tgif_bool8 = !!(_val) } } } } -#define tgif_arg_byte(_val) { .type = TGIF_TYPE_BYTE, .u = { .tgif_static = { .byte_value = (_val) } } } -#define tgif_arg_string(_val) { .type = TGIF_TYPE_STRING_UTF8, .u = { .tgif_static = { .string_value = (uintptr_t) (_val) } } } -#define tgif_arg_string16(_val) { .type = TGIF_TYPE_STRING_UTF16, .u = { .tgif_static = { .string_value = (uintptr_t) (_val) } } } -#define tgif_arg_string32(_val) { .type = TGIF_TYPE_STRING_UTF32, .u = { .tgif_static = { .string_value = (uintptr_t) (_val) } } } - -#define tgif_arg_u8(_val) { .type = TGIF_TYPE_U8, .u = { .tgif_static = { .integer_value = { .tgif_u8 = (_val) } } } } -#define tgif_arg_u16(_val) { .type = TGIF_TYPE_U16, .u = { .tgif_static = { .integer_value = { .tgif_u16 = (_val) } } } } -#define tgif_arg_u32(_val) { .type = TGIF_TYPE_U32, .u = { .tgif_static = { .integer_value = { .tgif_u32 = (_val) } } } } -#define tgif_arg_u64(_val) { .type = TGIF_TYPE_U64, .u = { .tgif_static = { .integer_value = { .tgif_u64 = (_val) } } } } -#define tgif_arg_s8(_val) { .type = TGIF_TYPE_S8, .u = { .tgif_static = { .integer_value = { .tgif_s8 = (_val) } } } } -#define tgif_arg_s16(_val) { .type = TGIF_TYPE_S16, .u = { .tgif_static = { .integer_value = { .tgif_s16 = (_val) } } } } -#define tgif_arg_s32(_val) { .type = TGIF_TYPE_S32, .u = { .tgif_static = { .integer_value = { .tgif_s32 = (_val) } } } } -#define tgif_arg_s64(_val) { .type = TGIF_TYPE_S64, .u = { .tgif_static = { .integer_value = { .tgif_s64 = (_val) } } } } -#define tgif_arg_pointer(_val) { .type = TGIF_TYPE_POINTER, .u = { .tgif_static = { .integer_value = { .tgif_uptr = (uintptr_t) (_val) } } } } -#define tgif_arg_float_binary16(_val) { .type = TGIF_TYPE_FLOAT_BINARY16, .u = { .tgif_static = { .float_value = { .tgif_float_binary16 = (_val) } } } } -#define tgif_arg_float_binary32(_val) { .type = TGIF_TYPE_FLOAT_BINARY32, .u = { .tgif_static = { .float_value = { .tgif_float_binary32 = (_val) } } } } -#define tgif_arg_float_binary64(_val) { .type = TGIF_TYPE_FLOAT_BINARY64, .u = { .tgif_static = { .float_value = { .tgif_float_binary64 = (_val) } } } } -#define tgif_arg_float_binary128(_val) { .type = TGIF_TYPE_FLOAT_BINARY128, .u = { .tgif_static = { .float_value = { .tgif_float_binary128 = (_val) } } } } - -#define tgif_arg_struct(_tgif_type) { .type = TGIF_TYPE_STRUCT, .u = { .tgif_static = { .tgif_struct = (_tgif_type) } } } -#define tgif_arg_array(_tgif_type) { .type = TGIF_TYPE_ARRAY, .u = { .tgif_static = { .tgif_array = (_tgif_type) } } } -#define tgif_arg_vla(_tgif_type) { .type = TGIF_TYPE_VLA, .u = { .tgif_static = { .tgif_vla = (_tgif_type) } } } -#define tgif_arg_vla_visitor(_ctx) { .type = TGIF_TYPE_VLA_VISITOR, .u = { .tgif_static = { .tgif_vla_app_visitor_ctx = (_ctx) } } } - -/* Gather field arguments */ - -#define tgif_arg_gather_bool(_ptr) { .type = TGIF_TYPE_GATHER_BOOL, .u = { .tgif_static = { .tgif_bool_gather_ptr = (_ptr) } } } -#define tgif_arg_gather_byte(_ptr) { .type = TGIF_TYPE_GATHER_BYTE, .u = { .tgif_static = { .tgif_byte_gather_ptr = (_ptr) } } } -#define tgif_arg_gather_pointer(_ptr) { .type = TGIF_TYPE_GATHER_POINTER, .u = { .tgif_static = { .tgif_integer_gather_ptr = (_ptr) } } } -#define tgif_arg_gather_integer(_ptr) { .type = TGIF_TYPE_GATHER_INTEGER, .u = { .tgif_static = { .tgif_integer_gather_ptr = (_ptr) } } } -#define tgif_arg_gather_float(_ptr) { .type = TGIF_TYPE_GATHER_FLOAT, .u = { .tgif_static = { .tgif_float_gather_ptr = (_ptr) } } } -#define tgif_arg_gather_string(_ptr) { .type = TGIF_TYPE_GATHER_STRING, .u = { .tgif_static = { .tgif_string_gather_ptr = (_ptr) } } } -#define tgif_arg_gather_struct(_ptr) { .type = TGIF_TYPE_GATHER_STRUCT, .u = { .tgif_static = { .tgif_struct_gather_ptr = (_ptr) } } } -#define tgif_arg_gather_array(_ptr) { .type = TGIF_TYPE_GATHER_ARRAY, .u = { .tgif_static = { .tgif_array_gather_ptr = (_ptr) } } } -#define tgif_arg_gather_vla(_ptr, _length_ptr) { .type = TGIF_TYPE_GATHER_VLA, .u = { .tgif_static = { .tgif_vla_gather = { .ptr = (_ptr), .length_ptr = (_length_ptr) } } } } - -/* Dynamic field arguments */ - -#define tgif_arg_dynamic_null(_attr) \ - { \ - .type = TGIF_TYPE_DYNAMIC_NULL, \ - .u = { \ - .tgif_dynamic = { \ - .tgif_null = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - }, \ - }, \ - }, \ - } - -#define tgif_arg_dynamic_bool(_val, _attr) \ - { \ - .type = TGIF_TYPE_DYNAMIC_BOOL, \ - .u = { \ - .tgif_dynamic = { \ - .tgif_bool = { \ - .type = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - .bool_size = sizeof(uint8_t), \ - .len_bits = 0, \ - .byte_order = TGIF_TYPE_BYTE_ORDER_HOST, \ - }, \ - .value = { \ - .tgif_bool8 = !!(_val), \ - }, \ - }, \ - }, \ - }, \ - } - -#define tgif_arg_dynamic_byte(_val, _attr) \ - { \ - .type = TGIF_TYPE_DYNAMIC_BYTE, \ - .u = { \ - .tgif_dynamic = { \ - .tgif_byte = { \ - .type = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - }, \ - .value = (_val), \ - }, \ - }, \ - }, \ - } -#define _tgif_arg_dynamic_string(_val, _byte_order, _unit_size, _attr) \ - { \ - .type = TGIF_TYPE_DYNAMIC_STRING, \ - .u = { \ - .tgif_dynamic = { \ - .tgif_string = { \ - .type = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - .unit_size = _unit_size, \ - .byte_order = _byte_order, \ - }, \ - .value = (uintptr_t) (_val), \ - }, \ - }, \ - }, \ - } -#define tgif_arg_dynamic_string(_val, _attr) \ - _tgif_arg_dynamic_string(_val, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_string16(_val, _attr) \ - _tgif_arg_dynamic_string(_val, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint16_t), TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_string16_le(_val, _attr) \ - _tgif_arg_dynamic_string(_val, TGIF_TYPE_BYTE_ORDER_LE, sizeof(uint16_t), TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_string16_be(_val, _attr) \ - _tgif_arg_dynamic_string(_val, TGIF_TYPE_BYTE_ORDER_BE, sizeof(uint16_t), TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_string32(_val, _attr) \ - _tgif_arg_dynamic_string(_val, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint32_t), TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_string32_le(_val, _attr) \ - _tgif_arg_dynamic_string(_val, TGIF_TYPE_BYTE_ORDER_LE, sizeof(uint32_t), TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_string32_be(_val, _attr) \ - _tgif_arg_dynamic_string(_val, TGIF_TYPE_BYTE_ORDER_BE, sizeof(uint32_t), TGIF_PARAM(_attr)) - -#define _tgif_arg_dynamic_integer(_field, _val, _type, _signedness, _byte_order, _integer_size, _len_bits, _attr) \ - { \ - .type = _type, \ - .u = { \ - .tgif_dynamic = { \ - .tgif_integer = { \ - .type = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - .integer_size = _integer_size, \ - .len_bits = _len_bits, \ - .signedness = _signedness, \ - .byte_order = _byte_order, \ - }, \ - .value = { \ - _field = (_val), \ - }, \ - }, \ - }, \ - }, \ - } - -#define tgif_arg_dynamic_u8(_val, _attr) \ - _tgif_arg_dynamic_integer(.tgif_u8, _val, TGIF_TYPE_DYNAMIC_INTEGER, false, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(uint8_t), 0, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_s8(_val, _attr) \ - _tgif_arg_dynamic_integer(.tgif_s8, _val, TGIF_TYPE_DYNAMIC_INTEGER, true, TGIF_TYPE_BYTE_ORDER_HOST, sizeof(int8_t), 0, TGIF_PARAM(_attr)) - -#define _tgif_arg_dynamic_u16(_val, _byte_order, _attr) \ - _tgif_arg_dynamic_integer(.tgif_u16, _val, TGIF_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(uint16_t), 0, TGIF_PARAM(_attr)) -#define _tgif_arg_dynamic_u32(_val, _byte_order, _attr) \ - _tgif_arg_dynamic_integer(.tgif_u32, _val, TGIF_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(uint32_t), 0, TGIF_PARAM(_attr)) -#define _tgif_arg_dynamic_u64(_val, _byte_order, _attr) \ - _tgif_arg_dynamic_integer(.tgif_u64, _val, TGIF_TYPE_DYNAMIC_INTEGER, false, _byte_order, sizeof(uint64_t), 0, TGIF_PARAM(_attr)) - -#define _tgif_arg_dynamic_s16(_val, _byte_order, _attr) \ - _tgif_arg_dynamic_integer(.tgif_s16, _val, TGIF_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(int16_t), 0, TGIF_PARAM(_attr)) -#define _tgif_arg_dynamic_s32(_val, _byte_order, _attr) \ - _tgif_arg_dynamic_integer(.tgif_s32, _val, TGIF_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(int32_t), 0, TGIF_PARAM(_attr)) -#define _tgif_arg_dynamic_s64(_val, _byte_order, _attr) \ - _tgif_arg_dynamic_integer(.tgif_s64, _val, TGIF_TYPE_DYNAMIC_INTEGER, true, _byte_order, sizeof(int64_t), 0, TGIF_PARAM(_attr)) - -#define _tgif_arg_dynamic_pointer(_val, _byte_order, _attr) \ - _tgif_arg_dynamic_integer(.tgif_uptr, (uintptr_t) (_val), TGIF_TYPE_DYNAMIC_POINTER, false, _byte_order, \ - sizeof(uintptr_t), 0, TGIF_PARAM(_attr)) - -#define _tgif_arg_dynamic_float(_field, _val, _type, _byte_order, _float_size, _attr) \ - { \ - .type = _type, \ - .u = { \ - .tgif_dynamic = { \ - .tgif_float = { \ - .type = { \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - .float_size = _float_size, \ - .byte_order = _byte_order, \ - }, \ - .value = { \ - _field = (_val), \ - }, \ - }, \ - }, \ - }, \ - } - -#define _tgif_arg_dynamic_float_binary16(_val, _byte_order, _attr) \ - _tgif_arg_dynamic_float(.tgif_float_binary16, _val, TGIF_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float16), TGIF_PARAM(_attr)) -#define _tgif_arg_dynamic_float_binary32(_val, _byte_order, _attr) \ - _tgif_arg_dynamic_float(.tgif_float_binary32, _val, TGIF_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float32), TGIF_PARAM(_attr)) -#define _tgif_arg_dynamic_float_binary64(_val, _byte_order, _attr) \ - _tgif_arg_dynamic_float(.tgif_float_binary64, _val, TGIF_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float64), TGIF_PARAM(_attr)) -#define _tgif_arg_dynamic_float_binary128(_val, _byte_order, _attr) \ - _tgif_arg_dynamic_float(.tgif_float_binary128, _val, TGIF_TYPE_DYNAMIC_FLOAT, _byte_order, sizeof(_Float128), TGIF_PARAM(_attr)) - -/* Host endian */ -#define tgif_arg_dynamic_u16(_val, _attr) _tgif_arg_dynamic_u16(_val, TGIF_TYPE_BYTE_ORDER_HOST, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_u32(_val, _attr) _tgif_arg_dynamic_u32(_val, TGIF_TYPE_BYTE_ORDER_HOST, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_u64(_val, _attr) _tgif_arg_dynamic_u64(_val, TGIF_TYPE_BYTE_ORDER_HOST, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_s16(_val, _attr) _tgif_arg_dynamic_s16(_val, TGIF_TYPE_BYTE_ORDER_HOST, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_s32(_val, _attr) _tgif_arg_dynamic_s32(_val, TGIF_TYPE_BYTE_ORDER_HOST, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_s64(_val, _attr) _tgif_arg_dynamic_s64(_val, TGIF_TYPE_BYTE_ORDER_HOST, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_pointer(_val, _attr) _tgif_arg_dynamic_pointer(_val, TGIF_TYPE_BYTE_ORDER_HOST, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_float_binary16(_val, _attr) _tgif_arg_dynamic_float_binary16(_val, TGIF_TYPE_FLOAT_WORD_ORDER_HOST, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_float_binary32(_val, _attr) _tgif_arg_dynamic_float_binary32(_val, TGIF_TYPE_FLOAT_WORD_ORDER_HOST, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_float_binary64(_val, _attr) _tgif_arg_dynamic_float_binary64(_val, TGIF_TYPE_FLOAT_WORD_ORDER_HOST, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_float_binary128(_val, _attr) _tgif_arg_dynamic_float_binary128(_val, TGIF_TYPE_FLOAT_WORD_ORDER_HOST, TGIF_PARAM(_attr)) - -/* Little endian */ -#define tgif_arg_dynamic_u16_le(_val, _attr) _tgif_arg_dynamic_u16(_val, TGIF_TYPE_BYTE_ORDER_LE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_u32_le(_val, _attr) _tgif_arg_dynamic_u32(_val, TGIF_TYPE_BYTE_ORDER_LE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_u64_le(_val, _attr) _tgif_arg_dynamic_u64(_val, TGIF_TYPE_BYTE_ORDER_LE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_s16_le(_val, _attr) _tgif_arg_dynamic_s16(_val, TGIF_TYPE_BYTE_ORDER_LE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_s32_le(_val, _attr) _tgif_arg_dynamic_s32(_val, TGIF_TYPE_BYTE_ORDER_LE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_s64_le(_val, _attr) _tgif_arg_dynamic_s64(_val, TGIF_TYPE_BYTE_ORDER_LE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_pointer_le(_val, _attr) _tgif_arg_dynamic_pointer(_val, TGIF_TYPE_BYTE_ORDER_LE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_float_binary16_le(_val, _attr) _tgif_arg_dynamic_float_binary16(_val, TGIF_TYPE_BYTE_ORDER_LE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_float_binary32_le(_val, _attr) _tgif_arg_dynamic_float_binary32(_val, TGIF_TYPE_BYTE_ORDER_LE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_float_binary64_le(_val, _attr) _tgif_arg_dynamic_float_binary64(_val, TGIF_TYPE_BYTE_ORDER_LE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_float_binary128_le(_val, _attr) _tgif_arg_dynamic_float_binary128(_val, TGIF_TYPE_BYTE_ORDER_LE, TGIF_PARAM(_attr)) - -/* Big endian */ -#define tgif_arg_dynamic_u16_be(_val, _attr) _tgif_arg_dynamic_u16(_val, TGIF_TYPE_BYTE_ORDER_BE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_u32_be(_val, _attr) _tgif_arg_dynamic_u32(_val, TGIF_TYPE_BYTE_ORDER_BE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_u64_be(_val, _attr) _tgif_arg_dynamic_u64(_val, TGIF_TYPE_BYTE_ORDER_BE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_s16_be(_val, _attr) _tgif_arg_dynamic_s16(_val, TGIF_TYPE_BYTE_ORDER_BE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_s32_be(_val, _attr) _tgif_arg_dynamic_s32(_val, TGIF_TYPE_BYTE_ORDER_BE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_s64_be(_val, _attr) _tgif_arg_dynamic_s64(_val, TGIF_TYPE_BYTE_ORDER_BE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_pointer_be(_val, _attr) _tgif_arg_dynamic_pointer(_val, TGIF_TYPE_BYTE_ORDER_BE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_float_binary16_be(_val, _attr) _tgif_arg_dynamic_float_binary16(_val, TGIF_TYPE_BYTE_ORDER_BE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_float_binary32_be(_val, _attr) _tgif_arg_dynamic_float_binary32(_val, TGIF_TYPE_BYTE_ORDER_BE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_float_binary64_be(_val, _attr) _tgif_arg_dynamic_float_binary64(_val, TGIF_TYPE_BYTE_ORDER_BE, TGIF_PARAM(_attr)) -#define tgif_arg_dynamic_float_binary128_be(_val, _attr) _tgif_arg_dynamic_float_binary128(_val, TGIF_TYPE_BYTE_ORDER_BE, TGIF_PARAM(_attr)) - -#define tgif_arg_dynamic_vla(_vla) \ - { \ - .type = TGIF_TYPE_DYNAMIC_VLA, \ - .u = { \ - .tgif_dynamic = { \ - .tgif_dynamic_vla = (_vla), \ - }, \ - }, \ - } - -#define tgif_arg_dynamic_vla_visitor(_dynamic_vla_visitor, _ctx, _attr) \ - { \ - .type = TGIF_TYPE_DYNAMIC_VLA_VISITOR, \ - .u = { \ - .tgif_dynamic = { \ - .tgif_dynamic_vla_visitor = { \ - .app_ctx = _ctx, \ - .visitor = _dynamic_vla_visitor, \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - }, \ - }, \ - }, \ - } - -#define tgif_arg_dynamic_struct(_struct) \ - { \ - .type = TGIF_TYPE_DYNAMIC_STRUCT, \ - .u = { \ - .tgif_dynamic = { \ - .tgif_dynamic_struct = (_struct), \ - }, \ - }, \ - } - -#define tgif_arg_dynamic_struct_visitor(_dynamic_struct_visitor, _ctx, _attr) \ - { \ - .type = TGIF_TYPE_DYNAMIC_STRUCT_VISITOR, \ - .u = { \ - .tgif_dynamic = { \ - .tgif_dynamic_struct_visitor = { \ - .app_ctx = _ctx, \ - .visitor = _dynamic_struct_visitor, \ - .attr = _attr, \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - }, \ - }, \ - }, \ - } - -#define tgif_arg_dynamic_define_vec(_identifier, _sav, _attr) \ - const struct tgif_arg _identifier##_vec[] = { _sav }; \ - const struct tgif_arg_dynamic_vla _identifier = { \ - .sav = _identifier##_vec, \ - .attr = _attr, \ - .len = TGIF_ARRAY_SIZE(_identifier##_vec), \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - } - -#define tgif_arg_dynamic_define_struct(_identifier, _struct_fields, _attr) \ - const struct tgif_arg_dynamic_field _identifier##_fields[] = { _struct_fields }; \ - const struct tgif_arg_dynamic_struct _identifier = { \ - .fields = _identifier##_fields, \ - .attr = _attr, \ - .len = TGIF_ARRAY_SIZE(_identifier##_fields), \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - } - -#define tgif_arg_define_vec(_identifier, _sav) \ - const struct tgif_arg _identifier##_vec[] = { _sav }; \ - const struct tgif_arg_vec _identifier = { \ - .sav = _identifier##_vec, \ - .len = TGIF_ARRAY_SIZE(_identifier##_vec), \ - } - -#define tgif_arg_dynamic_field(_name, _elem) \ - { \ - .field_name = _name, \ - .elem = _elem, \ - } - -/* - * Event instrumentation description registration, runtime enabled state - * check, and instrumentation invocation. - */ - -#define tgif_arg_list(...) __VA_ARGS__ - -#define tgif_event_cond(_identifier) \ - if (tgif_unlikely(__atomic_load_n(&tgif_event_enable__##_identifier, \ - __ATOMIC_RELAXED))) - -#define tgif_event_call(_identifier, _sav) \ - { \ - const struct tgif_arg tgif_sav[] = { _sav }; \ - const struct tgif_arg_vec tgif_arg_vec = { \ - .sav = tgif_sav, \ - .len = TGIF_ARRAY_SIZE(tgif_sav), \ - }; \ - tgif_call(&(_identifier), &tgif_arg_vec); \ - } - -#define tgif_event(_identifier, _sav) \ - tgif_event_cond(_identifier) \ - tgif_event_call(_identifier, TGIF_PARAM(_sav)) - -#define tgif_event_call_variadic(_identifier, _sav, _var_fields, _attr) \ - { \ - const struct tgif_arg tgif_sav[] = { _sav }; \ - const struct tgif_arg_vec tgif_arg_vec = { \ - .sav = tgif_sav, \ - .len = TGIF_ARRAY_SIZE(tgif_sav), \ - }; \ - const struct tgif_arg_dynamic_field tgif_fields[] = { _var_fields }; \ - const struct tgif_arg_dynamic_struct var_struct = { \ - .fields = tgif_fields, \ - .attr = _attr, \ - .len = TGIF_ARRAY_SIZE(tgif_fields), \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - }; \ - tgif_call_variadic(&(_identifier), &tgif_arg_vec, &var_struct); \ - } - -#define tgif_event_variadic(_identifier, _sav, _var, _attr) \ - tgif_event_cond(_identifier) \ - tgif_event_call_variadic(_identifier, TGIF_PARAM(_sav), TGIF_PARAM(_var), TGIF_PARAM(_attr)) - -#define _tgif_define_event(_linkage, _identifier, _provider, _event, _loglevel, _fields, _attr, _flags) \ - _linkage uintptr_t tgif_event_enable__##_identifier __attribute__((section("tgif_event_enable"))); \ - _linkage struct tgif_event_description __attribute__((section("tgif_event_description"))) \ - _identifier = { \ - .enabled = &(tgif_event_enable__##_identifier), \ - .provider_name = _provider, \ - .event_name = _event, \ - .fields = _fields, \ - .attr = _attr, \ - .callbacks = &tgif_empty_callback, \ - .flags = (_flags), \ - .version = 0, \ - .loglevel = _loglevel, \ - .nr_fields = TGIF_ARRAY_SIZE(TGIF_PARAM(_fields)), \ - .nr_attr = TGIF_ARRAY_SIZE(TGIF_PARAM(_attr)), \ - .nr_callbacks = 0, \ - }; \ - static const struct tgif_event_description *tgif_event_ptr__##_identifier \ - __attribute__((section("tgif_event_description_ptr"), used)) = &(_identifier); - -#define tgif_static_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \ - _tgif_define_event(static, _identifier, _provider, _event, _loglevel, TGIF_PARAM(_fields), \ - TGIF_PARAM(_attr), 0) - -#define tgif_static_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \ - _tgif_define_event(static, _identifier, _provider, _event, _loglevel, TGIF_PARAM(_fields), \ - TGIF_PARAM(_attr), TGIF_EVENT_FLAG_VARIADIC) - -#define tgif_hidden_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \ - _tgif_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \ - _loglevel, TGIF_PARAM(_fields), TGIF_PARAM(_attr), 0) - -#define tgif_hidden_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \ - _tgif_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \ - _loglevel, TGIF_PARAM(_fields), TGIF_PARAM(_attr), TGIF_EVENT_FLAG_VARIADIC) - -#define tgif_export_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \ - _tgif_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \ - _loglevel, TGIF_PARAM(_fields), TGIF_PARAM(_attr), 0) - -#define tgif_export_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \ - _tgif_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \ - _loglevel, TGIF_PARAM(_fields), TGIF_PARAM(_attr), TGIF_EVENT_FLAG_VARIADIC) - -#define tgif_declare_event(_identifier) \ - extern uintptr_t tgif_event_enable_##_identifier; \ - extern struct tgif_event_description _identifier - -#ifdef __cplusplus -extern "C" { -#endif - -extern const struct tgif_callback tgif_empty_callback; - -void tgif_call(const struct tgif_event_description *desc, - const struct tgif_arg_vec *tgif_arg_vec); -void tgif_call_variadic(const struct tgif_event_description *desc, - const struct tgif_arg_vec *tgif_arg_vec, - const struct tgif_arg_dynamic_struct *var_struct); - -struct tgif_events_register_handle *tgif_events_register(struct tgif_event_description **events, - uint32_t nr_events); -void tgif_events_unregister(struct tgif_events_register_handle *handle); - -/* - * Userspace tracer registration API. This allows userspace tracers to - * register event notification callbacks to be notified of the currently - * registered instrumentation, and to register their callbacks to - * specific events. - */ -typedef void (*tgif_tracer_callback_func)(const struct tgif_event_description *desc, - const struct tgif_arg_vec *tgif_arg_vec, - void *priv); -typedef void (*tgif_tracer_callback_variadic_func)(const struct tgif_event_description *desc, - const struct tgif_arg_vec *tgif_arg_vec, - const struct tgif_arg_dynamic_struct *var_struct, - void *priv); - -int tgif_tracer_callback_register(struct tgif_event_description *desc, - tgif_tracer_callback_func call, - void *priv); -int tgif_tracer_callback_variadic_register(struct tgif_event_description *desc, - tgif_tracer_callback_variadic_func call_variadic, - void *priv); -int tgif_tracer_callback_unregister(struct tgif_event_description *desc, - tgif_tracer_callback_func call, - void *priv); -int tgif_tracer_callback_variadic_unregister(struct tgif_event_description *desc, - tgif_tracer_callback_variadic_func call_variadic, - void *priv); - -enum tgif_tracer_notification { - TGIF_TRACER_NOTIFICATION_INSERT_EVENTS, - TGIF_TRACER_NOTIFICATION_REMOVE_EVENTS, -}; - -/* Callback is invoked with tgif library internal lock held. */ -struct tgif_tracer_handle *tgif_tracer_event_notification_register( - void (*cb)(enum tgif_tracer_notification notif, - struct tgif_event_description **events, uint32_t nr_events, void *priv), - void *priv); -void tgif_tracer_event_notification_unregister(struct tgif_tracer_handle *handle); - -/* - * Explicit hooks to initialize/finalize the tgif instrumentation - * library. Those are also library constructor/destructor. - */ -void tgif_init(void) __attribute__((constructor)); -void tgif_exit(void) __attribute__((destructor)); - -/* - * The following constructors/destructors perform automatic registration - * of the declared tgif events. Those may have to be called explicitly - * in a statically linked library. - */ - -/* - * These weak symbols, the constructor, and destructor take care of - * registering only _one_ instance of the tgif instrumentation per - * shared-ojbect (or for the whole main program). - */ -extern struct tgif_event_description * __start_tgif_event_description_ptr[] - __attribute__((weak, visibility("hidden"))); -extern struct tgif_event_description * __stop_tgif_event_description_ptr[] - __attribute__((weak, visibility("hidden"))); -int tgif_event_description_ptr_registered - __attribute__((weak, visibility("hidden"))); -struct tgif_events_register_handle *tgif_events_handle - __attribute__((weak, visibility("hidden"))); - -static void -tgif_event_description_ptr_init(void) - __attribute__((no_instrument_function)) - __attribute__((constructor)); -static void -tgif_event_description_ptr_init(void) -{ - if (tgif_event_description_ptr_registered++) - return; - tgif_events_handle = tgif_events_register(__start_tgif_event_description_ptr, - __stop_tgif_event_description_ptr - __start_tgif_event_description_ptr); -} - -static void -tgif_event_description_ptr_exit(void) - __attribute__((no_instrument_function)) - __attribute__((destructor)); -static void -tgif_event_description_ptr_exit(void) -{ - if (--tgif_event_description_ptr_registered) - return; - tgif_events_unregister(tgif_events_handle); - tgif_events_handle = NULL; -} - -#ifdef __cplusplus -} -#endif - -#endif /* _TGIF_TRACE_H */ diff --git a/src/Makefile.am b/src/Makefile.am index cdedca3..c4268d8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,18 +15,18 @@ libsmp_la_SOURCES = \ smp.h # Public libaries -lib_LTLIBRARIES = libtgif.la +lib_LTLIBRARIES = libside.la -libtgif_la_SOURCES = \ +libside_la_SOURCES = \ list.h \ - tgif.c \ + side.c \ tracer.c -libtgif_la_LDFLAGS = -no-undefined -version-info $(TGIF_LIBRARY_VERSION) -libtgif_la_LIBADD = \ +libside_la_LDFLAGS = -no-undefined -version-info $(SIDE_LIBRARY_VERSION) +libside_la_LIBADD = \ librcu.la \ libsmp.la \ $(RSEQ_LIBS) pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libtgif.pc +pkgconfig_DATA = libside.pc diff --git a/src/libside.pc.in b/src/libside.pc.in new file mode 100644 index 0000000..a261bf1 --- /dev/null +++ b/src/libside.pc.in @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: 2022 EfficiOS Inc. + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: Restartable sequence +Description: Restartable sequence library +Version: @PACKAGE_VERSION@ +Requires: +Libs: -L${libdir} -lside +Cflags: -I${includedir} diff --git a/src/libtgif.pc.in b/src/libtgif.pc.in deleted file mode 100644 index d76b2bc..0000000 --- a/src/libtgif.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: MIT -# SPDX-FileCopyrightText: 2022 EfficiOS Inc. - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: Restartable sequence -Description: Restartable sequence library -Version: @PACKAGE_VERSION@ -Requires: -Libs: -L${libdir} -ltgif -Cflags: -I${includedir} diff --git a/src/list.h b/src/list.h index 31f5608..f017e1a 100644 --- a/src/list.h +++ b/src/list.h @@ -3,20 +3,20 @@ * Copyright 2022 Mathieu Desnoyers */ -#ifndef _TGIF_LIST_H -#define _TGIF_LIST_H +#ifndef _SIDE_LIST_H +#define _SIDE_LIST_H -struct tgif_list_node { - struct tgif_list_node *next; - struct tgif_list_node *prev; +struct side_list_node { + struct side_list_node *next; + struct side_list_node *prev; }; -struct tgif_list_head { - struct tgif_list_node node; +struct side_list_head { + struct side_list_node node; }; -#define DEFINE_TGIF_LIST_HEAD(_identifier) \ - struct tgif_list_head _identifier = { \ +#define DEFINE_SIDE_LIST_HEAD(_identifier) \ + struct side_list_head _identifier = { \ .node = { \ .next = &(_identifier).node, \ .prev = &(_identifier).node, \ @@ -24,7 +24,7 @@ struct tgif_list_head { } static inline -void tgif_list_insert_node_tail(struct tgif_list_head *head, struct tgif_list_node *node) +void side_list_insert_node_tail(struct side_list_head *head, struct side_list_node *node) { node->next = &head->node; node->prev = head->node.prev; @@ -33,7 +33,7 @@ void tgif_list_insert_node_tail(struct tgif_list_head *head, struct tgif_list_no } static inline -void tgif_list_insert_node_head(struct tgif_list_head *head, struct tgif_list_node *node) +void side_list_insert_node_head(struct side_list_head *head, struct side_list_node *node) { node->next = head->node.next; node->prev = &head->node; @@ -42,23 +42,23 @@ void tgif_list_insert_node_head(struct tgif_list_head *head, struct tgif_list_no } static inline -void tgif_list_remove_node(struct tgif_list_node *node) +void side_list_remove_node(struct side_list_node *node) { node->next->prev = node->prev; node->prev->next = node->next; } -#define tgif_list_for_each_entry(_entry, _head, _member) \ - for ((_entry) = tgif_container_of((_head)->node.next, __typeof__(*(_entry)), _member); \ +#define side_list_for_each_entry(_entry, _head, _member) \ + for ((_entry) = side_container_of((_head)->node.next, __typeof__(*(_entry)), _member); \ &(_entry)->_member != &(_head)->node; \ - (_entry) = tgif_container_of((_entry)->_member.next, __typeof__(*(_entry)), _member)) + (_entry) = side_container_of((_entry)->_member.next, __typeof__(*(_entry)), _member)) /* List iteration, safe against node reclaim while iterating. */ -#define tgif_list_for_each_entry_safe(_entry, _next_entry, _head, _member) \ - for ((_entry) = tgif_container_of((_head)->node.next, __typeof__(*(_entry)), _member), \ - (_next_entry) = tgif_container_of((_entry)->_member.next, __typeof__(*(_entry)), _member); \ +#define side_list_for_each_entry_safe(_entry, _next_entry, _head, _member) \ + for ((_entry) = side_container_of((_head)->node.next, __typeof__(*(_entry)), _member), \ + (_next_entry) = side_container_of((_entry)->_member.next, __typeof__(*(_entry)), _member); \ &(_entry)->_member != &(_head)->node; \ - (_entry) = tgif_container_of((_next_entry)->_member.next, __typeof__(*(_entry)), _member), \ - (_next_entry) = tgif_container_of((_entry)->_member.next, __typeof__(*(_entry)), _member)) + (_entry) = side_container_of((_next_entry)->_member.next, __typeof__(*(_entry)), _member), \ + (_next_entry) = side_container_of((_entry)->_member.next, __typeof__(*(_entry)), _member)) -#endif /* _TGIF_LIST_H */ +#endif /* _SIDE_LIST_H */ diff --git a/src/rcu.c b/src/rcu.c index 834d33f..9652725 100644 --- a/src/rcu.c +++ b/src/rcu.c @@ -22,7 +22,7 @@ * If both rseq (with glibc support) and membarrier system calls are * available, use them to replace barriers and atomics on the fast-path. */ -unsigned int tgif_rcu_rseq_membarrier_available; +unsigned int side_rcu_rseq_membarrier_available; static int membarrier(int cmd, unsigned int flags, int cpu_id) @@ -34,16 +34,16 @@ membarrier(int cmd, unsigned int flags, int cpu_id) * Wait/wakeup scheme with single waiter/many wakers. */ static -void wait_gp_prepare(struct tgif_rcu_gp_state *gp_state) +void wait_gp_prepare(struct side_rcu_gp_state *gp_state) { __atomic_store_n(&gp_state->futex, -1, __ATOMIC_RELAXED); /* * This memory barrier (H) pairs with memory barrier (F). It * orders store to futex before load of RCU reader's counter * state, thus ensuring that load of RCU reader's counters does - * not leak outtgif of futex state=-1. + * not leak outside of futex state=-1. */ - if (tgif_rcu_rseq_membarrier_available) { + if (side_rcu_rseq_membarrier_available) { if (membarrier(MEMBARRIER_CMD_PRIVATE_EXPEDITED, 0, 0)) { perror("membarrier"); abort(); @@ -54,15 +54,15 @@ void wait_gp_prepare(struct tgif_rcu_gp_state *gp_state) } static -void wait_gp_end(struct tgif_rcu_gp_state *gp_state) +void wait_gp_end(struct side_rcu_gp_state *gp_state) { /* * This memory barrier (G) pairs with memory barrier (F). It * orders load of RCU reader's counter state before storing the * futex value, thus ensuring that load of RCU reader's counters - * does not leak outtgif of futex state=-1. + * does not leak outside of futex state=-1. */ - if (tgif_rcu_rseq_membarrier_available) { + if (side_rcu_rseq_membarrier_available) { if (membarrier(MEMBARRIER_CMD_PRIVATE_EXPEDITED, 0, 0)) { perror("membarrier"); abort(); @@ -74,14 +74,14 @@ void wait_gp_end(struct tgif_rcu_gp_state *gp_state) } static -void wait_gp(struct tgif_rcu_gp_state *gp_state) +void wait_gp(struct side_rcu_gp_state *gp_state) { /* * This memory barrier (G) pairs with memory barrier (F). It * orders load of RCU reader's counter state before loading the * futex value. */ - if (tgif_rcu_rseq_membarrier_available) { + if (side_rcu_rseq_membarrier_available) { if (membarrier(MEMBARRIER_CMD_PRIVATE_EXPEDITED, 0, 0)) { perror("membarrier"); abort(); @@ -114,13 +114,13 @@ void wait_gp(struct tgif_rcu_gp_state *gp_state) /* active_readers is an input/output parameter. */ static -void check_active_readers(struct tgif_rcu_gp_state *gp_state, bool *active_readers) +void check_active_readers(struct side_rcu_gp_state *gp_state, bool *active_readers) { uintptr_t sum[2] = { 0, 0 }; /* begin - end */ int i; for (i = 0; i < gp_state->nr_cpus; i++) { - struct tgif_rcu_cpu_gp_state *cpu_state = &gp_state->percpu_state[i]; + struct side_rcu_cpu_gp_state *cpu_state = &gp_state->percpu_state[i]; if (active_readers[0]) { sum[0] -= __atomic_load_n(&cpu_state->count[0].end, __ATOMIC_RELAXED); @@ -142,7 +142,7 @@ void check_active_readers(struct tgif_rcu_gp_state *gp_state, bool *active_reade * incremented before "end", as guaranteed by memory barriers * (A) or (B). */ - if (tgif_rcu_rseq_membarrier_available) { + if (side_rcu_rseq_membarrier_available) { if (membarrier(MEMBARRIER_CMD_PRIVATE_EXPEDITED, 0, 0)) { perror("membarrier"); abort(); @@ -152,7 +152,7 @@ void check_active_readers(struct tgif_rcu_gp_state *gp_state, bool *active_reade } for (i = 0; i < gp_state->nr_cpus; i++) { - struct tgif_rcu_cpu_gp_state *cpu_state = &gp_state->percpu_state[i]; + struct side_rcu_cpu_gp_state *cpu_state = &gp_state->percpu_state[i]; if (active_readers[0]) { sum[0] += __atomic_load_n(&cpu_state->count[0].begin, __ATOMIC_RELAXED); @@ -175,7 +175,7 @@ void check_active_readers(struct tgif_rcu_gp_state *gp_state, bool *active_reade * active_readers is an input/output parameter. */ static -void wait_for_prev_period_readers(struct tgif_rcu_gp_state *gp_state, bool *active_readers) +void wait_for_prev_period_readers(struct side_rcu_gp_state *gp_state, bool *active_readers) { unsigned int prev_period = gp_state->period ^ 1; @@ -209,22 +209,22 @@ void wait_for_prev_period_readers(struct tgif_rcu_gp_state *gp_state, bool *acti * grace period observes that no readers are present for each given * period, at which point the active_readers state becomes false. */ -void tgif_rcu_wait_grace_period(struct tgif_rcu_gp_state *gp_state) +void side_rcu_wait_grace_period(struct side_rcu_gp_state *gp_state) { bool active_readers[2] = { true, true }; /* * This memory barrier (D) pairs with memory barriers (A) and - * (B) on the read-tgif. + * (B) on the read-side. * * It orders prior loads and stores before the "end"/"begin" * reader state loads. In other words, it orders prior loads and * stores before observation of active readers quiescence, - * effectively ensuring that read-tgif critical sections which + * effectively ensuring that read-side critical sections which * exist after the grace period completes are ordered after * loads and stores performed before the grace period. */ - if (tgif_rcu_rseq_membarrier_available) { + if (side_rcu_rseq_membarrier_available) { if (membarrier(MEMBARRIER_CMD_PRIVATE_EXPEDITED, 0, 0)) { perror("membarrier"); abort(); @@ -262,17 +262,17 @@ unlock: end: /* * This memory barrier (E) pairs with memory barriers (A) and - * (B) on the read-tgif. + * (B) on the read-side. * * It orders the "end"/"begin" reader state loads before * following loads and stores. In other words, it orders * observation of active readers quiescence before following - * loads and stores, effectively ensuring that read-tgif + * loads and stores, effectively ensuring that read-side * critical sections which existed prior to the grace period * are ordered before loads and stores performed after the grace * period. */ - if (tgif_rcu_rseq_membarrier_available) { + if (side_rcu_rseq_membarrier_available) { if (membarrier(MEMBARRIER_CMD_PRIVATE_EXPEDITED, 0, 0)) { perror("membarrier"); abort(); @@ -282,7 +282,7 @@ end: } } -void tgif_rcu_gp_init(struct tgif_rcu_gp_state *rcu_gp) +void side_rcu_gp_init(struct side_rcu_gp_state *rcu_gp) { bool has_membarrier = false, has_rseq = false; @@ -291,8 +291,8 @@ void tgif_rcu_gp_init(struct tgif_rcu_gp_state *rcu_gp) if (!rcu_gp->nr_cpus) abort(); pthread_mutex_init(&rcu_gp->gp_lock, NULL); - rcu_gp->percpu_state = (struct tgif_rcu_cpu_gp_state *) - calloc(rcu_gp->nr_cpus, sizeof(struct tgif_rcu_cpu_gp_state)); + rcu_gp->percpu_state = (struct side_rcu_cpu_gp_state *) + calloc(rcu_gp->nr_cpus, sizeof(struct side_rcu_cpu_gp_state)); if (!rcu_gp->percpu_state) abort(); if (!membarrier(MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, 0, 0)) @@ -300,10 +300,10 @@ void tgif_rcu_gp_init(struct tgif_rcu_gp_state *rcu_gp) if (rseq_available(RSEQ_AVAILABLE_QUERY_LIBC)) has_rseq = true; if (has_membarrier && has_rseq) - tgif_rcu_rseq_membarrier_available = 1; + side_rcu_rseq_membarrier_available = 1; } -void tgif_rcu_gp_exit(struct tgif_rcu_gp_state *rcu_gp) +void side_rcu_gp_exit(struct side_rcu_gp_state *rcu_gp) { rseq_prepare_unload(); pthread_mutex_destroy(&rcu_gp->gp_lock); diff --git a/src/rcu.h b/src/rcu.h index 1fe09e3..9d33511 100644 --- a/src/rcu.h +++ b/src/rcu.h @@ -3,8 +3,8 @@ * Copyright 2022 Mathieu Desnoyers */ -#ifndef _TGIF_RCU_H -#define _TGIF_RCU_H +#ifndef _SIDE_RCU_H +#define _SIDE_RCU_H #include #include @@ -16,35 +16,35 @@ #include #include #include -#include +#include -#define TGIF_CACHE_LINE_SIZE 256 +#define SIDE_CACHE_LINE_SIZE 256 -struct tgif_rcu_percpu_count { +struct side_rcu_percpu_count { uintptr_t begin; uintptr_t rseq_begin; uintptr_t end; uintptr_t rseq_end; }; -struct tgif_rcu_cpu_gp_state { - struct tgif_rcu_percpu_count count[2]; -} __attribute__((__aligned__(TGIF_CACHE_LINE_SIZE))); +struct side_rcu_cpu_gp_state { + struct side_rcu_percpu_count count[2]; +} __attribute__((__aligned__(SIDE_CACHE_LINE_SIZE))); -struct tgif_rcu_gp_state { - struct tgif_rcu_cpu_gp_state *percpu_state; +struct side_rcu_gp_state { + struct side_rcu_cpu_gp_state *percpu_state; int nr_cpus; int32_t futex; unsigned int period; pthread_mutex_t gp_lock; }; -struct tgif_rcu_read_state { - struct tgif_rcu_percpu_count *percpu_count; +struct side_rcu_read_state { + struct side_rcu_percpu_count *percpu_count; int cpu; }; -extern unsigned int tgif_rcu_rseq_membarrier_available __attribute__((visibility("hidden"))); +extern unsigned int side_rcu_rseq_membarrier_available __attribute__((visibility("hidden"))); static inline int futex(int32_t *uaddr, int op, int32_t val, @@ -54,13 +54,13 @@ int futex(int32_t *uaddr, int op, int32_t val, } /* - * Wake-up tgif_rcu_wait_grace_period. Called concurrently from many + * Wake-up side_rcu_wait_grace_period. Called concurrently from many * threads. */ static inline -void tgif_rcu_wake_up_gp(struct tgif_rcu_gp_state *gp_state) +void side_rcu_wake_up_gp(struct side_rcu_gp_state *gp_state) { - if (tgif_unlikely(__atomic_load_n(&gp_state->futex, __ATOMIC_RELAXED) == -1)) { + if (side_unlikely(__atomic_load_n(&gp_state->futex, __ATOMIC_RELAXED) == -1)) { __atomic_store_n(&gp_state->futex, 0, __ATOMIC_RELAXED); /* TODO: handle futex return values. */ (void) futex(&gp_state->futex, FUTEX_WAKE, 1, NULL, NULL, 0); @@ -68,10 +68,10 @@ void tgif_rcu_wake_up_gp(struct tgif_rcu_gp_state *gp_state) } static inline -void tgif_rcu_read_begin(struct tgif_rcu_gp_state *gp_state, struct tgif_rcu_read_state *read_state) +void side_rcu_read_begin(struct side_rcu_gp_state *gp_state, struct side_rcu_read_state *read_state) { - struct tgif_rcu_percpu_count *begin_cpu_count; - struct tgif_rcu_cpu_gp_state *cpu_gp_state; + struct side_rcu_percpu_count *begin_cpu_count; + struct side_rcu_cpu_gp_state *cpu_gp_state; unsigned int period; int cpu; @@ -80,14 +80,14 @@ void tgif_rcu_read_begin(struct tgif_rcu_gp_state *gp_state, struct tgif_rcu_rea cpu_gp_state = &gp_state->percpu_state[cpu]; read_state->percpu_count = begin_cpu_count = &cpu_gp_state->count[period]; read_state->cpu = cpu; - if (tgif_likely(tgif_rcu_rseq_membarrier_available && + if (side_likely(side_rcu_rseq_membarrier_available && !rseq_addv((intptr_t *)&begin_cpu_count->rseq_begin, 1, cpu))) { /* * This compiler barrier (A) is paired with membarrier() at (C), * (D), (E). It effectively upgrades this compiler barrier to a * SEQ_CST fence with respect to the paired barriers. * - * This barrier (A) ensures that the contents of the read-tgif + * This barrier (A) ensures that the contents of the read-side * critical section does not leak before the "begin" counter * increment. It pairs with memory barriers (D) and (E). * @@ -100,7 +100,7 @@ void tgif_rcu_read_begin(struct tgif_rcu_gp_state *gp_state, struct tgif_rcu_rea } /* Fallback to atomic increment and SEQ_CST. */ cpu = sched_getcpu(); - if (tgif_unlikely(cpu < 0)) + if (side_unlikely(cpu < 0)) cpu = 0; read_state->cpu = cpu; cpu_gp_state = &gp_state->percpu_state[cpu]; @@ -109,9 +109,9 @@ void tgif_rcu_read_begin(struct tgif_rcu_gp_state *gp_state, struct tgif_rcu_rea } static inline -void tgif_rcu_read_end(struct tgif_rcu_gp_state *gp_state, struct tgif_rcu_read_state *read_state) +void side_rcu_read_end(struct side_rcu_gp_state *gp_state, struct side_rcu_read_state *read_state) { - struct tgif_rcu_percpu_count *begin_cpu_count = read_state->percpu_count; + struct side_rcu_percpu_count *begin_cpu_count = read_state->percpu_count; int cpu = read_state->cpu; /* @@ -119,7 +119,7 @@ void tgif_rcu_read_end(struct tgif_rcu_gp_state *gp_state, struct tgif_rcu_read_ * (D), (E). It effectively upgrades this compiler barrier to a * SEQ_CST fence with respect to the paired barriers. * - * This barrier (B) ensures that the contents of the read-tgif + * This barrier (B) ensures that the contents of the read-side * critical section does not leak after the "end" counter * increment. It pairs with memory barriers (D) and (E). * @@ -128,7 +128,7 @@ void tgif_rcu_read_end(struct tgif_rcu_gp_state *gp_state, struct tgif_rcu_read_ * It is redundant with barrier (A) for that purpose. */ rseq_barrier(); - if (tgif_likely(tgif_rcu_rseq_membarrier_available && + if (side_likely(side_rcu_rseq_membarrier_available && !rseq_addv((intptr_t *)&begin_cpu_count->rseq_end, 1, cpu))) { /* * This barrier (F) is paired with membarrier() @@ -147,20 +147,20 @@ void tgif_rcu_read_end(struct tgif_rcu_gp_state *gp_state, struct tgif_rcu_read_ */ __atomic_thread_fence(__ATOMIC_SEQ_CST); end: - tgif_rcu_wake_up_gp(gp_state); + side_rcu_wake_up_gp(gp_state); } -#define tgif_rcu_dereference(p) \ +#define side_rcu_dereference(p) \ __extension__ \ ({ \ - __typeof__(p) _____tgif_v = __atomic_load_n(&(p), __ATOMIC_CONSUME); \ - (_____tgif_v); \ + __typeof__(p) _____side_v = __atomic_load_n(&(p), __ATOMIC_CONSUME); \ + (_____side_v); \ }) -#define tgif_rcu_assign_pointer(p, v) __atomic_store_n(&(p), v, __ATOMIC_RELEASE); \ +#define side_rcu_assign_pointer(p, v) __atomic_store_n(&(p), v, __ATOMIC_RELEASE); \ -void tgif_rcu_wait_grace_period(struct tgif_rcu_gp_state *gp_state) __attribute__((visibility("hidden"))); -void tgif_rcu_gp_init(struct tgif_rcu_gp_state *rcu_gp) __attribute__((visibility("hidden"))); -void tgif_rcu_gp_exit(struct tgif_rcu_gp_state *rcu_gp) __attribute__((visibility("hidden"))); +void side_rcu_wait_grace_period(struct side_rcu_gp_state *gp_state) __attribute__((visibility("hidden"))); +void side_rcu_gp_init(struct side_rcu_gp_state *rcu_gp) __attribute__((visibility("hidden"))); +void side_rcu_gp_exit(struct side_rcu_gp_state *rcu_gp) __attribute__((visibility("hidden"))); -#endif /* _TGIF_RCU_H */ +#endif /* _SIDE_RCU_H */ diff --git a/src/side.c b/src/side.c new file mode 100644 index 0000000..9196c09 --- /dev/null +++ b/src/side.c @@ -0,0 +1,422 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright 2022 Mathieu Desnoyers + */ + +#include +#include + +#include "rcu.h" +#include "list.h" + +/* Top 8 bits reserved for kernel tracer use. */ +#if SIDE_BITS_PER_LONG == 64 +# define SIDE_EVENT_ENABLED_KERNEL_MASK 0xFF00000000000000ULL +# define SIDE_EVENT_ENABLED_KERNEL_USER_EVENT_MASK 0x8000000000000000ULL + +/* Allow 2^56 tracer references on an event. */ +# define SIDE_EVENT_ENABLED_USER_MASK 0x00FFFFFFFFFFFFFFULL +#else +# define SIDE_EVENT_ENABLED_KERNEL_MASK 0xFF000000UL +# define SIDE_EVENT_ENABLED_KERNEL_USER_EVENT_MASK 0x80000000UL + +/* Allow 2^24 tracer references on an event. */ +# define SIDE_EVENT_ENABLED_USER_MASK 0x00FFFFFFUL +#endif + +struct side_events_register_handle { + struct side_list_node node; + struct side_event_description **events; + uint32_t nr_events; +}; + +struct side_tracer_handle { + struct side_list_node node; + void (*cb)(enum side_tracer_notification notif, + struct side_event_description **events, uint32_t nr_events, void *priv); + void *priv; +}; + +static struct side_rcu_gp_state rcu_gp; + +/* + * Lazy initialization for early use within library constructors. + */ +static bool initialized; +/* + * Do not register/unregister any more events after destructor. + */ +static bool finalized; + +/* + * Recursive mutex to allow tracer callbacks to use the side API. + */ +static pthread_mutex_t side_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; + +static DEFINE_SIDE_LIST_HEAD(side_events_list); +static DEFINE_SIDE_LIST_HEAD(side_tracer_list); + +/* + * The empty callback has a NULL function callback pointer, which stops + * iteration on the array of callbacks immediately. + */ +const struct side_callback side_empty_callback = { }; + +void side_call(const struct side_event_description *desc, const struct side_arg_vec *side_arg_vec) +{ + struct side_rcu_read_state rcu_read_state; + const struct side_callback *side_cb; + uintptr_t enabled; + + if (side_unlikely(finalized)) + return; + if (side_unlikely(!initialized)) + side_init(); + if (side_unlikely(desc->flags & SIDE_EVENT_FLAG_VARIADIC)) { + printf("ERROR: unexpected variadic event description\n"); + abort(); + } + enabled = __atomic_load_n(desc->enabled, __ATOMIC_RELAXED); + if (side_unlikely(enabled & SIDE_EVENT_ENABLED_KERNEL_USER_EVENT_MASK)) { + // TODO: call kernel write. + } + side_rcu_read_begin(&rcu_gp, &rcu_read_state); + for (side_cb = side_rcu_dereference(desc->callbacks); side_cb->u.call != NULL; side_cb++) + side_cb->u.call(desc, side_arg_vec, side_cb->priv); + side_rcu_read_end(&rcu_gp, &rcu_read_state); +} + +void side_call_variadic(const struct side_event_description *desc, + const struct side_arg_vec *side_arg_vec, + const struct side_arg_dynamic_struct *var_struct) +{ + struct side_rcu_read_state rcu_read_state; + const struct side_callback *side_cb; + uintptr_t enabled; + + if (side_unlikely(finalized)) + return; + if (side_unlikely(!initialized)) + side_init(); + if (side_unlikely(!(desc->flags & SIDE_EVENT_FLAG_VARIADIC))) { + printf("ERROR: unexpected non-variadic event description\n"); + abort(); + } + enabled = __atomic_load_n(desc->enabled, __ATOMIC_RELAXED); + if (side_unlikely(enabled & SIDE_EVENT_ENABLED_KERNEL_USER_EVENT_MASK)) { + // TODO: call kernel write. + } + side_rcu_read_begin(&rcu_gp, &rcu_read_state); + for (side_cb = side_rcu_dereference(desc->callbacks); side_cb->u.call_variadic != NULL; side_cb++) + side_cb->u.call_variadic(desc, side_arg_vec, var_struct, side_cb->priv); + side_rcu_read_end(&rcu_gp, &rcu_read_state); +} + +static +const struct side_callback *side_tracer_callback_lookup( + const struct side_event_description *desc, + void *call, void *priv) +{ + const struct side_callback *cb; + + for (cb = desc->callbacks; cb->u.call != NULL; cb++) { + if ((void *) cb->u.call == call && cb->priv == priv) + return cb; + } + return NULL; +} + +static +int _side_tracer_callback_register(struct side_event_description *desc, + void *call, void *priv) +{ + struct side_callback *old_cb, *new_cb; + int ret = SIDE_ERROR_OK; + uint32_t old_nr_cb; + + if (!call) + return SIDE_ERROR_INVAL; + if (finalized) + return SIDE_ERROR_EXITING; + if (!initialized) + side_init(); + pthread_mutex_lock(&side_lock); + old_nr_cb = desc->nr_callbacks; + if (old_nr_cb == UINT32_MAX) { + ret = SIDE_ERROR_INVAL; + goto unlock; + } + /* Reject duplicate (call, priv) tuples. */ + if (side_tracer_callback_lookup(desc, call, priv)) { + ret = SIDE_ERROR_EXIST; + goto unlock; + } + old_cb = (struct side_callback *) desc->callbacks; + /* old_nr_cb + 1 (new cb) + 1 (NULL) */ + new_cb = (struct side_callback *) calloc(old_nr_cb + 2, sizeof(struct side_callback)); + if (!new_cb) { + ret = SIDE_ERROR_NOMEM; + goto unlock; + } + memcpy(new_cb, old_cb, old_nr_cb); + if (desc->flags & SIDE_EVENT_FLAG_VARIADIC) + new_cb[old_nr_cb].u.call_variadic = + (side_tracer_callback_variadic_func) call; + else + new_cb[old_nr_cb].u.call = + (side_tracer_callback_func) call; + new_cb[old_nr_cb].priv = priv; + side_rcu_assign_pointer(desc->callbacks, new_cb); + side_rcu_wait_grace_period(&rcu_gp); + if (old_nr_cb) + free(old_cb); + desc->nr_callbacks++; + /* Increment concurrently with kernel setting the top bits. */ + if (!old_nr_cb) + (void) __atomic_add_fetch(desc->enabled, 1, __ATOMIC_RELAXED); +unlock: + pthread_mutex_unlock(&side_lock); + return ret; +} + +int side_tracer_callback_register(struct side_event_description *desc, + side_tracer_callback_func call, + void *priv) +{ + if (desc->flags & SIDE_EVENT_FLAG_VARIADIC) + return SIDE_ERROR_INVAL; + return _side_tracer_callback_register(desc, (void *) call, priv); +} + +int side_tracer_callback_variadic_register(struct side_event_description *desc, + side_tracer_callback_variadic_func call_variadic, + void *priv) +{ + if (!(desc->flags & SIDE_EVENT_FLAG_VARIADIC)) + return SIDE_ERROR_INVAL; + return _side_tracer_callback_register(desc, (void *) call_variadic, priv); +} + +static int _side_tracer_callback_unregister(struct side_event_description *desc, + void *call, void *priv) +{ + struct side_callback *old_cb, *new_cb; + const struct side_callback *cb_pos; + uint32_t pos_idx; + int ret = SIDE_ERROR_OK; + uint32_t old_nr_cb; + + if (!call) + return SIDE_ERROR_INVAL; + if (finalized) + return SIDE_ERROR_EXITING; + if (!initialized) + side_init(); + pthread_mutex_lock(&side_lock); + cb_pos = side_tracer_callback_lookup(desc, call, priv); + if (!cb_pos) { + ret = SIDE_ERROR_NOENT; + goto unlock; + } + old_nr_cb = desc->nr_callbacks; + old_cb = (struct side_callback *) desc->callbacks; + if (old_nr_cb == 1) { + new_cb = (struct side_callback *) &side_empty_callback; + } else { + pos_idx = cb_pos - desc->callbacks; + /* Remove entry at pos_idx. */ + /* old_nr_cb - 1 (removed cb) + 1 (NULL) */ + new_cb = (struct side_callback *) calloc(old_nr_cb, sizeof(struct side_callback)); + if (!new_cb) { + ret = SIDE_ERROR_NOMEM; + goto unlock; + } + memcpy(new_cb, old_cb, pos_idx); + memcpy(&new_cb[pos_idx], &old_cb[pos_idx + 1], old_nr_cb - pos_idx - 1); + } + side_rcu_assign_pointer(desc->callbacks, new_cb); + side_rcu_wait_grace_period(&rcu_gp); + free(old_cb); + desc->nr_callbacks--; + /* Decrement concurrently with kernel setting the top bits. */ + if (old_nr_cb == 1) + (void) __atomic_add_fetch(desc->enabled, -1, __ATOMIC_RELAXED); +unlock: + pthread_mutex_unlock(&side_lock); + return ret; +} + +int side_tracer_callback_unregister(struct side_event_description *desc, + side_tracer_callback_func call, + void *priv) +{ + if (desc->flags & SIDE_EVENT_FLAG_VARIADIC) + return SIDE_ERROR_INVAL; + return _side_tracer_callback_unregister(desc, (void *) call, priv); +} + +int side_tracer_callback_variadic_unregister(struct side_event_description *desc, + side_tracer_callback_variadic_func call_variadic, + void *priv) +{ + if (!(desc->flags & SIDE_EVENT_FLAG_VARIADIC)) + return SIDE_ERROR_INVAL; + return _side_tracer_callback_unregister(desc, (void *) call_variadic, priv); +} + +struct side_events_register_handle *side_events_register(struct side_event_description **events, uint32_t nr_events) +{ + struct side_events_register_handle *events_handle = NULL; + struct side_tracer_handle *tracer_handle; + + if (finalized) + return NULL; + if (!initialized) + side_init(); + events_handle = (struct side_events_register_handle *) + calloc(1, sizeof(struct side_events_register_handle)); + if (!events_handle) + return NULL; + events_handle->events = events; + events_handle->nr_events = nr_events; + + pthread_mutex_lock(&side_lock); + side_list_insert_node_tail(&side_events_list, &events_handle->node); + side_list_for_each_entry(tracer_handle, &side_tracer_list, node) { + tracer_handle->cb(SIDE_TRACER_NOTIFICATION_INSERT_EVENTS, + events, nr_events, tracer_handle->priv); + } + pthread_mutex_unlock(&side_lock); + //TODO: call event batch register ioctl + return events_handle; +} + +static +void side_event_remove_callbacks(struct side_event_description *desc) +{ + uint32_t nr_cb = desc->nr_callbacks; + struct side_callback *old_cb; + + if (!nr_cb) + return; + old_cb = (struct side_callback *) desc->callbacks; + (void) __atomic_add_fetch(desc->enabled, -1, __ATOMIC_RELAXED); + /* + * Setting the state back to 0 cb and empty callbacks out of + * caution. This should not matter because instrumentation is + * unreachable. + */ + desc->nr_callbacks = 0; + side_rcu_assign_pointer(desc->callbacks, &side_empty_callback); + /* + * No need to wait for grace period because instrumentation is + * unreachable. + */ + free(old_cb); +} + +/* + * Unregister event handle. At this point, all side events in that + * handle should be unreachable. + */ +void side_events_unregister(struct side_events_register_handle *events_handle) +{ + struct side_tracer_handle *tracer_handle; + uint32_t i; + + if (!events_handle) + return; + if (finalized) + return; + if (!initialized) + side_init(); + pthread_mutex_lock(&side_lock); + side_list_remove_node(&events_handle->node); + side_list_for_each_entry(tracer_handle, &side_tracer_list, node) { + tracer_handle->cb(SIDE_TRACER_NOTIFICATION_REMOVE_EVENTS, + events_handle->events, events_handle->nr_events, + tracer_handle->priv); + } + for (i = 0; i < events_handle->nr_events; i++) { + struct side_event_description *event = events_handle->events[i]; + + /* Skip NULL pointers */ + if (!event) + continue; + side_event_remove_callbacks(event); + } + pthread_mutex_unlock(&side_lock); + //TODO: call event batch unregister ioctl + free(events_handle); +} + +struct side_tracer_handle *side_tracer_event_notification_register( + void (*cb)(enum side_tracer_notification notif, + struct side_event_description **events, uint32_t nr_events, void *priv), + void *priv) +{ + struct side_tracer_handle *tracer_handle; + struct side_events_register_handle *events_handle; + + if (finalized) + return NULL; + if (!initialized) + side_init(); + tracer_handle = (struct side_tracer_handle *) + calloc(1, sizeof(struct side_tracer_handle)); + if (!tracer_handle) + return NULL; + pthread_mutex_lock(&side_lock); + tracer_handle->cb = cb; + tracer_handle->priv = priv; + side_list_insert_node_tail(&side_tracer_list, &tracer_handle->node); + side_list_for_each_entry(events_handle, &side_events_list, node) { + cb(SIDE_TRACER_NOTIFICATION_INSERT_EVENTS, + events_handle->events, events_handle->nr_events, priv); + } + pthread_mutex_unlock(&side_lock); + return tracer_handle; +} + +void side_tracer_event_notification_unregister(struct side_tracer_handle *tracer_handle) +{ + struct side_events_register_handle *events_handle; + + if (finalized) + return; + if (!initialized) + side_init(); + pthread_mutex_lock(&side_lock); + side_list_for_each_entry(events_handle, &side_events_list, node) { + tracer_handle->cb(SIDE_TRACER_NOTIFICATION_REMOVE_EVENTS, + events_handle->events, events_handle->nr_events, + tracer_handle->priv); + } + side_list_remove_node(&tracer_handle->node); + pthread_mutex_unlock(&side_lock); +} + +void side_init(void) +{ + if (initialized) + return; + side_rcu_gp_init(&rcu_gp); + initialized = true; +} + +/* + * side_exit() is executed from a library destructor. It can be called + * explicitly at application exit as well. Concurrent side API use is + * not expected at that point. + */ +void side_exit(void) +{ + struct side_events_register_handle *handle, *tmp; + + if (finalized) + return; + side_list_for_each_entry_safe(handle, tmp, &side_events_list, node) + side_events_unregister(handle); + side_rcu_gp_exit(&rcu_gp); + finalized = true; +} diff --git a/src/smp.c b/src/smp.c index 0816389..9788e93 100644 --- a/src/smp.c +++ b/src/smp.c @@ -17,13 +17,13 @@ #include #include #include -#include +#include #include "smp.h" #define __max(a,b) ((a)>(b)?(a):(b)) -#define TGIF_CPUMASK_SIZE 4096 +#define SIDE_CPUMASK_SIZE 4096 static int possible_cpus_array_len_cache; @@ -230,11 +230,11 @@ error: static void update_possible_cpus_array_len_cache(void) { - char buf[TGIF_CPUMASK_SIZE]; + char buf[SIDE_CPUMASK_SIZE]; int ret; /* Get the possible cpu mask from sysfs, fallback to sysconf. */ - ret = get_possible_cpu_mask_from_sysfs((char *) &buf, TGIF_CPUMASK_SIZE); + ret = get_possible_cpu_mask_from_sysfs((char *) &buf, SIDE_CPUMASK_SIZE); if (ret <= 0) goto fallback; @@ -271,7 +271,7 @@ end: */ int get_possible_cpus_array_len(void) { - if (tgif_unlikely(!possible_cpus_array_len_cache)) + if (side_unlikely(!possible_cpus_array_len_cache)) update_possible_cpus_array_len_cache(); return possible_cpus_array_len_cache; diff --git a/src/smp.h b/src/smp.h index d06ef07..36a0afc 100644 --- a/src/smp.h +++ b/src/smp.h @@ -4,9 +4,9 @@ * Copyright (C) 2019 Michael Jeanson */ -#ifndef _TGIF_SMP_H -#define _TGIF_SMP_H +#ifndef _SIDE_SMP_H +#define _SIDE_SMP_H int get_possible_cpus_array_len(void) __attribute__((visibility("hidden"))); -#endif /* _TGIF_SMP_H */ +#endif /* _SIDE_SMP_H */ diff --git a/src/tgif.c b/src/tgif.c deleted file mode 100644 index 7549269..0000000 --- a/src/tgif.c +++ /dev/null @@ -1,422 +0,0 @@ -// SPDX-License-Identifier: MIT -/* - * Copyright 2022 Mathieu Desnoyers - */ - -#include -#include - -#include "rcu.h" -#include "list.h" - -/* Top 8 bits reserved for kernel tracer use. */ -#if TGIF_BITS_PER_LONG == 64 -# define TGIF_EVENT_ENABLED_KERNEL_MASK 0xFF00000000000000ULL -# define TGIF_EVENT_ENABLED_KERNEL_USER_EVENT_MASK 0x8000000000000000ULL - -/* Allow 2^56 tracer references on an event. */ -# define TGIF_EVENT_ENABLED_USER_MASK 0x00FFFFFFFFFFFFFFULL -#else -# define TGIF_EVENT_ENABLED_KERNEL_MASK 0xFF000000UL -# define TGIF_EVENT_ENABLED_KERNEL_USER_EVENT_MASK 0x80000000UL - -/* Allow 2^24 tracer references on an event. */ -# define TGIF_EVENT_ENABLED_USER_MASK 0x00FFFFFFUL -#endif - -struct tgif_events_register_handle { - struct tgif_list_node node; - struct tgif_event_description **events; - uint32_t nr_events; -}; - -struct tgif_tracer_handle { - struct tgif_list_node node; - void (*cb)(enum tgif_tracer_notification notif, - struct tgif_event_description **events, uint32_t nr_events, void *priv); - void *priv; -}; - -static struct tgif_rcu_gp_state rcu_gp; - -/* - * Lazy initialization for early use within library constructors. - */ -static bool initialized; -/* - * Do not register/unregister any more events after destructor. - */ -static bool finalized; - -/* - * Recursive mutex to allow tracer callbacks to use the tgif API. - */ -static pthread_mutex_t tgif_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; - -static DEFINE_TGIF_LIST_HEAD(tgif_events_list); -static DEFINE_TGIF_LIST_HEAD(tgif_tracer_list); - -/* - * The empty callback has a NULL function callback pointer, which stops - * iteration on the array of callbacks immediately. - */ -const struct tgif_callback tgif_empty_callback = { }; - -void tgif_call(const struct tgif_event_description *desc, const struct tgif_arg_vec *tgif_arg_vec) -{ - struct tgif_rcu_read_state rcu_read_state; - const struct tgif_callback *tgif_cb; - uintptr_t enabled; - - if (tgif_unlikely(finalized)) - return; - if (tgif_unlikely(!initialized)) - tgif_init(); - if (tgif_unlikely(desc->flags & TGIF_EVENT_FLAG_VARIADIC)) { - printf("ERROR: unexpected variadic event description\n"); - abort(); - } - enabled = __atomic_load_n(desc->enabled, __ATOMIC_RELAXED); - if (tgif_unlikely(enabled & TGIF_EVENT_ENABLED_KERNEL_USER_EVENT_MASK)) { - // TODO: call kernel write. - } - tgif_rcu_read_begin(&rcu_gp, &rcu_read_state); - for (tgif_cb = tgif_rcu_dereference(desc->callbacks); tgif_cb->u.call != NULL; tgif_cb++) - tgif_cb->u.call(desc, tgif_arg_vec, tgif_cb->priv); - tgif_rcu_read_end(&rcu_gp, &rcu_read_state); -} - -void tgif_call_variadic(const struct tgif_event_description *desc, - const struct tgif_arg_vec *tgif_arg_vec, - const struct tgif_arg_dynamic_struct *var_struct) -{ - struct tgif_rcu_read_state rcu_read_state; - const struct tgif_callback *tgif_cb; - uintptr_t enabled; - - if (tgif_unlikely(finalized)) - return; - if (tgif_unlikely(!initialized)) - tgif_init(); - if (tgif_unlikely(!(desc->flags & TGIF_EVENT_FLAG_VARIADIC))) { - printf("ERROR: unexpected non-variadic event description\n"); - abort(); - } - enabled = __atomic_load_n(desc->enabled, __ATOMIC_RELAXED); - if (tgif_unlikely(enabled & TGIF_EVENT_ENABLED_KERNEL_USER_EVENT_MASK)) { - // TODO: call kernel write. - } - tgif_rcu_read_begin(&rcu_gp, &rcu_read_state); - for (tgif_cb = tgif_rcu_dereference(desc->callbacks); tgif_cb->u.call_variadic != NULL; tgif_cb++) - tgif_cb->u.call_variadic(desc, tgif_arg_vec, var_struct, tgif_cb->priv); - tgif_rcu_read_end(&rcu_gp, &rcu_read_state); -} - -static -const struct tgif_callback *tgif_tracer_callback_lookup( - const struct tgif_event_description *desc, - void *call, void *priv) -{ - const struct tgif_callback *cb; - - for (cb = desc->callbacks; cb->u.call != NULL; cb++) { - if ((void *) cb->u.call == call && cb->priv == priv) - return cb; - } - return NULL; -} - -static -int _tgif_tracer_callback_register(struct tgif_event_description *desc, - void *call, void *priv) -{ - struct tgif_callback *old_cb, *new_cb; - int ret = TGIF_ERROR_OK; - uint32_t old_nr_cb; - - if (!call) - return TGIF_ERROR_INVAL; - if (finalized) - return TGIF_ERROR_EXITING; - if (!initialized) - tgif_init(); - pthread_mutex_lock(&tgif_lock); - old_nr_cb = desc->nr_callbacks; - if (old_nr_cb == UINT32_MAX) { - ret = TGIF_ERROR_INVAL; - goto unlock; - } - /* Reject duplicate (call, priv) tuples. */ - if (tgif_tracer_callback_lookup(desc, call, priv)) { - ret = TGIF_ERROR_EXIST; - goto unlock; - } - old_cb = (struct tgif_callback *) desc->callbacks; - /* old_nr_cb + 1 (new cb) + 1 (NULL) */ - new_cb = (struct tgif_callback *) calloc(old_nr_cb + 2, sizeof(struct tgif_callback)); - if (!new_cb) { - ret = TGIF_ERROR_NOMEM; - goto unlock; - } - memcpy(new_cb, old_cb, old_nr_cb); - if (desc->flags & TGIF_EVENT_FLAG_VARIADIC) - new_cb[old_nr_cb].u.call_variadic = - (tgif_tracer_callback_variadic_func) call; - else - new_cb[old_nr_cb].u.call = - (tgif_tracer_callback_func) call; - new_cb[old_nr_cb].priv = priv; - tgif_rcu_assign_pointer(desc->callbacks, new_cb); - tgif_rcu_wait_grace_period(&rcu_gp); - if (old_nr_cb) - free(old_cb); - desc->nr_callbacks++; - /* Increment concurrently with kernel setting the top bits. */ - if (!old_nr_cb) - (void) __atomic_add_fetch(desc->enabled, 1, __ATOMIC_RELAXED); -unlock: - pthread_mutex_unlock(&tgif_lock); - return ret; -} - -int tgif_tracer_callback_register(struct tgif_event_description *desc, - tgif_tracer_callback_func call, - void *priv) -{ - if (desc->flags & TGIF_EVENT_FLAG_VARIADIC) - return TGIF_ERROR_INVAL; - return _tgif_tracer_callback_register(desc, (void *) call, priv); -} - -int tgif_tracer_callback_variadic_register(struct tgif_event_description *desc, - tgif_tracer_callback_variadic_func call_variadic, - void *priv) -{ - if (!(desc->flags & TGIF_EVENT_FLAG_VARIADIC)) - return TGIF_ERROR_INVAL; - return _tgif_tracer_callback_register(desc, (void *) call_variadic, priv); -} - -static int _tgif_tracer_callback_unregister(struct tgif_event_description *desc, - void *call, void *priv) -{ - struct tgif_callback *old_cb, *new_cb; - const struct tgif_callback *cb_pos; - uint32_t pos_idx; - int ret = TGIF_ERROR_OK; - uint32_t old_nr_cb; - - if (!call) - return TGIF_ERROR_INVAL; - if (finalized) - return TGIF_ERROR_EXITING; - if (!initialized) - tgif_init(); - pthread_mutex_lock(&tgif_lock); - cb_pos = tgif_tracer_callback_lookup(desc, call, priv); - if (!cb_pos) { - ret = TGIF_ERROR_NOENT; - goto unlock; - } - old_nr_cb = desc->nr_callbacks; - old_cb = (struct tgif_callback *) desc->callbacks; - if (old_nr_cb == 1) { - new_cb = (struct tgif_callback *) &tgif_empty_callback; - } else { - pos_idx = cb_pos - desc->callbacks; - /* Remove entry at pos_idx. */ - /* old_nr_cb - 1 (removed cb) + 1 (NULL) */ - new_cb = (struct tgif_callback *) calloc(old_nr_cb, sizeof(struct tgif_callback)); - if (!new_cb) { - ret = TGIF_ERROR_NOMEM; - goto unlock; - } - memcpy(new_cb, old_cb, pos_idx); - memcpy(&new_cb[pos_idx], &old_cb[pos_idx + 1], old_nr_cb - pos_idx - 1); - } - tgif_rcu_assign_pointer(desc->callbacks, new_cb); - tgif_rcu_wait_grace_period(&rcu_gp); - free(old_cb); - desc->nr_callbacks--; - /* Decrement concurrently with kernel setting the top bits. */ - if (old_nr_cb == 1) - (void) __atomic_add_fetch(desc->enabled, -1, __ATOMIC_RELAXED); -unlock: - pthread_mutex_unlock(&tgif_lock); - return ret; -} - -int tgif_tracer_callback_unregister(struct tgif_event_description *desc, - tgif_tracer_callback_func call, - void *priv) -{ - if (desc->flags & TGIF_EVENT_FLAG_VARIADIC) - return TGIF_ERROR_INVAL; - return _tgif_tracer_callback_unregister(desc, (void *) call, priv); -} - -int tgif_tracer_callback_variadic_unregister(struct tgif_event_description *desc, - tgif_tracer_callback_variadic_func call_variadic, - void *priv) -{ - if (!(desc->flags & TGIF_EVENT_FLAG_VARIADIC)) - return TGIF_ERROR_INVAL; - return _tgif_tracer_callback_unregister(desc, (void *) call_variadic, priv); -} - -struct tgif_events_register_handle *tgif_events_register(struct tgif_event_description **events, uint32_t nr_events) -{ - struct tgif_events_register_handle *events_handle = NULL; - struct tgif_tracer_handle *tracer_handle; - - if (finalized) - return NULL; - if (!initialized) - tgif_init(); - events_handle = (struct tgif_events_register_handle *) - calloc(1, sizeof(struct tgif_events_register_handle)); - if (!events_handle) - return NULL; - events_handle->events = events; - events_handle->nr_events = nr_events; - - pthread_mutex_lock(&tgif_lock); - tgif_list_insert_node_tail(&tgif_events_list, &events_handle->node); - tgif_list_for_each_entry(tracer_handle, &tgif_tracer_list, node) { - tracer_handle->cb(TGIF_TRACER_NOTIFICATION_INSERT_EVENTS, - events, nr_events, tracer_handle->priv); - } - pthread_mutex_unlock(&tgif_lock); - //TODO: call event batch register ioctl - return events_handle; -} - -static -void tgif_event_remove_callbacks(struct tgif_event_description *desc) -{ - uint32_t nr_cb = desc->nr_callbacks; - struct tgif_callback *old_cb; - - if (!nr_cb) - return; - old_cb = (struct tgif_callback *) desc->callbacks; - (void) __atomic_add_fetch(desc->enabled, -1, __ATOMIC_RELAXED); - /* - * Setting the state back to 0 cb and empty callbacks out of - * caution. This should not matter because instrumentation is - * unreachable. - */ - desc->nr_callbacks = 0; - tgif_rcu_assign_pointer(desc->callbacks, &tgif_empty_callback); - /* - * No need to wait for grace period because instrumentation is - * unreachable. - */ - free(old_cb); -} - -/* - * Unregister event handle. At this point, all tgif events in that - * handle should be unreachable. - */ -void tgif_events_unregister(struct tgif_events_register_handle *events_handle) -{ - struct tgif_tracer_handle *tracer_handle; - uint32_t i; - - if (!events_handle) - return; - if (finalized) - return; - if (!initialized) - tgif_init(); - pthread_mutex_lock(&tgif_lock); - tgif_list_remove_node(&events_handle->node); - tgif_list_for_each_entry(tracer_handle, &tgif_tracer_list, node) { - tracer_handle->cb(TGIF_TRACER_NOTIFICATION_REMOVE_EVENTS, - events_handle->events, events_handle->nr_events, - tracer_handle->priv); - } - for (i = 0; i < events_handle->nr_events; i++) { - struct tgif_event_description *event = events_handle->events[i]; - - /* Skip NULL pointers */ - if (!event) - continue; - tgif_event_remove_callbacks(event); - } - pthread_mutex_unlock(&tgif_lock); - //TODO: call event batch unregister ioctl - free(events_handle); -} - -struct tgif_tracer_handle *tgif_tracer_event_notification_register( - void (*cb)(enum tgif_tracer_notification notif, - struct tgif_event_description **events, uint32_t nr_events, void *priv), - void *priv) -{ - struct tgif_tracer_handle *tracer_handle; - struct tgif_events_register_handle *events_handle; - - if (finalized) - return NULL; - if (!initialized) - tgif_init(); - tracer_handle = (struct tgif_tracer_handle *) - calloc(1, sizeof(struct tgif_tracer_handle)); - if (!tracer_handle) - return NULL; - pthread_mutex_lock(&tgif_lock); - tracer_handle->cb = cb; - tracer_handle->priv = priv; - tgif_list_insert_node_tail(&tgif_tracer_list, &tracer_handle->node); - tgif_list_for_each_entry(events_handle, &tgif_events_list, node) { - cb(TGIF_TRACER_NOTIFICATION_INSERT_EVENTS, - events_handle->events, events_handle->nr_events, priv); - } - pthread_mutex_unlock(&tgif_lock); - return tracer_handle; -} - -void tgif_tracer_event_notification_unregister(struct tgif_tracer_handle *tracer_handle) -{ - struct tgif_events_register_handle *events_handle; - - if (finalized) - return; - if (!initialized) - tgif_init(); - pthread_mutex_lock(&tgif_lock); - tgif_list_for_each_entry(events_handle, &tgif_events_list, node) { - tracer_handle->cb(TGIF_TRACER_NOTIFICATION_REMOVE_EVENTS, - events_handle->events, events_handle->nr_events, - tracer_handle->priv); - } - tgif_list_remove_node(&tracer_handle->node); - pthread_mutex_unlock(&tgif_lock); -} - -void tgif_init(void) -{ - if (initialized) - return; - tgif_rcu_gp_init(&rcu_gp); - initialized = true; -} - -/* - * tgif_exit() is executed from a library destructor. It can be called - * explicitly at application exit as well. Concurrent tgif API use is - * not expected at that point. - */ -void tgif_exit(void) -{ - struct tgif_events_register_handle *handle, *tmp; - - if (finalized) - return; - tgif_list_for_each_entry_safe(handle, tmp, &tgif_events_list, node) - tgif_events_unregister(handle); - tgif_rcu_gp_exit(&rcu_gp); - finalized = true; -} diff --git a/src/tracer.c b/src/tracer.c index f86d4c8..8dd9388 100644 --- a/src/tracer.c +++ b/src/tracer.c @@ -11,7 +11,7 @@ #include #include -#include +#include enum tracer_display_base { TRACER_DISPLAY_BASE_2, @@ -25,43 +25,43 @@ union int64_value { int64_t s; }; -static struct tgif_tracer_handle *tracer_handle; +static struct side_tracer_handle *tracer_handle; static -void tracer_print_struct(const struct tgif_type *type_desc, const struct tgif_arg_vec *tgif_arg_vec); +void tracer_print_struct(const struct side_type *type_desc, const struct side_arg_vec *side_arg_vec); static -void tracer_print_array(const struct tgif_type *type_desc, const struct tgif_arg_vec *tgif_arg_vec); +void tracer_print_array(const struct side_type *type_desc, const struct side_arg_vec *side_arg_vec); static -void tracer_print_vla(const struct tgif_type *type_desc, const struct tgif_arg_vec *tgif_arg_vec); +void tracer_print_vla(const struct side_type *type_desc, const struct side_arg_vec *side_arg_vec); static -void tracer_print_vla_visitor(const struct tgif_type *type_desc, void *app_ctx); +void tracer_print_vla_visitor(const struct side_type *type_desc, void *app_ctx); static -void tracer_print_dynamic(const struct tgif_arg *dynamic_item); +void tracer_print_dynamic(const struct side_arg *dynamic_item); static -uint32_t tracer_print_gather_bool_type(const struct tgif_type_gather *type_gather, const void *_ptr); +uint32_t tracer_print_gather_bool_type(const struct side_type_gather *type_gather, const void *_ptr); static -uint32_t tracer_print_gather_byte_type(const struct tgif_type_gather *type_gather, const void *_ptr); +uint32_t tracer_print_gather_byte_type(const struct side_type_gather *type_gather, const void *_ptr); static -uint32_t tracer_print_gather_integer_type(const struct tgif_type_gather *type_gather, const void *_ptr, +uint32_t tracer_print_gather_integer_type(const struct side_type_gather *type_gather, const void *_ptr, enum tracer_display_base default_base); static -uint32_t tracer_print_gather_float_type(const struct tgif_type_gather *type_gather, const void *_ptr); +uint32_t tracer_print_gather_float_type(const struct side_type_gather *type_gather, const void *_ptr); static -uint32_t tracer_print_gather_string_type(const struct tgif_type_gather *type_gather, const void *_ptr); +uint32_t tracer_print_gather_string_type(const struct side_type_gather *type_gather, const void *_ptr); static -uint32_t tracer_print_gather_enum_type(const struct tgif_type_gather *type_gather, const void *_ptr); +uint32_t tracer_print_gather_enum_type(const struct side_type_gather *type_gather, const void *_ptr); static -uint32_t tracer_print_gather_struct(const struct tgif_type_gather *type_gather, const void *_ptr); +uint32_t tracer_print_gather_struct(const struct side_type_gather *type_gather, const void *_ptr); static -uint32_t tracer_print_gather_array(const struct tgif_type_gather *type_gather, const void *_ptr); +uint32_t tracer_print_gather_array(const struct side_type_gather *type_gather, const void *_ptr); static -uint32_t tracer_print_gather_vla(const struct tgif_type_gather *type_gather, const void *_ptr, +uint32_t tracer_print_gather_vla(const struct side_type_gather *type_gather, const void *_ptr, const void *_length_ptr); static -void tracer_print_type(const struct tgif_type *type_desc, const struct tgif_arg *item); +void tracer_print_type(const struct side_type *type_desc, const struct side_arg *item); static -void tracer_convert_string_to_utf8(const void *p, uint8_t unit_size, enum tgif_type_label_byte_order byte_order, +void tracer_convert_string_to_utf8(const void *p, uint8_t unit_size, enum side_type_label_byte_order byte_order, size_t *strlen_with_null, char **output_str) { @@ -81,12 +81,12 @@ void tracer_convert_string_to_utf8(const void *p, uint8_t unit_size, enum tgif_t const uint16_t *p16 = p; switch (byte_order) { - case TGIF_TYPE_BYTE_ORDER_LE: + case SIDE_TYPE_BYTE_ORDER_LE: { fromcode = "UTF-16LE"; break; } - case TGIF_TYPE_BYTE_ORDER_BE: + case SIDE_TYPE_BYTE_ORDER_BE: { fromcode = "UTF-16BE"; break; @@ -109,12 +109,12 @@ void tracer_convert_string_to_utf8(const void *p, uint8_t unit_size, enum tgif_t const uint32_t *p32 = p; switch (byte_order) { - case TGIF_TYPE_BYTE_ORDER_LE: + case SIDE_TYPE_BYTE_ORDER_LE: { fromcode = "UTF-32LE"; break; } - case TGIF_TYPE_BYTE_ORDER_BE: + case SIDE_TYPE_BYTE_ORDER_BE: { fromcode = "UTF-32BE"; break; @@ -168,7 +168,7 @@ void tracer_convert_string_to_utf8(const void *p, uint8_t unit_size, enum tgif_t } static -void tracer_print_string(const void *p, uint8_t unit_size, enum tgif_type_label_byte_order byte_order, +void tracer_print_string(const void *p, uint8_t unit_size, enum side_type_label_byte_order byte_order, size_t *strlen_with_null) { char *output_str = NULL; @@ -180,34 +180,34 @@ void tracer_print_string(const void *p, uint8_t unit_size, enum tgif_type_label_ } static -int64_t get_attr_integer_value(const struct tgif_attr *attr) +int64_t get_attr_integer_value(const struct side_attr *attr) { int64_t val; switch (attr->value.type) { - case TGIF_ATTR_TYPE_U8: - val = attr->value.u.integer_value.tgif_u8; + case SIDE_ATTR_TYPE_U8: + val = attr->value.u.integer_value.side_u8; break; - case TGIF_ATTR_TYPE_U16: - val = attr->value.u.integer_value.tgif_u16; + case SIDE_ATTR_TYPE_U16: + val = attr->value.u.integer_value.side_u16; break; - case TGIF_ATTR_TYPE_U32: - val = attr->value.u.integer_value.tgif_u32; + case SIDE_ATTR_TYPE_U32: + val = attr->value.u.integer_value.side_u32; break; - case TGIF_ATTR_TYPE_U64: - val = attr->value.u.integer_value.tgif_u64; + case SIDE_ATTR_TYPE_U64: + val = attr->value.u.integer_value.side_u64; break; - case TGIF_ATTR_TYPE_S8: - val = attr->value.u.integer_value.tgif_s8; + case SIDE_ATTR_TYPE_S8: + val = attr->value.u.integer_value.side_s8; break; - case TGIF_ATTR_TYPE_S16: - val = attr->value.u.integer_value.tgif_s16; + case SIDE_ATTR_TYPE_S16: + val = attr->value.u.integer_value.side_s16; break; - case TGIF_ATTR_TYPE_S32: - val = attr->value.u.integer_value.tgif_s32; + case SIDE_ATTR_TYPE_S32: + val = attr->value.u.integer_value.side_s32; break; - case TGIF_ATTR_TYPE_S64: - val = attr->value.u.integer_value.tgif_s64; + case SIDE_ATTR_TYPE_S64: + val = attr->value.u.integer_value.side_s64; break; default: fprintf(stderr, "Unexpected attribute type\n"); @@ -217,13 +217,13 @@ int64_t get_attr_integer_value(const struct tgif_attr *attr) } static -enum tracer_display_base get_attr_display_base(const struct tgif_attr *_attr, uint32_t nr_attr, +enum tracer_display_base get_attr_display_base(const struct side_attr *_attr, uint32_t nr_attr, enum tracer_display_base default_base) { uint32_t i; for (i = 0; i < nr_attr; i++) { - const struct tgif_attr *attr = &_attr[i]; + const struct side_attr *attr = &_attr[i]; char *utf8_str = NULL; bool cmp; @@ -254,7 +254,7 @@ enum tracer_display_base get_attr_display_base(const struct tgif_attr *_attr, ui } static -void tracer_print_attr_type(const char *separator, const struct tgif_attr *attr) +void tracer_print_attr_type(const char *separator, const struct side_attr *attr) { char *utf8_str = NULL; @@ -264,66 +264,66 @@ void tracer_print_attr_type(const char *separator, const struct tgif_attr *attr) if (utf8_str != attr->key.p) free(utf8_str); switch (attr->value.type) { - case TGIF_ATTR_TYPE_BOOL: + case SIDE_ATTR_TYPE_BOOL: printf("%s", attr->value.u.bool_value ? "true" : "false"); break; - case TGIF_ATTR_TYPE_U8: - printf("%" PRIu8, attr->value.u.integer_value.tgif_u8); + case SIDE_ATTR_TYPE_U8: + printf("%" PRIu8, attr->value.u.integer_value.side_u8); break; - case TGIF_ATTR_TYPE_U16: - printf("%" PRIu16, attr->value.u.integer_value.tgif_u16); + case SIDE_ATTR_TYPE_U16: + printf("%" PRIu16, attr->value.u.integer_value.side_u16); break; - case TGIF_ATTR_TYPE_U32: - printf("%" PRIu32, attr->value.u.integer_value.tgif_u32); + case SIDE_ATTR_TYPE_U32: + printf("%" PRIu32, attr->value.u.integer_value.side_u32); break; - case TGIF_ATTR_TYPE_U64: - printf("%" PRIu64, attr->value.u.integer_value.tgif_u64); + case SIDE_ATTR_TYPE_U64: + printf("%" PRIu64, attr->value.u.integer_value.side_u64); break; - case TGIF_ATTR_TYPE_S8: - printf("%" PRId8, attr->value.u.integer_value.tgif_s8); + case SIDE_ATTR_TYPE_S8: + printf("%" PRId8, attr->value.u.integer_value.side_s8); break; - case TGIF_ATTR_TYPE_S16: - printf("%" PRId16, attr->value.u.integer_value.tgif_s16); + case SIDE_ATTR_TYPE_S16: + printf("%" PRId16, attr->value.u.integer_value.side_s16); break; - case TGIF_ATTR_TYPE_S32: - printf("%" PRId32, attr->value.u.integer_value.tgif_s32); + case SIDE_ATTR_TYPE_S32: + printf("%" PRId32, attr->value.u.integer_value.side_s32); break; - case TGIF_ATTR_TYPE_S64: - printf("%" PRId64, attr->value.u.integer_value.tgif_s64); + case SIDE_ATTR_TYPE_S64: + printf("%" PRId64, attr->value.u.integer_value.side_s64); break; - case TGIF_ATTR_TYPE_FLOAT_BINARY16: + case SIDE_ATTR_TYPE_FLOAT_BINARY16: #if __HAVE_FLOAT16 - printf("%g", (double) attr->value.u.float_value.tgif_float_binary16); + printf("%g", (double) attr->value.u.float_value.side_float_binary16); break; #else fprintf(stderr, "ERROR: Unsupported binary16 float type\n"); abort(); #endif - case TGIF_ATTR_TYPE_FLOAT_BINARY32: + case SIDE_ATTR_TYPE_FLOAT_BINARY32: #if __HAVE_FLOAT32 - printf("%g", (double) attr->value.u.float_value.tgif_float_binary32); + printf("%g", (double) attr->value.u.float_value.side_float_binary32); break; #else fprintf(stderr, "ERROR: Unsupported binary32 float type\n"); abort(); #endif - case TGIF_ATTR_TYPE_FLOAT_BINARY64: + case SIDE_ATTR_TYPE_FLOAT_BINARY64: #if __HAVE_FLOAT64 - printf("%g", (double) attr->value.u.float_value.tgif_float_binary64); + printf("%g", (double) attr->value.u.float_value.side_float_binary64); break; #else fprintf(stderr, "ERROR: Unsupported binary64 float type\n"); abort(); #endif - case TGIF_ATTR_TYPE_FLOAT_BINARY128: + case SIDE_ATTR_TYPE_FLOAT_BINARY128: #if __HAVE_FLOAT128 - printf("%Lg", (long double) attr->value.u.float_value.tgif_float_binary128); + printf("%Lg", (long double) attr->value.u.float_value.side_float_binary128); break; #else fprintf(stderr, "ERROR: Unsupported binary128 float type\n"); abort(); #endif - case TGIF_ATTR_TYPE_STRING: + case SIDE_ATTR_TYPE_STRING: tracer_print_string(attr->value.u.string_value.p, attr->value.u.string_value.unit_size, attr->value.u.string_value.byte_order, NULL); @@ -337,7 +337,7 @@ void tracer_print_attr_type(const char *separator, const struct tgif_attr *attr) static void print_attributes(const char *prefix_str, const char *separator, - const struct tgif_attr *attr, uint32_t nr_attr) + const struct side_attr *attr, uint32_t nr_attr) { uint32_t i; @@ -352,8 +352,8 @@ void print_attributes(const char *prefix_str, const char *separator, } static -union int64_value tracer_load_integer_value(const struct tgif_type_integer *type_integer, - const union tgif_integer_value *value, +union int64_value tracer_load_integer_value(const struct side_type_integer *type_integer, + const union side_integer_value *value, uint16_t offset_bits, uint16_t *_len_bits) { union int64_value v64; @@ -366,63 +366,63 @@ union int64_value tracer_load_integer_value(const struct tgif_type_integer *type len_bits = type_integer->len_bits; if (len_bits + offset_bits > type_integer->integer_size * CHAR_BIT) abort(); - reverse_bo = type_integer->byte_order != TGIF_TYPE_BYTE_ORDER_HOST; + reverse_bo = type_integer->byte_order != SIDE_TYPE_BYTE_ORDER_HOST; switch (type_integer->integer_size) { case 1: if (type_integer->signedness) - v64.s = value->tgif_s8; + v64.s = value->side_s8; else - v64.u = value->tgif_u8; + v64.u = value->side_u8; break; case 2: if (type_integer->signedness) { - int16_t tgif_s16; + int16_t side_s16; - tgif_s16 = value->tgif_s16; + side_s16 = value->side_s16; if (reverse_bo) - tgif_s16 = tgif_bswap_16(tgif_s16); - v64.s = tgif_s16; + side_s16 = side_bswap_16(side_s16); + v64.s = side_s16; } else { - uint16_t tgif_u16; + uint16_t side_u16; - tgif_u16 = value->tgif_u16; + side_u16 = value->side_u16; if (reverse_bo) - tgif_u16 = tgif_bswap_16(tgif_u16); - v64.u = tgif_u16; + side_u16 = side_bswap_16(side_u16); + v64.u = side_u16; } break; case 4: if (type_integer->signedness) { - int32_t tgif_s32; + int32_t side_s32; - tgif_s32 = value->tgif_s32; + side_s32 = value->side_s32; if (reverse_bo) - tgif_s32 = tgif_bswap_32(tgif_s32); - v64.s = tgif_s32; + side_s32 = side_bswap_32(side_s32); + v64.s = side_s32; } else { - uint32_t tgif_u32; + uint32_t side_u32; - tgif_u32 = value->tgif_u32; + side_u32 = value->side_u32; if (reverse_bo) - tgif_u32 = tgif_bswap_32(tgif_u32); - v64.u = tgif_u32; + side_u32 = side_bswap_32(side_u32); + v64.u = side_u32; } break; case 8: if (type_integer->signedness) { - int64_t tgif_s64; + int64_t side_s64; - tgif_s64 = value->tgif_s64; + side_s64 = value->side_s64; if (reverse_bo) - tgif_s64 = tgif_bswap_64(tgif_s64); - v64.s = tgif_s64; + side_s64 = side_bswap_64(side_s64); + v64.s = side_s64; } else { - uint64_t tgif_u64; + uint64_t side_u64; - tgif_u64 = value->tgif_u64; + side_u64 = value->side_u64; if (reverse_bo) - tgif_u64 = tgif_bswap_64(tgif_u64); - v64.u = tgif_u64; + side_u64 = side_bswap_64(side_u64); + v64.u = side_u64; } break; default: @@ -443,13 +443,13 @@ union int64_value tracer_load_integer_value(const struct tgif_type_integer *type } static -void print_enum_labels(const struct tgif_enum_mappings *mappings, union int64_value v64) +void print_enum_labels(const struct side_enum_mappings *mappings, union int64_value v64) { uint32_t i, print_count = 0; printf(", labels: [ "); for (i = 0; i < mappings->nr_mappings; i++) { - const struct tgif_enum_mapping *mapping = &mappings->mappings[i]; + const struct side_enum_mapping *mapping = &mappings->mappings[i]; if (mapping->range_end < mapping->range_begin) { fprintf(stderr, "ERROR: Unexpected enum range: %" PRIu64 "-%" PRIu64 "\n", @@ -467,18 +467,18 @@ void print_enum_labels(const struct tgif_enum_mappings *mappings, union int64_va } static -void tracer_print_enum(const struct tgif_type *type_desc, const struct tgif_arg *item) +void tracer_print_enum(const struct side_type *type_desc, const struct side_arg *item) { - const struct tgif_enum_mappings *mappings = type_desc->u.tgif_enum.mappings; - const struct tgif_type *elem_type = type_desc->u.tgif_enum.elem_type; + const struct side_enum_mappings *mappings = type_desc->u.side_enum.mappings; + const struct side_type *elem_type = type_desc->u.side_enum.elem_type; union int64_value v64; if (elem_type->type != item->type) { fprintf(stderr, "ERROR: Unexpected enum element type\n"); abort(); } - v64 = tracer_load_integer_value(&elem_type->u.tgif_integer, - &item->u.tgif_static.integer_value, 0, NULL); + v64 = tracer_load_integer_value(&elem_type->u.side_integer, + &item->u.side_static.integer_value, 0, NULL); print_attributes("attr", ":", mappings->attr, mappings->nr_attr); printf("%s", mappings->nr_attr ? ", " : ""); tracer_print_type(elem_type, item); @@ -486,24 +486,24 @@ void tracer_print_enum(const struct tgif_type *type_desc, const struct tgif_arg } static -uint32_t elem_type_to_stride(const struct tgif_type *elem_type) +uint32_t elem_type_to_stride(const struct side_type *elem_type) { uint32_t stride_bit; switch (elem_type->type) { - case TGIF_TYPE_BYTE: + case SIDE_TYPE_BYTE: stride_bit = 8; break; - case TGIF_TYPE_U8: - case TGIF_TYPE_U16: - case TGIF_TYPE_U32: - case TGIF_TYPE_U64: - case TGIF_TYPE_S8: - case TGIF_TYPE_S16: - case TGIF_TYPE_S32: - case TGIF_TYPE_S64: - return elem_type->u.tgif_integer.integer_size * CHAR_BIT; + case SIDE_TYPE_U8: + case SIDE_TYPE_U16: + case SIDE_TYPE_U32: + case SIDE_TYPE_U64: + case SIDE_TYPE_S8: + case SIDE_TYPE_S16: + case SIDE_TYPE_S32: + case SIDE_TYPE_S64: + return elem_type->u.side_integer.integer_size * CHAR_BIT; default: fprintf(stderr, "ERROR: Unexpected enum bitmap element type\n"); abort(); @@ -512,37 +512,37 @@ uint32_t elem_type_to_stride(const struct tgif_type *elem_type) } static -void tracer_print_enum_bitmap(const struct tgif_type *type_desc, - const struct tgif_arg *item) +void tracer_print_enum_bitmap(const struct side_type *type_desc, + const struct side_arg *item) { - const struct tgif_enum_bitmap_mappings *tgif_enum_mappings = type_desc->u.tgif_enum_bitmap.mappings; - const struct tgif_type *enum_elem_type = type_desc->u.tgif_enum_bitmap.elem_type, *elem_type; + const struct side_enum_bitmap_mappings *side_enum_mappings = type_desc->u.side_enum_bitmap.mappings; + const struct side_type *enum_elem_type = type_desc->u.side_enum_bitmap.elem_type, *elem_type; uint32_t i, print_count = 0, stride_bit, nr_items; - const struct tgif_arg *array_item; + const struct side_arg *array_item; switch (enum_elem_type->type) { - case TGIF_TYPE_U8: /* Fall-through */ - case TGIF_TYPE_BYTE: /* Fall-through */ - case TGIF_TYPE_U16: /* Fall-through */ - case TGIF_TYPE_U32: /* Fall-through */ - case TGIF_TYPE_U64: /* Fall-through */ - case TGIF_TYPE_S8: /* Fall-through */ - case TGIF_TYPE_S16: /* Fall-through */ - case TGIF_TYPE_S32: /* Fall-through */ - case TGIF_TYPE_S64: + case SIDE_TYPE_U8: /* Fall-through */ + case SIDE_TYPE_BYTE: /* Fall-through */ + case SIDE_TYPE_U16: /* Fall-through */ + case SIDE_TYPE_U32: /* Fall-through */ + case SIDE_TYPE_U64: /* Fall-through */ + case SIDE_TYPE_S8: /* Fall-through */ + case SIDE_TYPE_S16: /* Fall-through */ + case SIDE_TYPE_S32: /* Fall-through */ + case SIDE_TYPE_S64: elem_type = enum_elem_type; array_item = item; nr_items = 1; break; - case TGIF_TYPE_ARRAY: - elem_type = enum_elem_type->u.tgif_array.elem_type; - array_item = item->u.tgif_static.tgif_array->sav; - nr_items = type_desc->u.tgif_array.length; + case SIDE_TYPE_ARRAY: + elem_type = enum_elem_type->u.side_array.elem_type; + array_item = item->u.side_static.side_array->sav; + nr_items = type_desc->u.side_array.length; break; - case TGIF_TYPE_VLA: - elem_type = enum_elem_type->u.tgif_vla.elem_type; - array_item = item->u.tgif_static.tgif_vla->sav; - nr_items = item->u.tgif_static.tgif_vla->len; + case SIDE_TYPE_VLA: + elem_type = enum_elem_type->u.side_vla.elem_type; + array_item = item->u.side_static.side_vla->sav; + nr_items = item->u.side_static.side_vla->len; break; default: fprintf(stderr, "ERROR: Unexpected enum element type\n"); @@ -550,11 +550,11 @@ void tracer_print_enum_bitmap(const struct tgif_type *type_desc, } stride_bit = elem_type_to_stride(elem_type); - print_attributes("attr", ":", tgif_enum_mappings->attr, tgif_enum_mappings->nr_attr); - printf("%s", tgif_enum_mappings->nr_attr ? ", " : ""); + print_attributes("attr", ":", side_enum_mappings->attr, side_enum_mappings->nr_attr); + printf("%s", side_enum_mappings->nr_attr ? ", " : ""); printf("labels: [ "); - for (i = 0; i < tgif_enum_mappings->nr_mappings; i++) { - const struct tgif_enum_bitmap_mapping *mapping = &tgif_enum_mappings->mappings[i]; + for (i = 0; i < side_enum_mappings->nr_mappings; i++) { + const struct side_enum_bitmap_mapping *mapping = &side_enum_mappings->mappings[i]; bool match = false; uint64_t bit; @@ -566,8 +566,8 @@ void tracer_print_enum_bitmap(const struct tgif_type *type_desc, for (bit = mapping->range_begin; bit <= mapping->range_end; bit++) { if (bit > (nr_items * stride_bit) - 1) break; - if (elem_type->type == TGIF_TYPE_BYTE) { - uint8_t v = array_item[bit / 8].u.tgif_static.byte_value; + if (elem_type->type == SIDE_TYPE_BYTE) { + uint8_t v = array_item[bit / 8].u.side_static.byte_value; if (v & (1ULL << (bit % 8))) { match = true; goto match; @@ -575,8 +575,8 @@ void tracer_print_enum_bitmap(const struct tgif_type *type_desc, } else { union int64_value v64; - v64 = tracer_load_integer_value(&elem_type->u.tgif_integer, - &array_item[bit / stride_bit].u.tgif_static.integer_value, + v64 = tracer_load_integer_value(&elem_type->u.side_integer, + &array_item[bit / stride_bit].u.side_static.integer_value, 0, NULL); if (v64.u & (1ULL << (bit % stride_bit))) { match = true; @@ -610,7 +610,7 @@ void print_integer_binary(uint64_t v, int bits) static void tracer_print_type_header(const char *separator, - const struct tgif_attr *attr, uint32_t nr_attr) + const struct side_attr *attr, uint32_t nr_attr) { print_attributes("attr", separator, attr, nr_attr); printf("%s", nr_attr ? ", " : ""); @@ -619,8 +619,8 @@ void tracer_print_type_header(const char *separator, static void tracer_print_type_bool(const char *separator, - const struct tgif_type_bool *type_bool, - const union tgif_bool_value *value, + const struct side_type_bool *type_bool, + const union side_bool_value *value, uint16_t offset_bits) { uint32_t len_bits; @@ -633,39 +633,39 @@ void tracer_print_type_bool(const char *separator, len_bits = type_bool->len_bits; if (len_bits + offset_bits > type_bool->bool_size * CHAR_BIT) abort(); - reverse_bo = type_bool->byte_order != TGIF_TYPE_BYTE_ORDER_HOST; + reverse_bo = type_bool->byte_order != SIDE_TYPE_BYTE_ORDER_HOST; switch (type_bool->bool_size) { case 1: - v = value->tgif_bool8; + v = value->side_bool8; break; case 2: { - uint16_t tgif_u16; + uint16_t side_u16; - tgif_u16 = value->tgif_bool16; + side_u16 = value->side_bool16; if (reverse_bo) - tgif_u16 = tgif_bswap_16(tgif_u16); - v = tgif_u16; + side_u16 = side_bswap_16(side_u16); + v = side_u16; break; } case 4: { - uint32_t tgif_u32; + uint32_t side_u32; - tgif_u32 = value->tgif_bool32; + side_u32 = value->side_bool32; if (reverse_bo) - tgif_u32 = tgif_bswap_32(tgif_u32); - v = tgif_u32; + side_u32 = side_bswap_32(side_u32); + v = side_u32; break; } case 8: { - uint64_t tgif_u64; + uint64_t side_u64; - tgif_u64 = value->tgif_bool64; + side_u64 = value->side_bool64; if (reverse_bo) - tgif_u64 = tgif_bswap_64(tgif_u64); - v = tgif_u64; + side_u64 = side_bswap_64(side_u64); + v = side_u64; break; } default: @@ -680,8 +680,8 @@ void tracer_print_type_bool(const char *separator, static void tracer_print_type_integer(const char *separator, - const struct tgif_type_integer *type_integer, - const union tgif_integer_value *value, + const struct side_type_integer *type_integer, + const union side_integer_value *value, uint16_t offset_bits, enum tracer_display_base default_base) { @@ -721,13 +721,13 @@ void tracer_print_type_integer(const char *separator, static void tracer_print_type_float(const char *separator, - const struct tgif_type_float *type_float, - const union tgif_float_value *value) + const struct side_type_float *type_float, + const union side_float_value *value) { bool reverse_bo; tracer_print_type_header(separator, type_float->attr, type_float->nr_attr); - reverse_bo = type_float->byte_order != TGIF_TYPE_FLOAT_WORD_ORDER_HOST; + reverse_bo = type_float->byte_order != SIDE_TYPE_FLOAT_WORD_ORDER_HOST; switch (type_float->float_size) { case 2: { @@ -736,11 +736,11 @@ void tracer_print_type_float(const char *separator, _Float16 f; uint16_t u; } float16 = { - .f = value->tgif_float_binary16, + .f = value->side_float_binary16, }; if (reverse_bo) - float16.u = tgif_bswap_16(float16.u); + float16.u = side_bswap_16(float16.u); printf("%g", (double) float16.f); break; #else @@ -755,11 +755,11 @@ void tracer_print_type_float(const char *separator, _Float32 f; uint32_t u; } float32 = { - .f = value->tgif_float_binary32, + .f = value->side_float_binary32, }; if (reverse_bo) - float32.u = tgif_bswap_32(float32.u); + float32.u = side_bswap_32(float32.u); printf("%g", (double) float32.f); break; #else @@ -774,11 +774,11 @@ void tracer_print_type_float(const char *separator, _Float64 f; uint64_t u; } float64 = { - .f = value->tgif_float_binary64, + .f = value->side_float_binary64, }; if (reverse_bo) - float64.u = tgif_bswap_64(float64.u); + float64.u = side_bswap_64(float64.u); printf("%g", (double) float64.f); break; #else @@ -793,11 +793,11 @@ void tracer_print_type_float(const char *separator, _Float128 f; char arr[16]; } float128 = { - .f = value->tgif_float_binary128, + .f = value->side_float_binary128, }; if (reverse_bo) - tgif_bswap_128p(float128.arr); + side_bswap_128p(float128.arr); printf("%Lg", (long double) float128.f); break; #else @@ -812,21 +812,21 @@ void tracer_print_type_float(const char *separator, } static -void tracer_print_type(const struct tgif_type *type_desc, const struct tgif_arg *item) +void tracer_print_type(const struct side_type *type_desc, const struct side_arg *item) { - enum tgif_type_label type; + enum side_type_label type; switch (type_desc->type) { - case TGIF_TYPE_ENUM: + case SIDE_TYPE_ENUM: switch (item->type) { - case TGIF_TYPE_U8: - case TGIF_TYPE_U16: - case TGIF_TYPE_U32: - case TGIF_TYPE_U64: - case TGIF_TYPE_S8: - case TGIF_TYPE_S16: - case TGIF_TYPE_S32: - case TGIF_TYPE_S64: + case SIDE_TYPE_U8: + case SIDE_TYPE_U16: + case SIDE_TYPE_U32: + case SIDE_TYPE_U64: + case SIDE_TYPE_S8: + case SIDE_TYPE_S16: + case SIDE_TYPE_S32: + case SIDE_TYPE_S64: break; default: fprintf(stderr, "ERROR: type mismatch between description and arguments\n"); @@ -835,15 +835,15 @@ void tracer_print_type(const struct tgif_type *type_desc, const struct tgif_arg } break; - case TGIF_TYPE_ENUM_BITMAP: + case SIDE_TYPE_ENUM_BITMAP: switch (item->type) { - case TGIF_TYPE_U8: - case TGIF_TYPE_BYTE: - case TGIF_TYPE_U16: - case TGIF_TYPE_U32: - case TGIF_TYPE_U64: - case TGIF_TYPE_ARRAY: - case TGIF_TYPE_VLA: + case SIDE_TYPE_U8: + case SIDE_TYPE_BYTE: + case SIDE_TYPE_U16: + case SIDE_TYPE_U32: + case SIDE_TYPE_U64: + case SIDE_TYPE_ARRAY: + case SIDE_TYPE_VLA: break; default: fprintf(stderr, "ERROR: type mismatch between description and arguments\n"); @@ -852,9 +852,9 @@ void tracer_print_type(const struct tgif_type *type_desc, const struct tgif_arg } break; - case TGIF_TYPE_GATHER_ENUM: + case SIDE_TYPE_GATHER_ENUM: switch (item->type) { - case TGIF_TYPE_GATHER_INTEGER: + case SIDE_TYPE_GATHER_INTEGER: break; default: fprintf(stderr, "ERROR: type mismatch between description and arguments\n"); @@ -863,19 +863,19 @@ void tracer_print_type(const struct tgif_type *type_desc, const struct tgif_arg } break; - case TGIF_TYPE_DYNAMIC: + case SIDE_TYPE_DYNAMIC: switch (item->type) { - case TGIF_TYPE_DYNAMIC_NULL: - case TGIF_TYPE_DYNAMIC_BOOL: - case TGIF_TYPE_DYNAMIC_INTEGER: - case TGIF_TYPE_DYNAMIC_BYTE: - case TGIF_TYPE_DYNAMIC_POINTER: - case TGIF_TYPE_DYNAMIC_FLOAT: - case TGIF_TYPE_DYNAMIC_STRING: - case TGIF_TYPE_DYNAMIC_STRUCT: - case TGIF_TYPE_DYNAMIC_STRUCT_VISITOR: - case TGIF_TYPE_DYNAMIC_VLA: - case TGIF_TYPE_DYNAMIC_VLA_VISITOR: + case SIDE_TYPE_DYNAMIC_NULL: + case SIDE_TYPE_DYNAMIC_BOOL: + case SIDE_TYPE_DYNAMIC_INTEGER: + case SIDE_TYPE_DYNAMIC_BYTE: + case SIDE_TYPE_DYNAMIC_POINTER: + case SIDE_TYPE_DYNAMIC_FLOAT: + case SIDE_TYPE_DYNAMIC_STRING: + case SIDE_TYPE_DYNAMIC_STRUCT: + case SIDE_TYPE_DYNAMIC_STRUCT_VISITOR: + case SIDE_TYPE_DYNAMIC_VLA: + case SIDE_TYPE_DYNAMIC_VLA_VISITOR: break; default: fprintf(stderr, "ERROR: Unexpected dynamic type\n"); @@ -892,136 +892,136 @@ void tracer_print_type(const struct tgif_type *type_desc, const struct tgif_arg break; } - if (type_desc->type == TGIF_TYPE_ENUM || type_desc->type == TGIF_TYPE_ENUM_BITMAP || - type_desc->type == TGIF_TYPE_GATHER_ENUM) - type = (enum tgif_type_label) type_desc->type; + if (type_desc->type == SIDE_TYPE_ENUM || type_desc->type == SIDE_TYPE_ENUM_BITMAP || + type_desc->type == SIDE_TYPE_GATHER_ENUM) + type = (enum side_type_label) type_desc->type; else - type = (enum tgif_type_label) item->type; + type = (enum side_type_label) item->type; printf("{ "); switch (type) { /* Stack-copy basic types */ - case TGIF_TYPE_NULL: - tracer_print_type_header(":", type_desc->u.tgif_null.attr, type_desc->u.tgif_null.nr_attr); + case SIDE_TYPE_NULL: + tracer_print_type_header(":", type_desc->u.side_null.attr, type_desc->u.side_null.nr_attr); printf(""); break; - case TGIF_TYPE_BOOL: - tracer_print_type_bool(":", &type_desc->u.tgif_bool, &item->u.tgif_static.bool_value, 0); + case SIDE_TYPE_BOOL: + tracer_print_type_bool(":", &type_desc->u.side_bool, &item->u.side_static.bool_value, 0); break; - case TGIF_TYPE_U8: - case TGIF_TYPE_U16: - case TGIF_TYPE_U32: - case TGIF_TYPE_U64: - case TGIF_TYPE_S8: - case TGIF_TYPE_S16: - case TGIF_TYPE_S32: - case TGIF_TYPE_S64: - tracer_print_type_integer(":", &type_desc->u.tgif_integer, &item->u.tgif_static.integer_value, 0, + case SIDE_TYPE_U8: + case SIDE_TYPE_U16: + case SIDE_TYPE_U32: + case SIDE_TYPE_U64: + case SIDE_TYPE_S8: + case SIDE_TYPE_S16: + case SIDE_TYPE_S32: + case SIDE_TYPE_S64: + tracer_print_type_integer(":", &type_desc->u.side_integer, &item->u.side_static.integer_value, 0, TRACER_DISPLAY_BASE_10); break; - case TGIF_TYPE_BYTE: - tracer_print_type_header(":", type_desc->u.tgif_byte.attr, type_desc->u.tgif_byte.nr_attr); - printf("0x%" PRIx8, item->u.tgif_static.byte_value); + case SIDE_TYPE_BYTE: + tracer_print_type_header(":", type_desc->u.side_byte.attr, type_desc->u.side_byte.nr_attr); + printf("0x%" PRIx8, item->u.side_static.byte_value); break; - case TGIF_TYPE_POINTER: - tracer_print_type_integer(":", &type_desc->u.tgif_integer, &item->u.tgif_static.integer_value, 0, + case SIDE_TYPE_POINTER: + tracer_print_type_integer(":", &type_desc->u.side_integer, &item->u.side_static.integer_value, 0, TRACER_DISPLAY_BASE_16); break; - case TGIF_TYPE_FLOAT_BINARY16: - case TGIF_TYPE_FLOAT_BINARY32: - case TGIF_TYPE_FLOAT_BINARY64: - case TGIF_TYPE_FLOAT_BINARY128: - tracer_print_type_float(":", &type_desc->u.tgif_float, &item->u.tgif_static.float_value); + case SIDE_TYPE_FLOAT_BINARY16: + case SIDE_TYPE_FLOAT_BINARY32: + case SIDE_TYPE_FLOAT_BINARY64: + case SIDE_TYPE_FLOAT_BINARY128: + tracer_print_type_float(":", &type_desc->u.side_float, &item->u.side_static.float_value); break; - case TGIF_TYPE_STRING_UTF8: - case TGIF_TYPE_STRING_UTF16: - case TGIF_TYPE_STRING_UTF32: - tracer_print_type_header(":", type_desc->u.tgif_string.attr, type_desc->u.tgif_string.nr_attr); - tracer_print_string((const void *)(uintptr_t) item->u.tgif_static.string_value, - type_desc->u.tgif_string.unit_size, type_desc->u.tgif_string.byte_order, NULL); + case SIDE_TYPE_STRING_UTF8: + case SIDE_TYPE_STRING_UTF16: + case SIDE_TYPE_STRING_UTF32: + tracer_print_type_header(":", type_desc->u.side_string.attr, type_desc->u.side_string.nr_attr); + tracer_print_string((const void *)(uintptr_t) item->u.side_static.string_value, + type_desc->u.side_string.unit_size, type_desc->u.side_string.byte_order, NULL); break; /* Stack-copy compound types */ - case TGIF_TYPE_STRUCT: - tracer_print_struct(type_desc, item->u.tgif_static.tgif_struct); + case SIDE_TYPE_STRUCT: + tracer_print_struct(type_desc, item->u.side_static.side_struct); break; - case TGIF_TYPE_ARRAY: - tracer_print_array(type_desc, item->u.tgif_static.tgif_array); + case SIDE_TYPE_ARRAY: + tracer_print_array(type_desc, item->u.side_static.side_array); break; - case TGIF_TYPE_VLA: - tracer_print_vla(type_desc, item->u.tgif_static.tgif_vla); + case SIDE_TYPE_VLA: + tracer_print_vla(type_desc, item->u.side_static.side_vla); break; - case TGIF_TYPE_VLA_VISITOR: - tracer_print_vla_visitor(type_desc, item->u.tgif_static.tgif_vla_app_visitor_ctx); + case SIDE_TYPE_VLA_VISITOR: + tracer_print_vla_visitor(type_desc, item->u.side_static.side_vla_app_visitor_ctx); break; /* Stack-copy enumeration types */ - case TGIF_TYPE_ENUM: + case SIDE_TYPE_ENUM: tracer_print_enum(type_desc, item); break; - case TGIF_TYPE_ENUM_BITMAP: + case SIDE_TYPE_ENUM_BITMAP: tracer_print_enum_bitmap(type_desc, item); break; /* Gather basic types */ - case TGIF_TYPE_GATHER_BOOL: - (void) tracer_print_gather_bool_type(&type_desc->u.tgif_gather, item->u.tgif_static.tgif_bool_gather_ptr); + case SIDE_TYPE_GATHER_BOOL: + (void) tracer_print_gather_bool_type(&type_desc->u.side_gather, item->u.side_static.side_bool_gather_ptr); break; - case TGIF_TYPE_GATHER_INTEGER: - (void) tracer_print_gather_integer_type(&type_desc->u.tgif_gather, item->u.tgif_static.tgif_integer_gather_ptr, + case SIDE_TYPE_GATHER_INTEGER: + (void) tracer_print_gather_integer_type(&type_desc->u.side_gather, item->u.side_static.side_integer_gather_ptr, TRACER_DISPLAY_BASE_10); break; - case TGIF_TYPE_GATHER_BYTE: - (void) tracer_print_gather_byte_type(&type_desc->u.tgif_gather, item->u.tgif_static.tgif_byte_gather_ptr); + case SIDE_TYPE_GATHER_BYTE: + (void) tracer_print_gather_byte_type(&type_desc->u.side_gather, item->u.side_static.side_byte_gather_ptr); break; - case TGIF_TYPE_GATHER_POINTER: - (void) tracer_print_gather_integer_type(&type_desc->u.tgif_gather, item->u.tgif_static.tgif_integer_gather_ptr, + case SIDE_TYPE_GATHER_POINTER: + (void) tracer_print_gather_integer_type(&type_desc->u.side_gather, item->u.side_static.side_integer_gather_ptr, TRACER_DISPLAY_BASE_16); break; - case TGIF_TYPE_GATHER_FLOAT: - (void) tracer_print_gather_float_type(&type_desc->u.tgif_gather, item->u.tgif_static.tgif_float_gather_ptr); + case SIDE_TYPE_GATHER_FLOAT: + (void) tracer_print_gather_float_type(&type_desc->u.side_gather, item->u.side_static.side_float_gather_ptr); break; - case TGIF_TYPE_GATHER_STRING: - (void) tracer_print_gather_string_type(&type_desc->u.tgif_gather, item->u.tgif_static.tgif_string_gather_ptr); + case SIDE_TYPE_GATHER_STRING: + (void) tracer_print_gather_string_type(&type_desc->u.side_gather, item->u.side_static.side_string_gather_ptr); break; /* Gather compound type */ - case TGIF_TYPE_GATHER_STRUCT: - (void) tracer_print_gather_struct(&type_desc->u.tgif_gather, item->u.tgif_static.tgif_struct_gather_ptr); + case SIDE_TYPE_GATHER_STRUCT: + (void) tracer_print_gather_struct(&type_desc->u.side_gather, item->u.side_static.side_struct_gather_ptr); break; - case TGIF_TYPE_GATHER_ARRAY: - (void) tracer_print_gather_array(&type_desc->u.tgif_gather, item->u.tgif_static.tgif_array_gather_ptr); + case SIDE_TYPE_GATHER_ARRAY: + (void) tracer_print_gather_array(&type_desc->u.side_gather, item->u.side_static.side_array_gather_ptr); break; - case TGIF_TYPE_GATHER_VLA: - (void) tracer_print_gather_vla(&type_desc->u.tgif_gather, item->u.tgif_static.tgif_vla_gather.ptr, - item->u.tgif_static.tgif_vla_gather.length_ptr); + case SIDE_TYPE_GATHER_VLA: + (void) tracer_print_gather_vla(&type_desc->u.side_gather, item->u.side_static.side_vla_gather.ptr, + item->u.side_static.side_vla_gather.length_ptr); break; /* Gather enumeration types */ - case TGIF_TYPE_GATHER_ENUM: - (void) tracer_print_gather_enum_type(&type_desc->u.tgif_gather, item->u.tgif_static.tgif_integer_gather_ptr); + case SIDE_TYPE_GATHER_ENUM: + (void) tracer_print_gather_enum_type(&type_desc->u.side_gather, item->u.side_static.side_integer_gather_ptr); break; /* Dynamic basic types */ - case TGIF_TYPE_DYNAMIC_NULL: - case TGIF_TYPE_DYNAMIC_BOOL: - case TGIF_TYPE_DYNAMIC_INTEGER: - case TGIF_TYPE_DYNAMIC_BYTE: - case TGIF_TYPE_DYNAMIC_POINTER: - case TGIF_TYPE_DYNAMIC_FLOAT: - case TGIF_TYPE_DYNAMIC_STRING: + case SIDE_TYPE_DYNAMIC_NULL: + case SIDE_TYPE_DYNAMIC_BOOL: + case SIDE_TYPE_DYNAMIC_INTEGER: + case SIDE_TYPE_DYNAMIC_BYTE: + case SIDE_TYPE_DYNAMIC_POINTER: + case SIDE_TYPE_DYNAMIC_FLOAT: + case SIDE_TYPE_DYNAMIC_STRING: /* Dynamic compound types */ - case TGIF_TYPE_DYNAMIC_STRUCT: - case TGIF_TYPE_DYNAMIC_STRUCT_VISITOR: - case TGIF_TYPE_DYNAMIC_VLA: - case TGIF_TYPE_DYNAMIC_VLA_VISITOR: + case SIDE_TYPE_DYNAMIC_STRUCT: + case SIDE_TYPE_DYNAMIC_STRUCT_VISITOR: + case SIDE_TYPE_DYNAMIC_VLA: + case SIDE_TYPE_DYNAMIC_VLA_VISITOR: tracer_print_dynamic(item); break; default: @@ -1032,77 +1032,77 @@ void tracer_print_type(const struct tgif_type *type_desc, const struct tgif_arg } static -void tracer_print_field(const struct tgif_event_field *item_desc, const struct tgif_arg *item) +void tracer_print_field(const struct side_event_field *item_desc, const struct side_arg *item) { printf("%s: ", item_desc->field_name); - tracer_print_type(&item_desc->tgif_type, item); + tracer_print_type(&item_desc->side_type, item); } static -void tracer_print_struct(const struct tgif_type *type_desc, const struct tgif_arg_vec *tgif_arg_vec) +void tracer_print_struct(const struct side_type *type_desc, const struct side_arg_vec *side_arg_vec) { - const struct tgif_arg *sav = tgif_arg_vec->sav; - uint32_t i, tgif_sav_len = tgif_arg_vec->len; + const struct side_arg *sav = side_arg_vec->sav; + uint32_t i, side_sav_len = side_arg_vec->len; - if (type_desc->u.tgif_struct->nr_fields != tgif_sav_len) { + if (type_desc->u.side_struct->nr_fields != side_sav_len) { fprintf(stderr, "ERROR: number of fields mismatch between description and arguments of structure\n"); abort(); } - print_attributes("attr", ":", type_desc->u.tgif_struct->attr, type_desc->u.tgif_struct->nr_attr); - printf("%s", type_desc->u.tgif_struct->nr_attr ? ", " : ""); + print_attributes("attr", ":", type_desc->u.side_struct->attr, type_desc->u.side_struct->nr_attr); + printf("%s", type_desc->u.side_struct->nr_attr ? ", " : ""); printf("fields: { "); - for (i = 0; i < tgif_sav_len; i++) { + for (i = 0; i < side_sav_len; i++) { printf("%s", i ? ", " : ""); - tracer_print_field(&type_desc->u.tgif_struct->fields[i], &sav[i]); + tracer_print_field(&type_desc->u.side_struct->fields[i], &sav[i]); } printf(" }"); } static -void tracer_print_array(const struct tgif_type *type_desc, const struct tgif_arg_vec *tgif_arg_vec) +void tracer_print_array(const struct side_type *type_desc, const struct side_arg_vec *side_arg_vec) { - const struct tgif_arg *sav = tgif_arg_vec->sav; - uint32_t i, tgif_sav_len = tgif_arg_vec->len; + const struct side_arg *sav = side_arg_vec->sav; + uint32_t i, side_sav_len = side_arg_vec->len; - if (type_desc->u.tgif_array.length != tgif_sav_len) { + if (type_desc->u.side_array.length != side_sav_len) { fprintf(stderr, "ERROR: length mismatch between description and arguments of array\n"); abort(); } - print_attributes("attr", ":", type_desc->u.tgif_array.attr, type_desc->u.tgif_array.nr_attr); - printf("%s", type_desc->u.tgif_array.nr_attr ? ", " : ""); + print_attributes("attr", ":", type_desc->u.side_array.attr, type_desc->u.side_array.nr_attr); + printf("%s", type_desc->u.side_array.nr_attr ? ", " : ""); printf("elements: "); printf("[ "); - for (i = 0; i < tgif_sav_len; i++) { + for (i = 0; i < side_sav_len; i++) { printf("%s", i ? ", " : ""); - tracer_print_type(type_desc->u.tgif_array.elem_type, &sav[i]); + tracer_print_type(type_desc->u.side_array.elem_type, &sav[i]); } printf(" ]"); } static -void tracer_print_vla(const struct tgif_type *type_desc, const struct tgif_arg_vec *tgif_arg_vec) +void tracer_print_vla(const struct side_type *type_desc, const struct side_arg_vec *side_arg_vec) { - const struct tgif_arg *sav = tgif_arg_vec->sav; - uint32_t i, tgif_sav_len = tgif_arg_vec->len; + const struct side_arg *sav = side_arg_vec->sav; + uint32_t i, side_sav_len = side_arg_vec->len; - print_attributes("attr", ":", type_desc->u.tgif_vla.attr, type_desc->u.tgif_vla.nr_attr); - printf("%s", type_desc->u.tgif_vla.nr_attr ? ", " : ""); + print_attributes("attr", ":", type_desc->u.side_vla.attr, type_desc->u.side_vla.nr_attr); + printf("%s", type_desc->u.side_vla.nr_attr ? ", " : ""); printf("elements: "); printf("[ "); - for (i = 0; i < tgif_sav_len; i++) { + for (i = 0; i < side_sav_len; i++) { printf("%s", i ? ", " : ""); - tracer_print_type(type_desc->u.tgif_vla.elem_type, &sav[i]); + tracer_print_type(type_desc->u.side_vla.elem_type, &sav[i]); } printf(" ]"); } static -const char *tracer_gather_access(enum tgif_type_gather_access_mode access_mode, const char *ptr) +const char *tracer_gather_access(enum side_type_gather_access_mode access_mode, const char *ptr) { switch (access_mode) { - case TGIF_TYPE_GATHER_ACCESS_DIRECT: + case SIDE_TYPE_GATHER_ACCESS_DIRECT: return ptr; - case TGIF_TYPE_GATHER_ACCESS_POINTER: + case SIDE_TYPE_GATHER_ACCESS_POINTER: /* Dereference pointer */ memcpy(&ptr, ptr, sizeof(ptr)); return ptr; @@ -1112,12 +1112,12 @@ const char *tracer_gather_access(enum tgif_type_gather_access_mode access_mode, } static -uint32_t tracer_gather_size(enum tgif_type_gather_access_mode access_mode, uint32_t len) +uint32_t tracer_gather_size(enum side_type_gather_access_mode access_mode, uint32_t len) { switch (access_mode) { - case TGIF_TYPE_GATHER_ACCESS_DIRECT: + case SIDE_TYPE_GATHER_ACCESS_DIRECT: return len; - case TGIF_TYPE_GATHER_ACCESS_POINTER: + case SIDE_TYPE_GATHER_ACCESS_POINTER: return sizeof(void *); default: abort(); @@ -1125,29 +1125,29 @@ uint32_t tracer_gather_size(enum tgif_type_gather_access_mode access_mode, uint3 } static -union int64_value tracer_load_gather_integer_value(const struct tgif_type_gather_integer *tgif_integer, +union int64_value tracer_load_gather_integer_value(const struct side_type_gather_integer *side_integer, const void *_ptr) { - enum tgif_type_gather_access_mode access_mode = - (enum tgif_type_gather_access_mode) tgif_integer->access_mode; - uint32_t integer_size_bytes = tgif_integer->type.integer_size; + enum side_type_gather_access_mode access_mode = + (enum side_type_gather_access_mode) side_integer->access_mode; + uint32_t integer_size_bytes = side_integer->type.integer_size; const char *ptr = (const char *) _ptr; - union tgif_integer_value value; + union side_integer_value value; - ptr = tracer_gather_access(access_mode, ptr + tgif_integer->offset); + ptr = tracer_gather_access(access_mode, ptr + side_integer->offset); memcpy(&value, ptr, integer_size_bytes); - return tracer_load_integer_value(&tgif_integer->type, &value, - tgif_integer->offset_bits, NULL); + return tracer_load_integer_value(&side_integer->type, &value, + side_integer->offset_bits, NULL); } static -uint32_t tracer_print_gather_bool_type(const struct tgif_type_gather *type_gather, const void *_ptr) +uint32_t tracer_print_gather_bool_type(const struct side_type_gather *type_gather, const void *_ptr) { - enum tgif_type_gather_access_mode access_mode = - (enum tgif_type_gather_access_mode) type_gather->u.tgif_bool.access_mode; - uint32_t bool_size_bytes = type_gather->u.tgif_bool.type.bool_size; + enum side_type_gather_access_mode access_mode = + (enum side_type_gather_access_mode) type_gather->u.side_bool.access_mode; + uint32_t bool_size_bytes = type_gather->u.side_bool.type.bool_size; const char *ptr = (const char *) _ptr; - union tgif_bool_value value; + union side_bool_value value; switch (bool_size_bytes) { case 1: @@ -1158,38 +1158,38 @@ uint32_t tracer_print_gather_bool_type(const struct tgif_type_gather *type_gathe default: abort(); } - ptr = tracer_gather_access(access_mode, ptr + type_gather->u.tgif_bool.offset); + ptr = tracer_gather_access(access_mode, ptr + type_gather->u.side_bool.offset); memcpy(&value, ptr, bool_size_bytes); - tracer_print_type_bool(":", &type_gather->u.tgif_bool.type, &value, - type_gather->u.tgif_bool.offset_bits); + tracer_print_type_bool(":", &type_gather->u.side_bool.type, &value, + type_gather->u.side_bool.offset_bits); return tracer_gather_size(access_mode, bool_size_bytes); } static -uint32_t tracer_print_gather_byte_type(const struct tgif_type_gather *type_gather, const void *_ptr) +uint32_t tracer_print_gather_byte_type(const struct side_type_gather *type_gather, const void *_ptr) { - enum tgif_type_gather_access_mode access_mode = - (enum tgif_type_gather_access_mode) type_gather->u.tgif_byte.access_mode; + enum side_type_gather_access_mode access_mode = + (enum side_type_gather_access_mode) type_gather->u.side_byte.access_mode; const char *ptr = (const char *) _ptr; uint8_t value; - ptr = tracer_gather_access(access_mode, ptr + type_gather->u.tgif_byte.offset); + ptr = tracer_gather_access(access_mode, ptr + type_gather->u.side_byte.offset); memcpy(&value, ptr, 1); - tracer_print_type_header(":", type_gather->u.tgif_byte.type.attr, - type_gather->u.tgif_byte.type.nr_attr); + tracer_print_type_header(":", type_gather->u.side_byte.type.attr, + type_gather->u.side_byte.type.nr_attr); printf("0x%" PRIx8, value); return tracer_gather_size(access_mode, 1); } static -uint32_t tracer_print_gather_integer_type(const struct tgif_type_gather *type_gather, const void *_ptr, +uint32_t tracer_print_gather_integer_type(const struct side_type_gather *type_gather, const void *_ptr, enum tracer_display_base default_base) { - enum tgif_type_gather_access_mode access_mode = - (enum tgif_type_gather_access_mode) type_gather->u.tgif_integer.access_mode; - uint32_t integer_size_bytes = type_gather->u.tgif_integer.type.integer_size; + enum side_type_gather_access_mode access_mode = + (enum side_type_gather_access_mode) type_gather->u.side_integer.access_mode; + uint32_t integer_size_bytes = type_gather->u.side_integer.type.integer_size; const char *ptr = (const char *) _ptr; - union tgif_integer_value value; + union side_integer_value value; switch (integer_size_bytes) { case 1: @@ -1200,21 +1200,21 @@ uint32_t tracer_print_gather_integer_type(const struct tgif_type_gather *type_ga default: abort(); } - ptr = tracer_gather_access(access_mode, ptr + type_gather->u.tgif_integer.offset); + ptr = tracer_gather_access(access_mode, ptr + type_gather->u.side_integer.offset); memcpy(&value, ptr, integer_size_bytes); - tracer_print_type_integer(":", &type_gather->u.tgif_integer.type, &value, - type_gather->u.tgif_integer.offset_bits, default_base); + tracer_print_type_integer(":", &type_gather->u.side_integer.type, &value, + type_gather->u.side_integer.offset_bits, default_base); return tracer_gather_size(access_mode, integer_size_bytes); } static -uint32_t tracer_print_gather_float_type(const struct tgif_type_gather *type_gather, const void *_ptr) +uint32_t tracer_print_gather_float_type(const struct side_type_gather *type_gather, const void *_ptr) { - enum tgif_type_gather_access_mode access_mode = - (enum tgif_type_gather_access_mode) type_gather->u.tgif_float.access_mode; - uint32_t float_size_bytes = type_gather->u.tgif_float.type.float_size; + enum side_type_gather_access_mode access_mode = + (enum side_type_gather_access_mode) type_gather->u.side_float.access_mode; + uint32_t float_size_bytes = type_gather->u.side_float.type.float_size; const char *ptr = (const char *) _ptr; - union tgif_float_value value; + union side_float_value value; switch (float_size_bytes) { case 2: @@ -1225,76 +1225,76 @@ uint32_t tracer_print_gather_float_type(const struct tgif_type_gather *type_gath default: abort(); } - ptr = tracer_gather_access(access_mode, ptr + type_gather->u.tgif_float.offset); + ptr = tracer_gather_access(access_mode, ptr + type_gather->u.side_float.offset); memcpy(&value, ptr, float_size_bytes); - tracer_print_type_float(":", &type_gather->u.tgif_float.type, &value); + tracer_print_type_float(":", &type_gather->u.side_float.type, &value); return tracer_gather_size(access_mode, float_size_bytes); } static -uint32_t tracer_print_gather_string_type(const struct tgif_type_gather *type_gather, const void *_ptr) +uint32_t tracer_print_gather_string_type(const struct side_type_gather *type_gather, const void *_ptr) { - enum tgif_type_gather_access_mode access_mode = - (enum tgif_type_gather_access_mode) type_gather->u.tgif_string.access_mode; + enum side_type_gather_access_mode access_mode = + (enum side_type_gather_access_mode) type_gather->u.side_string.access_mode; const char *ptr = (const char *) _ptr; size_t string_len; - ptr = tracer_gather_access(access_mode, ptr + type_gather->u.tgif_string.offset); - tracer_print_type_header(":", type_gather->u.tgif_string.type.attr, - type_gather->u.tgif_string.type.nr_attr); + ptr = tracer_gather_access(access_mode, ptr + type_gather->u.side_string.offset); + tracer_print_type_header(":", type_gather->u.side_string.type.attr, + type_gather->u.side_string.type.nr_attr); if (ptr) { - tracer_print_string(ptr, type_gather->u.tgif_string.type.unit_size, - type_gather->u.tgif_string.type.byte_order, &string_len); + tracer_print_string(ptr, type_gather->u.side_string.type.unit_size, + type_gather->u.side_string.type.byte_order, &string_len); } else { printf(""); - string_len = type_gather->u.tgif_string.type.unit_size; + string_len = type_gather->u.side_string.type.unit_size; } return tracer_gather_size(access_mode, string_len); } static -uint32_t tracer_print_gather_type(const struct tgif_type *type_desc, const void *ptr) +uint32_t tracer_print_gather_type(const struct side_type *type_desc, const void *ptr) { uint32_t len; printf("{ "); switch (type_desc->type) { /* Gather basic types */ - case TGIF_TYPE_GATHER_BOOL: - len = tracer_print_gather_bool_type(&type_desc->u.tgif_gather, ptr); + case SIDE_TYPE_GATHER_BOOL: + len = tracer_print_gather_bool_type(&type_desc->u.side_gather, ptr); break; - case TGIF_TYPE_GATHER_INTEGER: - len = tracer_print_gather_integer_type(&type_desc->u.tgif_gather, ptr, + case SIDE_TYPE_GATHER_INTEGER: + len = tracer_print_gather_integer_type(&type_desc->u.side_gather, ptr, TRACER_DISPLAY_BASE_10); break; - case TGIF_TYPE_GATHER_BYTE: - len = tracer_print_gather_byte_type(&type_desc->u.tgif_gather, ptr); + case SIDE_TYPE_GATHER_BYTE: + len = tracer_print_gather_byte_type(&type_desc->u.side_gather, ptr); break; - case TGIF_TYPE_GATHER_POINTER: - len = tracer_print_gather_integer_type(&type_desc->u.tgif_gather, ptr, + case SIDE_TYPE_GATHER_POINTER: + len = tracer_print_gather_integer_type(&type_desc->u.side_gather, ptr, TRACER_DISPLAY_BASE_16); break; - case TGIF_TYPE_GATHER_FLOAT: - len = tracer_print_gather_float_type(&type_desc->u.tgif_gather, ptr); + case SIDE_TYPE_GATHER_FLOAT: + len = tracer_print_gather_float_type(&type_desc->u.side_gather, ptr); break; - case TGIF_TYPE_GATHER_STRING: - len = tracer_print_gather_string_type(&type_desc->u.tgif_gather, ptr); + case SIDE_TYPE_GATHER_STRING: + len = tracer_print_gather_string_type(&type_desc->u.side_gather, ptr); break; /* Gather enum types */ - case TGIF_TYPE_GATHER_ENUM: - len = tracer_print_gather_enum_type(&type_desc->u.tgif_gather, ptr); + case SIDE_TYPE_GATHER_ENUM: + len = tracer_print_gather_enum_type(&type_desc->u.side_gather, ptr); break; /* Gather compound types */ - case TGIF_TYPE_GATHER_STRUCT: - len = tracer_print_gather_struct(&type_desc->u.tgif_gather, ptr); + case SIDE_TYPE_GATHER_STRUCT: + len = tracer_print_gather_struct(&type_desc->u.side_gather, ptr); break; - case TGIF_TYPE_GATHER_ARRAY: - len = tracer_print_gather_array(&type_desc->u.tgif_gather, ptr); + case SIDE_TYPE_GATHER_ARRAY: + len = tracer_print_gather_array(&type_desc->u.side_gather, ptr); break; - case TGIF_TYPE_GATHER_VLA: - len = tracer_print_gather_vla(&type_desc->u.tgif_gather, ptr, ptr); + case SIDE_TYPE_GATHER_VLA: + len = tracer_print_gather_vla(&type_desc->u.side_gather, ptr, ptr); break; default: fprintf(stderr, ""); @@ -1305,16 +1305,16 @@ uint32_t tracer_print_gather_type(const struct tgif_type *type_desc, const void } static -uint32_t tracer_print_gather_enum_type(const struct tgif_type_gather *type_gather, const void *_ptr) +uint32_t tracer_print_gather_enum_type(const struct side_type_gather *type_gather, const void *_ptr) { - const struct tgif_enum_mappings *mappings = type_gather->u.tgif_enum.mappings; - const struct tgif_type *enum_elem_type = type_gather->u.tgif_enum.elem_type; - const struct tgif_type_gather_integer *tgif_integer = &enum_elem_type->u.tgif_gather.u.tgif_integer; - enum tgif_type_gather_access_mode access_mode = - (enum tgif_type_gather_access_mode) tgif_integer->access_mode; - uint32_t integer_size_bytes = tgif_integer->type.integer_size; + const struct side_enum_mappings *mappings = type_gather->u.side_enum.mappings; + const struct side_type *enum_elem_type = type_gather->u.side_enum.elem_type; + const struct side_type_gather_integer *side_integer = &enum_elem_type->u.side_gather.u.side_integer; + enum side_type_gather_access_mode access_mode = + (enum side_type_gather_access_mode) side_integer->access_mode; + uint32_t integer_size_bytes = side_integer->type.integer_size; const char *ptr = (const char *) _ptr; - union tgif_integer_value value; + union side_integer_value value; union int64_value v64; switch (integer_size_bytes) { @@ -1326,9 +1326,9 @@ uint32_t tracer_print_gather_enum_type(const struct tgif_type_gather *type_gathe default: abort(); } - ptr = tracer_gather_access(access_mode, ptr + tgif_integer->offset); + ptr = tracer_gather_access(access_mode, ptr + side_integer->offset); memcpy(&value, ptr, integer_size_bytes); - v64 = tracer_load_gather_integer_value(tgif_integer, &value); + v64 = tracer_load_gather_integer_value(side_integer, &value); print_attributes("attr", ":", mappings->attr, mappings->nr_attr); printf("%s", mappings->nr_attr ? ", " : ""); tracer_print_gather_type(enum_elem_type, ptr); @@ -1337,142 +1337,142 @@ uint32_t tracer_print_gather_enum_type(const struct tgif_type_gather *type_gathe } static -void tracer_print_gather_field(const struct tgif_event_field *field, const void *ptr) +void tracer_print_gather_field(const struct side_event_field *field, const void *ptr) { printf("%s: ", field->field_name); - (void) tracer_print_gather_type(&field->tgif_type, ptr); + (void) tracer_print_gather_type(&field->side_type, ptr); } static -uint32_t tracer_print_gather_struct(const struct tgif_type_gather *type_gather, const void *_ptr) +uint32_t tracer_print_gather_struct(const struct side_type_gather *type_gather, const void *_ptr) { - enum tgif_type_gather_access_mode access_mode = - (enum tgif_type_gather_access_mode) type_gather->u.tgif_struct.access_mode; + enum side_type_gather_access_mode access_mode = + (enum side_type_gather_access_mode) type_gather->u.side_struct.access_mode; const char *ptr = (const char *) _ptr; uint32_t i; - ptr = tracer_gather_access(access_mode, ptr + type_gather->u.tgif_struct.offset); - print_attributes("attr", ":", type_gather->u.tgif_struct.type->attr, type_gather->u.tgif_struct.type->nr_attr); - printf("%s", type_gather->u.tgif_struct.type->nr_attr ? ", " : ""); + ptr = tracer_gather_access(access_mode, ptr + type_gather->u.side_struct.offset); + print_attributes("attr", ":", type_gather->u.side_struct.type->attr, type_gather->u.side_struct.type->nr_attr); + printf("%s", type_gather->u.side_struct.type->nr_attr ? ", " : ""); printf("fields: { "); - for (i = 0; i < type_gather->u.tgif_struct.type->nr_fields; i++) { + for (i = 0; i < type_gather->u.side_struct.type->nr_fields; i++) { printf("%s", i ? ", " : ""); - tracer_print_gather_field(&type_gather->u.tgif_struct.type->fields[i], ptr); + tracer_print_gather_field(&type_gather->u.side_struct.type->fields[i], ptr); } printf(" }"); - return tracer_gather_size(access_mode, type_gather->u.tgif_struct.size); + return tracer_gather_size(access_mode, type_gather->u.side_struct.size); } static -uint32_t tracer_print_gather_array(const struct tgif_type_gather *type_gather, const void *_ptr) +uint32_t tracer_print_gather_array(const struct side_type_gather *type_gather, const void *_ptr) { - enum tgif_type_gather_access_mode access_mode = - (enum tgif_type_gather_access_mode) type_gather->u.tgif_array.access_mode; + enum side_type_gather_access_mode access_mode = + (enum side_type_gather_access_mode) type_gather->u.side_array.access_mode; const char *ptr = (const char *) _ptr, *orig_ptr; uint32_t i; - ptr = tracer_gather_access(access_mode, ptr + type_gather->u.tgif_array.offset); + ptr = tracer_gather_access(access_mode, ptr + type_gather->u.side_array.offset); orig_ptr = ptr; - print_attributes("attr", ":", type_gather->u.tgif_array.type.attr, type_gather->u.tgif_array.type.nr_attr); - printf("%s", type_gather->u.tgif_array.type.nr_attr ? ", " : ""); + print_attributes("attr", ":", type_gather->u.side_array.type.attr, type_gather->u.side_array.type.nr_attr); + printf("%s", type_gather->u.side_array.type.nr_attr ? ", " : ""); printf("elements: "); printf("[ "); - for (i = 0; i < type_gather->u.tgif_array.type.length; i++) { - switch (type_gather->u.tgif_array.type.elem_type->type) { - case TGIF_TYPE_GATHER_VLA: + for (i = 0; i < type_gather->u.side_array.type.length; i++) { + switch (type_gather->u.side_array.type.elem_type->type) { + case SIDE_TYPE_GATHER_VLA: fprintf(stderr, "\n"); abort(); default: break; } printf("%s", i ? ", " : ""); - ptr += tracer_print_gather_type(type_gather->u.tgif_array.type.elem_type, ptr); + ptr += tracer_print_gather_type(type_gather->u.side_array.type.elem_type, ptr); } printf(" ]"); return tracer_gather_size(access_mode, ptr - orig_ptr); } static -uint32_t tracer_print_gather_vla(const struct tgif_type_gather *type_gather, const void *_ptr, +uint32_t tracer_print_gather_vla(const struct side_type_gather *type_gather, const void *_ptr, const void *_length_ptr) { - enum tgif_type_gather_access_mode access_mode = - (enum tgif_type_gather_access_mode) type_gather->u.tgif_vla.access_mode; + enum side_type_gather_access_mode access_mode = + (enum side_type_gather_access_mode) type_gather->u.side_vla.access_mode; const char *ptr = (const char *) _ptr, *orig_ptr; const char *length_ptr = (const char *) _length_ptr; union int64_value v64; uint32_t i, length; /* Access length */ - switch (type_gather->u.tgif_vla.length_type->type) { - case TGIF_TYPE_GATHER_INTEGER: + switch (type_gather->u.side_vla.length_type->type) { + case SIDE_TYPE_GATHER_INTEGER: break; default: fprintf(stderr, "\n"); abort(); } - v64 = tracer_load_gather_integer_value(&type_gather->u.tgif_vla.length_type->u.tgif_gather.u.tgif_integer, + v64 = tracer_load_gather_integer_value(&type_gather->u.side_vla.length_type->u.side_gather.u.side_integer, length_ptr); length = (uint32_t) v64.u; - ptr = tracer_gather_access(access_mode, ptr + type_gather->u.tgif_vla.offset); + ptr = tracer_gather_access(access_mode, ptr + type_gather->u.side_vla.offset); orig_ptr = ptr; - print_attributes("attr", ":", type_gather->u.tgif_vla.type.attr, type_gather->u.tgif_vla.type.nr_attr); - printf("%s", type_gather->u.tgif_vla.type.nr_attr ? ", " : ""); + print_attributes("attr", ":", type_gather->u.side_vla.type.attr, type_gather->u.side_vla.type.nr_attr); + printf("%s", type_gather->u.side_vla.type.nr_attr ? ", " : ""); printf("elements: "); printf("[ "); for (i = 0; i < length; i++) { - switch (type_gather->u.tgif_vla.type.elem_type->type) { - case TGIF_TYPE_GATHER_VLA: + switch (type_gather->u.side_vla.type.elem_type->type) { + case SIDE_TYPE_GATHER_VLA: fprintf(stderr, "\n"); abort(); default: break; } printf("%s", i ? ", " : ""); - ptr += tracer_print_gather_type(type_gather->u.tgif_vla.type.elem_type, ptr); + ptr += tracer_print_gather_type(type_gather->u.side_vla.type.elem_type, ptr); } printf(" ]"); return tracer_gather_size(access_mode, ptr - orig_ptr); } struct tracer_visitor_priv { - const struct tgif_type *elem_type; + const struct side_type *elem_type; int i; }; static -enum tgif_visitor_status tracer_write_elem_cb(const struct tgif_tracer_visitor_ctx *tracer_ctx, - const struct tgif_arg *elem) +enum side_visitor_status tracer_write_elem_cb(const struct side_tracer_visitor_ctx *tracer_ctx, + const struct side_arg *elem) { struct tracer_visitor_priv *tracer_priv = (struct tracer_visitor_priv *) tracer_ctx->priv; printf("%s", tracer_priv->i++ ? ", " : ""); tracer_print_type(tracer_priv->elem_type, elem); - return TGIF_VISITOR_STATUS_OK; + return SIDE_VISITOR_STATUS_OK; } static -void tracer_print_vla_visitor(const struct tgif_type *type_desc, void *app_ctx) +void tracer_print_vla_visitor(const struct side_type *type_desc, void *app_ctx) { - enum tgif_visitor_status status; + enum side_visitor_status status; struct tracer_visitor_priv tracer_priv = { - .elem_type = type_desc->u.tgif_vla_visitor.elem_type, + .elem_type = type_desc->u.side_vla_visitor.elem_type, .i = 0, }; - const struct tgif_tracer_visitor_ctx tracer_ctx = { + const struct side_tracer_visitor_ctx tracer_ctx = { .write_elem = tracer_write_elem_cb, .priv = &tracer_priv, }; - print_attributes("attr", ":", type_desc->u.tgif_vla_visitor.attr, type_desc->u.tgif_vla_visitor.nr_attr); - printf("%s", type_desc->u.tgif_vla_visitor.nr_attr ? ", " : ""); + print_attributes("attr", ":", type_desc->u.side_vla_visitor.attr, type_desc->u.side_vla_visitor.nr_attr); + printf("%s", type_desc->u.side_vla_visitor.nr_attr ? ", " : ""); printf("elements: "); printf("[ "); - status = type_desc->u.tgif_vla_visitor.visitor(&tracer_ctx, app_ctx); + status = type_desc->u.side_vla_visitor.visitor(&tracer_ctx, app_ctx); switch (status) { - case TGIF_VISITOR_STATUS_OK: + case SIDE_VISITOR_STATUS_OK: break; - case TGIF_VISITOR_STATUS_ERROR: + case SIDE_VISITOR_STATUS_ERROR: fprintf(stderr, "ERROR: Visitor error\n"); abort(); } @@ -1480,9 +1480,9 @@ void tracer_print_vla_visitor(const struct tgif_type *type_desc, void *app_ctx) } static -void tracer_print_dynamic_struct(const struct tgif_arg_dynamic_struct *dynamic_struct) +void tracer_print_dynamic_struct(const struct side_arg_dynamic_struct *dynamic_struct) { - const struct tgif_arg_dynamic_field *fields = dynamic_struct->fields; + const struct side_arg_dynamic_field *fields = dynamic_struct->fields; uint32_t i, len = dynamic_struct->len; print_attributes("attr", "::", dynamic_struct->attr, dynamic_struct->nr_attr); @@ -1502,9 +1502,9 @@ struct tracer_dynamic_struct_visitor_priv { }; static -enum tgif_visitor_status tracer_dynamic_struct_write_elem_cb( - const struct tgif_tracer_dynamic_struct_visitor_ctx *tracer_ctx, - const struct tgif_arg_dynamic_field *dynamic_field) +enum side_visitor_status tracer_dynamic_struct_write_elem_cb( + const struct side_tracer_dynamic_struct_visitor_ctx *tracer_ctx, + const struct side_arg_dynamic_field *dynamic_field) { struct tracer_dynamic_struct_visitor_priv *tracer_priv = (struct tracer_dynamic_struct_visitor_priv *) tracer_ctx->priv; @@ -1512,31 +1512,31 @@ enum tgif_visitor_status tracer_dynamic_struct_write_elem_cb( printf("%s", tracer_priv->i++ ? ", " : ""); printf("%s:: ", dynamic_field->field_name); tracer_print_dynamic(&dynamic_field->elem); - return TGIF_VISITOR_STATUS_OK; + return SIDE_VISITOR_STATUS_OK; } static -void tracer_print_dynamic_struct_visitor(const struct tgif_arg *item) +void tracer_print_dynamic_struct_visitor(const struct side_arg *item) { - enum tgif_visitor_status status; + enum side_visitor_status status; struct tracer_dynamic_struct_visitor_priv tracer_priv = { .i = 0, }; - const struct tgif_tracer_dynamic_struct_visitor_ctx tracer_ctx = { + const struct side_tracer_dynamic_struct_visitor_ctx tracer_ctx = { .write_field = tracer_dynamic_struct_write_elem_cb, .priv = &tracer_priv, }; - void *app_ctx = item->u.tgif_dynamic.tgif_dynamic_struct_visitor.app_ctx; + void *app_ctx = item->u.side_dynamic.side_dynamic_struct_visitor.app_ctx; - print_attributes("attr", "::", item->u.tgif_dynamic.tgif_dynamic_struct_visitor.attr, item->u.tgif_dynamic.tgif_dynamic_struct_visitor.nr_attr); - printf("%s", item->u.tgif_dynamic.tgif_dynamic_struct_visitor.nr_attr ? ", " : ""); + print_attributes("attr", "::", item->u.side_dynamic.side_dynamic_struct_visitor.attr, item->u.side_dynamic.side_dynamic_struct_visitor.nr_attr); + printf("%s", item->u.side_dynamic.side_dynamic_struct_visitor.nr_attr ? ", " : ""); printf("fields:: "); printf("[ "); - status = item->u.tgif_dynamic.tgif_dynamic_struct_visitor.visitor(&tracer_ctx, app_ctx); + status = item->u.side_dynamic.side_dynamic_struct_visitor.visitor(&tracer_ctx, app_ctx); switch (status) { - case TGIF_VISITOR_STATUS_OK: + case SIDE_VISITOR_STATUS_OK: break; - case TGIF_VISITOR_STATUS_ERROR: + case SIDE_VISITOR_STATUS_ERROR: fprintf(stderr, "ERROR: Visitor error\n"); abort(); } @@ -1544,16 +1544,16 @@ void tracer_print_dynamic_struct_visitor(const struct tgif_arg *item) } static -void tracer_print_dynamic_vla(const struct tgif_arg_dynamic_vla *vla) +void tracer_print_dynamic_vla(const struct side_arg_dynamic_vla *vla) { - const struct tgif_arg *sav = vla->sav; - uint32_t i, tgif_sav_len = vla->len; + const struct side_arg *sav = vla->sav; + uint32_t i, side_sav_len = vla->len; print_attributes("attr", "::", vla->attr, vla->nr_attr); printf("%s", vla->nr_attr ? ", " : ""); printf("elements:: "); printf("[ "); - for (i = 0; i < tgif_sav_len; i++) { + for (i = 0; i < side_sav_len; i++) { printf("%s", i ? ", " : ""); tracer_print_dynamic(&sav[i]); } @@ -1565,40 +1565,40 @@ struct tracer_dynamic_vla_visitor_priv { }; static -enum tgif_visitor_status tracer_dynamic_vla_write_elem_cb( - const struct tgif_tracer_visitor_ctx *tracer_ctx, - const struct tgif_arg *elem) +enum side_visitor_status tracer_dynamic_vla_write_elem_cb( + const struct side_tracer_visitor_ctx *tracer_ctx, + const struct side_arg *elem) { struct tracer_dynamic_vla_visitor_priv *tracer_priv = (struct tracer_dynamic_vla_visitor_priv *) tracer_ctx->priv; printf("%s", tracer_priv->i++ ? ", " : ""); tracer_print_dynamic(elem); - return TGIF_VISITOR_STATUS_OK; + return SIDE_VISITOR_STATUS_OK; } static -void tracer_print_dynamic_vla_visitor(const struct tgif_arg *item) +void tracer_print_dynamic_vla_visitor(const struct side_arg *item) { - enum tgif_visitor_status status; + enum side_visitor_status status; struct tracer_dynamic_vla_visitor_priv tracer_priv = { .i = 0, }; - const struct tgif_tracer_visitor_ctx tracer_ctx = { + const struct side_tracer_visitor_ctx tracer_ctx = { .write_elem = tracer_dynamic_vla_write_elem_cb, .priv = &tracer_priv, }; - void *app_ctx = item->u.tgif_dynamic.tgif_dynamic_vla_visitor.app_ctx; + void *app_ctx = item->u.side_dynamic.side_dynamic_vla_visitor.app_ctx; - print_attributes("attr", "::", item->u.tgif_dynamic.tgif_dynamic_vla_visitor.attr, item->u.tgif_dynamic.tgif_dynamic_vla_visitor.nr_attr); - printf("%s", item->u.tgif_dynamic.tgif_dynamic_vla_visitor.nr_attr ? ", " : ""); + print_attributes("attr", "::", item->u.side_dynamic.side_dynamic_vla_visitor.attr, item->u.side_dynamic.side_dynamic_vla_visitor.nr_attr); + printf("%s", item->u.side_dynamic.side_dynamic_vla_visitor.nr_attr ? ", " : ""); printf("elements:: "); printf("[ "); - status = item->u.tgif_dynamic.tgif_dynamic_vla_visitor.visitor(&tracer_ctx, app_ctx); + status = item->u.side_dynamic.side_dynamic_vla_visitor.visitor(&tracer_ctx, app_ctx); switch (status) { - case TGIF_VISITOR_STATUS_OK: + case SIDE_VISITOR_STATUS_OK: break; - case TGIF_VISITOR_STATUS_ERROR: + case SIDE_VISITOR_STATUS_ERROR: fprintf(stderr, "ERROR: Visitor error\n"); abort(); } @@ -1606,52 +1606,52 @@ void tracer_print_dynamic_vla_visitor(const struct tgif_arg *item) } static -void tracer_print_dynamic(const struct tgif_arg *item) +void tracer_print_dynamic(const struct side_arg *item) { printf("{ "); switch (item->type) { /* Dynamic basic types */ - case TGIF_TYPE_DYNAMIC_NULL: - tracer_print_type_header("::", item->u.tgif_dynamic.tgif_null.attr, item->u.tgif_dynamic.tgif_null.nr_attr); + case SIDE_TYPE_DYNAMIC_NULL: + tracer_print_type_header("::", item->u.side_dynamic.side_null.attr, item->u.side_dynamic.side_null.nr_attr); printf(""); break; - case TGIF_TYPE_DYNAMIC_BOOL: - tracer_print_type_bool("::", &item->u.tgif_dynamic.tgif_bool.type, &item->u.tgif_dynamic.tgif_bool.value, 0); + case SIDE_TYPE_DYNAMIC_BOOL: + tracer_print_type_bool("::", &item->u.side_dynamic.side_bool.type, &item->u.side_dynamic.side_bool.value, 0); break; - case TGIF_TYPE_DYNAMIC_INTEGER: - tracer_print_type_integer("::", &item->u.tgif_dynamic.tgif_integer.type, &item->u.tgif_dynamic.tgif_integer.value, 0, + case SIDE_TYPE_DYNAMIC_INTEGER: + tracer_print_type_integer("::", &item->u.side_dynamic.side_integer.type, &item->u.side_dynamic.side_integer.value, 0, TRACER_DISPLAY_BASE_10); break; - case TGIF_TYPE_DYNAMIC_BYTE: - tracer_print_type_header("::", item->u.tgif_dynamic.tgif_byte.type.attr, item->u.tgif_dynamic.tgif_byte.type.nr_attr); - printf("0x%" PRIx8, item->u.tgif_dynamic.tgif_byte.value); + case SIDE_TYPE_DYNAMIC_BYTE: + tracer_print_type_header("::", item->u.side_dynamic.side_byte.type.attr, item->u.side_dynamic.side_byte.type.nr_attr); + printf("0x%" PRIx8, item->u.side_dynamic.side_byte.value); break; - case TGIF_TYPE_DYNAMIC_POINTER: - tracer_print_type_integer("::", &item->u.tgif_dynamic.tgif_integer.type, &item->u.tgif_dynamic.tgif_integer.value, 0, + case SIDE_TYPE_DYNAMIC_POINTER: + tracer_print_type_integer("::", &item->u.side_dynamic.side_integer.type, &item->u.side_dynamic.side_integer.value, 0, TRACER_DISPLAY_BASE_16); break; - case TGIF_TYPE_DYNAMIC_FLOAT: - tracer_print_type_float("::", &item->u.tgif_dynamic.tgif_float.type, - &item->u.tgif_dynamic.tgif_float.value); + case SIDE_TYPE_DYNAMIC_FLOAT: + tracer_print_type_float("::", &item->u.side_dynamic.side_float.type, + &item->u.side_dynamic.side_float.value); break; - case TGIF_TYPE_DYNAMIC_STRING: - tracer_print_type_header("::", item->u.tgif_dynamic.tgif_string.type.attr, item->u.tgif_dynamic.tgif_string.type.nr_attr); - tracer_print_string((const char *)(uintptr_t) item->u.tgif_dynamic.tgif_string.value, - item->u.tgif_dynamic.tgif_string.type.unit_size, - item->u.tgif_dynamic.tgif_string.type.byte_order, NULL); + case SIDE_TYPE_DYNAMIC_STRING: + tracer_print_type_header("::", item->u.side_dynamic.side_string.type.attr, item->u.side_dynamic.side_string.type.nr_attr); + tracer_print_string((const char *)(uintptr_t) item->u.side_dynamic.side_string.value, + item->u.side_dynamic.side_string.type.unit_size, + item->u.side_dynamic.side_string.type.byte_order, NULL); break; /* Dynamic compound types */ - case TGIF_TYPE_DYNAMIC_STRUCT: - tracer_print_dynamic_struct(item->u.tgif_dynamic.tgif_dynamic_struct); + case SIDE_TYPE_DYNAMIC_STRUCT: + tracer_print_dynamic_struct(item->u.side_dynamic.side_dynamic_struct); break; - case TGIF_TYPE_DYNAMIC_STRUCT_VISITOR: + case SIDE_TYPE_DYNAMIC_STRUCT_VISITOR: tracer_print_dynamic_struct_visitor(item); break; - case TGIF_TYPE_DYNAMIC_VLA: - tracer_print_dynamic_vla(item->u.tgif_dynamic.tgif_dynamic_vla); + case SIDE_TYPE_DYNAMIC_VLA: + tracer_print_dynamic_vla(item->u.side_dynamic.side_dynamic_vla); break; - case TGIF_TYPE_DYNAMIC_VLA_VISITOR: + case SIDE_TYPE_DYNAMIC_VLA_VISITOR: tracer_print_dynamic_vla_visitor(item); break; default: @@ -1662,52 +1662,52 @@ void tracer_print_dynamic(const struct tgif_arg *item) } static -void tracer_print_static_fields(const struct tgif_event_description *desc, - const struct tgif_arg_vec *tgif_arg_vec, +void tracer_print_static_fields(const struct side_event_description *desc, + const struct side_arg_vec *side_arg_vec, uint32_t *nr_items) { - const struct tgif_arg *sav = tgif_arg_vec->sav; - uint32_t i, tgif_sav_len = tgif_arg_vec->len; + const struct side_arg *sav = side_arg_vec->sav; + uint32_t i, side_sav_len = side_arg_vec->len; printf("provider: %s, event: %s", desc->provider_name, desc->event_name); - if (desc->nr_fields != tgif_sav_len) { + if (desc->nr_fields != side_sav_len) { fprintf(stderr, "ERROR: number of fields mismatch between description and arguments\n"); abort(); } print_attributes(", attr", ":", desc->attr, desc->nr_attr); - printf("%s", tgif_sav_len ? ", fields: [ " : ""); - for (i = 0; i < tgif_sav_len; i++) { + printf("%s", side_sav_len ? ", fields: [ " : ""); + for (i = 0; i < side_sav_len; i++) { printf("%s", i ? ", " : ""); tracer_print_field(&desc->fields[i], &sav[i]); } if (nr_items) *nr_items = i; - if (tgif_sav_len) + if (side_sav_len) printf(" ]"); } static -void tracer_call(const struct tgif_event_description *desc, - const struct tgif_arg_vec *tgif_arg_vec, +void tracer_call(const struct side_event_description *desc, + const struct side_arg_vec *side_arg_vec, void *priv __attribute__((unused))) { uint32_t nr_fields = 0; - tracer_print_static_fields(desc, tgif_arg_vec, &nr_fields); + tracer_print_static_fields(desc, side_arg_vec, &nr_fields); printf("\n"); } static -void tracer_call_variadic(const struct tgif_event_description *desc, - const struct tgif_arg_vec *tgif_arg_vec, - const struct tgif_arg_dynamic_struct *var_struct, +void tracer_call_variadic(const struct side_event_description *desc, + const struct side_arg_vec *side_arg_vec, + const struct side_arg_dynamic_struct *var_struct, void *priv __attribute__((unused))) { uint32_t nr_fields = 0, i, var_struct_len = var_struct->len; - tracer_print_static_fields(desc, tgif_arg_vec, &nr_fields); + tracer_print_static_fields(desc, side_arg_vec, &nr_fields); - if (tgif_unlikely(!(desc->flags & TGIF_EVENT_FLAG_VARIADIC))) { + if (side_unlikely(!(desc->flags & SIDE_EVENT_FLAG_VARIADIC))) { fprintf(stderr, "ERROR: unexpected non-variadic event description\n"); abort(); } @@ -1724,8 +1724,8 @@ void tracer_call_variadic(const struct tgif_event_description *desc, } static -void tracer_event_notification(enum tgif_tracer_notification notif, - struct tgif_event_description **events, uint32_t nr_events, +void tracer_event_notification(enum side_tracer_notification notif, + struct side_event_description **events, uint32_t nr_events, void *priv __attribute__((unused))) { uint32_t i; @@ -1733,32 +1733,32 @@ void tracer_event_notification(enum tgif_tracer_notification notif, printf("----------------------------------------------------------\n"); printf("Tracer notified of events %s\n", - notif == TGIF_TRACER_NOTIFICATION_INSERT_EVENTS ? "inserted" : "removed"); + notif == SIDE_TRACER_NOTIFICATION_INSERT_EVENTS ? "inserted" : "removed"); for (i = 0; i < nr_events; i++) { - struct tgif_event_description *event = events[i]; + struct side_event_description *event = events[i]; /* Skip NULL pointers */ if (!event) continue; printf("provider: %s, event: %s\n", event->provider_name, event->event_name); - if (notif == TGIF_TRACER_NOTIFICATION_INSERT_EVENTS) { - if (event->flags & TGIF_EVENT_FLAG_VARIADIC) { - ret = tgif_tracer_callback_variadic_register(event, tracer_call_variadic, NULL); + if (notif == SIDE_TRACER_NOTIFICATION_INSERT_EVENTS) { + if (event->flags & SIDE_EVENT_FLAG_VARIADIC) { + ret = side_tracer_callback_variadic_register(event, tracer_call_variadic, NULL); if (ret) abort(); } else { - ret = tgif_tracer_callback_register(event, tracer_call, NULL); + ret = side_tracer_callback_register(event, tracer_call, NULL); if (ret) abort(); } } else { - if (event->flags & TGIF_EVENT_FLAG_VARIADIC) { - ret = tgif_tracer_callback_variadic_unregister(event, tracer_call_variadic, NULL); + if (event->flags & SIDE_EVENT_FLAG_VARIADIC) { + ret = side_tracer_callback_variadic_unregister(event, tracer_call_variadic, NULL); if (ret) abort(); } else { - ret = tgif_tracer_callback_unregister(event, tracer_call, NULL); + ret = side_tracer_callback_unregister(event, tracer_call, NULL); if (ret) abort(); } @@ -1772,7 +1772,7 @@ void tracer_init(void); static void tracer_init(void) { - tracer_handle = tgif_tracer_event_notification_register(tracer_event_notification, NULL); + tracer_handle = side_tracer_event_notification_register(tracer_event_notification, NULL); if (!tracer_handle) abort(); } @@ -1782,5 +1782,5 @@ void tracer_exit(void); static void tracer_exit(void) { - tgif_tracer_event_notification_unregister(tracer_handle); + side_tracer_event_notification_unregister(tracer_handle); } diff --git a/tests/Makefile.am b/tests/Makefile.am index b9db5d8..5db6c08 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -8,16 +8,16 @@ SUBDIRS = utils TEST_EXTENSIONS = .tap TAP_LOG_DRIVER_FLAGS = --merge --comments TAP_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' \ - TGIF_TESTS_SRCDIR='$(abs_top_srcdir)/tests' \ - TGIF_TESTS_BUILDDIR='$(abs_top_builddir)/tests' \ + SIDE_TESTS_SRCDIR='$(abs_top_srcdir)/tests' \ + SIDE_TESTS_BUILDDIR='$(abs_top_builddir)/tests' \ $(SHELL) $(srcdir)/utils/tap-driver.sh noinst_PROGRAMS = \ - regression/tgif-rcu-test \ + regression/side-rcu-test \ unit/test -regression_tgif_rcu_test_SOURCES = regression/tgif-rcu-test.c -regression_tgif_rcu_test_LDADD = \ +regression_side_rcu_test_SOURCES = regression/side-rcu-test.c +regression_side_rcu_test_LDADD = \ $(top_builddir)/src/librcu.la \ $(top_builddir)/src/libsmp.la \ $(top_builddir)/tests/utils/libtap.la \ @@ -25,7 +25,7 @@ regression_tgif_rcu_test_LDADD = \ unit_test_SOURCES = unit/test.c unit_test_LDADD = \ - $(top_builddir)/src/libtgif.la \ + $(top_builddir)/src/libside.la \ $(top_builddir)/tests/utils/libtap.la \ $(RSEQ_LIBS) diff --git a/tests/regression/side-rcu-test.c b/tests/regression/side-rcu-test.c new file mode 100644 index 0000000..c8f477f --- /dev/null +++ b/tests/regression/side-rcu-test.c @@ -0,0 +1,237 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright 2022 Mathieu Desnoyers + */ + +#include +#include +#include + +static int nr_reader_threads = 2; +static int nr_writer_threads = 2; +static int duration_s = 10; + +static volatile int start_test, stop_test; + +struct thread_ctx { + pthread_t thread_id; + uint64_t count; +}; + +#include "../../src/rcu.h" + +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; + +static struct side_rcu_gp_state test_rcu_gp; + +#define POISON_VALUE 55 + +struct test_data { + int v; +}; + +static struct test_data *rcu_p; + +static +void *test_reader_thread(void *arg) +{ + struct thread_ctx *thread_ctx = (struct thread_ctx *) arg; + uint64_t count = 0; + + while (!start_test) { } + + while (!stop_test) { + struct side_rcu_read_state rcu_read_state; + struct test_data *p; + int v; + + side_rcu_read_begin(&test_rcu_gp, &rcu_read_state); + p = side_rcu_dereference(rcu_p); + if (p) { + v = p->v; + if (v != 0 && v != 1) { + fprintf(stderr, "Unexpected value: %d\n", v); + abort(); + } + } + side_rcu_read_end(&test_rcu_gp, &rcu_read_state); + count++; + } + thread_ctx->count = count; + return NULL; +} + +static +void *test_writer_thread(void *arg) +{ + struct thread_ctx *thread_ctx = (struct thread_ctx *) arg; + uint64_t count = 0; + + while (!start_test) { } + + while (!stop_test) { + struct test_data *new_data, *old_data; + + new_data = calloc(1, sizeof(struct test_data)); + if (!new_data) + abort(); + + pthread_mutex_lock(&lock); + old_data = rcu_p; + if (old_data) + new_data->v = old_data->v ^ 1; /* 0 or 1 */ + side_rcu_assign_pointer(rcu_p, new_data); + pthread_mutex_unlock(&lock); + + side_rcu_wait_grace_period(&test_rcu_gp); + + if (old_data) { + old_data->v = POISON_VALUE; + free(old_data); + } + count++; + } + thread_ctx->count = count; + return NULL; +} + +static +void print_help(void) +{ + printf("Invoke with command line arguments:\n"); + printf(" -d (test duration in seconds)\n"); + printf(" -r (number of reader threads)\n"); + printf(" -w (number of writers threads)\n"); +} + +static +int parse_cmd_line(int argc, const char **argv) +{ + const char *arg = NULL; + int i, ret = 0; + + for (i = 1; i < argc; i++) { + arg = argv[i]; + + switch (arg[0]) { + case '-': + switch (arg[1]) { + case '\0': + goto error; + case 'd': + if (i == argc - 1) + goto error_extra_arg; + duration_s = atoi(argv[i + 1]); + i++; + break; + case 'r': + if (i == argc - 1) + goto error_extra_arg; + nr_reader_threads = atoi(argv[i + 1]); + i++; + break; + case 'w': + if (i == argc - 1) + goto error_extra_arg; + nr_writer_threads = atoi(argv[i + 1]); + i++; + break; + case 'h': + print_help(); + ret = 1; + break; + } + break; + default: + goto error; + } + + } + return ret; + +error: + fprintf(stderr, "Unknown command line option '%s'\n", arg); + return -1; +error_extra_arg: + fprintf(stderr, "Command line option '%s' requires an extra argument\n", arg); + return -1; +} + +int main(int argc, const char **argv) +{ + struct thread_ctx *reader_ctx; + struct thread_ctx *writer_ctx; + int i, ret; + int sleep_s; + uint64_t read_tot = 0, write_tot = 0; + + ret = parse_cmd_line(argc, argv); + if (ret < 0) + return -1; + if (ret > 0) + return 0; + + sleep_s = duration_s; + side_rcu_gp_init(&test_rcu_gp); + reader_ctx = calloc(nr_reader_threads, sizeof(struct thread_ctx)); + if (!reader_ctx) + abort(); + writer_ctx = calloc(nr_writer_threads, sizeof(struct thread_ctx)); + if (!writer_ctx) + abort(); + + + for (i = 0; i < nr_reader_threads; i++) { + ret = pthread_create(&reader_ctx[i].thread_id, NULL, test_reader_thread, &reader_ctx[i]); + if (ret) { + errno = ret; + perror("pthread_create"); + abort(); + } + } + for (i = 0; i < nr_writer_threads; i++) { + ret = pthread_create(&writer_ctx[i].thread_id, NULL, test_writer_thread, &writer_ctx[i]); + if (ret) { + errno = ret; + perror("pthread_create"); + abort(); + } + } + + start_test = 1; + + while (sleep_s > 0) { + sleep_s = sleep(sleep_s); + } + + stop_test = 1; + + for (i = 0; i < nr_reader_threads; i++) { + void *res; + + ret = pthread_join(reader_ctx[i].thread_id, &res); + if (ret) { + errno = ret; + perror("pthread_join"); + abort(); + } + read_tot += reader_ctx[i].count; + } + for (i = 0; i < nr_writer_threads; i++) { + void *res; + + ret = pthread_join(writer_ctx[i].thread_id, &res); + if (ret) { + errno = ret; + perror("pthread_join"); + abort(); + } + write_tot += writer_ctx[i].count; + } + printf("Summary: duration: %d s, nr_reader_threads: %d, nr_writer_threads: %d, reads: %" PRIu64 ", writes: %" PRIu64 "\n", + duration_s, nr_reader_threads, nr_writer_threads, read_tot, write_tot); + free(reader_ctx); + free(writer_ctx); + side_rcu_gp_exit(&test_rcu_gp); + return 0; +} diff --git a/tests/regression/tgif-rcu-test.c b/tests/regression/tgif-rcu-test.c deleted file mode 100644 index db2d314..0000000 --- a/tests/regression/tgif-rcu-test.c +++ /dev/null @@ -1,237 +0,0 @@ -// SPDX-License-Identifier: MIT -/* - * Copyright 2022 Mathieu Desnoyers - */ - -#include -#include -#include - -static int nr_reader_threads = 2; -static int nr_writer_threads = 2; -static int duration_s = 10; - -static volatile int start_test, stop_test; - -struct thread_ctx { - pthread_t thread_id; - uint64_t count; -}; - -#include "../../src/rcu.h" - -static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; - -static struct tgif_rcu_gp_state test_rcu_gp; - -#define POISON_VALUE 55 - -struct test_data { - int v; -}; - -static struct test_data *rcu_p; - -static -void *test_reader_thread(void *arg) -{ - struct thread_ctx *thread_ctx = (struct thread_ctx *) arg; - uint64_t count = 0; - - while (!start_test) { } - - while (!stop_test) { - struct tgif_rcu_read_state rcu_read_state; - struct test_data *p; - int v; - - tgif_rcu_read_begin(&test_rcu_gp, &rcu_read_state); - p = tgif_rcu_dereference(rcu_p); - if (p) { - v = p->v; - if (v != 0 && v != 1) { - fprintf(stderr, "Unexpected value: %d\n", v); - abort(); - } - } - tgif_rcu_read_end(&test_rcu_gp, &rcu_read_state); - count++; - } - thread_ctx->count = count; - return NULL; -} - -static -void *test_writer_thread(void *arg) -{ - struct thread_ctx *thread_ctx = (struct thread_ctx *) arg; - uint64_t count = 0; - - while (!start_test) { } - - while (!stop_test) { - struct test_data *new_data, *old_data; - - new_data = calloc(1, sizeof(struct test_data)); - if (!new_data) - abort(); - - pthread_mutex_lock(&lock); - old_data = rcu_p; - if (old_data) - new_data->v = old_data->v ^ 1; /* 0 or 1 */ - tgif_rcu_assign_pointer(rcu_p, new_data); - pthread_mutex_unlock(&lock); - - tgif_rcu_wait_grace_period(&test_rcu_gp); - - if (old_data) { - old_data->v = POISON_VALUE; - free(old_data); - } - count++; - } - thread_ctx->count = count; - return NULL; -} - -static -void print_help(void) -{ - printf("Invoke with command line arguments:\n"); - printf(" -d (test duration in seconds)\n"); - printf(" -r (number of reader threads)\n"); - printf(" -w (number of writers threads)\n"); -} - -static -int parse_cmd_line(int argc, const char **argv) -{ - const char *arg = NULL; - int i, ret = 0; - - for (i = 1; i < argc; i++) { - arg = argv[i]; - - switch (arg[0]) { - case '-': - switch (arg[1]) { - case '\0': - goto error; - case 'd': - if (i == argc - 1) - goto error_extra_arg; - duration_s = atoi(argv[i + 1]); - i++; - break; - case 'r': - if (i == argc - 1) - goto error_extra_arg; - nr_reader_threads = atoi(argv[i + 1]); - i++; - break; - case 'w': - if (i == argc - 1) - goto error_extra_arg; - nr_writer_threads = atoi(argv[i + 1]); - i++; - break; - case 'h': - print_help(); - ret = 1; - break; - } - break; - default: - goto error; - } - - } - return ret; - -error: - fprintf(stderr, "Unknown command line option '%s'\n", arg); - return -1; -error_extra_arg: - fprintf(stderr, "Command line option '%s' requires an extra argument\n", arg); - return -1; -} - -int main(int argc, const char **argv) -{ - struct thread_ctx *reader_ctx; - struct thread_ctx *writer_ctx; - int i, ret; - int sleep_s; - uint64_t read_tot = 0, write_tot = 0; - - ret = parse_cmd_line(argc, argv); - if (ret < 0) - return -1; - if (ret > 0) - return 0; - - sleep_s = duration_s; - tgif_rcu_gp_init(&test_rcu_gp); - reader_ctx = calloc(nr_reader_threads, sizeof(struct thread_ctx)); - if (!reader_ctx) - abort(); - writer_ctx = calloc(nr_writer_threads, sizeof(struct thread_ctx)); - if (!writer_ctx) - abort(); - - - for (i = 0; i < nr_reader_threads; i++) { - ret = pthread_create(&reader_ctx[i].thread_id, NULL, test_reader_thread, &reader_ctx[i]); - if (ret) { - errno = ret; - perror("pthread_create"); - abort(); - } - } - for (i = 0; i < nr_writer_threads; i++) { - ret = pthread_create(&writer_ctx[i].thread_id, NULL, test_writer_thread, &writer_ctx[i]); - if (ret) { - errno = ret; - perror("pthread_create"); - abort(); - } - } - - start_test = 1; - - while (sleep_s > 0) { - sleep_s = sleep(sleep_s); - } - - stop_test = 1; - - for (i = 0; i < nr_reader_threads; i++) { - void *res; - - ret = pthread_join(reader_ctx[i].thread_id, &res); - if (ret) { - errno = ret; - perror("pthread_join"); - abort(); - } - read_tot += reader_ctx[i].count; - } - for (i = 0; i < nr_writer_threads; i++) { - void *res; - - ret = pthread_join(writer_ctx[i].thread_id, &res); - if (ret) { - errno = ret; - perror("pthread_join"); - abort(); - } - write_tot += writer_ctx[i].count; - } - printf("Summary: duration: %d s, nr_reader_threads: %d, nr_writer_threads: %d, reads: %" PRIu64 ", writes: %" PRIu64 "\n", - duration_s, nr_reader_threads, nr_writer_threads, read_tot, write_tot); - free(reader_ctx); - free(writer_ctx); - tgif_rcu_gp_exit(&test_rcu_gp); - return 0; -} diff --git a/tests/unit/test.c b/tests/unit/test.c index 3c34952..f258a37 100644 --- a/tests/unit/test.c +++ b/tests/unit/test.c @@ -10,20 +10,20 @@ #include #include -#include +#include /* User code example */ -tgif_static_event(my_provider_event, "myprovider", "myevent", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_u32("abc", tgif_attr_list()), - tgif_field_s64("def", tgif_attr_list()), - tgif_field_pointer("ptr", tgif_attr_list()), - tgif_field_dynamic("dynamic"), - tgif_field_dynamic("dynamic_pointer"), - tgif_field_null("null", tgif_attr_list()), +side_static_event(my_provider_event, "myprovider", "myevent", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_u32("abc", side_attr_list()), + side_field_s64("def", side_attr_list()), + side_field_pointer("ptr", side_attr_list()), + side_field_dynamic("dynamic"), + side_field_dynamic("dynamic_pointer"), + side_field_null("null", side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); static @@ -32,127 +32,127 @@ void test_fields(void) uint32_t uw = 42; int64_t sdw = -500; - tgif_event(my_provider_event, - tgif_arg_list( - tgif_arg_u32(uw), - tgif_arg_s64(sdw), - tgif_arg_pointer((void *) 0x1), - tgif_arg_dynamic_string("zzz", tgif_attr_list()), - tgif_arg_dynamic_pointer((void *) 0x1, tgif_attr_list()), - tgif_arg_null(), + side_event(my_provider_event, + side_arg_list( + side_arg_u32(uw), + side_arg_s64(sdw), + side_arg_pointer((void *) 0x1), + side_arg_dynamic_string("zzz", side_attr_list()), + side_arg_dynamic_pointer((void *) 0x1, side_attr_list()), + side_arg_null(), ) ); } -tgif_hidden_event(my_provider_event_hidden, "myprovider", "myeventhidden", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_u32("abc", tgif_attr_list()), +side_hidden_event(my_provider_event_hidden, "myprovider", "myeventhidden", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_u32("abc", side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); static void test_event_hidden(void) { - tgif_event(my_provider_event_hidden, tgif_arg_list(tgif_arg_u32(2))); + side_event(my_provider_event_hidden, side_arg_list(side_arg_u32(2))); } -tgif_declare_event(my_provider_event_export); +side_declare_event(my_provider_event_export); -tgif_export_event(my_provider_event_export, "myprovider", "myeventexport", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_u32("abc", tgif_attr_list()), +side_export_event(my_provider_event_export, "myprovider", "myeventexport", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_u32("abc", side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); static void test_event_export(void) { - tgif_event(my_provider_event_export, tgif_arg_list(tgif_arg_u32(2))); + side_event(my_provider_event_export, side_arg_list(side_arg_u32(2))); } -tgif_static_event(my_provider_event_struct_literal, "myprovider", "myeventstructliteral", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_struct("structliteral", - tgif_struct_literal( - tgif_field_list( - tgif_field_u32("x", tgif_attr_list()), - tgif_field_s64("y", tgif_attr_list()), +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_attr_list()), + side_field_s64("y", side_attr_list()), ), - tgif_attr_list() + side_attr_list() ) ), - tgif_field_u8("z", tgif_attr_list()), + side_field_u8("z", side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); static void test_struct_literal(void) { - tgif_event_cond(my_provider_event_struct_literal) { - tgif_arg_define_vec(mystruct, tgif_arg_list(tgif_arg_u32(21), tgif_arg_s64(22))); - tgif_event_call(my_provider_event_struct_literal, tgif_arg_list(tgif_arg_struct(&mystruct), tgif_arg_u8(55))); + side_event_cond(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 tgif_define_struct(mystructdef, - tgif_field_list( - tgif_field_u32("x", tgif_attr_list()), - tgif_field_s64("y", tgif_attr_list()), +static side_define_struct(mystructdef, + side_field_list( + side_field_u32("x", side_attr_list()), + side_field_s64("y", side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); -tgif_static_event(my_provider_event_struct, "myprovider", "myeventstruct", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_struct("struct", &mystructdef), - tgif_field_u8("z", tgif_attr_list()), +side_static_event(my_provider_event_struct, "myprovider", "myeventstruct", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_struct("struct", &mystructdef), + side_field_u8("z", side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); static void test_struct(void) { - tgif_event_cond(my_provider_event_struct) { - tgif_arg_define_vec(mystruct, tgif_arg_list(tgif_arg_u32(21), tgif_arg_s64(22))); - tgif_event_call(my_provider_event_struct, tgif_arg_list(tgif_arg_struct(&mystruct), tgif_arg_u8(55))); + side_event_cond(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))); } } -tgif_static_event(my_provider_event_array, "myprovider", "myarray", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_array("arr", tgif_elem(tgif_type_u32(tgif_attr_list())), 3, tgif_attr_list()), - tgif_field_s64("v", tgif_attr_list()), +side_static_event(my_provider_event_array, "myprovider", "myarray", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_array("arr", side_elem(side_type_u32(side_attr_list())), 3, side_attr_list()), + side_field_s64("v", side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); static void test_array(void) { - tgif_event_cond(my_provider_event_array) { - tgif_arg_define_vec(myarray, tgif_arg_list(tgif_arg_u32(1), tgif_arg_u32(2), tgif_arg_u32(3))); - tgif_event_call(my_provider_event_array, tgif_arg_list(tgif_arg_array(&myarray), tgif_arg_s64(42))); + side_event_cond(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))); } } -tgif_static_event(my_provider_event_vla, "myprovider", "myvla", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_vla("vla", tgif_elem(tgif_type_u32(tgif_attr_list())), tgif_attr_list()), - tgif_field_s64("v", tgif_attr_list()), +side_static_event(my_provider_event_vla, "myprovider", "myvla", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_vla("vla", side_elem(side_type_u32(side_attr_list())), side_attr_list()), + side_field_s64("v", side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); static void test_vla(void) { - tgif_event_cond(my_provider_event_vla) { - tgif_arg_define_vec(myvla, tgif_arg_list(tgif_arg_u32(1), tgif_arg_u32(2), tgif_arg_u32(3))); - tgif_event_call(my_provider_event_vla, tgif_arg_list(tgif_arg_vla(&myvla), tgif_arg_s64(42))); + side_event_cond(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))); } } @@ -164,39 +164,39 @@ struct app_visitor_ctx { }; static -enum tgif_visitor_status test_visitor(const struct tgif_tracer_visitor_ctx *tracer_ctx, void *_ctx) +enum side_visitor_status test_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_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 tgif_arg elem = tgif_arg_u32(ctx->ptr[i]); + const struct side_arg elem = side_arg_u32(ctx->ptr[i]); - if (tracer_ctx->write_elem(tracer_ctx, &elem) != TGIF_VISITOR_STATUS_OK) - return TGIF_VISITOR_STATUS_ERROR; + if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) + return SIDE_VISITOR_STATUS_ERROR; } - return TGIF_VISITOR_STATUS_OK; + return SIDE_VISITOR_STATUS_OK; } static uint32_t testarray[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; -tgif_static_event(my_provider_event_vla_visitor, "myprovider", "myvlavisit", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_vla_visitor("vlavisit", tgif_elem(tgif_type_u32(tgif_attr_list())), test_visitor, tgif_attr_list()), - tgif_field_s64("v", tgif_attr_list()), +side_static_event(my_provider_event_vla_visitor, "myprovider", "myvlavisit", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_vla_visitor("vlavisit", side_elem(side_type_u32(side_attr_list())), test_visitor, side_attr_list()), + side_field_s64("v", side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); static void test_vla_visitor(void) { - tgif_event_cond(my_provider_event_vla_visitor) { + side_event_cond(my_provider_event_vla_visitor) { struct app_visitor_ctx ctx = { .ptr = testarray, - .length = TGIF_ARRAY_SIZE(testarray), + .length = SIDE_ARRAY_SIZE(testarray), }; - tgif_event_call(my_provider_event_vla_visitor, tgif_arg_list(tgif_arg_vla_visitor(&ctx), tgif_arg_s64(42))); + side_event_call(my_provider_event_vla_visitor, side_arg_list(side_arg_vla_visitor(&ctx), side_arg_s64(42))); } } @@ -208,18 +208,18 @@ struct app_visitor_2d_inner_ctx { }; static -enum tgif_visitor_status test_inner_visitor(const struct tgif_tracer_visitor_ctx *tracer_ctx, void *_ctx) +enum side_visitor_status test_inner_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_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 tgif_arg elem = tgif_arg_u32(ctx->ptr[i]); + const struct side_arg elem = side_arg_u32(ctx->ptr[i]); - if (tracer_ctx->write_elem(tracer_ctx, &elem) != TGIF_VISITOR_STATUS_OK) - return TGIF_VISITOR_STATUS_ERROR; + if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) + return SIDE_VISITOR_STATUS_ERROR; } - return TGIF_VISITOR_STATUS_OK; + return SIDE_VISITOR_STATUS_OK; } struct app_visitor_2d_outer_ctx { @@ -228,7 +228,7 @@ struct app_visitor_2d_outer_ctx { }; static -enum tgif_visitor_status test_outer_visitor(const struct tgif_tracer_visitor_ctx *tracer_ctx, void *_ctx) +enum side_visitor_status test_outer_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) { struct app_visitor_2d_outer_ctx *ctx = (struct app_visitor_2d_outer_ctx *) _ctx; uint32_t length = ctx->length, i; @@ -238,11 +238,11 @@ enum tgif_visitor_status test_outer_visitor(const struct tgif_tracer_visitor_ctx .ptr = ctx->ptr[i], .length = 2, }; - const struct tgif_arg elem = tgif_arg_vla_visitor(&inner_ctx); - if (tracer_ctx->write_elem(tracer_ctx, &elem) != TGIF_VISITOR_STATUS_OK) - return TGIF_VISITOR_STATUS_ERROR; + const struct side_arg elem = side_arg_vla_visitor(&inner_ctx); + if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) + return SIDE_VISITOR_STATUS_ERROR; } - return TGIF_VISITOR_STATUS_OK; + return SIDE_VISITOR_STATUS_OK; } static uint32_t testarray2d[][2] = { @@ -251,307 +251,307 @@ static uint32_t testarray2d[][2] = { { 55, 66 }, }; -tgif_static_event(my_provider_event_vla_visitor2d, "myprovider", "myvlavisit2d", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_vla_visitor("vlavisit2d", - tgif_elem( - tgif_type_vla_visitor( - tgif_elem(tgif_type_u32(tgif_attr_list())), +side_static_event(my_provider_event_vla_visitor2d, "myprovider", "myvlavisit2d", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_vla_visitor("vlavisit2d", + side_elem( + side_type_vla_visitor( + side_elem(side_type_u32(side_attr_list())), test_inner_visitor, - tgif_attr_list()) - ), test_outer_visitor, tgif_attr_list()), - tgif_field_s64("v", tgif_attr_list()), + side_attr_list()) + ), test_outer_visitor, side_attr_list()), + side_field_s64("v", side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); static void test_vla_visitor_2d(void) { - tgif_event_cond(my_provider_event_vla_visitor2d) { + side_event_cond(my_provider_event_vla_visitor2d) { struct app_visitor_2d_outer_ctx ctx = { .ptr = testarray2d, - .length = TGIF_ARRAY_SIZE(testarray2d), + .length = SIDE_ARRAY_SIZE(testarray2d), }; - tgif_event_call(my_provider_event_vla_visitor2d, tgif_arg_list(tgif_arg_vla_visitor(&ctx), tgif_arg_s64(42))); + side_event_call(my_provider_event_vla_visitor2d, side_arg_list(side_arg_vla_visitor(&ctx), side_arg_s64(42))); } } -tgif_static_event(my_provider_event_dynamic_basic, - "myprovider", "mydynamicbasic", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_dynamic("dynamic"), +side_static_event(my_provider_event_dynamic_basic, + "myprovider", "mydynamicbasic", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_dynamic("dynamic"), ), - tgif_attr_list() + side_attr_list() ); static void test_dynamic_basic_type(void) { - tgif_event(my_provider_event_dynamic_basic, - tgif_arg_list(tgif_arg_dynamic_s16(-33, tgif_attr_list()))); + side_event(my_provider_event_dynamic_basic, + side_arg_list(side_arg_dynamic_s16(-33, side_attr_list()))); } -tgif_static_event(my_provider_event_dynamic_vla, - "myprovider", "mydynamicvla", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_dynamic("dynamic"), +side_static_event(my_provider_event_dynamic_vla, + "myprovider", "mydynamicvla", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_dynamic("dynamic"), ), - tgif_attr_list() + side_attr_list() ); static void test_dynamic_vla(void) { - tgif_arg_dynamic_define_vec(myvla, - tgif_arg_list( - tgif_arg_dynamic_u32(1, tgif_attr_list()), - tgif_arg_dynamic_u32(2, tgif_attr_list()), - tgif_arg_dynamic_u32(3, tgif_attr_list()), + side_arg_dynamic_define_vec(myvla, + side_arg_list( + side_arg_dynamic_u32(1, side_attr_list()), + side_arg_dynamic_u32(2, side_attr_list()), + side_arg_dynamic_u32(3, side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); - tgif_event(my_provider_event_dynamic_vla, - tgif_arg_list(tgif_arg_dynamic_vla(&myvla))); + side_event(my_provider_event_dynamic_vla, + side_arg_list(side_arg_dynamic_vla(&myvla))); } -tgif_static_event(my_provider_event_dynamic_null, - "myprovider", "mydynamicnull", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_dynamic("dynamic"), +side_static_event(my_provider_event_dynamic_null, + "myprovider", "mydynamicnull", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_dynamic("dynamic"), ), - tgif_attr_list() + side_attr_list() ); static void test_dynamic_null(void) { - tgif_event(my_provider_event_dynamic_null, - tgif_arg_list(tgif_arg_dynamic_null(tgif_attr_list()))); + side_event(my_provider_event_dynamic_null, + side_arg_list(side_arg_dynamic_null(side_attr_list()))); } -tgif_static_event(my_provider_event_dynamic_struct, - "myprovider", "mydynamicstruct", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_dynamic("dynamic"), +side_static_event(my_provider_event_dynamic_struct, + "myprovider", "mydynamicstruct", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_dynamic("dynamic"), ), - tgif_attr_list() + side_attr_list() ); static void test_dynamic_struct(void) { - tgif_arg_dynamic_define_struct(mystruct, - tgif_arg_list( - tgif_arg_dynamic_field("a", tgif_arg_dynamic_u32(43, tgif_attr_list())), - tgif_arg_dynamic_field("b", tgif_arg_dynamic_string("zzz", tgif_attr_list())), - tgif_arg_dynamic_field("c", tgif_arg_dynamic_null(tgif_attr_list())), + side_arg_dynamic_define_struct(mystruct, + side_arg_list( + side_arg_dynamic_field("a", side_arg_dynamic_u32(43, side_attr_list())), + side_arg_dynamic_field("b", side_arg_dynamic_string("zzz", side_attr_list())), + side_arg_dynamic_field("c", side_arg_dynamic_null(side_attr_list())), ), - tgif_attr_list() + side_attr_list() ); - tgif_event(my_provider_event_dynamic_struct, - tgif_arg_list(tgif_arg_dynamic_struct(&mystruct))); + side_event(my_provider_event_dynamic_struct, + side_arg_list(side_arg_dynamic_struct(&mystruct))); } -tgif_static_event(my_provider_event_dynamic_nested_struct, - "myprovider", "mydynamicnestedstruct", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_dynamic("dynamic"), +side_static_event(my_provider_event_dynamic_nested_struct, + "myprovider", "mydynamicnestedstruct", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_dynamic("dynamic"), ), - tgif_attr_list() + side_attr_list() ); static void test_dynamic_nested_struct(void) { - tgif_arg_dynamic_define_struct(nested, - tgif_arg_list( - tgif_arg_dynamic_field("a", tgif_arg_dynamic_u32(43, tgif_attr_list())), - tgif_arg_dynamic_field("b", tgif_arg_dynamic_u8(55, tgif_attr_list())), + side_arg_dynamic_define_struct(nested, + side_arg_list( + side_arg_dynamic_field("a", side_arg_dynamic_u32(43, side_attr_list())), + side_arg_dynamic_field("b", side_arg_dynamic_u8(55, side_attr_list())), ), - tgif_attr_list() + side_attr_list() ); - tgif_arg_dynamic_define_struct(nested2, - tgif_arg_list( - tgif_arg_dynamic_field("aa", tgif_arg_dynamic_u64(128, tgif_attr_list())), - tgif_arg_dynamic_field("bb", tgif_arg_dynamic_u16(1, tgif_attr_list())), + side_arg_dynamic_define_struct(nested2, + side_arg_list( + side_arg_dynamic_field("aa", side_arg_dynamic_u64(128, side_attr_list())), + side_arg_dynamic_field("bb", side_arg_dynamic_u16(1, side_attr_list())), ), - tgif_attr_list() + side_attr_list() ); - tgif_arg_dynamic_define_struct(mystruct, - tgif_arg_list( - tgif_arg_dynamic_field("nested", tgif_arg_dynamic_struct(&nested)), - tgif_arg_dynamic_field("nested2", tgif_arg_dynamic_struct(&nested2)), + side_arg_dynamic_define_struct(mystruct, + side_arg_list( + side_arg_dynamic_field("nested", side_arg_dynamic_struct(&nested)), + side_arg_dynamic_field("nested2", side_arg_dynamic_struct(&nested2)), ), - tgif_attr_list() + side_attr_list() ); - tgif_event(my_provider_event_dynamic_nested_struct, - tgif_arg_list(tgif_arg_dynamic_struct(&mystruct))); + side_event(my_provider_event_dynamic_nested_struct, + side_arg_list(side_arg_dynamic_struct(&mystruct))); } -tgif_static_event(my_provider_event_dynamic_vla_struct, - "myprovider", "mydynamicvlastruct", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_dynamic("dynamic"), +side_static_event(my_provider_event_dynamic_vla_struct, + "myprovider", "mydynamicvlastruct", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_dynamic("dynamic"), ), - tgif_attr_list() + side_attr_list() ); static void test_dynamic_vla_struct(void) { - tgif_arg_dynamic_define_struct(nested, - tgif_arg_list( - tgif_arg_dynamic_field("a", tgif_arg_dynamic_u32(43, tgif_attr_list())), - tgif_arg_dynamic_field("b", tgif_arg_dynamic_u8(55, tgif_attr_list())), + side_arg_dynamic_define_struct(nested, + side_arg_list( + side_arg_dynamic_field("a", side_arg_dynamic_u32(43, side_attr_list())), + side_arg_dynamic_field("b", side_arg_dynamic_u8(55, side_attr_list())), ), - tgif_attr_list() + side_attr_list() ); - tgif_arg_dynamic_define_vec(myvla, - tgif_arg_list( - tgif_arg_dynamic_struct(&nested), - tgif_arg_dynamic_struct(&nested), - tgif_arg_dynamic_struct(&nested), - tgif_arg_dynamic_struct(&nested), + side_arg_dynamic_define_vec(myvla, + side_arg_list( + side_arg_dynamic_struct(&nested), + side_arg_dynamic_struct(&nested), + side_arg_dynamic_struct(&nested), + side_arg_dynamic_struct(&nested), ), - tgif_attr_list() + side_attr_list() ); - tgif_event(my_provider_event_dynamic_vla_struct, - tgif_arg_list(tgif_arg_dynamic_vla(&myvla))); + side_event(my_provider_event_dynamic_vla_struct, + side_arg_list(side_arg_dynamic_vla(&myvla))); } -tgif_static_event(my_provider_event_dynamic_struct_vla, - "myprovider", "mydynamicstructvla", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_dynamic("dynamic"), +side_static_event(my_provider_event_dynamic_struct_vla, + "myprovider", "mydynamicstructvla", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_dynamic("dynamic"), ), - tgif_attr_list() + side_attr_list() ); static void test_dynamic_struct_vla(void) { - tgif_arg_dynamic_define_vec(myvla, - tgif_arg_list( - tgif_arg_dynamic_u32(1, tgif_attr_list()), - tgif_arg_dynamic_u32(2, tgif_attr_list()), - tgif_arg_dynamic_u32(3, tgif_attr_list()), + side_arg_dynamic_define_vec(myvla, + side_arg_list( + side_arg_dynamic_u32(1, side_attr_list()), + side_arg_dynamic_u32(2, side_attr_list()), + side_arg_dynamic_u32(3, side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); - tgif_arg_dynamic_define_vec(myvla2, - tgif_arg_list( - tgif_arg_dynamic_u32(4, tgif_attr_list()), - tgif_arg_dynamic_u64(5, tgif_attr_list()), - tgif_arg_dynamic_u32(6, tgif_attr_list()), + side_arg_dynamic_define_vec(myvla2, + side_arg_list( + side_arg_dynamic_u32(4, side_attr_list()), + side_arg_dynamic_u64(5, side_attr_list()), + side_arg_dynamic_u32(6, side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); - tgif_arg_dynamic_define_struct(mystruct, - tgif_arg_list( - tgif_arg_dynamic_field("a", tgif_arg_dynamic_vla(&myvla)), - tgif_arg_dynamic_field("b", tgif_arg_dynamic_vla(&myvla2)), + side_arg_dynamic_define_struct(mystruct, + side_arg_list( + side_arg_dynamic_field("a", side_arg_dynamic_vla(&myvla)), + side_arg_dynamic_field("b", side_arg_dynamic_vla(&myvla2)), ), - tgif_attr_list() + side_attr_list() ); - tgif_event(my_provider_event_dynamic_struct_vla, - tgif_arg_list(tgif_arg_dynamic_struct(&mystruct))); + side_event(my_provider_event_dynamic_struct_vla, + side_arg_list(side_arg_dynamic_struct(&mystruct))); } -tgif_static_event(my_provider_event_dynamic_nested_vla, - "myprovider", "mydynamicnestedvla", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_dynamic("dynamic"), +side_static_event(my_provider_event_dynamic_nested_vla, + "myprovider", "mydynamicnestedvla", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_dynamic("dynamic"), ), - tgif_attr_list() + side_attr_list() ); static void test_dynamic_nested_vla(void) { - tgif_arg_dynamic_define_vec(nestedvla, - tgif_arg_list( - tgif_arg_dynamic_u32(1, tgif_attr_list()), - tgif_arg_dynamic_u16(2, tgif_attr_list()), - tgif_arg_dynamic_u32(3, tgif_attr_list()), + side_arg_dynamic_define_vec(nestedvla, + side_arg_list( + side_arg_dynamic_u32(1, side_attr_list()), + side_arg_dynamic_u16(2, side_attr_list()), + side_arg_dynamic_u32(3, side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); - tgif_arg_dynamic_define_vec(nestedvla2, - tgif_arg_list( - tgif_arg_dynamic_u8(4, tgif_attr_list()), - tgif_arg_dynamic_u32(5, tgif_attr_list()), - tgif_arg_dynamic_u32(6, tgif_attr_list()), + side_arg_dynamic_define_vec(nestedvla2, + side_arg_list( + side_arg_dynamic_u8(4, side_attr_list()), + side_arg_dynamic_u32(5, side_attr_list()), + side_arg_dynamic_u32(6, side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); - tgif_arg_dynamic_define_vec(myvla, - tgif_arg_list( - tgif_arg_dynamic_vla(&nestedvla), - tgif_arg_dynamic_vla(&nestedvla2), + side_arg_dynamic_define_vec(myvla, + side_arg_list( + side_arg_dynamic_vla(&nestedvla), + side_arg_dynamic_vla(&nestedvla2), ), - tgif_attr_list() + side_attr_list() ); - tgif_event(my_provider_event_dynamic_nested_vla, - tgif_arg_list(tgif_arg_dynamic_vla(&myvla))); + side_event(my_provider_event_dynamic_nested_vla, + side_arg_list(side_arg_dynamic_vla(&myvla))); } -tgif_static_event_variadic(my_provider_event_variadic, - "myprovider", "myvariadicevent", TGIF_LOGLEVEL_DEBUG, - tgif_field_list(), - tgif_attr_list() +side_static_event_variadic(my_provider_event_variadic, + "myprovider", "myvariadicevent", SIDE_LOGLEVEL_DEBUG, + side_field_list(), + side_attr_list() ); static void test_variadic(void) { - tgif_event_variadic(my_provider_event_variadic, - tgif_arg_list(), - tgif_arg_list( - tgif_arg_dynamic_field("a", tgif_arg_dynamic_u32(55, tgif_attr_list())), - tgif_arg_dynamic_field("b", tgif_arg_dynamic_s8(-4, tgif_attr_list())), + side_event_variadic(my_provider_event_variadic, + side_arg_list(), + side_arg_list( + side_arg_dynamic_field("a", side_arg_dynamic_u32(55, side_attr_list())), + side_arg_dynamic_field("b", side_arg_dynamic_s8(-4, side_attr_list())), ), - tgif_attr_list() + side_attr_list() ); } -tgif_static_event_variadic(my_provider_event_static_variadic, - "myprovider", "mystaticvariadicevent", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_u32("abc", tgif_attr_list()), - tgif_field_u16("def", tgif_attr_list()), +side_static_event_variadic(my_provider_event_static_variadic, + "myprovider", "mystaticvariadicevent", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_u32("abc", side_attr_list()), + side_field_u16("def", side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); static void test_static_variadic(void) { - tgif_event_variadic(my_provider_event_static_variadic, - tgif_arg_list( - tgif_arg_u32(1), - tgif_arg_u16(2), + side_event_variadic(my_provider_event_static_variadic, + side_arg_list( + side_arg_u32(1), + side_arg_u16(2), ), - tgif_arg_list( - tgif_arg_dynamic_field("a", tgif_arg_dynamic_u32(55, tgif_attr_list())), - tgif_arg_dynamic_field("b", tgif_arg_dynamic_s8(-4, tgif_attr_list())), + side_arg_list( + side_arg_dynamic_field("a", side_arg_dynamic_u32(55, side_attr_list())), + side_arg_dynamic_field("b", side_arg_dynamic_s8(-4, side_attr_list())), ), - tgif_attr_list() + side_attr_list() ); } -tgif_static_event(my_provider_event_bool, "myprovider", "myeventbool", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_bool("a_false", tgif_attr_list()), - tgif_field_bool("b_true", tgif_attr_list()), - tgif_field_bool("c_true", tgif_attr_list()), - tgif_field_bool("d_true", tgif_attr_list()), - tgif_field_bool("e_true", tgif_attr_list()), - tgif_field_bool("f_false", tgif_attr_list()), - tgif_field_bool("g_true", tgif_attr_list()), +side_static_event(my_provider_event_bool, "myprovider", "myeventbool", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_bool("a_false", side_attr_list()), + side_field_bool("b_true", side_attr_list()), + side_field_bool("c_true", side_attr_list()), + side_field_bool("d_true", side_attr_list()), + side_field_bool("e_true", side_attr_list()), + side_field_bool("f_false", side_attr_list()), + side_field_bool("g_true", side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); static @@ -565,46 +565,46 @@ void test_bool(void) bool f = false; uint32_t g = 256; - tgif_event(my_provider_event_bool, - tgif_arg_list( - tgif_arg_bool(a), - tgif_arg_bool(b), - tgif_arg_bool(c), - tgif_arg_bool(d), - tgif_arg_bool(e), - tgif_arg_bool(f), - tgif_arg_bool(g), + side_event(my_provider_event_bool, + side_arg_list( + side_arg_bool(a), + side_arg_bool(b), + side_arg_bool(c), + side_arg_bool(d), + side_arg_bool(e), + side_arg_bool(f), + side_arg_bool(g), ) ); } -tgif_static_event_variadic(my_provider_event_dynamic_bool, - "myprovider", "mydynamicbool", TGIF_LOGLEVEL_DEBUG, - tgif_field_list(), - tgif_attr_list() +side_static_event_variadic(my_provider_event_dynamic_bool, + "myprovider", "mydynamicbool", SIDE_LOGLEVEL_DEBUG, + side_field_list(), + side_attr_list() ); static void test_dynamic_bool(void) { - tgif_event_variadic(my_provider_event_dynamic_bool, - tgif_arg_list(), - tgif_arg_list( - tgif_arg_dynamic_field("a_true", tgif_arg_dynamic_bool(55, tgif_attr_list())), - tgif_arg_dynamic_field("b_true", tgif_arg_dynamic_bool(-4, tgif_attr_list())), - tgif_arg_dynamic_field("c_false", tgif_arg_dynamic_bool(0, tgif_attr_list())), - tgif_arg_dynamic_field("d_true", tgif_arg_dynamic_bool(256, tgif_attr_list())), + side_event_variadic(my_provider_event_dynamic_bool, + side_arg_list(), + side_arg_list( + side_arg_dynamic_field("a_true", side_arg_dynamic_bool(55, side_attr_list())), + side_arg_dynamic_field("b_true", side_arg_dynamic_bool(-4, side_attr_list())), + side_arg_dynamic_field("c_false", side_arg_dynamic_bool(0, side_attr_list())), + side_arg_dynamic_field("d_true", side_arg_dynamic_bool(256, side_attr_list())), ), - tgif_attr_list() + side_attr_list() ); } -tgif_static_event(my_provider_event_dynamic_vla_visitor, - "myprovider", "mydynamicvlavisitor", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_dynamic("dynamic"), +side_static_event(my_provider_event_dynamic_vla_visitor, + "myprovider", "mydynamicvlavisitor", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_dynamic("dynamic"), ), - tgif_attr_list() + side_attr_list() ); struct app_dynamic_vla_visitor_ctx { @@ -613,17 +613,17 @@ struct app_dynamic_vla_visitor_ctx { }; static -enum tgif_visitor_status test_dynamic_vla_visitor(const struct tgif_tracer_visitor_ctx *tracer_ctx, void *_ctx) +enum side_visitor_status test_dynamic_vla_visitor(const struct side_tracer_visitor_ctx *tracer_ctx, void *_ctx) { struct app_dynamic_vla_visitor_ctx *ctx = (struct app_dynamic_vla_visitor_ctx *) _ctx; uint32_t length = ctx->length, i; for (i = 0; i < length; i++) { - const struct tgif_arg elem = tgif_arg_dynamic_u32(ctx->ptr[i], tgif_attr_list()); - if (tracer_ctx->write_elem(tracer_ctx, &elem) != TGIF_VISITOR_STATUS_OK) - return TGIF_VISITOR_STATUS_ERROR; + const struct side_arg elem = side_arg_dynamic_u32(ctx->ptr[i], side_attr_list()); + if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK) + return SIDE_VISITOR_STATUS_ERROR; } - return TGIF_VISITOR_STATUS_OK; + return SIDE_VISITOR_STATUS_OK; } static uint32_t testarray_dynamic_vla[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; @@ -631,25 +631,25 @@ static uint32_t testarray_dynamic_vla[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; static void test_dynamic_vla_with_visitor(void) { - tgif_event_cond(my_provider_event_dynamic_vla_visitor) { + side_event_cond(my_provider_event_dynamic_vla_visitor) { struct app_dynamic_vla_visitor_ctx ctx = { .ptr = testarray_dynamic_vla, - .length = TGIF_ARRAY_SIZE(testarray_dynamic_vla), + .length = SIDE_ARRAY_SIZE(testarray_dynamic_vla), }; - tgif_event_call(my_provider_event_dynamic_vla_visitor, - tgif_arg_list( - tgif_arg_dynamic_vla_visitor(test_dynamic_vla_visitor, &ctx, tgif_attr_list()) + side_event_call(my_provider_event_dynamic_vla_visitor, + side_arg_list( + side_arg_dynamic_vla_visitor(test_dynamic_vla_visitor, &ctx, side_attr_list()) ) ); } } -tgif_static_event(my_provider_event_dynamic_struct_visitor, - "myprovider", "mydynamicstructvisitor", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_dynamic("dynamic"), +side_static_event(my_provider_event_dynamic_struct_visitor, + "myprovider", "mydynamicstructvisitor", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_dynamic("dynamic"), ), - tgif_attr_list() + side_attr_list() ); struct struct_visitor_pair { @@ -663,20 +663,20 @@ struct app_dynamic_struct_visitor_ctx { }; static -enum tgif_visitor_status test_dynamic_struct_visitor(const struct tgif_tracer_dynamic_struct_visitor_ctx *tracer_ctx, void *_ctx) +enum side_visitor_status test_dynamic_struct_visitor(const struct side_tracer_dynamic_struct_visitor_ctx *tracer_ctx, void *_ctx) { struct app_dynamic_struct_visitor_ctx *ctx = (struct app_dynamic_struct_visitor_ctx *) _ctx; uint32_t length = ctx->length, i; for (i = 0; i < length; i++) { - struct tgif_arg_dynamic_field dynamic_field = { + struct side_arg_dynamic_field dynamic_field = { .field_name = ctx->ptr[i].name, - .elem = tgif_arg_dynamic_u32(ctx->ptr[i].value, tgif_attr_list()), + .elem = side_arg_dynamic_u32(ctx->ptr[i].value, side_attr_list()), }; - if (tracer_ctx->write_field(tracer_ctx, &dynamic_field) != TGIF_VISITOR_STATUS_OK) - return TGIF_VISITOR_STATUS_ERROR; + if (tracer_ctx->write_field(tracer_ctx, &dynamic_field) != SIDE_VISITOR_STATUS_OK) + return SIDE_VISITOR_STATUS_ERROR; } - return TGIF_VISITOR_STATUS_OK; + return SIDE_VISITOR_STATUS_OK; } static struct struct_visitor_pair testarray_dynamic_struct[] = { @@ -689,187 +689,187 @@ static struct struct_visitor_pair testarray_dynamic_struct[] = { static void test_dynamic_struct_with_visitor(void) { - tgif_event_cond(my_provider_event_dynamic_struct_visitor) { + side_event_cond(my_provider_event_dynamic_struct_visitor) { struct app_dynamic_struct_visitor_ctx ctx = { .ptr = testarray_dynamic_struct, - .length = TGIF_ARRAY_SIZE(testarray_dynamic_struct), + .length = SIDE_ARRAY_SIZE(testarray_dynamic_struct), }; - tgif_event_call(my_provider_event_dynamic_struct_visitor, - tgif_arg_list( - tgif_arg_dynamic_struct_visitor(test_dynamic_struct_visitor, &ctx, tgif_attr_list()) + side_event_call(my_provider_event_dynamic_struct_visitor, + side_arg_list( + side_arg_dynamic_struct_visitor(test_dynamic_struct_visitor, &ctx, side_attr_list()) ) ); } } -tgif_static_event(my_provider_event_user_attribute, "myprovider", "myevent_user_attribute", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_u32("abc", tgif_attr_list()), - tgif_field_s64("def", tgif_attr_list()), +side_static_event(my_provider_event_user_attribute, "myprovider", "myevent_user_attribute", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_u32("abc", side_attr_list()), + side_field_s64("def", side_attr_list()), ), - tgif_attr_list( - tgif_attr("user_attribute_a", tgif_attr_string("val1")), - tgif_attr("user_attribute_b", tgif_attr_string("val2")), + side_attr_list( + side_attr("user_attribute_a", side_attr_string("val1")), + side_attr("user_attribute_b", side_attr_string("val2")), ) ); static void test_event_user_attribute(void) { - tgif_event(my_provider_event_user_attribute, tgif_arg_list(tgif_arg_u32(1), tgif_arg_s64(2))); + side_event(my_provider_event_user_attribute, side_arg_list(side_arg_u32(1), side_arg_s64(2))); } -tgif_static_event(my_provider_field_user_attribute, "myprovider", "myevent_field_attribute", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_u32("abc", - tgif_attr_list( - tgif_attr("user_attribute_a", tgif_attr_string("val1")), - tgif_attr("user_attribute_b", tgif_attr_u32(2)), +side_static_event(my_provider_field_user_attribute, "myprovider", "myevent_field_attribute", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_u32("abc", + side_attr_list( + side_attr("user_attribute_a", side_attr_string("val1")), + side_attr("user_attribute_b", side_attr_u32(2)), ) ), - tgif_field_s64("def", - tgif_attr_list( - tgif_attr("user_attribute_c", tgif_attr_string("val3")), - tgif_attr("user_attribute_d", tgif_attr_s64(-5)), + side_field_s64("def", + side_attr_list( + side_attr("user_attribute_c", side_attr_string("val3")), + side_attr("user_attribute_d", side_attr_s64(-5)), ) ), ), - tgif_attr_list() + side_attr_list() ); static void test_field_user_attribute(void) { - tgif_event(my_provider_field_user_attribute, tgif_arg_list(tgif_arg_u32(1), tgif_arg_s64(2))); + side_event(my_provider_field_user_attribute, side_arg_list(side_arg_u32(1), side_arg_s64(2))); } -tgif_static_event_variadic(my_provider_event_variadic_attr, - "myprovider", "myvariadiceventattr", TGIF_LOGLEVEL_DEBUG, - tgif_field_list(), - tgif_attr_list() +side_static_event_variadic(my_provider_event_variadic_attr, + "myprovider", "myvariadiceventattr", SIDE_LOGLEVEL_DEBUG, + side_field_list(), + side_attr_list() ); static void test_variadic_attr(void) { - tgif_event_variadic(my_provider_event_variadic_attr, - tgif_arg_list(), - tgif_arg_list( - tgif_arg_dynamic_field("a", - tgif_arg_dynamic_u32(55, - tgif_attr_list( - tgif_attr("user_attribute_c", tgif_attr_string("valX")), - tgif_attr("user_attribute_d", tgif_attr_u8(55)), + side_event_variadic(my_provider_event_variadic_attr, + side_arg_list(), + side_arg_list( + side_arg_dynamic_field("a", + side_arg_dynamic_u32(55, + side_attr_list( + side_attr("user_attribute_c", side_attr_string("valX")), + side_attr("user_attribute_d", side_attr_u8(55)), ) ) ), - tgif_arg_dynamic_field("b", - tgif_arg_dynamic_s8(-4, - tgif_attr_list( - tgif_attr("X", tgif_attr_u8(1)), - tgif_attr("Y", tgif_attr_s8(2)), + side_arg_dynamic_field("b", + side_arg_dynamic_s8(-4, + side_attr_list( + side_attr("X", side_attr_u8(1)), + side_attr("Y", side_attr_s8(2)), ) ) ), ), - tgif_attr_list() + side_attr_list() ); } -tgif_static_event_variadic(my_provider_event_variadic_vla_attr, - "myprovider", "myvariadiceventvlaattr", TGIF_LOGLEVEL_DEBUG, - tgif_field_list(), - tgif_attr_list() +side_static_event_variadic(my_provider_event_variadic_vla_attr, + "myprovider", "myvariadiceventvlaattr", SIDE_LOGLEVEL_DEBUG, + side_field_list(), + side_attr_list() ); static void test_variadic_vla_attr(void) { - tgif_arg_dynamic_define_vec(myvla, - tgif_arg_list( - tgif_arg_dynamic_u32(1, - tgif_attr_list( - tgif_attr("Z", tgif_attr_u8(0)), - tgif_attr("A", tgif_attr_u8(123)), + side_arg_dynamic_define_vec(myvla, + side_arg_list( + side_arg_dynamic_u32(1, + side_attr_list( + side_attr("Z", side_attr_u8(0)), + side_attr("A", side_attr_u8(123)), ) ), - tgif_arg_dynamic_u32(2, tgif_attr_list()), - tgif_arg_dynamic_u32(3, tgif_attr_list()), + side_arg_dynamic_u32(2, side_attr_list()), + side_arg_dynamic_u32(3, side_attr_list()), ), - tgif_attr_list( - tgif_attr("X", tgif_attr_u8(1)), - tgif_attr("Y", tgif_attr_u8(2)), + side_attr_list( + side_attr("X", side_attr_u8(1)), + side_attr("Y", side_attr_u8(2)), ) ); - tgif_event_variadic(my_provider_event_variadic_vla_attr, - tgif_arg_list(), - tgif_arg_list( - tgif_arg_dynamic_field("a", tgif_arg_dynamic_vla(&myvla)), + side_event_variadic(my_provider_event_variadic_vla_attr, + side_arg_list(), + side_arg_list( + side_arg_dynamic_field("a", side_arg_dynamic_vla(&myvla)), ), - tgif_attr_list() + side_attr_list() ); } -tgif_static_event_variadic(my_provider_event_variadic_struct_attr, - "myprovider", "myvariadiceventstructattr", TGIF_LOGLEVEL_DEBUG, - tgif_field_list(), - tgif_attr_list() +side_static_event_variadic(my_provider_event_variadic_struct_attr, + "myprovider", "myvariadiceventstructattr", SIDE_LOGLEVEL_DEBUG, + side_field_list(), + side_attr_list() ); static void test_variadic_struct_attr(void) { - tgif_event_cond(my_provider_event_variadic_struct_attr) { - tgif_arg_dynamic_define_struct(mystruct, - tgif_arg_list( - tgif_arg_dynamic_field("a", - tgif_arg_dynamic_u32(43, - tgif_attr_list( - tgif_attr("A", tgif_attr_bool(true)), + side_event_cond(my_provider_event_variadic_struct_attr) { + side_arg_dynamic_define_struct(mystruct, + side_arg_list( + side_arg_dynamic_field("a", + side_arg_dynamic_u32(43, + side_attr_list( + side_attr("A", side_attr_bool(true)), ) ) ), - tgif_arg_dynamic_field("b", tgif_arg_dynamic_u8(55, tgif_attr_list())), + side_arg_dynamic_field("b", side_arg_dynamic_u8(55, side_attr_list())), ), - tgif_attr_list( - tgif_attr("X", tgif_attr_u8(1)), - tgif_attr("Y", tgif_attr_u8(2)), + side_attr_list( + side_attr("X", side_attr_u8(1)), + side_attr("Y", side_attr_u8(2)), ) ); - tgif_event_call_variadic(my_provider_event_variadic_struct_attr, - tgif_arg_list(), - tgif_arg_list( - tgif_arg_dynamic_field("a", tgif_arg_dynamic_struct(&mystruct)), + 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)), ), - tgif_attr_list() + side_attr_list() ); } } -tgif_static_event(my_provider_event_float, "myprovider", "myeventfloat", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( +side_static_event(my_provider_event_float, "myprovider", "myeventfloat", SIDE_LOGLEVEL_DEBUG, + side_field_list( #if __HAVE_FLOAT16 - tgif_field_float_binary16("binary16", tgif_attr_list()), - tgif_field_float_binary16_le("binary16_le", tgif_attr_list()), - tgif_field_float_binary16_be("binary16_be", tgif_attr_list()), + side_field_float_binary16("binary16", side_attr_list()), + side_field_float_binary16_le("binary16_le", side_attr_list()), + side_field_float_binary16_be("binary16_be", side_attr_list()), #endif #if __HAVE_FLOAT32 - tgif_field_float_binary32("binary32", tgif_attr_list()), - tgif_field_float_binary32_le("binary32_le", tgif_attr_list()), - tgif_field_float_binary32_be("binary32_be", tgif_attr_list()), + side_field_float_binary32("binary32", side_attr_list()), + side_field_float_binary32_le("binary32_le", side_attr_list()), + side_field_float_binary32_be("binary32_be", side_attr_list()), #endif #if __HAVE_FLOAT64 - tgif_field_float_binary64("binary64", tgif_attr_list()), - tgif_field_float_binary64_le("binary64_le", tgif_attr_list()), - tgif_field_float_binary64_be("binary64_be", tgif_attr_list()), + side_field_float_binary64("binary64", side_attr_list()), + side_field_float_binary64_le("binary64_le", side_attr_list()), + side_field_float_binary64_be("binary64_be", side_attr_list()), #endif #if __HAVE_FLOAT128 - tgif_field_float_binary128("binary128", tgif_attr_list()), - tgif_field_float_binary128_le("binary128_le", tgif_attr_list()), - tgif_field_float_binary128_be("binary128_be", tgif_attr_list()), + side_field_float_binary128("binary128", side_attr_list()), + side_field_float_binary128_le("binary128_le", side_attr_list()), + side_field_float_binary128_be("binary128_be", side_attr_list()), #endif ), - tgif_attr_list() + side_attr_list() ); static @@ -909,68 +909,68 @@ void test_float(void) #endif #if __HAVE_FLOAT16 - float16.u = tgif_bswap_16(float16.u); + float16.u = side_bswap_16(float16.u); #endif #if __HAVE_FLOAT32 - float32.u = tgif_bswap_32(float32.u); + float32.u = side_bswap_32(float32.u); #endif #if __HAVE_FLOAT64 - float64.u = tgif_bswap_64(float64.u); + float64.u = side_bswap_64(float64.u); #endif #if __HAVE_FLOAT128 - tgif_bswap_128p(float128.arr); + side_bswap_128p(float128.arr); #endif - tgif_event(my_provider_event_float, - tgif_arg_list( + side_event(my_provider_event_float, + side_arg_list( #if __HAVE_FLOAT16 - tgif_arg_float_binary16(1.1), -# if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN - tgif_arg_float_binary16(1.1), - tgif_arg_float_binary16(float16.f), + side_arg_float_binary16(1.1), +# if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN + side_arg_float_binary16(1.1), + side_arg_float_binary16(float16.f), # else - tgif_arg_float_binary16(float16.f), - tgif_arg_float_binary16(1.1), + side_arg_float_binary16(float16.f), + side_arg_float_binary16(1.1), # endif #endif #if __HAVE_FLOAT32 - tgif_arg_float_binary32(2.2), -# if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN - tgif_arg_float_binary32(2.2), - tgif_arg_float_binary32(float32.f), + side_arg_float_binary32(2.2), +# if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN + side_arg_float_binary32(2.2), + side_arg_float_binary32(float32.f), # else - tgif_arg_float_binary32(float32.f), - tgif_arg_float_binary32(2.2), + side_arg_float_binary32(float32.f), + side_arg_float_binary32(2.2), # endif #endif #if __HAVE_FLOAT64 - tgif_arg_float_binary64(3.3), -# if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN - tgif_arg_float_binary64(3.3), - tgif_arg_float_binary64(float64.f), + side_arg_float_binary64(3.3), +# if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN + side_arg_float_binary64(3.3), + side_arg_float_binary64(float64.f), # else - tgif_arg_float_binary64(float64.f), - tgif_arg_float_binary64(3.3), + side_arg_float_binary64(float64.f), + side_arg_float_binary64(3.3), # endif #endif #if __HAVE_FLOAT128 - tgif_arg_float_binary128(4.4), -# if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN - tgif_arg_float_binary128(4.4), - tgif_arg_float_binary128(float128.f), + side_arg_float_binary128(4.4), +# if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN + side_arg_float_binary128(4.4), + side_arg_float_binary128(float128.f), # else - tgif_arg_float_binary128(float128.f), - tgif_arg_float_binary128(4.4), + side_arg_float_binary128(float128.f), + side_arg_float_binary128(4.4), # endif #endif ) ); } -tgif_static_event_variadic(my_provider_event_variadic_float, - "myprovider", "myvariadicfloat", TGIF_LOGLEVEL_DEBUG, - tgif_field_list(), - tgif_attr_list() +side_static_event_variadic(my_provider_event_variadic_float, + "myprovider", "myvariadicfloat", SIDE_LOGLEVEL_DEBUG, + side_field_list(), + side_attr_list() ); static @@ -1010,411 +1010,411 @@ void test_variadic_float(void) #endif #if __HAVE_FLOAT16 - float16.u = tgif_bswap_16(float16.u); + float16.u = side_bswap_16(float16.u); #endif #if __HAVE_FLOAT32 - float32.u = tgif_bswap_32(float32.u); + float32.u = side_bswap_32(float32.u); #endif #if __HAVE_FLOAT64 - float64.u = tgif_bswap_64(float64.u); + float64.u = side_bswap_64(float64.u); #endif #if __HAVE_FLOAT128 - tgif_bswap_128p(float128.arr); + side_bswap_128p(float128.arr); #endif - tgif_event_variadic(my_provider_event_variadic_float, - tgif_arg_list(), - tgif_arg_list( + side_event_variadic(my_provider_event_variadic_float, + side_arg_list(), + side_arg_list( #if __HAVE_FLOAT16 - tgif_arg_dynamic_field("binary16", tgif_arg_dynamic_float_binary16(1.1, tgif_attr_list())), -# if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN - tgif_arg_dynamic_field("binary16_le", tgif_arg_dynamic_float_binary16_le(1.1, tgif_attr_list())), - tgif_arg_dynamic_field("binary16_be", tgif_arg_dynamic_float_binary16_be(float16.f, tgif_attr_list())), + side_arg_dynamic_field("binary16", side_arg_dynamic_float_binary16(1.1, side_attr_list())), +# if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN + side_arg_dynamic_field("binary16_le", side_arg_dynamic_float_binary16_le(1.1, side_attr_list())), + side_arg_dynamic_field("binary16_be", side_arg_dynamic_float_binary16_be(float16.f, side_attr_list())), # else - tgif_arg_dynamic_field("binary16_le", tgif_arg_dynamic_float_binary16_le(float16.f, tgif_attr_list())), - tgif_arg_dynamic_field("binary16_be", tgif_arg_dynamic_float_binary16_be(1.1, tgif_attr_list())), + side_arg_dynamic_field("binary16_le", side_arg_dynamic_float_binary16_le(float16.f, side_attr_list())), + side_arg_dynamic_field("binary16_be", side_arg_dynamic_float_binary16_be(1.1, side_attr_list())), # endif #endif #if __HAVE_FLOAT32 - tgif_arg_dynamic_field("binary32", tgif_arg_dynamic_float_binary32(2.2, tgif_attr_list())), -# if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN - tgif_arg_dynamic_field("binary32_le", tgif_arg_dynamic_float_binary32_le(2.2, tgif_attr_list())), - tgif_arg_dynamic_field("binary32_be", tgif_arg_dynamic_float_binary32_be(float32.f, tgif_attr_list())), + side_arg_dynamic_field("binary32", side_arg_dynamic_float_binary32(2.2, side_attr_list())), +# if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN + side_arg_dynamic_field("binary32_le", side_arg_dynamic_float_binary32_le(2.2, side_attr_list())), + side_arg_dynamic_field("binary32_be", side_arg_dynamic_float_binary32_be(float32.f, side_attr_list())), # else - tgif_arg_dynamic_field("binary32_le", tgif_arg_dynamic_float_binary32_le(float32.f, tgif_attr_list())), - tgif_arg_dynamic_field("binary32_be", tgif_arg_dynamic_float_binary32_be(2.2, tgif_attr_list())), + side_arg_dynamic_field("binary32_le", side_arg_dynamic_float_binary32_le(float32.f, side_attr_list())), + side_arg_dynamic_field("binary32_be", side_arg_dynamic_float_binary32_be(2.2, side_attr_list())), # endif #endif #if __HAVE_FLOAT64 - tgif_arg_dynamic_field("binary64", tgif_arg_dynamic_float_binary64(3.3, tgif_attr_list())), -# if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN - tgif_arg_dynamic_field("binary64_le", tgif_arg_dynamic_float_binary64_le(3.3, tgif_attr_list())), - tgif_arg_dynamic_field("binary64_be", tgif_arg_dynamic_float_binary64_be(float64.f, tgif_attr_list())), + side_arg_dynamic_field("binary64", side_arg_dynamic_float_binary64(3.3, side_attr_list())), +# if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN + side_arg_dynamic_field("binary64_le", side_arg_dynamic_float_binary64_le(3.3, side_attr_list())), + side_arg_dynamic_field("binary64_be", side_arg_dynamic_float_binary64_be(float64.f, side_attr_list())), # else - tgif_arg_dynamic_field("binary64_le", tgif_arg_dynamic_float_binary64_le(float64.f, tgif_attr_list())), - tgif_arg_dynamic_field("binary64_be", tgif_arg_dynamic_float_binary64_be(3.3, tgif_attr_list())), + side_arg_dynamic_field("binary64_le", side_arg_dynamic_float_binary64_le(float64.f, side_attr_list())), + side_arg_dynamic_field("binary64_be", side_arg_dynamic_float_binary64_be(3.3, side_attr_list())), # endif #endif #if __HAVE_FLOAT128 - tgif_arg_dynamic_field("binary128", tgif_arg_dynamic_float_binary128(4.4, tgif_attr_list())), -# if TGIF_FLOAT_WORD_ORDER == TGIF_LITTLE_ENDIAN - tgif_arg_dynamic_field("binary128_le", tgif_arg_dynamic_float_binary128_le(4.4, tgif_attr_list())), - tgif_arg_dynamic_field("binary128_be", tgif_arg_dynamic_float_binary128_be(float128.f, tgif_attr_list())), + side_arg_dynamic_field("binary128", side_arg_dynamic_float_binary128(4.4, side_attr_list())), +# if SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN + side_arg_dynamic_field("binary128_le", side_arg_dynamic_float_binary128_le(4.4, side_attr_list())), + side_arg_dynamic_field("binary128_be", side_arg_dynamic_float_binary128_be(float128.f, side_attr_list())), # else - tgif_arg_dynamic_field("binary128_le", tgif_arg_dynamic_float_binary128_le(float128.f, tgif_attr_list())), - tgif_arg_dynamic_field("binary128_be", tgif_arg_dynamic_float_binary128_be(4.4, tgif_attr_list())), + side_arg_dynamic_field("binary128_le", side_arg_dynamic_float_binary128_le(float128.f, side_attr_list())), + side_arg_dynamic_field("binary128_be", side_arg_dynamic_float_binary128_be(4.4, side_attr_list())), # endif #endif ), - tgif_attr_list() + side_attr_list() ); } -static tgif_define_enum(myenum, - tgif_enum_mapping_list( - tgif_enum_mapping_range("one-ten", 1, 10), - tgif_enum_mapping_range("100-200", 100, 200), - tgif_enum_mapping_value("200", 200), - tgif_enum_mapping_value("300", 300), +static side_define_enum(myenum, + side_enum_mapping_list( + side_enum_mapping_range("one-ten", 1, 10), + side_enum_mapping_range("100-200", 100, 200), + side_enum_mapping_value("200", 200), + side_enum_mapping_value("300", 300), ), - tgif_attr_list() + side_attr_list() ); -tgif_static_event(my_provider_event_enum, "myprovider", "myeventenum", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_enum("5", &myenum, tgif_elem(tgif_type_u32(tgif_attr_list()))), - tgif_field_enum("400", &myenum, tgif_elem(tgif_type_u64(tgif_attr_list()))), - tgif_field_enum("200", &myenum, tgif_elem(tgif_type_u8(tgif_attr_list()))), - tgif_field_enum("-100", &myenum, tgif_elem(tgif_type_s8(tgif_attr_list()))), - tgif_field_enum("6_be", &myenum, tgif_elem(tgif_type_u32_be(tgif_attr_list()))), - tgif_field_enum("6_le", &myenum, tgif_elem(tgif_type_u32_le(tgif_attr_list()))), +side_static_event(my_provider_event_enum, "myprovider", "myeventenum", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_enum("5", &myenum, side_elem(side_type_u32(side_attr_list()))), + side_field_enum("400", &myenum, side_elem(side_type_u64(side_attr_list()))), + side_field_enum("200", &myenum, side_elem(side_type_u8(side_attr_list()))), + side_field_enum("-100", &myenum, side_elem(side_type_s8(side_attr_list()))), + side_field_enum("6_be", &myenum, side_elem(side_type_u32_be(side_attr_list()))), + side_field_enum("6_le", &myenum, side_elem(side_type_u32_le(side_attr_list()))), ), - tgif_attr_list() + side_attr_list() ); static void test_enum(void) { - tgif_event(my_provider_event_enum, - tgif_arg_list( - tgif_arg_u32(5), - tgif_arg_u64(400), - tgif_arg_u8(200), - tgif_arg_s8(-100), -#if TGIF_BYTE_ORDER == TGIF_LITTLE_ENDIAN - tgif_arg_u32(tgif_bswap_32(6)), - tgif_arg_u32(6), + side_event(my_provider_event_enum, + side_arg_list( + side_arg_u32(5), + side_arg_u64(400), + side_arg_u8(200), + side_arg_s8(-100), +#if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN + side_arg_u32(side_bswap_32(6)), + side_arg_u32(6), #else - tgif_arg_u32(6), - tgif_arg_u32(tgif_bswap_32(6)), + side_arg_u32(6), + side_arg_u32(side_bswap_32(6)), #endif ) ); } /* A bitmap enum maps bits to labels. */ -static tgif_define_enum_bitmap(myenum_bitmap, - tgif_enum_bitmap_mapping_list( - tgif_enum_bitmap_mapping_value("0", 0), - tgif_enum_bitmap_mapping_range("1-2", 1, 2), - tgif_enum_bitmap_mapping_range("2-4", 2, 4), - tgif_enum_bitmap_mapping_value("3", 3), - tgif_enum_bitmap_mapping_value("30", 30), - tgif_enum_bitmap_mapping_value("63", 63), - tgif_enum_bitmap_mapping_range("158-160", 158, 160), - tgif_enum_bitmap_mapping_value("159", 159), - tgif_enum_bitmap_mapping_range("500-700", 500, 700), +static side_define_enum_bitmap(myenum_bitmap, + side_enum_bitmap_mapping_list( + side_enum_bitmap_mapping_value("0", 0), + side_enum_bitmap_mapping_range("1-2", 1, 2), + side_enum_bitmap_mapping_range("2-4", 2, 4), + side_enum_bitmap_mapping_value("3", 3), + side_enum_bitmap_mapping_value("30", 30), + side_enum_bitmap_mapping_value("63", 63), + side_enum_bitmap_mapping_range("158-160", 158, 160), + side_enum_bitmap_mapping_value("159", 159), + side_enum_bitmap_mapping_range("500-700", 500, 700), ), - tgif_attr_list() + side_attr_list() ); -tgif_static_event(my_provider_event_enum_bitmap, "myprovider", "myeventenumbitmap", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_enum_bitmap("bit_0", &myenum_bitmap, tgif_elem(tgif_type_u32(tgif_attr_list()))), - tgif_field_enum_bitmap("bit_1", &myenum_bitmap, tgif_elem(tgif_type_u32(tgif_attr_list()))), - tgif_field_enum_bitmap("bit_2", &myenum_bitmap, tgif_elem(tgif_type_u8(tgif_attr_list()))), - tgif_field_enum_bitmap("bit_3", &myenum_bitmap, tgif_elem(tgif_type_u8(tgif_attr_list()))), - tgif_field_enum_bitmap("bit_30", &myenum_bitmap, tgif_elem(tgif_type_u32(tgif_attr_list()))), - tgif_field_enum_bitmap("bit_31", &myenum_bitmap, tgif_elem(tgif_type_u32(tgif_attr_list()))), - tgif_field_enum_bitmap("bit_63", &myenum_bitmap, tgif_elem(tgif_type_u64(tgif_attr_list()))), - tgif_field_enum_bitmap("bits_1+63", &myenum_bitmap, tgif_elem(tgif_type_u64(tgif_attr_list()))), - tgif_field_enum_bitmap("byte_bit_2", &myenum_bitmap, tgif_elem(tgif_type_byte(tgif_attr_list()))), - tgif_field_enum_bitmap("bit_159", &myenum_bitmap, - tgif_elem(tgif_type_array(tgif_elem(tgif_type_u32(tgif_attr_list())), 5, tgif_attr_list()))), - tgif_field_enum_bitmap("bit_159", &myenum_bitmap, - tgif_elem(tgif_type_vla(tgif_elem(tgif_type_u32(tgif_attr_list())), tgif_attr_list()))), - tgif_field_enum_bitmap("bit_2_be", &myenum_bitmap, tgif_elem(tgif_type_u32_be(tgif_attr_list()))), - tgif_field_enum_bitmap("bit_2_le", &myenum_bitmap, tgif_elem(tgif_type_u32_le(tgif_attr_list()))), +side_static_event(my_provider_event_enum_bitmap, "myprovider", "myeventenumbitmap", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_enum_bitmap("bit_0", &myenum_bitmap, side_elem(side_type_u32(side_attr_list()))), + side_field_enum_bitmap("bit_1", &myenum_bitmap, side_elem(side_type_u32(side_attr_list()))), + side_field_enum_bitmap("bit_2", &myenum_bitmap, side_elem(side_type_u8(side_attr_list()))), + side_field_enum_bitmap("bit_3", &myenum_bitmap, side_elem(side_type_u8(side_attr_list()))), + side_field_enum_bitmap("bit_30", &myenum_bitmap, side_elem(side_type_u32(side_attr_list()))), + side_field_enum_bitmap("bit_31", &myenum_bitmap, side_elem(side_type_u32(side_attr_list()))), + side_field_enum_bitmap("bit_63", &myenum_bitmap, side_elem(side_type_u64(side_attr_list()))), + side_field_enum_bitmap("bits_1+63", &myenum_bitmap, side_elem(side_type_u64(side_attr_list()))), + side_field_enum_bitmap("byte_bit_2", &myenum_bitmap, side_elem(side_type_byte(side_attr_list()))), + side_field_enum_bitmap("bit_159", &myenum_bitmap, + side_elem(side_type_array(side_elem(side_type_u32(side_attr_list())), 5, side_attr_list()))), + side_field_enum_bitmap("bit_159", &myenum_bitmap, + side_elem(side_type_vla(side_elem(side_type_u32(side_attr_list())), side_attr_list()))), + side_field_enum_bitmap("bit_2_be", &myenum_bitmap, side_elem(side_type_u32_be(side_attr_list()))), + side_field_enum_bitmap("bit_2_le", &myenum_bitmap, side_elem(side_type_u32_le(side_attr_list()))), ), - tgif_attr_list() + side_attr_list() ); static void test_enum_bitmap(void) { - tgif_event_cond(my_provider_event_enum_bitmap) { - tgif_arg_define_vec(myarray, - tgif_arg_list( - tgif_arg_u32(0), - tgif_arg_u32(0), - tgif_arg_u32(0), - tgif_arg_u32(0), - tgif_arg_u32(0x80000000), /* bit 159 */ + side_event_cond(my_provider_event_enum_bitmap) { + side_arg_define_vec(myarray, + side_arg_list( + side_arg_u32(0), + side_arg_u32(0), + side_arg_u32(0), + side_arg_u32(0), + side_arg_u32(0x80000000), /* bit 159 */ ) ); - tgif_event_call(my_provider_event_enum_bitmap, - tgif_arg_list( - tgif_arg_u32(1U << 0), - tgif_arg_u32(1U << 1), - tgif_arg_u8(1U << 2), - tgif_arg_u8(1U << 3), - tgif_arg_u32(1U << 30), - tgif_arg_u32(1U << 31), - tgif_arg_u64(1ULL << 63), - tgif_arg_u64((1ULL << 1) | (1ULL << 63)), - tgif_arg_byte(1U << 2), - tgif_arg_array(&myarray), - tgif_arg_vla(&myarray), -#if TGIF_BYTE_ORDER == TGIF_LITTLE_ENDIAN - tgif_arg_u32(tgif_bswap_32(1U << 2)), - tgif_arg_u32(1U << 2), + side_event_call(my_provider_event_enum_bitmap, + side_arg_list( + side_arg_u32(1U << 0), + side_arg_u32(1U << 1), + side_arg_u8(1U << 2), + side_arg_u8(1U << 3), + side_arg_u32(1U << 30), + side_arg_u32(1U << 31), + 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), +#if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN + side_arg_u32(side_bswap_32(1U << 2)), + side_arg_u32(1U << 2), #else - tgif_arg_u32(1U << 2), - tgif_arg_u32(tgif_bswap_32(1U << 2)), + side_arg_u32(1U << 2), + side_arg_u32(side_bswap_32(1U << 2)), #endif ) ); } } -tgif_static_event_variadic(my_provider_event_blob, "myprovider", "myeventblob", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_byte("blobfield", tgif_attr_list()), - tgif_field_array("arrayblob", tgif_elem(tgif_type_byte(tgif_attr_list())), 3, tgif_attr_list()), +side_static_event_variadic(my_provider_event_blob, "myprovider", "myeventblob", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_byte("blobfield", side_attr_list()), + side_field_array("arrayblob", side_elem(side_type_byte(side_attr_list())), 3, side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); static void test_blob(void) { - tgif_event_cond(my_provider_event_blob) { - tgif_arg_define_vec(myarray, tgif_arg_list(tgif_arg_byte(1), tgif_arg_byte(2), tgif_arg_byte(3))); - tgif_arg_dynamic_define_vec(myvla, - tgif_arg_list( - tgif_arg_dynamic_byte(0x22, tgif_attr_list()), - tgif_arg_dynamic_byte(0x33, tgif_attr_list()), + side_event_cond(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_dynamic_define_vec(myvla, + side_arg_list( + side_arg_dynamic_byte(0x22, side_attr_list()), + side_arg_dynamic_byte(0x33, side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); - tgif_event_call_variadic(my_provider_event_blob, - tgif_arg_list( - tgif_arg_byte(0x55), - tgif_arg_array(&myarray), + side_event_call_variadic(my_provider_event_blob, + side_arg_list( + side_arg_byte(0x55), + side_arg_array(&myarray), ), - tgif_arg_list( - tgif_arg_dynamic_field("varblobfield", - tgif_arg_dynamic_byte(0x55, tgif_attr_list()) + side_arg_list( + side_arg_dynamic_field("varblobfield", + side_arg_dynamic_byte(0x55, side_attr_list()) ), - tgif_arg_dynamic_field("varblobvla", tgif_arg_dynamic_vla(&myvla)), + side_arg_dynamic_field("varblobvla", side_arg_dynamic_vla(&myvla)), ), - tgif_attr_list() + side_attr_list() ); } } -tgif_static_event_variadic(my_provider_event_format_string, - "myprovider", "myeventformatstring", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_string("fmt", tgif_attr_list()), +side_static_event_variadic(my_provider_event_format_string, + "myprovider", "myeventformatstring", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_string("fmt", side_attr_list()), ), - tgif_attr_list( - tgif_attr("lang.c.format_string", tgif_attr_bool(true)), + side_attr_list( + side_attr("lang.c.format_string", side_attr_bool(true)), ) ); static void test_fmt_string(void) { - tgif_event_cond(my_provider_event_format_string) { - tgif_arg_dynamic_define_vec(args, - tgif_arg_list( - tgif_arg_dynamic_string("blah", tgif_attr_list()), - tgif_arg_dynamic_s32(123, tgif_attr_list()), + side_event_cond(my_provider_event_format_string) { + side_arg_dynamic_define_vec(args, + side_arg_list( + side_arg_dynamic_string("blah", side_attr_list()), + side_arg_dynamic_s32(123, side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); - tgif_event_call_variadic(my_provider_event_format_string, - tgif_arg_list( - tgif_arg_string("This is a formatted string with str: %s int: %d"), + side_event_call_variadic(my_provider_event_format_string, + side_arg_list( + side_arg_string("This is a formatted string with str: %s int: %d"), ), - tgif_arg_list( - tgif_arg_dynamic_field("arguments", tgif_arg_dynamic_vla(&args)), + side_arg_list( + side_arg_dynamic_field("arguments", side_arg_dynamic_vla(&args)), ), - tgif_attr_list() + side_attr_list() ); } } -tgif_static_event_variadic(my_provider_event_endian, "myprovider", "myevent_endian", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_u16_le("u16_le", tgif_attr_list()), - tgif_field_u32_le("u32_le", tgif_attr_list()), - tgif_field_u64_le("u64_le", tgif_attr_list()), - tgif_field_s16_le("s16_le", tgif_attr_list()), - tgif_field_s32_le("s32_le", tgif_attr_list()), - tgif_field_s64_le("s64_le", tgif_attr_list()), - tgif_field_u16_be("u16_be", tgif_attr_list()), - tgif_field_u32_be("u32_be", tgif_attr_list()), - tgif_field_u64_be("u64_be", tgif_attr_list()), - tgif_field_s16_be("s16_be", tgif_attr_list()), - tgif_field_s32_be("s32_be", tgif_attr_list()), - tgif_field_s64_be("s64_be", tgif_attr_list()), +side_static_event_variadic(my_provider_event_endian, "myprovider", "myevent_endian", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_u16_le("u16_le", side_attr_list()), + side_field_u32_le("u32_le", side_attr_list()), + side_field_u64_le("u64_le", side_attr_list()), + side_field_s16_le("s16_le", side_attr_list()), + side_field_s32_le("s32_le", side_attr_list()), + side_field_s64_le("s64_le", side_attr_list()), + side_field_u16_be("u16_be", side_attr_list()), + side_field_u32_be("u32_be", side_attr_list()), + side_field_u64_be("u64_be", side_attr_list()), + side_field_s16_be("s16_be", side_attr_list()), + side_field_s32_be("s32_be", side_attr_list()), + side_field_s64_be("s64_be", side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); static void test_endian(void) { - tgif_event_variadic(my_provider_event_endian, - tgif_arg_list( -#if TGIF_BYTE_ORDER == TGIF_LITTLE_ENDIAN - tgif_arg_u16(1), - tgif_arg_u32(1), - tgif_arg_u64(1), - tgif_arg_s16(1), - tgif_arg_s32(1), - tgif_arg_s64(1), - tgif_arg_u16(tgif_bswap_16(1)), - tgif_arg_u32(tgif_bswap_32(1)), - tgif_arg_u64(tgif_bswap_64(1)), - tgif_arg_s16(tgif_bswap_16(1)), - tgif_arg_s32(tgif_bswap_32(1)), - tgif_arg_s64(tgif_bswap_64(1)), + side_event_variadic(my_provider_event_endian, + side_arg_list( +#if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN + side_arg_u16(1), + side_arg_u32(1), + side_arg_u64(1), + side_arg_s16(1), + side_arg_s32(1), + side_arg_s64(1), + side_arg_u16(side_bswap_16(1)), + side_arg_u32(side_bswap_32(1)), + side_arg_u64(side_bswap_64(1)), + side_arg_s16(side_bswap_16(1)), + side_arg_s32(side_bswap_32(1)), + side_arg_s64(side_bswap_64(1)), #else - tgif_arg_u16(tgif_bswap_16(1)), - tgif_arg_u32(tgif_bswap_32(1)), - tgif_arg_u64(tgif_bswap_64(1)), - tgif_arg_s16(tgif_bswap_16(1)), - tgif_arg_s32(tgif_bswap_32(1)), - tgif_arg_s64(tgif_bswap_64(1)), - tgif_arg_u16(1), - tgif_arg_u32(1), - tgif_arg_u64(1), - tgif_arg_s16(1), - tgif_arg_s32(1), - tgif_arg_s64(1), + side_arg_u16(side_bswap_16(1)), + side_arg_u32(side_bswap_32(1)), + side_arg_u64(side_bswap_64(1)), + side_arg_s16(side_bswap_16(1)), + side_arg_s32(side_bswap_32(1)), + side_arg_s64(side_bswap_64(1)), + side_arg_u16(1), + side_arg_u32(1), + side_arg_u64(1), + side_arg_s16(1), + side_arg_s32(1), + side_arg_s64(1), #endif ), - tgif_arg_list( -#if TGIF_BYTE_ORDER == TGIF_LITTLE_ENDIAN - tgif_arg_dynamic_field("u16_le", tgif_arg_dynamic_u16_le(1, tgif_attr_list())), - tgif_arg_dynamic_field("u32_le", tgif_arg_dynamic_u32_le(1, tgif_attr_list())), - tgif_arg_dynamic_field("u64_le", tgif_arg_dynamic_u64_le(1, tgif_attr_list())), - tgif_arg_dynamic_field("s16_le", tgif_arg_dynamic_s16_le(1, tgif_attr_list())), - tgif_arg_dynamic_field("s32_le", tgif_arg_dynamic_s32_le(1, tgif_attr_list())), - tgif_arg_dynamic_field("s64_le", tgif_arg_dynamic_s64_le(1, tgif_attr_list())), - tgif_arg_dynamic_field("u16_be", tgif_arg_dynamic_u16_be(tgif_bswap_16(1), tgif_attr_list())), - tgif_arg_dynamic_field("u32_be", tgif_arg_dynamic_u32_be(tgif_bswap_32(1), tgif_attr_list())), - tgif_arg_dynamic_field("u64_be", tgif_arg_dynamic_u64_be(tgif_bswap_64(1), tgif_attr_list())), - tgif_arg_dynamic_field("s16_be", tgif_arg_dynamic_s16_be(tgif_bswap_16(1), tgif_attr_list())), - tgif_arg_dynamic_field("s32_be", tgif_arg_dynamic_s32_be(tgif_bswap_32(1), tgif_attr_list())), - tgif_arg_dynamic_field("s64_be", tgif_arg_dynamic_s64_be(tgif_bswap_64(1), tgif_attr_list())), + side_arg_list( +#if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN + side_arg_dynamic_field("u16_le", side_arg_dynamic_u16_le(1, side_attr_list())), + side_arg_dynamic_field("u32_le", side_arg_dynamic_u32_le(1, side_attr_list())), + side_arg_dynamic_field("u64_le", side_arg_dynamic_u64_le(1, side_attr_list())), + side_arg_dynamic_field("s16_le", side_arg_dynamic_s16_le(1, side_attr_list())), + side_arg_dynamic_field("s32_le", side_arg_dynamic_s32_le(1, side_attr_list())), + side_arg_dynamic_field("s64_le", side_arg_dynamic_s64_le(1, side_attr_list())), + side_arg_dynamic_field("u16_be", side_arg_dynamic_u16_be(side_bswap_16(1), side_attr_list())), + side_arg_dynamic_field("u32_be", side_arg_dynamic_u32_be(side_bswap_32(1), side_attr_list())), + side_arg_dynamic_field("u64_be", side_arg_dynamic_u64_be(side_bswap_64(1), side_attr_list())), + side_arg_dynamic_field("s16_be", side_arg_dynamic_s16_be(side_bswap_16(1), side_attr_list())), + side_arg_dynamic_field("s32_be", side_arg_dynamic_s32_be(side_bswap_32(1), side_attr_list())), + side_arg_dynamic_field("s64_be", side_arg_dynamic_s64_be(side_bswap_64(1), side_attr_list())), #else - tgif_arg_dynamic_field("u16_le", tgif_arg_dynamic_u16_le(tgif_bswap_16(1), tgif_attr_list())), - tgif_arg_dynamic_field("u32_le", tgif_arg_dynamic_u32_le(tgif_bswap_32(1), tgif_attr_list())), - tgif_arg_dynamic_field("u64_le", tgif_arg_dynamic_u64_le(tgif_bswap_64(1), tgif_attr_list())), - tgif_arg_dynamic_field("s16_le", tgif_arg_dynamic_s16_le(tgif_bswap_16(1), tgif_attr_list())), - tgif_arg_dynamic_field("s32_le", tgif_arg_dynamic_s32_le(tgif_bswap_32(1), tgif_attr_list())), - tgif_arg_dynamic_field("s64_le", tgif_arg_dynamic_s64_le(tgif_bswap_64(1), tgif_attr_list())), - tgif_arg_dynamic_field("u16_be", tgif_arg_dynamic_u16_be(1, tgif_attr_list())), - tgif_arg_dynamic_field("u32_be", tgif_arg_dynamic_u32_be(1, tgif_attr_list())), - tgif_arg_dynamic_field("u64_be", tgif_arg_dynamic_u64_be(1, tgif_attr_list())), - tgif_arg_dynamic_field("s16_be", tgif_arg_dynamic_s16_be(1, tgif_attr_list())), - tgif_arg_dynamic_field("s32_be", tgif_arg_dynamic_s32_be(1, tgif_attr_list())), - tgif_arg_dynamic_field("s64_be", tgif_arg_dynamic_s64_be(1, tgif_attr_list())), + side_arg_dynamic_field("u16_le", side_arg_dynamic_u16_le(side_bswap_16(1), side_attr_list())), + side_arg_dynamic_field("u32_le", side_arg_dynamic_u32_le(side_bswap_32(1), side_attr_list())), + side_arg_dynamic_field("u64_le", side_arg_dynamic_u64_le(side_bswap_64(1), side_attr_list())), + side_arg_dynamic_field("s16_le", side_arg_dynamic_s16_le(side_bswap_16(1), side_attr_list())), + side_arg_dynamic_field("s32_le", side_arg_dynamic_s32_le(side_bswap_32(1), side_attr_list())), + side_arg_dynamic_field("s64_le", side_arg_dynamic_s64_le(side_bswap_64(1), side_attr_list())), + side_arg_dynamic_field("u16_be", side_arg_dynamic_u16_be(1, side_attr_list())), + side_arg_dynamic_field("u32_be", side_arg_dynamic_u32_be(1, side_attr_list())), + side_arg_dynamic_field("u64_be", side_arg_dynamic_u64_be(1, side_attr_list())), + side_arg_dynamic_field("s16_be", side_arg_dynamic_s16_be(1, side_attr_list())), + side_arg_dynamic_field("s32_be", side_arg_dynamic_s32_be(1, side_attr_list())), + side_arg_dynamic_field("s64_be", side_arg_dynamic_s64_be(1, side_attr_list())), #endif ), - tgif_attr_list() + side_attr_list() ); } -tgif_static_event(my_provider_event_base, "myprovider", "myevent_base", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_u8("u8base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))), - tgif_field_u8("u8base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))), - tgif_field_u8("u8base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))), - tgif_field_u8("u8base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))), - tgif_field_u16("u16base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))), - tgif_field_u16("u16base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))), - tgif_field_u16("u16base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))), - tgif_field_u16("u16base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))), - tgif_field_u32("u32base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))), - tgif_field_u32("u32base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))), - tgif_field_u32("u32base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))), - tgif_field_u32("u32base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))), - tgif_field_u64("u64base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))), - tgif_field_u64("u64base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))), - tgif_field_u64("u64base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))), - tgif_field_u64("u64base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))), - tgif_field_s8("s8base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))), - tgif_field_s8("s8base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))), - tgif_field_s8("s8base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))), - tgif_field_s8("s8base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))), - tgif_field_s16("s16base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))), - tgif_field_s16("s16base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))), - tgif_field_s16("s16base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))), - tgif_field_s16("s16base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))), - tgif_field_s32("s32base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))), - tgif_field_s32("s32base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))), - tgif_field_s32("s32base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))), - tgif_field_s32("s32base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))), - tgif_field_s64("s64base2", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(2)))), - tgif_field_s64("s64base8", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(8)))), - tgif_field_s64("s64base10", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))), - tgif_field_s64("s64base16", tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))), +side_static_event(my_provider_event_base, "myprovider", "myevent_base", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_u8("u8base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), + side_field_u8("u8base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), + side_field_u8("u8base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), + side_field_u8("u8base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), + side_field_u16("u16base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), + side_field_u16("u16base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), + side_field_u16("u16base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), + side_field_u16("u16base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), + side_field_u32("u32base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), + side_field_u32("u32base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), + side_field_u32("u32base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), + side_field_u32("u32base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), + side_field_u64("u64base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), + side_field_u64("u64base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), + side_field_u64("u64base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), + side_field_u64("u64base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), + side_field_s8("s8base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), + side_field_s8("s8base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), + side_field_s8("s8base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), + side_field_s8("s8base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), + side_field_s16("s16base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), + side_field_s16("s16base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), + side_field_s16("s16base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), + side_field_s16("s16base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), + side_field_s32("s32base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), + side_field_s32("s32base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), + side_field_s32("s32base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), + side_field_s32("s32base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), + side_field_s64("s64base2", side_attr_list(side_attr("std.integer.base", side_attr_u8(2)))), + side_field_s64("s64base8", side_attr_list(side_attr("std.integer.base", side_attr_u8(8)))), + side_field_s64("s64base10", side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), + side_field_s64("s64base16", side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), ), - tgif_attr_list() + side_attr_list() ); static void test_base(void) { - tgif_event(my_provider_event_base, - tgif_arg_list( - tgif_arg_u8(55), - tgif_arg_u8(55), - tgif_arg_u8(55), - tgif_arg_u8(55), - tgif_arg_u16(55), - tgif_arg_u16(55), - tgif_arg_u16(55), - tgif_arg_u16(55), - tgif_arg_u32(55), - tgif_arg_u32(55), - tgif_arg_u32(55), - tgif_arg_u32(55), - tgif_arg_u64(55), - tgif_arg_u64(55), - tgif_arg_u64(55), - tgif_arg_u64(55), - tgif_arg_s8(-55), - tgif_arg_s8(-55), - tgif_arg_s8(-55), - tgif_arg_s8(-55), - tgif_arg_s16(-55), - tgif_arg_s16(-55), - tgif_arg_s16(-55), - tgif_arg_s16(-55), - tgif_arg_s32(-55), - tgif_arg_s32(-55), - tgif_arg_s32(-55), - tgif_arg_s32(-55), - tgif_arg_s64(-55), - tgif_arg_s64(-55), - tgif_arg_s64(-55), - tgif_arg_s64(-55), + side_event(my_provider_event_base, + side_arg_list( + side_arg_u8(55), + side_arg_u8(55), + side_arg_u8(55), + side_arg_u8(55), + side_arg_u16(55), + side_arg_u16(55), + side_arg_u16(55), + side_arg_u16(55), + side_arg_u32(55), + side_arg_u32(55), + side_arg_u32(55), + side_arg_u32(55), + side_arg_u64(55), + side_arg_u64(55), + side_arg_u64(55), + side_arg_u64(55), + side_arg_s8(-55), + side_arg_s8(-55), + side_arg_s8(-55), + side_arg_s8(-55), + side_arg_s16(-55), + side_arg_s16(-55), + side_arg_s16(-55), + side_arg_s16(-55), + side_arg_s32(-55), + side_arg_s32(-55), + side_arg_s32(-55), + side_arg_s32(-55), + side_arg_s64(-55), + side_arg_s64(-55), + side_arg_s64(-55), + side_arg_s64(-55), ) ); } @@ -1434,65 +1434,65 @@ struct test { uint64_t test; }; -static tgif_define_struct(mystructgatherdef, - tgif_field_list( - tgif_field_gather_unsigned_integer("a", offsetof(struct test, a), - tgif_struct_field_sizeof(struct test, a), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), - tgif_field_gather_signed_integer("d", offsetof(struct test, d), - tgif_struct_field_sizeof(struct test, d), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), - tgif_field_gather_unsigned_integer("e", offsetof(struct test, e), - tgif_struct_field_sizeof(struct test, e), 8, 4, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))), - tgif_field_gather_signed_integer("f", offsetof(struct test, f), - tgif_struct_field_sizeof(struct test, f), 1, 4, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))), - tgif_field_gather_signed_integer("g", offsetof(struct test, g), - tgif_struct_field_sizeof(struct test, g), 11, 4, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))), - tgif_field_gather_signed_integer("h", offsetof(struct test, h), - tgif_struct_field_sizeof(struct test, h), 1, 31, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))), - tgif_field_gather_signed_integer("i", offsetof(struct test, i), - tgif_struct_field_sizeof(struct test, i), 33, 20, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))), - tgif_field_gather_signed_integer("j", offsetof(struct test, j), - tgif_struct_field_sizeof(struct test, j), 63, 1, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))), - tgif_field_gather_signed_integer("k", offsetof(struct test, k), - tgif_struct_field_sizeof(struct test, k), 1, 63, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))), - tgif_field_gather_unsigned_integer_le("test", offsetof(struct test, test), - tgif_struct_field_sizeof(struct test, test), 0, 64, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))), - tgif_field_gather_unsigned_integer_le("test_le", offsetof(struct test, test), - tgif_struct_field_sizeof(struct test, test), 0, 64, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))), - tgif_field_gather_unsigned_integer_be("test_be", offsetof(struct test, test), - tgif_struct_field_sizeof(struct test, test), 0, 64, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(16)))), +static side_define_struct(mystructgatherdef, + side_field_list( + side_field_gather_unsigned_integer("a", offsetof(struct test, a), + side_struct_field_sizeof(struct test, a), 0, 0, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), + side_field_gather_signed_integer("d", offsetof(struct test, d), + side_struct_field_sizeof(struct test, d), 0, 0, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), + side_field_gather_unsigned_integer("e", offsetof(struct test, e), + side_struct_field_sizeof(struct test, e), 8, 4, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), + side_field_gather_signed_integer("f", offsetof(struct test, f), + side_struct_field_sizeof(struct test, f), 1, 4, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), + side_field_gather_signed_integer("g", offsetof(struct test, g), + side_struct_field_sizeof(struct test, g), 11, 4, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), + side_field_gather_signed_integer("h", offsetof(struct test, h), + side_struct_field_sizeof(struct test, h), 1, 31, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), + side_field_gather_signed_integer("i", offsetof(struct test, i), + side_struct_field_sizeof(struct test, i), 33, 20, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))), + 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_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), + side_struct_field_sizeof(struct test, test), 0, 64, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), + side_field_gather_unsigned_integer_le("test_le", offsetof(struct test, test), + side_struct_field_sizeof(struct test, test), 0, 64, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), + side_field_gather_unsigned_integer_be("test_be", offsetof(struct test, test), + side_struct_field_sizeof(struct test, test), 0, 64, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))), ), - tgif_attr_list() + side_attr_list() ); -tgif_static_event(my_provider_event_structgather, "myprovider", "myeventstructgather", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_gather_struct("structgather", &mystructgatherdef, 0, sizeof(struct test), - TGIF_TYPE_GATHER_ACCESS_DIRECT), - tgif_field_gather_signed_integer("intgather", 0, sizeof(int32_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, - tgif_attr_list(tgif_attr("std.integer.base", tgif_attr_u8(10)))), +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_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)))), #if __HAVE_FLOAT32 - tgif_field_gather_float("f32", 0, sizeof(_Float32), TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), + side_field_gather_float("f32", 0, sizeof(_Float32), SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), #endif ), - tgif_attr_list() + side_attr_list() ); static void test_struct_gather(void) { - tgif_event_cond(my_provider_event_structgather) { + side_event_cond(my_provider_event_structgather) { struct test mystruct = { .a = 55, .b = 123, @@ -1511,12 +1511,12 @@ void test_struct_gather(void) #if __HAVE_FLOAT32 _Float32 f32 = 1.1; #endif - tgif_event_call(my_provider_event_structgather, - tgif_arg_list( - tgif_arg_gather_struct(&mystruct), - tgif_arg_gather_integer(&val), + side_event_call(my_provider_event_structgather, + side_arg_list( + side_arg_gather_struct(&mystruct), + side_arg_gather_integer(&val), #if __HAVE_FLOAT32 - tgif_arg_gather_float(&f32), + side_arg_gather_float(&f32), #endif ) ); @@ -1537,52 +1537,52 @@ struct testnest0 { struct testnest1 *nest; }; -static tgif_define_struct(mystructgathernest2, - tgif_field_list( - tgif_field_gather_unsigned_integer("c", offsetof(struct testnest2, c), - tgif_struct_field_sizeof(struct testnest2, c), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), +static side_define_struct(mystructgathernest2, + side_field_list( + side_field_gather_unsigned_integer("c", offsetof(struct testnest2, c), + side_struct_field_sizeof(struct testnest2, c), 0, 0, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); -static tgif_define_struct(mystructgathernest1, - tgif_field_list( - tgif_field_gather_unsigned_integer("b", offsetof(struct testnest1, b), - tgif_struct_field_sizeof(struct testnest1, b), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), - tgif_field_gather_struct("nest2", &mystructgathernest2, +static side_define_struct(mystructgathernest1, + side_field_list( + 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_attr_list()), + side_field_gather_struct("nest2", &mystructgathernest2, offsetof(struct testnest1, nest), sizeof(struct testnest2), - TGIF_TYPE_GATHER_ACCESS_POINTER), + SIDE_TYPE_GATHER_ACCESS_POINTER), ), - tgif_attr_list() + side_attr_list() ); -static tgif_define_struct(mystructgathernest0, - tgif_field_list( - tgif_field_gather_unsigned_integer("a", offsetof(struct testnest0, a), - tgif_struct_field_sizeof(struct testnest0, a), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), - tgif_field_gather_struct("nest1", &mystructgathernest1, +static side_define_struct(mystructgathernest0, + side_field_list( + 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_attr_list()), + side_field_gather_struct("nest1", &mystructgathernest1, offsetof(struct testnest0, nest), sizeof(struct testnest1), - TGIF_TYPE_GATHER_ACCESS_POINTER), + SIDE_TYPE_GATHER_ACCESS_POINTER), ), - tgif_attr_list() + side_attr_list() ); -tgif_static_event(my_provider_event_structgather_nest, - "myprovider", "myeventstructgathernest", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_gather_struct("nest0", &mystructgathernest0, 0, - sizeof(struct testnest0), TGIF_TYPE_GATHER_ACCESS_DIRECT), +side_static_event(my_provider_event_structgather_nest, + "myprovider", "myeventstructgathernest", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_gather_struct("nest0", &mystructgathernest0, 0, + sizeof(struct testnest0), SIDE_TYPE_GATHER_ACCESS_DIRECT), ), - tgif_attr_list() + side_attr_list() ); static void test_struct_gather_nest_ptr(void) { - tgif_event_cond(my_provider_event_structgather_nest) { + side_event_cond(my_provider_event_structgather_nest) { struct testnest2 mystruct2 = { .c = 77, }; @@ -1594,9 +1594,9 @@ void test_struct_gather_nest_ptr(void) .a = 55, .nest = &mystruct1, }; - tgif_event_call(my_provider_event_structgather_nest, - tgif_arg_list( - tgif_arg_gather_struct(&mystruct), + side_event_call(my_provider_event_structgather_nest, + side_arg_list( + side_arg_gather_struct(&mystruct), ) ); } @@ -1617,45 +1617,45 @@ struct testfloat { #endif }; -static tgif_define_struct(mystructgatherfloat, - tgif_field_list( +static side_define_struct(mystructgatherfloat, + side_field_list( #if __HAVE_FLOAT16 - tgif_field_gather_float("f16", offsetof(struct testfloat, f16), tgif_struct_field_sizeof(struct testfloat, f16), - TGIF_TYPE_GATHER_ACCESS_DIRECT, - tgif_attr_list()), + side_field_gather_float("f16", offsetof(struct testfloat, f16), side_struct_field_sizeof(struct testfloat, f16), + SIDE_TYPE_GATHER_ACCESS_DIRECT, + side_attr_list()), #endif #if __HAVE_FLOAT32 - tgif_field_gather_float("f32", offsetof(struct testfloat, f32), tgif_struct_field_sizeof(struct testfloat, f32), - TGIF_TYPE_GATHER_ACCESS_DIRECT, - tgif_attr_list()), + side_field_gather_float("f32", offsetof(struct testfloat, f32), side_struct_field_sizeof(struct testfloat, f32), + SIDE_TYPE_GATHER_ACCESS_DIRECT, + side_attr_list()), #endif #if __HAVE_FLOAT64 - tgif_field_gather_float("f64", offsetof(struct testfloat, f64), tgif_struct_field_sizeof(struct testfloat, f64), - TGIF_TYPE_GATHER_ACCESS_DIRECT, - tgif_attr_list()), + side_field_gather_float("f64", offsetof(struct testfloat, f64), side_struct_field_sizeof(struct testfloat, f64), + SIDE_TYPE_GATHER_ACCESS_DIRECT, + side_attr_list()), #endif #if __HAVE_FLOAT128 - tgif_field_gather_float("f128", offsetof(struct testfloat, f128), tgif_struct_field_sizeof(struct testfloat, f128), - TGIF_TYPE_GATHER_ACCESS_DIRECT, - tgif_attr_list()), + side_field_gather_float("f128", offsetof(struct testfloat, f128), side_struct_field_sizeof(struct testfloat, f128), + SIDE_TYPE_GATHER_ACCESS_DIRECT, + side_attr_list()), #endif ), - tgif_attr_list() + side_attr_list() ); -tgif_static_event(my_provider_event_structgatherfloat, - "myprovider", "myeventstructgatherfloat", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_gather_struct("structgatherfloat", &mystructgatherfloat, 0, - sizeof(struct testfloat), TGIF_TYPE_GATHER_ACCESS_DIRECT), +side_static_event(my_provider_event_structgatherfloat, + "myprovider", "myeventstructgatherfloat", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_gather_struct("structgatherfloat", &mystructgatherfloat, 0, + sizeof(struct testfloat), SIDE_TYPE_GATHER_ACCESS_DIRECT), ), - tgif_attr_list() + side_attr_list() ); static void test_struct_gather_float(void) { - tgif_event_cond(my_provider_event_structgatherfloat) { + side_event_cond(my_provider_event_structgatherfloat) { struct testfloat mystruct = { #if __HAVE_FLOAT16 .f16 = 1.1, @@ -1670,9 +1670,9 @@ void test_struct_gather_float(void) .f128 = 4.4, #endif }; - tgif_event_call(my_provider_event_structgatherfloat, - tgif_arg_list( - tgif_arg_gather_struct(&mystruct), + side_event_call(my_provider_event_structgatherfloat, + side_arg_list( + side_arg_gather_struct(&mystruct), ) ); } @@ -1687,45 +1687,45 @@ struct testarray { uint32_t *ptr; }; -static tgif_define_struct(mystructgatherarray, - tgif_field_list( - tgif_field_gather_array("array", - tgif_elem(tgif_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list())), - TGIF_ARRAY_SIZE(mygatherarray), +static side_define_struct(mystructgatherarray, + side_field_list( + side_field_gather_array("array", + side_elem(side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), + SIDE_ARRAY_SIZE(mygatherarray), offsetof(struct testarray, ptr), - TGIF_TYPE_GATHER_ACCESS_POINTER, - tgif_attr_list()), + SIDE_TYPE_GATHER_ACCESS_POINTER, + side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); -tgif_static_event(my_provider_event_structgatherarray, - "myprovider", "myeventstructgatherarray", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_gather_struct("structgatherarray", &mystructgatherarray, 0, - sizeof(struct testarray), TGIF_TYPE_GATHER_ACCESS_DIRECT), - tgif_field_gather_array("array2", - tgif_elem(tgif_type_gather_unsigned_integer(0, sizeof(uint16_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list())), - TGIF_ARRAY_SIZE(mygatherarray2), 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, - tgif_attr_list() +side_static_event(my_provider_event_structgatherarray, + "myprovider", "myeventstructgatherarray", SIDE_LOGLEVEL_DEBUG, + side_field_list( + 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, side_attr_list())), + SIDE_ARRAY_SIZE(mygatherarray2), 0, + SIDE_TYPE_GATHER_ACCESS_DIRECT, + side_attr_list() ), ), - tgif_attr_list() + side_attr_list() ); static void test_array_gather(void) { - tgif_event_cond(my_provider_event_structgatherarray) { + side_event_cond(my_provider_event_structgatherarray) { struct testarray mystruct = { .a = 55, .ptr = mygatherarray, }; - tgif_event_call(my_provider_event_structgatherarray, - tgif_arg_list( - tgif_arg_gather_struct(&mystruct), - tgif_arg_gather_array(&mygatherarray2), + side_event_call(my_provider_event_structgatherarray, + side_arg_list( + side_arg_gather_struct(&mystruct), + side_arg_gather_array(&mygatherarray2), ) ); } @@ -1743,61 +1743,61 @@ struct testgatherstructnest0 { int a; }; -static tgif_define_struct(mystructgatherstructnest1, - tgif_field_list( - tgif_field_gather_signed_integer("b", offsetof(struct testgatherstructnest1, b), - tgif_struct_field_sizeof(struct testgatherstructnest1, b), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), - tgif_field_gather_array("c", - tgif_elem( - tgif_type_gather_signed_integer(0, sizeof(uint32_t), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), +static side_define_struct(mystructgatherstructnest1, + side_field_list( + side_field_gather_signed_integer("b", offsetof(struct testgatherstructnest1, b), + side_struct_field_sizeof(struct testgatherstructnest1, b), 0, 0, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), + side_field_gather_array("c", + side_elem( + side_type_gather_signed_integer(0, sizeof(uint32_t), 0, 0, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), ), TESTSGNESTARRAY_LEN, offsetof(struct testgatherstructnest1, c), - TGIF_TYPE_GATHER_ACCESS_DIRECT, - tgif_attr_list()), + SIDE_TYPE_GATHER_ACCESS_DIRECT, + side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); -static tgif_define_struct(mystructgatherstructnest0, - tgif_field_list( - tgif_field_gather_signed_integer("a", offsetof(struct testgatherstructnest0, a), - tgif_struct_field_sizeof(struct testgatherstructnest0, a), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), - tgif_field_gather_struct("structnest0", &mystructgatherstructnest1, +static side_define_struct(mystructgatherstructnest0, + side_field_list( + 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_attr_list()), + side_field_gather_struct("structnest0", &mystructgatherstructnest1, offsetof(struct testgatherstructnest0, nest), sizeof(struct testgatherstructnest1), - TGIF_TYPE_GATHER_ACCESS_DIRECT), - tgif_field_gather_array("nestarray", - tgif_elem( - tgif_type_gather_struct(&mystructgatherstructnest1, + SIDE_TYPE_GATHER_ACCESS_DIRECT), + side_field_gather_array("nestarray", + side_elem( + side_type_gather_struct(&mystructgatherstructnest1, 0, sizeof(struct testgatherstructnest1), - TGIF_TYPE_GATHER_ACCESS_DIRECT), + SIDE_TYPE_GATHER_ACCESS_DIRECT), ), 2, offsetof(struct testgatherstructnest0, nestarray), - TGIF_TYPE_GATHER_ACCESS_DIRECT, - tgif_attr_list()), + SIDE_TYPE_GATHER_ACCESS_DIRECT, + side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); -tgif_static_event(my_provider_event_gatherstructnest, - "myprovider", "myeventgatherstructnest", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_gather_struct("structgather", &mystructgatherstructnest0, 0, - sizeof(struct testgatherstructnest0), TGIF_TYPE_GATHER_ACCESS_DIRECT), +side_static_event(my_provider_event_gatherstructnest, + "myprovider", "myeventgatherstructnest", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_gather_struct("structgather", &mystructgatherstructnest0, 0, + sizeof(struct testgatherstructnest0), SIDE_TYPE_GATHER_ACCESS_DIRECT), ), - tgif_attr_list() + side_attr_list() ); static void test_gather_structnest(void) { - tgif_event_cond(my_provider_event_gatherstructnest) { + side_event_cond(my_provider_event_gatherstructnest) { struct testgatherstructnest0 mystruct = { .nest = { .b = 66, @@ -1815,9 +1815,9 @@ void test_gather_structnest(void) }, .a = 55, }; - tgif_event_call(my_provider_event_gatherstructnest, - tgif_arg_list( - tgif_arg_gather_struct(&mystruct), + side_event_call(my_provider_event_gatherstructnest, + side_arg_list( + side_arg_gather_struct(&mystruct), ) ); } @@ -1832,53 +1832,53 @@ struct testgathervla { uint32_t *p; }; -static tgif_define_struct(mystructgathervla, - tgif_field_list( - tgif_field_gather_signed_integer("a", offsetof(struct testgathervla, a), - tgif_struct_field_sizeof(struct testgathervla, a), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list() +static side_define_struct(mystructgathervla, + side_field_list( + side_field_gather_signed_integer("a", offsetof(struct testgathervla, a), + side_struct_field_sizeof(struct testgathervla, a), 0, 0, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list() ), - tgif_field_gather_vla("nestvla", - tgif_elem(tgif_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list())), + side_field_gather_vla("nestvla", + side_elem(side_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), offsetof(struct testgathervla, p), - TGIF_TYPE_GATHER_ACCESS_POINTER, - tgif_length(tgif_type_gather_unsigned_integer(offsetof(struct testgathervla, len), - sizeof(uint16_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list())), - tgif_attr_list() + SIDE_TYPE_GATHER_ACCESS_POINTER, + side_length(side_type_gather_unsigned_integer(offsetof(struct testgathervla, len), + sizeof(uint16_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), + side_attr_list() ), ), - tgif_attr_list() + side_attr_list() ); -tgif_static_event(my_provider_event_gathervla, - "myprovider", "myeventgathervla", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_gather_struct("structgathervla", &mystructgathervla, 0, - sizeof(struct testgathervla), TGIF_TYPE_GATHER_ACCESS_DIRECT), - tgif_field_gather_vla("vla", - tgif_elem(tgif_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list())), - 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, - tgif_length(tgif_type_gather_unsigned_integer(0, sizeof(uint16_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list())), - tgif_attr_list() +side_static_event(my_provider_event_gathervla, + "myprovider", "myeventgathervla", SIDE_LOGLEVEL_DEBUG, + side_field_list( + 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, side_attr_list())), + 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, + side_length(side_type_gather_unsigned_integer(0, sizeof(uint16_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), + side_attr_list() ), ), - tgif_attr_list() + side_attr_list() ); static void test_gather_vla(void) { - tgif_event_cond(my_provider_event_gathervla) { + side_event_cond(my_provider_event_gathervla) { struct testgathervla mystruct = { .a = 55, - .len = TGIF_ARRAY_SIZE(gathervla), + .len = SIDE_ARRAY_SIZE(gathervla), .p = gathervla, }; uint16_t vla2_len = 5; - tgif_event_call(my_provider_event_gathervla, - tgif_arg_list( - tgif_arg_gather_struct(&mystruct), - tgif_arg_gather_vla(gathervla2, &vla2_len), + side_event_call(my_provider_event_gathervla, + side_arg_list( + side_arg_gather_struct(&mystruct), + side_arg_gather_vla(gathervla2, &vla2_len), ) ); } @@ -1890,34 +1890,34 @@ struct testgathervlaflex { uint64_t array[]; }; -static tgif_define_struct(mystructgathervlaflex, - tgif_field_list( - tgif_field_gather_vla("vlaflex", - tgif_elem(tgif_type_gather_unsigned_integer(0, sizeof(uint64_t), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list())), +static side_define_struct(mystructgathervlaflex, + side_field_list( + side_field_gather_vla("vlaflex", + side_elem(side_type_gather_unsigned_integer(0, sizeof(uint64_t), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), offsetof(struct testgathervlaflex, array), - TGIF_TYPE_GATHER_ACCESS_DIRECT, - tgif_length(tgif_type_gather_unsigned_integer(offsetof(struct testgathervlaflex, len), - tgif_struct_field_sizeof(struct testgathervlaflex, len), 0, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list())), - tgif_attr_list() + SIDE_TYPE_GATHER_ACCESS_DIRECT, + side_length(side_type_gather_unsigned_integer(offsetof(struct testgathervlaflex, len), + side_struct_field_sizeof(struct testgathervlaflex, len), 0, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), + side_attr_list() ), ), - tgif_attr_list() + side_attr_list() ); -tgif_static_event(my_provider_event_gathervlaflex, - "myprovider", "myeventgathervlaflex", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_gather_struct("structgathervlaflex", &mystructgathervlaflex, 0, - sizeof(struct testgathervlaflex), TGIF_TYPE_GATHER_ACCESS_DIRECT), +side_static_event(my_provider_event_gathervlaflex, + "myprovider", "myeventgathervlaflex", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_gather_struct("structgathervlaflex", &mystructgathervlaflex, 0, + sizeof(struct testgathervlaflex), SIDE_TYPE_GATHER_ACCESS_DIRECT), ), - tgif_attr_list() + side_attr_list() ); #define VLAFLEXLEN 6 static void test_gather_vla_flex(void) { - tgif_event_cond(my_provider_event_gathervlaflex) { + side_event_cond(my_provider_event_gathervlaflex) { struct testgathervlaflex *mystruct = (struct testgathervlaflex *) malloc(sizeof(*mystruct) + VLAFLEXLEN * sizeof(uint64_t)); @@ -1929,38 +1929,38 @@ void test_gather_vla_flex(void) mystruct->array[3] = 4; mystruct->array[4] = 5; mystruct->array[5] = 6; - tgif_event_call(my_provider_event_gathervlaflex, - tgif_arg_list( - tgif_arg_gather_struct(mystruct), + side_event_call(my_provider_event_gathervlaflex, + side_arg_list( + side_arg_gather_struct(mystruct), ) ); free(mystruct); } } -tgif_static_event(my_provider_event_gatherbyte, - "myprovider", "myeventgatherbyte", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_gather_byte("byte", 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), - tgif_field_gather_array("array", - tgif_elem(tgif_type_gather_byte(0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list())), - 3, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list() +side_static_event(my_provider_event_gatherbyte, + "myprovider", "myeventgatherbyte", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_gather_byte("byte", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), + side_field_gather_array("array", + side_elem(side_type_gather_byte(0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), + 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list() ), ), - tgif_attr_list() + side_attr_list() ); static void test_gather_byte(void) { - tgif_event_cond(my_provider_event_gatherbyte) { + side_event_cond(my_provider_event_gatherbyte) { uint8_t v = 0x44; uint8_t array[3] = { 0x1, 0x2, 0x3 }; - tgif_event_call(my_provider_event_gatherbyte, - tgif_arg_list( - tgif_arg_gather_byte(&v), - tgif_arg_gather_array(array), + side_event_call(my_provider_event_gatherbyte, + side_arg_list( + side_arg_gather_byte(&v), + side_arg_gather_array(array), ) ); } @@ -1969,125 +1969,125 @@ void test_gather_byte(void) #define ARRAYBOOLLEN 4 static bool arraybool[ARRAYBOOLLEN] = { false, true, false, true }; -tgif_static_event(my_provider_event_gatherbool, - "myprovider", "myeventgatherbool", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_gather_bool("v1_true", 0, sizeof(bool), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), - tgif_field_gather_bool("v2_false", 0, sizeof(bool), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), - tgif_field_gather_bool("v3_true", 0, sizeof(uint16_t), 1, 1, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), - tgif_field_gather_bool("v4_false", 0, sizeof(uint16_t), 1, 1, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), - tgif_field_gather_array("arraybool", - tgif_elem(tgif_type_gather_bool(0, sizeof(bool), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list())), - ARRAYBOOLLEN, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list() +side_static_event(my_provider_event_gatherbool, + "myprovider", "myeventgatherbool", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_gather_bool("v1_true", 0, sizeof(bool), 0, 0, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), + side_field_gather_bool("v2_false", 0, sizeof(bool), 0, 0, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), + side_field_gather_bool("v3_true", 0, sizeof(uint16_t), 1, 1, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), + side_field_gather_bool("v4_false", 0, sizeof(uint16_t), 1, 1, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), + side_field_gather_array("arraybool", + side_elem(side_type_gather_bool(0, sizeof(bool), 0, 0, + SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), + ARRAYBOOLLEN, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list() ), ), - tgif_attr_list() + side_attr_list() ); static void test_gather_bool(void) { - tgif_event_cond(my_provider_event_structgatherarray) { + side_event_cond(my_provider_event_structgatherarray) { bool v1 = true; bool v2 = false; uint16_t v3 = 1U << 1; uint16_t v4 = 1U << 2; - tgif_event_call(my_provider_event_gatherbool, - tgif_arg_list( - tgif_arg_gather_bool(&v1), - tgif_arg_gather_bool(&v2), - tgif_arg_gather_bool(&v3), - tgif_arg_gather_bool(&v4), - tgif_arg_gather_array(arraybool), + side_event_call(my_provider_event_gatherbool, + side_arg_list( + side_arg_gather_bool(&v1), + side_arg_gather_bool(&v2), + side_arg_gather_bool(&v3), + side_arg_gather_bool(&v4), + side_arg_gather_array(arraybool), ) ); } } -tgif_static_event(my_provider_event_gatherpointer, - "myprovider", "myeventgatherpointer", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_gather_pointer("ptr", 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), - tgif_field_gather_array("array", - tgif_elem(tgif_type_gather_pointer(0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list())), - 3, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list() +side_static_event(my_provider_event_gatherpointer, + "myprovider", "myeventgatherpointer", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_gather_pointer("ptr", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), + side_field_gather_array("array", + side_elem(side_type_gather_pointer(0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), + 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list() ), ), - tgif_attr_list() + side_attr_list() ); static void test_gather_pointer(void) { - tgif_event_cond(my_provider_event_structgatherarray) { + side_event_cond(my_provider_event_structgatherarray) { void *v = (void *)0x44; void *array[3] = { (void *)0x1, (void *)0x2, (void *)0x3 }; - tgif_event_call(my_provider_event_gatherpointer, - tgif_arg_list( - tgif_arg_gather_pointer(&v), - tgif_arg_gather_array(array), + side_event_call(my_provider_event_gatherpointer, + side_arg_list( + side_arg_gather_pointer(&v), + side_arg_gather_array(array), ) ); } } -static tgif_define_enum(myenumgather, - tgif_enum_mapping_list( - tgif_enum_mapping_range("one-ten", 1, 10), - tgif_enum_mapping_range("100-200", 100, 200), - tgif_enum_mapping_value("200", 200), - tgif_enum_mapping_value("300", 300), +static side_define_enum(myenumgather, + side_enum_mapping_list( + side_enum_mapping_range("one-ten", 1, 10), + side_enum_mapping_range("100-200", 100, 200), + side_enum_mapping_value("200", 200), + side_enum_mapping_value("300", 300), ), - tgif_attr_list() + side_attr_list() ); -tgif_static_event(my_provider_event_enum_gather, "myprovider", "myeventenumgather", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_gather_enum("5", &myenumgather, - tgif_elem( - tgif_type_gather_unsigned_integer(0, sizeof(uint32_t), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()) +side_static_event(my_provider_event_enum_gather, "myprovider", "myeventenumgather", SIDE_LOGLEVEL_DEBUG, + side_field_list( + 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_attr_list()) ) ), - tgif_field_gather_enum("400", &myenumgather, - tgif_elem( - tgif_type_gather_unsigned_integer(0, sizeof(uint64_t), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()) + 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_attr_list()) ) ), - tgif_field_gather_enum("200", &myenumgather, - tgif_elem( - tgif_type_gather_unsigned_integer(0, sizeof(uint8_t), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()) + 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_attr_list()) ) ), - tgif_field_gather_enum("-100", &myenumgather, - tgif_elem( - tgif_type_gather_signed_integer(0, sizeof(int8_t), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()) + 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_attr_list()) ) ), - tgif_field_gather_enum("6_be", &myenumgather, - tgif_elem( - tgif_type_gather_unsigned_integer_be(0, sizeof(uint32_t), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()) + 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_attr_list()) ) ), - tgif_field_gather_enum("6_le", &myenumgather, - tgif_elem( - tgif_type_gather_unsigned_integer_le(0, sizeof(uint32_t), 0, 0, - TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()) + 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, side_attr_list()) ) ), ), - tgif_attr_list() + side_attr_list() ); static @@ -2097,46 +2097,46 @@ void test_gather_enum(void) uint64_t v2 = 400; uint8_t v3 = 200; int8_t v4 = -100; -#if TGIF_BYTE_ORDER == TGIF_LITTLE_ENDIAN - uint32_t v5 = tgif_bswap_32(6); +#if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN + uint32_t v5 = side_bswap_32(6); uint32_t v6 = 6; #else uint32_t v5 = 6; - uint32_t v6 = tgif_bswap_32(6); + uint32_t v6 = side_bswap_32(6); #endif - tgif_event(my_provider_event_enum_gather, - tgif_arg_list( - tgif_arg_gather_integer(&v1), - tgif_arg_gather_integer(&v2), - tgif_arg_gather_integer(&v3), - tgif_arg_gather_integer(&v4), - tgif_arg_gather_integer(&v5), - tgif_arg_gather_integer(&v6), + side_event(my_provider_event_enum_gather, + side_arg_list( + side_arg_gather_integer(&v1), + side_arg_gather_integer(&v2), + side_arg_gather_integer(&v3), + side_arg_gather_integer(&v4), + side_arg_gather_integer(&v5), + side_arg_gather_integer(&v6), ) ); } -tgif_static_event(my_provider_event_gatherstring, - "myprovider", "myeventgatherstring", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_gather_string("string", 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), - tgif_field_gather_array("arrayptr", - tgif_elem(tgif_type_gather_string(0, TGIF_TYPE_GATHER_ACCESS_POINTER, tgif_attr_list())), - 3, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list() +side_static_event(my_provider_event_gatherstring, + "myprovider", "myeventgatherstring", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_gather_string("string", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), + side_field_gather_array("arrayptr", + side_elem(side_type_gather_string(0, SIDE_TYPE_GATHER_ACCESS_POINTER, side_attr_list())), + 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list() ), - tgif_field_gather_array("array", - tgif_elem(tgif_type_gather_string(0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list())), - 3, 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list() + side_field_gather_array("array", + side_elem(side_type_gather_string(0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())), + 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list() ), ), - tgif_attr_list() + side_attr_list() ); static void test_gather_string(void) { - tgif_event_cond(my_provider_event_gatherstring) { + side_event_cond(my_provider_event_gatherstring) { const char *str1 = "abcdef"; const char *ptrarray[3] = { "abc", @@ -2145,29 +2145,29 @@ void test_gather_string(void) }; char flatarray[] = { 'a', 'b', '\0', 'c', 'd', '\0', 'e', 'f', '\0' }; - tgif_event_call(my_provider_event_gatherstring, - tgif_arg_list( - tgif_arg_gather_string(str1), - tgif_arg_gather_array(ptrarray), - tgif_arg_gather_array(flatarray), + side_event_call(my_provider_event_gatherstring, + side_arg_list( + side_arg_gather_string(str1), + side_arg_gather_array(ptrarray), + side_arg_gather_array(flatarray), ) ); } } -tgif_static_event(my_provider_event_str_utf, "myprovider", "myevent_str_utf", TGIF_LOGLEVEL_DEBUG, - tgif_field_list( - tgif_field_string("utf8", tgif_attr_list()), - tgif_field_string32("utf32", tgif_attr_list()), - tgif_field_string16("utf16", tgif_attr_list()), - tgif_field_string32_le("utf32_le", tgif_attr_list()), - tgif_field_string16_le("utf16_le", tgif_attr_list()), - tgif_field_string32_be("utf32_be", tgif_attr_list()), - tgif_field_string16_be("utf16_be", tgif_attr_list()), - tgif_field_dynamic("dynamic_utf32"), - tgif_field_gather_string32("gather_utf32", 0, TGIF_TYPE_GATHER_ACCESS_DIRECT, tgif_attr_list()), +side_static_event(my_provider_event_str_utf, "myprovider", "myevent_str_utf", SIDE_LOGLEVEL_DEBUG, + side_field_list( + side_field_string("utf8", side_attr_list()), + side_field_string32("utf32", side_attr_list()), + side_field_string16("utf16", side_attr_list()), + side_field_string32_le("utf32_le", side_attr_list()), + side_field_string16_le("utf16_le", side_attr_list()), + side_field_string32_be("utf32_be", side_attr_list()), + side_field_string16_be("utf16_be", side_attr_list()), + side_field_dynamic("dynamic_utf32"), + side_field_gather_string32("gather_utf32", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()), ), - tgif_attr_list() + side_attr_list() ); static @@ -2182,29 +2182,29 @@ void test_string_utf(void) uint8_t str8[] = { 0xc2, 0xae, 'a', 'b', 'c', 0 }; uint32_t str32[] = { 0x000000ae, 'a', 'b', 'c', 0 }; uint16_t str16[] = { 0x00ae, 'a', 'b', 'c', 0 }; -#if TGIF_BYTE_ORDER == TGIF_LITTLE_ENDIAN +#if SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN uint32_t str32_le[] = { 0x000000ae, 'a', 'b', 'c', 0 }; uint16_t str16_le[] = { 0x00ae, 'a', 'b', 'c', 0 }; - uint32_t str32_be[] = { tgif_bswap_32(0x000000ae), tgif_bswap_32('a'), tgif_bswap_32('b'), tgif_bswap_32('c'), 0 }; - uint16_t str16_be[] = { tgif_bswap_16(0x00ae), tgif_bswap_16('a'), tgif_bswap_16('b'), tgif_bswap_16('c'), 0 }; + uint32_t str32_be[] = { side_bswap_32(0x000000ae), side_bswap_32('a'), side_bswap_32('b'), side_bswap_32('c'), 0 }; + uint16_t str16_be[] = { side_bswap_16(0x00ae), side_bswap_16('a'), side_bswap_16('b'), side_bswap_16('c'), 0 }; #else - uint32_t str32_le[] = { tgif_bswap_32(0x000000ae), tgif_bswap_32('a'), tgif_bswap_32('b'), tgif_bswap_32('c'), 0 }; - uint16_t str16_le[] = { tgif_bswap_16(0x00ae), tgif_bswap_16('a'), tgif_bswap_16('b'), tgif_bswap_16('c'), 0 }; + uint32_t str32_le[] = { side_bswap_32(0x000000ae), side_bswap_32('a'), side_bswap_32('b'), side_bswap_32('c'), 0 }; + uint16_t str16_le[] = { side_bswap_16(0x00ae), side_bswap_16('a'), side_bswap_16('b'), side_bswap_16('c'), 0 }; uint32_t str32_be[] = { 0x000000ae, 'a', 'b', 'c', 0 }; uint16_t str16_be[] = { 0x00ae, 'a', 'b', 'c', 0 }; #endif - tgif_event(my_provider_event_str_utf, - tgif_arg_list( - tgif_arg_string(str8), - tgif_arg_string32(str32), - tgif_arg_string16(str16), - tgif_arg_string32(str32_le), - tgif_arg_string16(str16_le), - tgif_arg_string32(str32_be), - tgif_arg_string16(str16_be), - tgif_arg_dynamic_string32(str32, tgif_attr_list()), - tgif_arg_gather_string(str32), + side_event(my_provider_event_str_utf, + side_arg_list( + side_arg_string(str8), + side_arg_string32(str32), + side_arg_string16(str16), + side_arg_string32(str32_le), + side_arg_string16(str16_le), + side_arg_string32(str32_be), + side_arg_string16(str16_be), + side_arg_dynamic_string32(str32, side_attr_list()), + side_arg_gather_string(str32), ) ); }