commit d1ad64a27ac50a257adb47e3676ed97ee8376466
parent e7009dcd065b94bf5da7f1f7c612654cd331619e
Author: Remy Noulin <loader2x@gmail.com>
Date: Wed, 17 Jun 2020 20:22:22 +0200
add defines for some gcc attributes
release/libsheepy.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++
src/libsheepy.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 108 insertions(+)
Diffstat:
2 files changed, 108 insertions(+), 0 deletions(-)
diff --git a/release/libsheepy.h b/release/libsheepy.h
@@ -7593,12 +7593,66 @@ int nanoSleepF(uint64_t time);
* }
*/
#define FALLTHRU __attribute__ ((fallthrough))
+
+/** always inline function */
+#define AINLINE inline __attribute__ ((always_inline))
+
+/** never inline function */
+#define NOINLINE __attribute__ ((noinline))
+
+/**
+ * pure function (no effect on assembly code with gcc 10)
+ * a pure function is one that has no side effects and whose return value reflects only
+ * the function's parameters or nonvolatile global variables.
+ * Any parameter or global variable access must be read-only
+ */
+//#define PURE __attribute__ ((pure))
+
+/**
+ * const function (no effect on assembly code with gcc 10)
+ * a const function is a pure function that cannot access global variables
+ * and cannot take pointers as parameters.
+ */
+//#define CONST __attribute__ ((const))
+
+/** function that always terminate the program, the compile optimizes the caller code better */
+#define NORETURN __attribute__ ((noreturn))
+
+/** function returning a pointer to a newly allocated buffer */
+#define AMALLOC __attribute__ ((malloc))
+
+/** force function callers to check return value */
+#define MUST_CHECK __attribute__ ((warn_unused_result))
+
+/** mark a function as used */
+#define USED __attribute__ ((used))
+
+/** force alignment */
+#define ALIGN(X) __attribute__ ((aligned, (x)))
+#define ALIGN_MAX __attribute__ ((aligned))
+
+/** branch anotation (use profile feedback-directed optimization instead) */
+//#define likely(x) __builtin_expect (!!(x), 1)
+//#define unlikely(x) __builtin_expect (!!(x), 0)
+
#else
#define UNUSED
#define DEPRECATED
#define PACKED
#define CLEANUP
#define FALLTHRU
+#define AINLINE
+#define NOINLINE
+#define PURE
+#define CONST
+#define NORETURN
+#define AMALLOC
+#define MUST_CHECK
+#define USED
+#define ALIGN(X)
+#define ALIGN_MAX
+#define likely(x) (x)
+#define unlikely(x) (x)
#endif
#endif // _libsheepyH
diff --git a/src/libsheepy.h b/src/libsheepy.h
@@ -7593,12 +7593,66 @@ int nanoSleepF(uint64_t time);
* }
*/
#define FALLTHRU __attribute__ ((fallthrough))
+
+/** always inline function */
+#define AINLINE inline __attribute__ ((always_inline))
+
+/** never inline function */
+#define NOINLINE __attribute__ ((noinline))
+
+/**
+ * pure function (no effect on assembly code with gcc 10)
+ * a pure function is one that has no side effects and whose return value reflects only
+ * the function's parameters or nonvolatile global variables.
+ * Any parameter or global variable access must be read-only
+ */
+//#define PURE __attribute__ ((pure))
+
+/**
+ * const function (no effect on assembly code with gcc 10)
+ * a const function is a pure function that cannot access global variables
+ * and cannot take pointers as parameters.
+ */
+//#define CONST __attribute__ ((const))
+
+/** function that always terminate the program, the compile optimizes the caller code better */
+#define NORETURN __attribute__ ((noreturn))
+
+/** function returning a pointer to a newly allocated buffer */
+#define AMALLOC __attribute__ ((malloc))
+
+/** force function callers to check return value */
+#define MUST_CHECK __attribute__ ((warn_unused_result))
+
+/** mark a function as used */
+#define USED __attribute__ ((used))
+
+/** force alignment */
+#define ALIGN(X) __attribute__ ((aligned, (x)))
+#define ALIGN_MAX __attribute__ ((aligned))
+
+/** branch anotation (use profile feedback-directed optimization instead) */
+//#define likely(x) __builtin_expect (!!(x), 1)
+//#define unlikely(x) __builtin_expect (!!(x), 0)
+
#else
#define UNUSED
#define DEPRECATED
#define PACKED
#define CLEANUP
#define FALLTHRU
+#define AINLINE
+#define NOINLINE
+#define PURE
+#define CONST
+#define NORETURN
+#define AMALLOC
+#define MUST_CHECK
+#define USED
+#define ALIGN(X)
+#define ALIGN_MAX
+#define likely(x) (x)
+#define unlikely(x) (x)
#endif
#endif // _libsheepyH