uint8_t c;
int32_t d;
uint16_t e;
+ int8_t f;
+ int16_t g;
+ int32_t h;
+ int64_t i;
+ int64_t j;
+ int64_t k;
};
static side_define_struct_sg(mystructsgdef,
side_field_sg_unsigned_integer("e", offsetof(struct test, e),
side_struct_field_sizeof_bit(struct test, e), 8, 4,
side_attr_list(side_attr("std.integer.base", side_attr_u8(16)))),
+ side_field_sg_signed_integer("f", offsetof(struct test, f),
+ side_struct_field_sizeof_bit(struct test, f), 1, 4,
+ side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
+ side_field_sg_signed_integer("g", offsetof(struct test, g),
+ side_struct_field_sizeof_bit(struct test, g), 11, 4,
+ side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
+ side_field_sg_signed_integer("h", offsetof(struct test, h),
+ side_struct_field_sizeof_bit(struct test, h), 1, 31,
+ side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
+ side_field_sg_signed_integer("i", offsetof(struct test, i),
+ side_struct_field_sizeof_bit(struct test, i), 33, 20,
+ side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
+ side_field_sg_signed_integer("j", offsetof(struct test, j),
+ side_struct_field_sizeof_bit(struct test, j), 63, 1,
+ side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
+ side_field_sg_signed_integer("k", offsetof(struct test, k),
+ side_struct_field_sizeof_bit(struct test, k), 1, 63,
+ side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
),
side_attr_list()
);
.c = 2,
.d = -55,
.e = 0xABCD,
+ .f = -1,
+ .g = -1,
+ .h = -1,
+ .i = -1,
+ .j = -1,
+ .k = -1,
};
side_event_call(my_provider_event_structsg, side_arg_list(side_arg_struct_sg(&mystruct)));
}
{
uint8_t v;
+ if (!sg_type->u.side_basic.len_bits || sg_type->u.side_basic.len_bits + sg_type->u.side_basic.offset_bits > 8)
+ abort();
memcpy(&v, ptr + sg_type->u.side_basic.integer_offset, sizeof(v));
v >>= sg_type->u.side_basic.offset_bits;
if (sg_type->u.side_basic.len_bits < 8)
{
uint16_t v;
+ if (!sg_type->u.side_basic.len_bits || sg_type->u.side_basic.len_bits + sg_type->u.side_basic.offset_bits > 16)
+ abort();
memcpy(&v, ptr + sg_type->u.side_basic.integer_offset, sizeof(v));
if (sg_type_to_host_reverse_bo(sg_type))
v = side_bswap_16(v);
{
uint32_t v;
+ if (!sg_type->u.side_basic.len_bits || sg_type->u.side_basic.len_bits + sg_type->u.side_basic.offset_bits > 32)
+ abort();
memcpy(&v, ptr + sg_type->u.side_basic.integer_offset, sizeof(v));
if (sg_type_to_host_reverse_bo(sg_type))
v = side_bswap_32(v);
{
uint64_t v;
+ if (!sg_type->u.side_basic.len_bits || sg_type->u.side_basic.len_bits + sg_type->u.side_basic.offset_bits > 64)
+ abort();
memcpy(&v, ptr + sg_type->u.side_basic.integer_offset, sizeof(v));
if (sg_type_to_host_reverse_bo(sg_type))
v = side_bswap_64(v);
{
int8_t v;
+ if (!sg_type->u.side_basic.len_bits || sg_type->u.side_basic.len_bits + sg_type->u.side_basic.offset_bits > 8)
+ abort();
memcpy(&v, ptr + sg_type->u.side_basic.integer_offset, sizeof(v));
v >>= sg_type->u.side_basic.offset_bits;
if (sg_type->u.side_basic.len_bits < 8)
printf("0%" PRIo8, v);
break;
case TRACER_DISPLAY_BASE_10:
+ /* Sign-extend. */
+ if (sg_type->u.side_basic.len_bits < 8) {
+ if (v & (1U << (sg_type->u.side_basic.len_bits - 1)))
+ v |= ~((1U << sg_type->u.side_basic.len_bits) - 1);
+ }
printf("%" PRId8, v);
break;
case TRACER_DISPLAY_BASE_16:
{
int16_t v;
+ if (!sg_type->u.side_basic.len_bits || sg_type->u.side_basic.len_bits + sg_type->u.side_basic.offset_bits > 16)
+ abort();
memcpy(&v, ptr + sg_type->u.side_basic.integer_offset, sizeof(v));
if (sg_type_to_host_reverse_bo(sg_type))
v = side_bswap_16(v);
printf("0%" PRIo16, v);
break;
case TRACER_DISPLAY_BASE_10:
+ /* Sign-extend. */
+ if (sg_type->u.side_basic.len_bits < 16) {
+ if (v & (1U << (sg_type->u.side_basic.len_bits - 1)))
+ v |= ~((1U << sg_type->u.side_basic.len_bits) - 1);
+ }
printf("%" PRId16, v);
break;
case TRACER_DISPLAY_BASE_16:
{
uint32_t v;
+ if (!sg_type->u.side_basic.len_bits || sg_type->u.side_basic.len_bits + sg_type->u.side_basic.offset_bits > 32)
+ abort();
memcpy(&v, ptr + sg_type->u.side_basic.integer_offset, sizeof(v));
if (sg_type_to_host_reverse_bo(sg_type))
v = side_bswap_32(v);
printf("0%" PRIo32, v);
break;
case TRACER_DISPLAY_BASE_10:
+ /* Sign-extend. */
+ if (sg_type->u.side_basic.len_bits < 32) {
+ if (v & (1U << (sg_type->u.side_basic.len_bits - 1)))
+ v |= ~((1U << sg_type->u.side_basic.len_bits) - 1);
+ }
printf("%" PRId32, v);
break;
case TRACER_DISPLAY_BASE_16:
{
uint64_t v;
+ if (!sg_type->u.side_basic.len_bits || sg_type->u.side_basic.len_bits + sg_type->u.side_basic.offset_bits > 64)
+ abort();
memcpy(&v, ptr + sg_type->u.side_basic.integer_offset, sizeof(v));
if (sg_type_to_host_reverse_bo(sg_type))
v = side_bswap_64(v);
printf("0%" PRIo64, v);
break;
case TRACER_DISPLAY_BASE_10:
+ /* Sign-extend. */
+ if (sg_type->u.side_basic.len_bits < 64) {
+ if (v & (1ULL << (sg_type->u.side_basic.len_bits - 1)))
+ v |= ~((1ULL << sg_type->u.side_basic.len_bits) - 1);
+ }
printf("%" PRId64, v);
break;
case TRACER_DISPLAY_BASE_16: