+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.
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