Skip to content

Commit 0e986bb

Browse files
committed
Clarify and unify attribute macros when used
1 parent 4d0611c commit 0e986bb

19 files changed

Lines changed: 84 additions & 74 deletions

File tree

ref_app/ref_app.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3233,6 +3233,7 @@
32333233
</ClInclude>
32343234
<ClInclude Include="src\util\STL_C++XX_stdfloat\stdfloat.h" />
32353235
<ClInclude Include="src\util\utility\util_alignas.h" />
3236+
<ClInclude Include="src\util\utility\util_attribute.h" />
32363237
<ClInclude Include="src\util\utility\util_baselexical_cast.h" />
32373238
<ClInclude Include="src\util\utility\util_bit_mask.h" />
32383239
<ClInclude Include="src\util\utility\util_communication.h" />

ref_app/ref_app.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2949,6 +2949,9 @@
29492949
<ClInclude Include="src\mcal\am6254_soc\mcal_osc.h">
29502950
<Filter>src\mcal\am6254_soc</Filter>
29512951
</ClInclude>
2952+
<ClInclude Include="src\util\utility\util_attribute.h">
2953+
<Filter>src\util\utility</Filter>
2954+
</ClInclude>
29522955
</ItemGroup>
29532956
<ItemGroup>
29542957
<None Include="src\util\STL\algorithm">

ref_app/src/app/benchmark/app_benchmark.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,7 @@
88
#ifndef APP_BENCHMARK_2018_10_02_H
99
#define APP_BENCHMARK_2018_10_02_H
1010

11-
#if defined(ATTRIBUTE)
12-
#undef ATTRIBUTE
13-
#endif
14-
15-
#if defined(_MSC_VER)
16-
#define ATTRIBUTE(a)
17-
#else
18-
#define ATTRIBUTE(a) __attribute__((a))
19-
#endif
11+
#include <util/utility/util_attribute.h>
2012

2113
#define APP_BENCHMARK_TYPE_NONE 0
2214
#define APP_BENCHMARK_TYPE_COMPLEX 1

ref_app/src/app/benchmark/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ The benchmark used is a ${\sim}100$ decimal digit AGM $\pi$ calculation.
8484
| Target | runtime $[ms]$ | relative |
8585
|--------------------|-----------------|------------|
8686
| `am6254_soc_` | 0.37 | 1.0 |
87-
| `am335x` | 1.5 | 4.0 |
87+
| `am335x` | 1.5 | 4.1 |
8888
| `stm32f446` | 5.1 | 14 |
8989
| `rpi_pico2_rp2350` | 6.3 | 17 |
9090
| `wch_ch32v307` | 8.0 | 22 |
9191
| `xtensa_esp32_s3` | 9.1 | 25 |
9292
| `rpi_pico_rp2040` | 19 | 51 |
93-
| `avr` | 420 | 760 |
93+
| `avr` | 410 | 1100 |
9494

9595
There are strikingly differing performance classes
9696
for the $8$-bit MICROCHIP(R) AVR controller of the ARDUINO

ref_app/src/app/led/app_led.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
///////////////////////////////////////////////////////////////////////////////
2-
// Copyright Christopher Kormanyos 2007 - 2024.
2+
// Copyright Christopher Kormanyos 2007 - 2025.
33
// Distributed under the Boost Software License,
44
// Version 1.0. (See accompanying file LICENSE_1_0.txt
55
// or copy at http://www.boost.org/LICENSE_1_0.txt)

ref_app/src/mcal/avr/mcal_gpt.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
///////////////////////////////////////////////////////////////////////////////
2-
// Copyright Christopher Kormanyos 2007 - 2024.
2+
// Copyright Christopher Kormanyos 2007 - 2025.
33
// Distributed under the Boost Software License,
44
// Version 1.0. (See accompanying file LICENSE_1_0.txt
55
// or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -8,12 +8,14 @@
88
#include <mcal_gpt.h>
99
#include <mcal_reg.h>
1010

11+
#include <util/utility/util_attribute.h>
12+
1113
namespace
1214
{
1315
// The one (and only one) system tick.
1416
volatile auto mcal_gpt_system_tick = mcal::gpt::value_type { };
1517

16-
auto gpt_is_initialized() -> bool& __attribute__((used, noinline));
18+
auto gpt_is_initialized() -> bool& ATTRIBUTE(used, noinline);
1719

1820
auto gpt_is_initialized() -> bool&
1921
{
@@ -24,7 +26,7 @@ namespace
2426
}
2527

2628
extern "C"
27-
auto __vector_16() -> void __attribute__((signal, used, externally_visible));
29+
auto __vector_16() -> void ATTRIBUTE(signal, used, externally_visible);
2830

2931
auto __vector_16() -> void
3032
{

ref_app/src/mcal/avr/mcal_wdg.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
///////////////////////////////////////////////////////////////////////////////
2-
// Copyright Christopher Kormanyos 2007 - 2024.
2+
// Copyright Christopher Kormanyos 2007 - 2025.
33
// Distributed under the Boost Software License,
44
// Version 1.0. (See accompanying file LICENSE_1_0.txt
55
// or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -8,7 +8,9 @@
88
#ifndef MCAL_WDT_2010_04_10_H
99
#define MCAL_WDT_2010_04_10_H
1010

11-
extern "C" void __my_startup() __attribute__((section(".startup"), used, noinline));
11+
#include <util/utility/util_attribute.h>
12+
13+
extern "C" void __my_startup() ATTRIBUTE(section(".startup"), used, noinline);
1214

1315
namespace sys { namespace idle { auto task_func() -> void; } }
1416

ref_app/src/os/os_cfg.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
///////////////////////////////////////////////////////////////////////////////
2-
// Copyright Christopher Kormanyos 2007 - 2024.
2+
// Copyright Christopher Kormanyos 2007 - 2025.
33
// Distributed under the Boost Software License,
44
// Version 1.0. (See accompanying file LICENSE_1_0.txt
55
// or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -92,11 +92,11 @@
9292
{ \
9393
os::task_control_block(app::led::task_init, \
9494
app::led::task_func, \
95-
os::timer_type::microseconds(UINT32_C( 4000)), \
95+
os::timer_type::microseconds(UINT32_C( 7000)), \
9696
os::timer_type::microseconds(UINT32_C( 0))), \
9797
os::task_control_block(app::benchmark::task_init, \
9898
app::benchmark::task_func, \
99-
os::timer_type::microseconds(UINT32_C( 750000)), \
99+
os::timer_type::microseconds(UINT32_C( 830000)), \
100100
os::timer_type::microseconds(UINT32_C( 379))), \
101101
os::task_control_block(sys::mon::task_init, \
102102
sys::mon::task_func, \

ref_app/src/sys/start/sys_start.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@
88
#include <mcal/mcal.h>
99
#include <os/os.h>
1010

11-
#if defined(_MSC_VER)
12-
#define ATTRIBUTE(a)
13-
#else
14-
#define ATTRIBUTE(a) __attribute__((a))
15-
#endif
11+
#include <util/utility/util_attribute.h>
1612

1713
#if (defined(__XTENSA__) && !defined(CONFIG_IDF_TARGET_ESP32S3))
18-
extern "C" ATTRIBUTE(used) auto app_main_loop() -> int;
14+
extern "C" auto app_main_loop() -> int ATTRIBUTE(used);
1915
#else
2016
ATTRIBUTE(used) auto main() -> int;
2117
#endif
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright Christopher Kormanyos 2025.
3+
// Distributed under the Boost Software License,
4+
// Version 1.0. (See accompanying file LICENSE_1_0.txt
5+
// or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
//
7+
8+
#ifndef UTIL_ATTRIBUTE_2025_08_09_H
9+
#define UTIL_ATTRIBUTE_2025_08_09_H
10+
11+
#if defined(ATTRIBUTE)
12+
#undef ATTRIBUTE
13+
#endif
14+
15+
#if defined(_MSC_VER)
16+
#define ATTRIBUTE(...)
17+
#else
18+
#define ATTRIBUTE(...) __attribute__((__VA_ARGS__))
19+
#endif
20+
21+
#endif // UTIL_ATTRIBUTE_2025_08_09_H

0 commit comments

Comments
 (0)