Ver código fonte

libdpkg: Use __attribute__ keyword depending on compiler support

Check for compiler support from preprocessor macros and selectively
enable specific __attribute__ specifications. We avoid exposing the
configure variable HAVE_C_ATTRIBUTE, which was never defined for the
installed headers. Remove the now unused DPKG_C_ATTRIBUTE autoconf
macro.
Guillem Jover 16 anos atrás
pai
commit
28b0443163
4 arquivos alterados com 8 adições e 20 exclusões
  1. 0 1
      configure.ac
  2. 2 0
      debian/changelog
  3. 6 2
      lib/dpkg/macros.h
  4. 0 17
      m4/dpkg-compiler.m4

+ 0 - 1
configure.ac

@@ -114,7 +114,6 @@ DPKG_TYPE_PTRDIFF_T
 AC_CHECK_SIZEOF([unsigned int])
 AC_CHECK_SIZEOF([unsigned long])
 DPKG_DECL_SYS_SIGLIST
-DPKG_C_ATTRIBUTE
 
 # Checks for library functions.
 DPKG_FUNC_VA_COPY

+ 2 - 0
debian/changelog

@@ -3,6 +3,8 @@ dpkg (1.15.6.1) UNRELEASED; urgency=low
   * Fix two memory leaks introduced in 1.15.6.
   * Always use C99 variadic macros, as the build requires them anyway, we
     avoid exposing the configure variable HAVE_C99 on installed headers.
+  * Use __attribute__ keyword depending on compiler support, we avoid
+    exposing the configure variable HAVE_C_ATTRIBUTE on installed headers.
 
  -- Guillem Jover <guillem@debian.org>  Sat, 13 Mar 2010 05:23:34 +0100
 

+ 6 - 2
lib/dpkg/macros.h

@@ -27,19 +27,23 @@
 
 /* Language definitions. */
 
-#if HAVE_C_ATTRIBUTE
+#if defined(__GNUC__) && (__GNUC__ >= 3)
 #define DPKG_ATTR_UNUSED	__attribute__((unused))
 #define DPKG_ATTR_CONST		__attribute__((const))
 #define DPKG_ATTR_NORET		__attribute__((noreturn))
 #define DPKG_ATTR_PRINTF(n)	__attribute__((format(printf, n, n + 1)))
 #define DPKG_ATTR_VPRINTF(n)	__attribute__((format(printf, n, 0)))
-#define DPKG_ATTR_SENTINEL	__attribute__((sentinel))
 #else
 #define DPKG_ATTR_UNUSED
 #define DPKG_ATTR_CONST
 #define DPKG_ATTR_NORET
 #define DPKG_ATTR_PRINTF(n)
 #define DPKG_ATTR_VPRINTF(n)
+#endif
+
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#define DPKG_ATTR_SENTINEL	__attribute__((sentinel))
+#else
 #define DPKG_ATTR_SENTINEL
 #endif
 

+ 0 - 17
m4/dpkg-compiler.m4

@@ -38,23 +38,6 @@ AC_DEFUN([DPKG_COMPILER_OPTIMISATIONS],
 fi])dnl
 ])
 
-# DPKG_C_ATTRIBUTE
-# ----------------
-# Check whether the C compiler supports __attribute__, defines HAVE_C_ATTRIBUTE
-AC_DEFUN([DPKG_C_ATTRIBUTE],
-[AC_CACHE_CHECK([whether compiler supports __attribute__], [dpkg_cv_attribute],
-	[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-		[[]],
-		[[extern int testfunction(int x) __attribute__((unused))]]
-	)],
-	[dpkg_cv_attribute=yes],
-	[dpkg_cv_attribute=no])])
-AS_IF([test "x$dpkg_cv_attribute" = "xyes"],
-	[AC_DEFINE([HAVE_C_ATTRIBUTE], 1,
-		[Define to 1 if compiler supports '__attribute__', 0 otherwise.])],
-	[AC_DEFINE([HAVE_C_ATTRIBUTE], 0)])dnl
-])# DPKG_C_ATTRIBUTE
-
 # DPKG_TRY_C99([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
 # ------------------------------------------------------
 # Try compiling some C99 code to see whether it works