mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-26 01:00:36 +08:00
* fix(cmake): link the functional gtest libraries as a group px4_platform, parameters and uorb_msgs all reference uORB, but uORB is listed before them, so a test only linked when something earlier happened to pull in px4_log.o. Inlined param_get() type checks did that for any test using DEFINE_PARAMETERS; without them PerformanceModel and StickYaw failed with undefined orb_advertise and orb_publish. Assisted-by: Claude:claude-opus-5-5 * refactor(platform): load DEFINE_PARAMETERS members from a table Every parameter cost a param_get_mark_used() call in its class constructor and a param_get() call in updateParamsImpl(), about 12 bytes each, for roughly 2000 parameters. Each Param now takes one pointer-sized slot, so the members a DEFINE_PARAMETERS list declares form an array. A ParamTable member declared right after them holds the handles and loads them all with one call, in the constructor and on update. External parameters keep a pointer instead of a reference so the loader can follow it. Assisted-by: Claude:claude-opus-5-5 * refactor(platform): use param_t for parameter table entries Each entry is a parameter handle with the storage kind in its top bits, so it takes the handle's type. Assisted-by: Claude:claude-opus-5-5 * refactor(platform): keep each Param at its natural size Padding every Param to a pointer-sized slot doubled float and int32 members on 64-bit targets and grew ParamBool from 1 to 4 bytes. The macro now passes the first parameter's address to the table, and the loader steps through the members at each kind's own size and alignment. A table placed before the parameters would instead load through the external parameters before their pointers are set. Assisted-by: Claude:claude-opus-5-5 * refactor(platform): drop the parameter table end marker APPLY_ALL leaves a comma after every entry, so the template argument list needed a closing element, which every class then stored in its entry array. The entries are now a static array of the class, whose braced initializer accepts the trailing comma. Assisted-by: Claude:claude-opus-5-5 * refactor(platform): check the parameter layout at compile time The language leaves padding between members to the compiler, so the table loader relies on the ABI placing each member at the next address its alignment allows. Each class's updateParamsImpl() now checks every parameter's offsetof against where the loader steps, so a compiler that pads differently fails the build instead of loading into the wrong members. Assisted-by: Claude:claude-opus-5-5 * docs(platform): describe how DEFINE_PARAMETERS loads parameters The table loader walks the members of a class from the first parameter's address, which is not obvious from the macros or the loader alone. A block above the macros now states the flash cost it removes, what the macro adds to a class, how the loader steps, and which static_asserts guard the layout it relies on. The namespace comment said a Param does not depend on the macro. That stopped being true when the constructors stopped loading. Assisted-by: Claude:claude-fable-5-2 * docs(platform): drop the flash figure from the parameter table comment A measured saving for one board goes stale as parameters are added. The comment now states what the table replaces the per-parameter calls with. Assisted-by: Claude:claude-fable-5-2 * fix(platform): build the parameter layout check on GCC before 9 GCC 7 and 8 ignore _Pragma diagnostics inside a macro expansion, so the offsetof warning in the DEFINE_PARAMETERS layout check stays an error on the VOXL 2 toolchain. Those compilers now build with -Wno-invalid-offsetof. The static_assert still runs there. Assisted-by: Claude:claude-opus-5-5