This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 2a1f24b8178 compiler: Add PRAGMA and unroll_loop.
2a1f24b8178 is described below
commit 2a1f24b817829f4e0a9fd9d1256fc9b72af9e328
Author: ouyangxiangzhen <[email protected]>
AuthorDate: Sun Jan 4 14:13:05 2026 +0800
compiler: Add PRAGMA and unroll_loop.
This commit added PRAGMA and unroll_loop to support compiler
loop-unrolling.
Signed-off-by: ouyangxiangzhen <[email protected]>
---
include/nuttx/compiler.h | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h
index 1dd51c86b8b..65cbce4e8d0 100644
--- a/include/nuttx/compiler.h
+++ b/include/nuttx/compiler.h
@@ -175,6 +175,14 @@
# define offsetof(a, b) __builtin_offsetof(a, b)
# define return_address(x) __builtin_return_address(x)
+# define PRAGMA(x) _Pragma(#x)
+
+# if defined(__clang__)
+# define unroll_loop(n) PRAGMA(clang loop unroll_count(n))
+# else
+# define unroll_loop(n) PRAGMA(GCC unroll n)
+# endif
+
/* Attributes
*
* GCC supports weak symbols which can be used to reduce code size because
@@ -814,6 +822,9 @@
# define offsetof(a, b) ((size_t)(&(((a *)(0))->b)))
# define return_address(x) 0
+# define PRAGMA(x)
+# define unroll_loop(n)
+
# define no_builtin(n)
/* Warning about usage of deprecated features. */
@@ -979,6 +990,9 @@
# define offsetof(a, b) ((size_t)(&(((a *)(0))->b)))
# define return_address(x) 0
+# define PRAGMA(x)
+# define unroll_loop(n)
+
# define no_builtin(n)
/* Warning about usage of deprecated features. */
@@ -1073,6 +1087,9 @@
# define offsetof(a, b) ((size_t)(&(((a *)(0))->b)))
# define return_address(x) 0
+# define PRAGMA(x)
+# define unroll_loop(n)
+
# define no_builtin(n)
/* Warning about usage of deprecated features. */
@@ -1175,6 +1192,9 @@
# define offsetof(a, b) ((size_t)(&(((a *)(0))->b)))
# define return_address(x) 0
+# define PRAGMA(x)
+# define unroll_loop(n)
+
# define no_builtin(n)
/* Warning about usage of deprecated features. */
@@ -1276,6 +1296,9 @@
# define offsetof(a, b) ((size_t)(&(((a *)(0))->b)))
# define return_address(x) 0
+# define PRAGMA(x)
+# define unroll_loop(n)
+
# define no_builtin(n)
/* Warning about usage of deprecated features. */
@@ -1368,6 +1391,9 @@
# define offsetof(a, b) ((size_t)(&(((a *)(0))->b)))
# define return_address(x) 0
+# define PRAGMA(x)
+# define unroll_loop(n)
+
# define no_builtin(n)
/* Warning about usage of deprecated features. */