From 38762fb6185904889bd5ef36320dd6887f9af760 Mon Sep 17 00:00:00 2001 From: Max Paperno Date: Wed, 20 Dec 2017 04:19:59 -0500 Subject: [PATCH] Move `__attribute__ ((section(s), used))` macro, and cosmetics in definitions.h. (#5549) --- radio/src/definitions.h | 46 +++++++++++++++++++---------------------- radio/src/stamp.cpp | 10 ++------- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/radio/src/definitions.h b/radio/src/definitions.h index 02ff26e61..df5bb4165 100644 --- a/radio/src/definitions.h +++ b/radio/src/definitions.h @@ -23,8 +23,10 @@ #if defined(SIMU) #define __ALIGNED + #define __SECTION_USED(s) #else - #define __ALIGNED __attribute__((aligned(32))) + #define __ALIGNED __attribute__((aligned(32))) + #define __SECTION_USED(s) __attribute__ ((section(s), used)) #endif #if defined(SIMU) @@ -36,14 +38,10 @@ #endif #if defined(PCBHORUS) && !defined(SIMU) - #define __SDRAM __attribute__((section(".sdram"), aligned(32))) -#else - #define __SDRAM __DMA -#endif - -#if defined(PCBHORUS) && !defined(SIMU) - #define __NOINIT __attribute__((section(".noinit"))) + #define __SDRAM __attribute__((section(".sdram"), aligned(32))) + #define __NOINIT __attribute__((section(".noinit"))) #else + #define __SDRAM __DMA #define __NOINIT #endif @@ -54,29 +52,27 @@ typedef __int24 int24_t; #endif #if __GNUC__ -#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__)) + #define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__)) #else -#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) ) + #define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) ) #endif #if defined(SIMU) -#if !defined(FORCEINLINE) -#define FORCEINLINE inline -#endif -#if !defined(NOINLINE) -#define NOINLINE -#endif -#define CONVERT_PTR_UINT(x) ((uint32_t)(uint64_t)(x)) -#define CONVERT_UINT_PTR(x) ((uint32_t*)(uint64_t)(x)) + #if !defined(FORCEINLINE) + #define FORCEINLINE inline + #endif + #if !defined(NOINLINE) + #define NOINLINE + #endif + #define CONVERT_PTR_UINT(x) ((uint32_t)(uint64_t)(x)) + #define CONVERT_UINT_PTR(x) ((uint32_t*)(uint64_t)(x)) #else -#if !defined(_MSC_VER) || (_MSC_VER < 1200) #define FORCEINLINE inline __attribute__ ((always_inline)) -#endif -#define NOINLINE __attribute__ ((noinline)) -#define SIMU_SLEEP(x) -#define SIMU_SLEEP_NORET(x) -#define CONVERT_PTR_UINT(x) ((uint32_t)(x)) -#define CONVERT_UINT_PTR(x) ((uint32_t *)(x)) + #define NOINLINE __attribute__ ((noinline)) + #define SIMU_SLEEP(x) + #define SIMU_SLEEP_NORET(x) + #define CONVERT_PTR_UINT(x) ((uint32_t)(x)) + #define CONVERT_UINT_PTR(x) ((uint32_t *)(x)) #endif #endif // _DEFINITIONS_H_ diff --git a/radio/src/stamp.cpp b/radio/src/stamp.cpp index f6387d7b0..4cc672c88 100644 --- a/radio/src/stamp.cpp +++ b/radio/src/stamp.cpp @@ -51,14 +51,8 @@ */ #if defined(STM32) -#if defined(SIMU) - #define ATTRIBUTE_SECTION(s) -#else - #define ATTRIBUTE_SECTION(s) __attribute__ ((section(s), used)) -#endif - -ATTRIBUTE_SECTION(".fwversiondata") const char firmware_version[] = "opentx-" FLAVOUR "-" VERSION " (" GIT_STR ")"; -ATTRIBUTE_SECTION(".bootversiondata") const char boot_version[] = "opentx-" FLAVOUR "-" VERSION " (" GIT_STR ")"; +__SECTION_USED(".fwversiondata") const char firmware_version[] = "opentx-" FLAVOUR "-" VERSION " (" GIT_STR ")"; +__SECTION_USED(".bootversiondata") const char boot_version[] = "opentx-" FLAVOUR "-" VERSION " (" GIT_STR ")"; /** * Tries to find opentx version in the first 1024 byte of either firmware/bootloader (the one not running) or the buffer