PURE_FUNC, CONST_FUNC, MUST_CHECK: New function attributes; LIKELY()/UNLIKELY():...
authorbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 14 Sep 2004 21:03:04 +0000 (21:03 +0000)
committerbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 14 Sep 2004 21:03:04 +0000 (21:03 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@204 38d2e660-2303-0410-9eaa-f027e97ec537

compiler.h

index a81120f498ca3ec0721bff2a14cb6a4b9c2aa221..e27959c7d76090a994e1cfeff16180ae33e353bc 100755 (executable)
@@ -15,6 +15,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.22  2004/09/14 21:03:04  bernie
+ *#* PURE_FUNC, CONST_FUNC, MUST_CHECK: New function attributes; LIKELY()/UNLIKELY(): Fix for non-integral expressions.
+ *#*
  *#* Revision 1.21  2004/09/06 21:38:31  bernie
  *#* Misc documentation and style fixes.
  *#*
        #define NORETURN                __attribute__((__noreturn__))
        #define UNUSED(type,arg)        __attribute__((__unused__)) type arg
        #define INLINE                  static inline __attribute__((__always_inline__))
-       #define LIKELY(x)               __builtin_expect((x), 1)
-       #define UNLIKELY(x)             __builtin_expect((x), 0)
-       #define RESTRICT                __restrict__
+       #define LIKELY(x)               __builtin_expect(!!(x), 1)
+       #define UNLIKELY(x)             __builtin_expect(!!(x), 0)
+       #define PURE_FUNC               __attribute__((pure))
+       #define CONST_FUNC              __attribute__((const))
+       #define RESTRICT                __restrict__
+       #define MUST_CHECK              __attribute__((warn_unused_result))
        #if GNUC_PREREQ(3,1)
-               #define DEPRECATED      __attribute__((__deprecated__))
+               #define DEPRECATED  __attribute__((__deprecated__))
        #endif
 
        #if CPU_X86
 #ifndef UNLIKELY
 #define UNLIKELY(x)            x
 #endif
+#ifndef PURE_FUNC
+#define PURE_FUNC              /* nothing */
+#endif
+#ifndef CONST_FUNC
+#define CONST_FUNC             /* nothing */
+#endif
 #ifndef RESTRICT
-#define RESTRICT
+#define RESTRICT               /* nothing */
+#endif
+#ifndef MUST_CHECK
+#define MUST_CHECK             /* nothing */
 #endif
 
 /* Support for harvard architectures */