mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-22 22:50:49 +08:00
events::send(id, log_levels, message) was an inline function, so every module using it got either a private clone or the body inlined at each call site. The message is never part of the sent event: it only feeds the build-time event generator and the optional console print. Keep a thin inline wrapper so the compiler still drops the unused message string, and build the event in one out-of-line function that takes the two log levels as scalars to keep the call sites small. This saves 1760 bytes of FLASH on px4_fmu-v6x and 1184 bytes on px4_fmu-v2. Assisted-by: Claude:claude-fable-5-1 Signed-off-by: Michael Rogov Papernov <michael@membrowse.com>
52 lines
2.0 KiB
C++
52 lines
2.0 KiB
C++
/****************************************************************************
|
|
*
|
|
* Copyright (c) 2026 PX4 Development Team. All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
*
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in
|
|
* the documentation and/or other materials provided with the
|
|
* distribution.
|
|
* 3. Neither the name PX4 nor the names of its contributors may be
|
|
* used to endorse or promote products derived from this software
|
|
* without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
*
|
|
****************************************************************************/
|
|
|
|
|
|
#include <px4_platform_common/events.h>
|
|
|
|
namespace events
|
|
{
|
|
namespace util
|
|
{
|
|
|
|
void sendWithoutMessage(uint32_t id, Log external, LogInternal internal)
|
|
{
|
|
event_s e{};
|
|
e.log_levels = ((uint8_t)internal << 4) | (uint8_t)external;
|
|
e.id = id;
|
|
send(e);
|
|
}
|
|
|
|
} /* namespace util */
|
|
} /* namespace events */
|