From 4438332396e6e1f950862a32a71df511865b4069 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 20 Apr 2024 00:09:11 +0200 Subject: [PATCH] memset_explicit: Fix compilation error on some OpenSolaris derivatives. * m4/extensions.m4 (gl_USE_SYSTEM_EXTENSIONS): Arrange to define __STDC_WANT_LIB_EXT1__ to 1. * modules/memset_explicit (Depends-on): Add extensions. * m4/memset_explicit.m4 (gl_FUNC_MEMSET_EXPLICIT): Require gl_USE_SYSTEM_EXTENSIONS. * lib/memset_explicit.c (__STDC_WANT_LIB_EXT1__): Remove definition. --- ChangeLog | 10 ++++++++++ lib/memset_explicit.c | 6 +----- m4/extensions.m4 | 8 +++++++- m4/memset_explicit.m4 | 4 +++- modules/memset_explicit | 1 + 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65770c9c33..1a8d80790b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2024-04-19 Bruno Haible + + memset_explicit: Fix compilation error on some OpenSolaris derivatives. + * m4/extensions.m4 (gl_USE_SYSTEM_EXTENSIONS): Arrange to define + __STDC_WANT_LIB_EXT1__ to 1. + * modules/memset_explicit (Depends-on): Add extensions. + * m4/memset_explicit.m4 (gl_FUNC_MEMSET_EXPLICIT): Require + gl_USE_SYSTEM_EXTENSIONS. + * lib/memset_explicit.c (__STDC_WANT_LIB_EXT1__): Remove definition. + 2024-04-19 Collin Funk gnulib-tool.py: Make use of GLModule's __hash__ method. diff --git a/lib/memset_explicit.c b/lib/memset_explicit.c index cf6cc64784..33c0987348 100644 --- a/lib/memset_explicit.c +++ b/lib/memset_explicit.c @@ -16,11 +16,7 @@ #include -/* memset_s need this define */ -#if HAVE_MEMSET_S -# define __STDC_WANT_LIB_EXT1__ 1 -#endif - +/* Specification. */ #include /* Set S's bytes to C, where S has LEN bytes. The compiler will not diff --git a/m4/extensions.m4 b/m4/extensions.m4 index 887c651564..fae4141358 100644 --- a/m4/extensions.m4 +++ b/m4/extensions.m4 @@ -1,5 +1,5 @@ # extensions.m4 -# serial 23 -*- Autoconf -*- +# serial 24 -*- Autoconf -*- dnl Copyright (C) 2003, 2006-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -230,4 +230,10 @@ AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS], [Define to enable the declarations of ISO C 11 types and functions.]) ;; esac + + dnl On OpenSolaris derivatives, the include files contains a couple of + dnl declarations that are only activated with an explicit + dnl -D__STDC_WANT_LIB_EXT1__. + AC_DEFINE([__STDC_WANT_LIB_EXT1__], [1], + [Define to enable the declarations of ISO C 23 Annex K types and functions.]) ]) diff --git a/m4/memset_explicit.m4 b/m4/memset_explicit.m4 index a47973ec4a..499a95968a 100644 --- a/m4/memset_explicit.m4 +++ b/m4/memset_explicit.m4 @@ -1,5 +1,5 @@ # memset_explicit.m4 -# serial 2 +# serial 3 dnl Copyright 2022-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -8,6 +8,8 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_MEMSET_EXPLICIT], [ AC_REQUIRE([gl_STRING_H_DEFAULTS]) + dnl Persuade OpenSolaris derivatives' to declare memset_s(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) gl_CHECK_FUNCS_ANDROID([memset_explicit], [[#include ]]) if test $ac_cv_func_memset_explicit = no; then diff --git a/modules/memset_explicit b/modules/memset_explicit index da16edefd6..294c9f4d8e 100644 --- a/modules/memset_explicit +++ b/modules/memset_explicit @@ -7,6 +7,7 @@ m4/memset_explicit.m4 Depends-on: string +extensions configure.ac: gl_FUNC_MEMSET_EXPLICIT -- 2.39.5