]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Delete configure-time test for attribute support, in favor of __has_attribute.
authorNiels Möller <nisse@lysator.liu.se>
Mon, 11 May 2026 17:51:22 +0000 (19:51 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Mon, 11 May 2026 17:51:22 +0000 (19:51 +0200)
ChangeLog
aclocal.m4
configure.ac
fat-setup.h

index 274c5392118c9750f145476f01e14922b64dbe01..e3e677d465d3017fac657f9887094a7f5989fdda 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2026-05-11  Niels Möller  <nisse@lysator.liu.se>
+
+       * aclocal.m4 (LSH_GCC_ATTRIBUTES): Delete macro, based on
+       AC_COMPILE_IF_ELSE, and cpnfig.h define HAVE_GCC_ATTRIBUTE.
+       Replaced by...
+       (NETTLE_C_ATTRIBUTES): Simpler macro, just adding code to config.h
+       to define CONSTRUCTOR, NORETURN, PRINTF_STYLE and UNUSED, when
+       corresponding attributes are supported according to
+       __has_attribute. The __has_attribute test was introduced in clang
+       and gcc a decade ago.
+       * configure.ac: Use NETTLE_C_ATTRIBUTES.
+       * fat-setup.h: Remove local definition of CONSTRUCTOR. Also drop
+       support for using #pragma init(...) with Sun compilers.
+
 2026-05-07  Niels Möller  <nisse@lysator.liu.se>
 
        Add support for sntrup761.
index 73bf0cfbf39a60ec3cf6acc04635bbdd8f0ca7cc..434e819da524e87af5a6adafcd2124db2dfd59b6 100644 (file)
@@ -38,37 +38,34 @@ AC_CACHE_VAL(lsh_cv_sys_ccpic,[
 CCPIC="$lsh_cv_sys_ccpic"
 AC_MSG_RESULT($CCPIC)])
 
-dnl LSH_GCC_ATTRIBUTES
-dnl Check for gcc's __attribute__ construction
-
-AC_DEFUN([LSH_GCC_ATTRIBUTES],
-[AC_CACHE_CHECK(for __attribute__,
-              lsh_cv_c_attribute,
-[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <stdlib.h>
-
-static void foo(void) __attribute__ ((noreturn));
-
-static void __attribute__ ((noreturn))
-foo(void)
-{
-  exit(1);
-}
-]], [[]])],
-  [lsh_cv_c_attribute=yes],
-  [lsh_cv_c_attribute=no])])
-
-AH_TEMPLATE([HAVE_GCC_ATTRIBUTE], [Define if the compiler understands __attribute__])
-if test "x$lsh_cv_c_attribute" = "xyes"; then
-  AC_DEFINE(HAVE_GCC_ATTRIBUTE)
-fi
-
-AH_BOTTOM(
-[#if __GNUC__ && HAVE_GCC_ATTRIBUTE
-# define NORETURN __attribute__ ((__noreturn__))
-# define PRINTF_STYLE(f, a) __attribute__ ((__format__ (__printf__, f, a)))
-# define UNUSED __attribute__ ((__unused__))
-#else
+dnl NETTLE_C_ATTRIBUTES
+dnl Add code to config.h checking __has_attribute for the attributes
+dnl we use.
+AC_DEFUN([NETTLE_C_ATTRIBUTES],
+[AH_BOTTOM([
+#ifdef __has_attribute
+# if __has_attribute (__constructor__)
+#  define CONSTRUCTOR __attribute__ ((__constructor__))
+# else
+#  define CONSTRUCTOR
+# endif
+# if __has_attribute (__noreturn__)
+#  define NORETURN __attribute__ ((__noreturn__))
+# else
+#  define NORETURN
+# endif
+# if __has_attribute (__format__)
+#  define PRINTF_STYLE(f, a) __attribute__ ((__format__ (__printf__, f, a)))
+# else
+#  define PRINTF_STYLE(f, a)
+# endif
+# if __has_attribute (__unused__)
+#  define UNUSED __attribute__ ((__unused__))
+# else
+#  define UNUSED
+# endif
+#else /* !_has_attribute */
+# define CONSTRUCTOR
 # define NORETURN
 # define PRINTF_STYLE(f, a)
 # define UNUSED
index af017d81a5dba8a4da8a4512e8fb6245f21e4922..c49462cb8c7bb8df02ba0b8fe7b8636560220194 100644 (file)
@@ -215,7 +215,7 @@ if test "x$nettle_cv_c_builtin_bswap64" = "xyes" ; then
   AC_DEFINE(HAVE_BUILTIN_BSWAP64)
 fi
 
-LSH_GCC_ATTRIBUTES
+NETTLE_C_ATTRIBUTES
 
 # Check for file locking. We (AC_PROG_CC?) have already checked for
 # sys/types.h and unistd.h.
index 37a600a839fc125168bee925c2f15a665f1d0fa6..3c53db41cff6ad3236fdd055dc4085220190593c 100644 (file)
      time.
 */
 
-#if HAVE_GCC_ATTRIBUTE
-# define CONSTRUCTOR __attribute__ ((constructor))
-#else
-# define CONSTRUCTOR
-# if defined (__sun)
-#  pragma init(fat_init)
-# endif
-#endif
-
 /* Disable use of ifunc for now. Problem is, there's no guarantee that
    one can call any libc functions from the ifunc resolver. On x86 and
    x86_64, the corresponding IRELATIVE relocs are supposed to be