From 54298f49d71347616df19b8d2f59c907374e07b3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 1 Mar 2014 22:27:11 +0100 Subject: move defines for version to macros.h also adds namespaced attributes for good usage Git-Dch: Ignore --- apt-pkg/contrib/macros.h | 84 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 67 insertions(+), 17 deletions(-) (limited to 'apt-pkg/contrib/macros.h') diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h index e53d01b8f..294242e68 100644 --- a/apt-pkg/contrib/macros.h +++ b/apt-pkg/contrib/macros.h @@ -54,37 +54,87 @@ #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)) - #define __attrib_const __attribute__ ((__const__)) - /* likely() and unlikely() can be used to mark boolean expressions - as (not) likely true which will help the compiler to optimise */ +#ifdef __GNUC__ +#define APT_GCC_VERSION (__GNUC__ << 8 | __GNUC_MINOR__) +#else +#define APT_GCC_VERSION 0 +#endif + +/* likely() and unlikely() can be used to mark boolean expressions + as (not) likely true which will help the compiler to optimise */ +#if APT_GCC_VERSION >= 0x0300 #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 __attrib_const /* no const attribute */ #define likely(x) (x) #define unlikely(x) (x) #endif +#if APT_GCC_VERSION >= 0x0300 + #define APT_UNUSED __attribute__((unused)) + #define APT_CONST __attribute__((const)) + #define APT_PURE __attribute__((pure)) + #define APT_NORETURN __attribute__((noreturn)) + #define APT_PRINTF(n) __attribute__((format(printf, n, n + 1))) +#else + #define APT_UNUSED + #define APT_CONST + #define APT_PURE + #define APT_NORETURN + #define APT_PRINTF(n) +#endif + +#if APT_GCC_VERSION > 0x0302 + #define APT_NONNULL(...) __attribute__((nonnull(__VA_ARGS__))) + #define APT_MUSTCHECK __attribute__((warn_unused_result)) +#else + #define APT_NONNULL(...) + #define APT_REQRET +#endif + +#if APT_GCC_VERSION >= 0x0400 + #define APT_SENTINEL __attribute__((sentinel)) +#else + #define APT_SENTINEL +#endif + // cold functions are unlikely() to be called -#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4 - #define __cold __attribute__ ((__cold__)) - #define __hot __attribute__ ((__hot__)) +#if APT_GCC_VERSION >= 0x0403 + #define APT_COLD __attribute__ ((__cold__)) + #define APT_HOT __attribute__ ((__hot__)) #else - #define __cold /* no cold marker */ - #define __hot /* no hot marker */ + #define __cold + #define __hot #endif -#ifdef __GNUG__ -// Methods have a hidden this parameter that is visible to this attribute +#ifndef APT_10_CLEANER_HEADERS +#if APT_GCC_VERSION >= 0x0300 + #define __must_check __attribute__ ((warn_unused_result)) + #define __deprecated __attribute__ ((deprecated)) + #define __attrib_const __attribute__ ((__const__)) #define __like_printf(n) __attribute__((format(printf, n, n + 1))) #else + #define __must_check /* no warn_unused_result */ + #define __deprecated /* no deprecated */ + #define __attrib_const /* no const attribute */ #define __like_printf(n) /* no like-printf */ #endif +#if APT_GCC_VERSION >= 0x0403 + #define __cold __attribute__ ((__cold__)) + #define __hot __attribute__ ((__hot__)) +#else + #define __cold /* no cold marker */ + #define __hot /* no hot marker */ +#endif +#endif + +// These lines are extracted by the makefiles and the buildsystem +// Increasing MAJOR or MINOR results in the need of recompiling all +// reverse-dependencies of libapt-pkg against the new SONAME. +// Non-ABI-Breaks should only increase RELEASE number. +// See also buildlib/libversion.mak +#define APT_PKG_MAJOR 4 +#define APT_PKG_MINOR 12 +#define APT_PKG_RELEASE 0 #endif -- cgit v1.2.3 From 453b82a388013e522b3a1b9fcd6ed0810dab1f4f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 5 Mar 2014 22:11:25 +0100 Subject: cleanup headers and especially #includes everywhere Beside being a bit cleaner it hopefully also resolves oddball problems I have with high levels of parallel jobs. Git-Dch: Ignore Reported-By: iwyu (include-what-you-use) --- apt-pkg/contrib/macros.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'apt-pkg/contrib/macros.h') diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h index 294242e68..d97053553 100644 --- a/apt-pkg/contrib/macros.h +++ b/apt-pkg/contrib/macros.h @@ -71,13 +71,13 @@ #endif #if APT_GCC_VERSION >= 0x0300 - #define APT_UNUSED __attribute__((unused)) + #define APT_DEPRECATED __attribute__ ((deprecated)) #define APT_CONST __attribute__((const)) #define APT_PURE __attribute__((pure)) #define APT_NORETURN __attribute__((noreturn)) #define APT_PRINTF(n) __attribute__((format(printf, n, n + 1))) #else - #define APT_UNUSED + #define APT_DEPRECATED #define APT_CONST #define APT_PURE #define APT_NORETURN @@ -103,8 +103,8 @@ #define APT_COLD __attribute__ ((__cold__)) #define APT_HOT __attribute__ ((__hot__)) #else - #define __cold - #define __hot + #define APT_COLD + #define APT_HOT #endif #ifndef APT_10_CLEANER_HEADERS -- cgit v1.2.3 From 63ff42089863cda53aee240ea0124106e8b4d983 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 21 Mar 2014 15:54:15 +0100 Subject: enable fvisibility=hidden for our private library While it is a huge undertaking to enable it for our public libraries as basically everything we exported so far could be seen as public interface our private library is new and under our full control, so we can do whatever we like with it. The benefits are not that big in return of course, but it reduces the size a bit, so thats great nontheless. Git-Dch: ignore --- apt-pkg/contrib/macros.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'apt-pkg/contrib/macros.h') diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h index d97053553..2d6448e5e 100644 --- a/apt-pkg/contrib/macros.h +++ b/apt-pkg/contrib/macros.h @@ -94,8 +94,12 @@ #if APT_GCC_VERSION >= 0x0400 #define APT_SENTINEL __attribute__((sentinel)) + #define APT_PUBLIC __attribute__ ((visibility ("default"))) + #define APT_HIDDEN __attribute__ ((visibility ("hidden"))) #else #define APT_SENTINEL + #define APT_PUBLIC + #define APT_HIDDEN #endif // cold functions are unlikely() to be called -- cgit v1.2.3