mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-14 07:33:34 +08:00
Packing control for generated types
This commit is contained in:
@@ -46,6 +46,10 @@ namespace ${nsc}
|
||||
{
|
||||
% endfor
|
||||
|
||||
#if UAVCAN_PACK_STRUCTS
|
||||
UAVCAN_PACKED_BEGIN
|
||||
#endif
|
||||
|
||||
struct ${t.short_name}
|
||||
{
|
||||
<%def name="generate_primary_body(type_name, max_bitlen, fields, constants)" buffered="True">
|
||||
@@ -174,6 +178,10 @@ ${'::uavcan::TailArrayOptDisabled' if (idx + 1) < len(fields) else 'tao_mode'});
|
||||
}
|
||||
};
|
||||
|
||||
#if UAVCAN_PACK_STRUCTS
|
||||
UAVCAN_PACKED_END
|
||||
#endif
|
||||
|
||||
// TODO Stream operator
|
||||
|
||||
% if t.has_default_dtid:
|
||||
@@ -181,6 +189,8 @@ namespace
|
||||
{
|
||||
::uavcan::DefaultDataTypeRegistrator<${t.short_name}> _uavcan_gdtr_registrator_${t.short_name};
|
||||
}
|
||||
% else:
|
||||
// No default registration
|
||||
% endif
|
||||
|
||||
% for nsc in t.cpp_namespace_components:
|
||||
|
||||
@@ -18,6 +18,17 @@ namespace uavcan
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Struct layout control.
|
||||
* Define UAVCAN_PACK_STRUCTS = 1 to reduce memory usage.
|
||||
*/
|
||||
#ifndef UAVCAN_PACKED_BEGIN
|
||||
# define UAVCAN_PACKED_BEGIN _Pragma("pack(push, 1)")
|
||||
#endif
|
||||
#ifndef UAVCAN_PACKED_END
|
||||
# define UAVCAN_PACKED_END _Pragma("pack(pop)")
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Should be OK for any target arch up to AMD64 and any compiler.
|
||||
* The library leverages compile-time checks to ensure that all types that are subject to dynamic allocation
|
||||
|
||||
Reference in New Issue
Block a user