Skip to content

Commit 01328aa

Browse files
committed
[utils] Refactor for consistent use of attributes
1 parent 9e2954f commit 01328aa

File tree

16 files changed

+25
-25
lines changed

16 files changed

+25
-25
lines changed

ext/gcc/new_delete.cpp.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void* malloc_traits(std::size_t size, uint32_t)
3333
template<bool with_traits>
3434
static inline void*
3535
%% if with_memory_traits
36-
new_assert(size_t size, modm_unused modm::MemoryTraits traits = modm::MemoryDefault)
36+
new_assert(size_t size, [[maybe_unused]] modm::MemoryTraits traits = modm::MemoryDefault)
3737
%% else
3838
new_assert(size_t size)
3939
%% endif
@@ -102,7 +102,7 @@ void* operator new[](std::size_t size, modm::MemoryTraits traits, const std::not
102102

103103
// ----------------------------------------------------------------------------
104104
extern "C" modm_weak
105-
void operator_delete(modm_unused void* ptr)
105+
void operator_delete([[maybe_unused]] void* ptr)
106106
{
107107
%% if with_heap
108108
free(ptr);

src/modm/architecture/interface/assert.hpp.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ using AssertionHandler = Abandonment (*)(const AssertionInfo &info);
8585
*
8686
* @note This assert is included in all builds!
8787
*/
88-
modm_noreturn void
88+
[[noreturn]] void
8989
modm_assert(bool condition,
9090
const char *name, const char *description,
9191
uintptr_t context=uintptr_t(-1));
@@ -145,7 +145,7 @@ modm_assert_continue_ignore_debug(bool condition,
145145
MODM_ASSERTION_HANDLER(handler)
146146
#else
147147
#define MODM_ASSERTION_HANDLER_DEBUG(handler) \
148-
static const modm::AssertionHandler modm_unused \
148+
static const modm::AssertionHandler [[maybe_unused]] \
149149
handler ## _assertion_handler_ptr = handler
150150
#endif
151151

src/modm/driver/display/ili9341.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#ifndef MODM_ILI9341_HPP
1212
#define MODM_ILI9341_HPP
1313

14+
#include <modm/architecture/utils.hpp>
1415
#include <modm/architecture/interface/delay.hpp>
1516
#include <modm/architecture/interface/register.hpp>
1617
#include <modm/math/utils/endianness.hpp>

src/modm/driver/display/ili9341_parallel.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ class Ili9341ParallelInterface: public ili9341
2424
Ili9341ParallelInterface(INTERFACE& interface)
2525
: interface(interface) {}
2626

27-
__attribute__((noinline)) void
27+
modm_noinline void
2828
writeCommand(Command command)
2929
{
3030
interface.writeIndex(i(command));
3131
}
32-
__attribute__((noinline)) void
32+
modm_noinline void
3333
writeCommand(Command command, uint8_t const *args, std::size_t length)
3434
{
3535
interface.writeIndex(i(command));

src/modm/driver/display/ili9341_spi.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ class Ili9341SPIInterface: public ili9341, public modm::SpiDevice<SPI>
3232
Dc::setOutput();
3333
}
3434

35-
__attribute__((noinline)) void
35+
modm_noinline void
3636
writeCommand(Command command)
3737
{
3838
Dc::reset(); // enable command
3939
SPI::transferBlocking(i(command));
4040
Dc::set(); // reset to data
4141
}
42-
__attribute__((noinline)) void
42+
modm_noinline void
4343
writeCommand(Command command, uint8_t const *args, std::size_t length)
4444
{
4545
Dc::reset(); // enable command

src/modm/math/filter/fir_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ modm::filter::Fir<T, N, BLOCK_SIZE, ScaleFactor>::append(const T& input)
7777
else printf("(%.3f) ", taps[i]);
7878
printf("\n");
7979
#endif // FIR_DEBUG_APPEND
80-
if(modm_likely(taps_index > 0)){
80+
if(taps_index > 0) [[likely]] {
8181
taps_index--;
8282
}
8383
else{

src/modm/platform/clock/systick/systick_timer.cpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static constexpr uint8_t systick_priority{(1ul << __NVIC_PRIO_BITS) - 1ul};
3838

3939
// ----------------------------------------------------------------------------
4040
void
41-
modm::platform::SysTickTimer::enable(uint32_t modm_unused reload, bool modm_unused prescaler8)
41+
modm::platform::SysTickTimer::enable([[maybe_unused]] uint32_t reload, [[maybe_unused]] bool prescaler8)
4242
{
4343
%% if not has_freertos
4444
// Lower systick interrupt priority to lowest level

src/modm/platform/core/cortex/delay_ns.cpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace modm
1717
{
1818

1919
// Only call via modm::delay_ns wrapper, since this function clobbers r0, r1, r2!!!
20-
void __attribute__((naked, aligned(4))) modm_fastcode
20+
void modm_naked modm_aligned(4) modm_fastcode
2121
platform::delay_ns(uint32_t)
2222
{
2323
// ns_per_loop = nanoseconds per cycle times cycles per loop

src/modm/platform/core/cortex/heap_table.cpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct table_pool_t
1919
uint32_t traits;
2020
uint8_t *const start;
2121
uint8_t *const end;
22-
} __attribute__((packed));
22+
} modm_packed;
2323

2424
extern "C" const table_pool_t __table_heap_start[];
2525
extern "C" const table_pool_t __table_heap_end[];

src/modm/platform/core/cortex/vectors.c.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void Undefined_Handler(void);
1717
/* Provide weak aliases for each Exception handler to Undefined_Handler.
1818
* As they are weak aliases, any function with the same name will override
1919
* this definition. */
20-
void Reset_Handler(void) __attribute__((noreturn));
20+
void Reset_Handler(void);
2121
void NMI_Handler(void) __attribute__((weak, alias("Undefined_Handler")));
2222
void HardFault_Handler(void) __attribute__((weak, alias("Undefined_Handler")));
2323
%% for pos in range(4 - 16, highest_irq + 1)

0 commit comments

Comments
 (0)