summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2010-01-22 08:27:20 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2010-01-22 08:27:20 +0100
commit3d43e5390d83a95b08d09e8b811523f2d99a092c (patch)
tree3dedea7cc43708d102bdbaeb39e9a72459b294a2 /apt-pkg
parentd16aade9b781538ad5d6d79eda7b69ff075aad85 (diff)
add a few gcc helpers, including [un]likely() and __deprecated
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/system.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/apt-pkg/contrib/system.h b/apt-pkg/contrib/system.h
index 7ec3d7feb..b57093b93 100644
--- a/apt-pkg/contrib/system.h
+++ b/apt-pkg/contrib/system.h
@@ -55,4 +55,26 @@
#define CLRFLAG(v,f) ((v) &=~FLAG(f))
#define CHKFLAG(v,f) ((v) & FLAG(f) ? true : false)
+// some nice optional GNUC features
+#if __GNUC__ >= 3
+ #define __must_check __attribute__ ((warn_unused_result))
+ #define __deprecated __attribute__ ((deprecated))
+ /* likely() and unlikely() can be used to mark boolean expressions
+ as (not) likely true which will help the compiler to optimise */
+ #define likely(x) __builtin_expect (!!(x), 1)
+ #define unlikely(x) __builtin_expect (!!(x), 0)
+#else
+ #define __must_check /* no warn_unused_result */
+ #define __deprecated /* no deprecated */
+ #define likely(x) (x)
+ #define unlikely(x) (x)
+#endif
+
+// cold functions are unlikely() to be called
+#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4
+ #define __cold __attribute__ ((__cold__))
+#else
+ #define __cold /* no cold marker */
+#endif
+
#endif