#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
+#include <math.h>
#include <side/macros.h>
/* SIDE stands for "Static Instrumentation Dynamically Enabled" */
SIDE_TYPE_S32,
SIDE_TYPE_S64,
+ SIDE_TYPE_FLOAT_BINARY16,
+ SIDE_TYPE_FLOAT_BINARY32,
+ SIDE_TYPE_FLOAT_BINARY64,
+ SIDE_TYPE_FLOAT_BINARY128,
+
SIDE_TYPE_STRING,
SIDE_TYPE_STRUCT,
SIDE_DYNAMIC_TYPE_S32,
SIDE_DYNAMIC_TYPE_S64,
+ SIDE_DYNAMIC_TYPE_FLOAT_BINARY16,
+ SIDE_DYNAMIC_TYPE_FLOAT_BINARY32,
+ SIDE_DYNAMIC_TYPE_FLOAT_BINARY64,
+ SIDE_DYNAMIC_TYPE_FLOAT_BINARY128,
+
SIDE_DYNAMIC_TYPE_STRING,
SIDE_DYNAMIC_TYPE_STRUCT,
int32_t side_s32;
int64_t side_s64;
+#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
+
const char *string;
const struct side_arg_dynamic_event_struct *side_dynamic_struct;
int32_t side_s32;
int64_t side_s64;
+#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
+
const char *string;
const struct side_arg_vec_description *side_struct;
const struct side_arg_vec_description *side_array;
#define side_arg_s16(val) { .type = SIDE_TYPE_S16, .u = { .side_s16 = (val) } }
#define side_arg_s32(val) { .type = SIDE_TYPE_S32, .u = { .side_s32 = (val) } }
#define side_arg_s64(val) { .type = SIDE_TYPE_S64, .u = { .side_s64 = (val) } }
+#define side_arg_float_binary16(val) { .type = SIDE_TYPE_FLOAT_BINARY16, .u = { .side_float_binary16 = (val) } }
+#define side_arg_float_binary32(val) { .type = SIDE_TYPE_FLOAT_BINARY32, .u = { .side_float_binary32 = (val) } }
+#define side_arg_float_binary64(val) { .type = SIDE_TYPE_FLOAT_BINARY64, .u = { .side_float_binary64 = (val) } }
+#define side_arg_float_binary128(val) { .type = SIDE_TYPE_FLOAT_BINARY128, .u = { .side_float_binary128 = (val) } }
+
#define side_arg_string(val) { .type = SIDE_TYPE_STRING, .u = { .string = (val) } }
#define side_arg_struct(_side_type) { .type = SIDE_TYPE_STRUCT, .u = { .side_struct = (_side_type) } }
#define side_arg_array(_side_type) { .type = SIDE_TYPE_ARRAY, .u = { .side_array = (_side_type) } }
}, \
}
+#define side_arg_dynamic_float_binary16(_val, _attr) \
+ { \
+ .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY16, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .attr = _attr, \
+ .u = { \
+ .side_float_binary16 = (_val), \
+ }, \
+ }
+#define side_arg_dynamic_float_binary32(_val, _attr) \
+ { \
+ .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY32, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .attr = _attr, \
+ .u = { \
+ .side_float_binary32 = (_val), \
+ }, \
+ }
+#define side_arg_dynamic_float_binary64(_val, _attr) \
+ { \
+ .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY64, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .attr = _attr, \
+ .u = { \
+ .side_float_binary64 = (_val), \
+ }, \
+ }
+#define side_arg_dynamic_float_binary128(_val, _attr) \
+ { \
+ .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY128, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .attr = _attr, \
+ .u = { \
+ .side_float_binary128 = (_val), \
+ }, \
+ }
+
#define side_arg_dynamic_string(_val, _attr) \
{ \
.dynamic_type = SIDE_DYNAMIC_TYPE_STRING, \
}
}
+static side_define_event(my_provider_event_float, "myprovider", "myeventfloat", SIDE_LOGLEVEL_DEBUG,
+ side_field_list(
+#if __HAVE_FLOAT16
+ side_field("binary16", SIDE_TYPE_FLOAT_BINARY16, side_attr_list()),
+#endif
+#if __HAVE_FLOAT32
+ side_field("binary32", SIDE_TYPE_FLOAT_BINARY32, side_attr_list()),
+#endif
+#if __HAVE_FLOAT64
+ side_field("binary64", SIDE_TYPE_FLOAT_BINARY64, side_attr_list()),
+#endif
+#if __HAVE_FLOAT128
+ side_field("binary128", SIDE_TYPE_FLOAT_BINARY128, side_attr_list()),
+#endif
+ ),
+ side_attr_list()
+);
+
+static
+void test_float(void)
+{
+ my_provider_event_float.enabled = 1;
+ side_event(&my_provider_event_float,
+ side_arg_list(
+#if __HAVE_FLOAT16
+ side_arg_float_binary16(1.1),
+#endif
+#if __HAVE_FLOAT32
+ side_arg_float_binary32(2.2),
+#endif
+#if __HAVE_FLOAT64
+ side_arg_float_binary64(3.3),
+#endif
+#if __HAVE_FLOAT128
+ side_arg_float_binary128(4.4),
+#endif
+ )
+ );
+}
+
+static side_define_event_variadic(my_provider_event_variadic_float,
+ "myprovider", "myvariadicfloat", SIDE_LOGLEVEL_DEBUG,
+ side_field_list(),
+ side_attr_list()
+);
+
+static
+void test_variadic_float(void)
+{
+ my_provider_event_variadic_float.enabled = 1;
+ side_event_variadic(&my_provider_event_variadic_float,
+ side_arg_list(),
+ side_arg_list(
+#if __HAVE_FLOAT16
+ side_arg_dynamic_field("binary16",
+ side_arg_dynamic_float_binary16(1.1, side_attr_list())
+ ),
+#endif
+#if __HAVE_FLOAT32
+ side_arg_dynamic_field("binary32",
+ side_arg_dynamic_float_binary32(2.2, side_attr_list())
+ ),
+#endif
+#if __HAVE_FLOAT64
+ side_arg_dynamic_field("binary64",
+ side_arg_dynamic_float_binary64(3.3, side_attr_list())
+ ),
+#endif
+#if __HAVE_FLOAT128
+ side_arg_dynamic_field("binary128",
+ side_arg_dynamic_float_binary128(4.4, side_attr_list())
+ ),
+#endif
+ )
+ );
+}
+
int main()
{
test_fields();
test_variadic_attr();
test_variadic_vla_attr();
test_variadic_struct_attr();
+ test_float();
+ test_variadic_float();
return 0;
}
case SIDE_TYPE_S64:
printf("%" PRId64, item->u.side_s64);
break;
+ case SIDE_TYPE_FLOAT_BINARY16:
+#if __HAVE_FLOAT16
+ printf("%g", (double) item->u.side_float_binary16);
+ break;
+#else
+ printf("ERROR: Unsupported binary16 float type\n");
+ abort();
+#endif
+ case SIDE_TYPE_FLOAT_BINARY32:
+#if __HAVE_FLOAT32
+ printf("%g", (double) item->u.side_float_binary32);
+ break;
+#else
+ printf("ERROR: Unsupported binary32 float type\n");
+ abort();
+#endif
+ case SIDE_TYPE_FLOAT_BINARY64:
+#if __HAVE_FLOAT64
+ printf("%g", (double) item->u.side_float_binary64);
+ break;
+#else
+ printf("ERROR: Unsupported binary64 float type\n");
+ abort();
+#endif
+ case SIDE_TYPE_FLOAT_BINARY128:
+#if __HAVE_FLOAT128
+ printf("%Lg", (long double) item->u.side_float_binary128);
+ break;
+#else
+ printf("ERROR: Unsupported binary128 float type\n");
+ abort();
+#endif
case SIDE_TYPE_STRING:
printf("\"%s\"", item->u.string);
break;
case SIDE_DYNAMIC_TYPE_S64:
printf("%" PRId64, item->u.side_s64);
break;
+ case SIDE_DYNAMIC_TYPE_FLOAT_BINARY16:
+#if __HAVE_FLOAT16
+ printf("%g", (double) item->u.side_float_binary16);
+ break;
+#else
+ printf("ERROR: Unsupported binary16 float type\n");
+ abort();
+#endif
+ case SIDE_DYNAMIC_TYPE_FLOAT_BINARY32:
+#if __HAVE_FLOAT32
+ printf("%g", (double) item->u.side_float_binary32);
+ break;
+#else
+ printf("ERROR: Unsupported binary32 float type\n");
+ abort();
+#endif
+ case SIDE_DYNAMIC_TYPE_FLOAT_BINARY64:
+#if __HAVE_FLOAT64
+ printf("%g", (double) item->u.side_float_binary64);
+ break;
+#else
+ printf("ERROR: Unsupported binary64 float type\n");
+ abort();
+#endif
+ case SIDE_DYNAMIC_TYPE_FLOAT_BINARY128:
+#if __HAVE_FLOAT128
+ printf("%Lg", (long double) item->u.side_float_binary128);
+ break;
+#else
+ printf("ERROR: Unsupported binary128 float type\n");
+ abort();
+#endif
case SIDE_DYNAMIC_TYPE_STRING:
printf("\"%s\"", item->u.string);
break;