summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-03-01 22:27:11 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-03-13 13:58:45 +0100
commit54298f49d71347616df19b8d2f59c907374e07b3 (patch)
tree3ef781c3c094f9af89b8190b64bd55ea58960e71
parent655122418d714f342b5d9789f45f8035f3fe8b9a (diff)
downloadapt-54298f49d71347616df19b8d2f59c907374e07b3.tar.gz
move defines for version to macros.h
also adds namespaced attributes for good usage Git-Dch: Ignore
-rw-r--r--apt-pkg/contrib/macros.h84
-rw-r--r--apt-pkg/init.h11
-rw-r--r--buildlib/libversion.mak6
-rwxr-xr-xprepare-release2
4 files changed, 72 insertions, 31 deletions
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
diff --git a/apt-pkg/init.h b/apt-pkg/init.h
index b6f3df753..4ee7a95ac 100644
--- a/apt-pkg/init.h
+++ b/apt-pkg/init.h
@@ -1,6 +1,5 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: init.h,v 1.9.2.2 2004/01/02 18:51:00 mdz Exp $
/* ######################################################################
Init - Initialize the package library
@@ -17,19 +16,11 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/pkgsystem.h>
#endif
+#include <apt-pkg/macros.h>
class pkgSystem;
class Configuration;
-// 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
-
extern const char *pkgVersion;
extern const char *pkgLibVersion;
diff --git a/buildlib/libversion.mak b/buildlib/libversion.mak
index 796c956e7..deb3da377 100644
--- a/buildlib/libversion.mak
+++ b/buildlib/libversion.mak
@@ -2,9 +2,9 @@
# Version number of libapt-pkg.
# Please increase MAJOR with each ABI break,
# with each non-ABI break to the lib, please increase RELEASE.
-# The versionnumber is extracted from apt-pkg/init.h - see also there.
-LIBAPTPKG_MAJOR=$(shell awk -v ORS='.' '/^\#define APT_PKG_M/ {print $$3}' $(BASE)/apt-pkg/init.h | sed 's/\.$$//')
-LIBAPTPKG_RELEASE=$(shell grep -E '^\#define APT_PKG_RELEASE' $(BASE)/apt-pkg/init.h | cut -d ' ' -f 3)
+# The versionnumber is extracted from apt-pkg/macros.h - see also there.
+LIBAPTPKG_MAJOR=$(shell awk -v ORS='.' '/^\#define APT_PKG_M/ {print $$3}' $(BASE)/apt-pkg/contrib/macros.h | sed 's/\.$$//')
+LIBAPTPKG_RELEASE=$(shell grep -E '^\#define APT_PKG_RELEASE' $(BASE)/apt-pkg/contrib/macros.h | cut -d ' ' -f 3)
# Version number of libapt-inst
# Please increase MAJOR with each ABI break,
diff --git a/prepare-release b/prepare-release
index 6229ee1fd..7b7fd1224 100755
--- a/prepare-release
+++ b/prepare-release
@@ -11,7 +11,7 @@ fi
VERSION=$(dpkg-parsechangelog | sed -n -e '/^Version:/s/^Version: //p')
DISTRIBUTION=$(dpkg-parsechangelog | sed -n -e '/^Distribution:/s/^Distribution: //p')
-LIBAPTPKGVERSION="$(awk -v ORS='.' '/^\#define APT_PKG_M/ {print $3}' apt-pkg/init.h | sed 's/\.$//')"
+LIBAPTPKGVERSION="$(awk -v ORS='.' '/^\#define APT_PKG_M/ {print $3}' apt-pkg/contrib/macros.h | sed 's/\.$//')"
LIBAPTINSTVERSION="$(egrep '^MAJOR=' apt-inst/makefile |cut -d '=' -f 2)"
librarysymbolsfromfile() {