summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuEe-GUI <[email protected]>2024-10-30 14:27:08 +0800
committerRbb666 <[email protected]>2024-11-04 10:10:15 +0800
commitd8db49c17af98cedfe1a7634233b505d92ce8445 (patch)
treeddcd4e3b05b4eab956431cf89b64bb2f52401f96
parenta573ea06b7bbf1f22c6add812770f9734f04ae66 (diff)
[COMPILER/FEATURE] Support rt_packed
__ARMCC_VERSION: https://smtp.keil.com/support/man/docs/armcc/armcc_chr1359124980173.htm __IAR_SYSTEMS_ICC__: <Not Found> __GNUC__: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-packed-type-attribute __ADSPBLACKFIN__: <Not Found> _MSC_VER: https://learn.microsoft.com/en-us/cpp/preprocessor/pack?view=msvc-170 __TI_COMPILER_VERSION__: https://software-dl.ti.com/codegen/docs/tiarmclang/rel1_3_0_LTS/migration_guide/migrating_c_and_cpp_source/pragmas_and_attributes.html __TASKING__: https://resources.tasking.com/sites/default/files/2021-02/TASKING_Alignment%20Requirements%20Restrictions_WEB.pdf Usage: ```c rt_packed(struct object1 { int dword; char byte; }); typedef struct object1 object1; rt_packed(struct object2 { int dword; char byte; }); ``` Signed-off-by: GuEe-GUI <[email protected]>
-rw-r--r--include/rtcompiler.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/rtcompiler.h b/include/rtcompiler.h
index bf1da29c2f..121f084ae9 100644
--- a/include/rtcompiler.h
+++ b/include/rtcompiler.h
@@ -16,6 +16,11 @@
#define rt_section(x) __attribute__((section(x)))
#define rt_used __attribute__((used))
#define rt_align(n) __attribute__((aligned(n)))
+#if __ARMCC_VERSION >= 6010050
+#define rt_packed(declare) declare __attribute__((packed))
+#else
+#define rt_packed(declare) declare
+#endif
#define rt_weak __attribute__((weak))
#define rt_typeof typeof
#define rt_noreturn
@@ -26,6 +31,7 @@
#define rt_used __root
#define PRAGMA(x) _Pragma(#x)
#define rt_align(n) PRAGMA(data_alignment=n)
+#define rt_packed(declare) declare
#define rt_weak __weak
#define rt_typeof __typeof
#define rt_noreturn
@@ -37,6 +43,7 @@
#define rt_section(x) __attribute__((section(x)))
#define rt_used __attribute__((used))
#define rt_align(n) __attribute__((aligned(n)))
+#define rt_packed(declare) declare __attribute__((packed))
#define rt_weak __attribute__((weak))
#define rt_typeof __typeof__
#define rt_noreturn __attribute__ ((noreturn))
@@ -46,6 +53,7 @@
#define rt_section(x) __attribute__((section(x)))
#define rt_used __attribute__((used))
#define rt_align(n) __attribute__((aligned(n)))
+#define rt_packed(declare) declare
#define rt_weak __attribute__((weak))
#define rt_typeof typeof
#define rt_noreturn
@@ -55,6 +63,7 @@
#define rt_section(x)
#define rt_used
#define rt_align(n) __declspec(align(n))
+#define rt_packed(declare) __pragma(pack(push, 1)) declare __pragma(pack(pop))
#define rt_weak
#define rt_typeof typeof
#define rt_noreturn
@@ -74,6 +83,7 @@
#endif
#define PRAGMA(x) _Pragma(#x)
#define rt_align(n) __attribute__((aligned(n)))
+#define rt_packed(declare) declare __attribute__((packed))
#ifdef __TI_EABI__
#define rt_weak __attribute__((weak))
#else
@@ -88,6 +98,7 @@
#define rt_used __attribute__((used, protect))
#define PRAGMA(x) _Pragma(#x)
#define rt_align(n) __attribute__((__align(n)))
+#define rt_packed(declare) declare __packed__
#define rt_weak __attribute__((weak))
#define rt_typeof typeof
#define rt_noreturn