Introduce dynamic compound literal
authorOlivier Dion <odion@efficios.com>
Mon, 7 Oct 2024 16:11:42 +0000 (12:11 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 23 Oct 2024 15:34:40 +0000 (11:34 -0400)
commitcba80ed5b5440d5c9f3fbe49f469bdee7960d468
tree8b174032870fe452093f944d953faf820ca27614
parent608caecbbcb92d24bf8253e742146e303ee83c4d
Introduce dynamic compound literal

In C++, compound literal are temporary objects which have a lifetime
bound to its expression.  To extend the lifetime of such objects, the
`SIDE_DYNAMIC_COMPOUND_LITERAL' macro is introduced.

In C, this macro expands to `SIDE_COMPOUND_LITERAL'.  In C++, it
allocates the necessary size to store the object onto the stack using
`alloca(3)'.  The memory is then initialized by copying the expression
to it.

This is necessary for attributes of dynamic fields.  However,
`SIDE_DYNAMIC_COMPOUND_LITERAL' only return a pointer to the object and
not its size.  To overcome this, the API is changed and the
`side_dynamic_attr_list()' macro must be used on dynamic arguments of
dynamic fields.  The macro itself is not defined by libside.  Instead,
macro dispatching is done to get the pointer to the object and its size.

Change-Id: Ieddaa6b2209c03031cef916033efd57564229db5
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/side/instrumentation-c-api.h
include/side/macros.h
tests/unit/test.c
This page took 0.023557 seconds and 4 git commands to generate.