Re: bug#50098: Configuring --with-libsigsegv results in link error

2021-08-22 Thread Evan Miller


> On Aug 22, 2021, at 21:15, Bruno Haible  wrote:
> 
> You can ignore this error — which merely indicates that the POSIX threads on
> macOS 10.4 are incomplete and gnulib does not work around this particular
> issue — and comment out the test-pthread and test-pthread-rwlock from the
> gltests/Makefile. Then you can do 'make check' and see whether the
> tests of the 'sigsegv' module work or not.
> 
> Bruno
> 

At last, the "sigsegv" stackoverflow tests fail:

../build-aux/test-driver: line 112: 12956 Illegal instruction "$@" 
>$log_file 2>&1
FAIL: test-sigsegv-catch-stackoverflow1
../build-aux/test-driver: line 112: 12963 Illegal instruction "$@" 
>$log_file 2>&1
FAIL: test-sigsegv-catch-stackoverflow2

The other tests pass – except for the "nanosleep" test, which I commented out 
due to an apparent hang. So it looks like the 10.4 platform needs to require 
libsigsegv after all.


Re: bug#50098: Configuring --with-libsigsegv results in link error

2021-08-22 Thread Bruno Haible
Evan Miller wrote:
> After updating gnulib master, the "make" step now ends with the error:
> 
> gcc -std=gnu99 -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I..  
> -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I. -I.. -I./.. -I../gllib 
> -I./../gllib   -Wno-error -g -O2 -MT test-pthread.o -MD -MP -MF $depbase.Tpo 
> -c -o test-pthread.o test-pthread.c &&\
> mv -f $depbase.Tpo $depbase.Po
> test-pthread.c:35: error: ‘PTHREAD_RWLOCK_INITIALIZER’ undeclared here (not 
> in a function)
> make[4]: *** [test-pthread.o] Error 1
> 
> Same or similar results with GCC4 and GCC7.

You can ignore this error — which merely indicates that the POSIX threads on
macOS 10.4 are incomplete and gnulib does not work around this particular
issue — and comment out the test-pthread and test-pthread-rwlock from the
gltests/Makefile. Then you can do 'make check' and see whether the
tests of the 'sigsegv' module work or not.

Bruno






snippet/unused-parameter: Mark unused module obsolete

2021-08-22 Thread Bruno Haible
Paul Eggert wrote:
> >> * Remove the snippet/unused-parameter module as it's not used now.
> > 
> > Indeed, this module is unused in gnulib. It may be used in packages that
> > use gnulib; therefore I vote for marking it 'obsolete' and remove it only
> > in a year or two.
> 
> Sounds good to me too.

Done:


2021-08-22  Bruno Haible  

snippet/unused-parameter: Mark unused module obsolete.
* modules/snippet/unused-parameter (Status, Notice): Mark as obsolete.

diff --git a/modules/snippet/unused-parameter b/modules/snippet/unused-parameter
index 561b3e45a..78a3e3328 100644
--- a/modules/snippet/unused-parameter
+++ b/modules/snippet/unused-parameter
@@ -1,6 +1,12 @@
 Description:
 A C macro for declaring that specific function parameters are not used.
 
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
 Applicability:
 all
 






Re: bug#50098: Configuring --with-libsigsegv results in link error

2021-08-22 Thread Evan Miller


> On Aug 22, 2021, at 16:42, Paul Eggert  wrote:
> 
> On 8/22/21 4:19 AM, Evan Miller wrote:
>> c-stack.c: In function 'die':
>> c-stack.c:106:17: warning: implicit declaration of function 'mempcpy' 
>> [-Wimplicit-function-declaration]
>>char *p = mempcpy (buf, progname, prognamelen);
> 
> Evidently some dependencies were missing from the c-stack module. I installed 
> the attached patch. Please try the same set of commands again.
> <0001-c-stack-depend-on-inttypes-mempcpy.patch>

After updating gnulib master, the "make" step now ends with the error:

gcc -std=gnu99 -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I..  
-DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I. -I.. -I./.. -I../gllib 
-I./../gllib   -Wno-error -g -O2 -MT test-pthread.o -MD -MP -MF $depbase.Tpo -c 
-o test-pthread.o test-pthread.c &&\
mv -f $depbase.Tpo $depbase.Po
test-pthread.c:35: error: ‘PTHREAD_RWLOCK_INITIALIZER’ undeclared here (not in 
a function)
make[4]: *** [test-pthread.o] Error 1

Same or similar results with GCC4 and GCC7.


Re: Regression in gnulib 48ece5c3f/gcc 11

2021-08-22 Thread Bruno Haible
[CCing bug-gnulib.]

Jan Engelhardt wrote in private email:
> I would like to point you to https://github.com/paul-j-lucas/cdecl/issues/12
> from which I gathered that gnulib's stdlib.in.h received a change (48ece5c3f)
> by you that added this part that breaks on gcc11 systems:
> 
> 
> +# if __GNUC__ >= 11 && !defined strdup
> +/* For -Wmismatched-dealloc: Associate strdup with free or rpl_free.  */
> +_GL_FUNCDECL_SYS (strdup, char *,
> +  (char const *__s)
> +  _GL_ARG_NONNULL ((1))
> +  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
> +# endif
> 
> 
> _GL_ATTRIBUTE_MALLOC was not defined in the file, and so leads to a compile
> error. Note how the file *does* define a fallback for _GL_ATTRIBUTE_PURE, 
> which
> is why the compiler did not stumble upon that name first.

Thanks for the report. Formally, this is not a supported situation
because the documentation [1] says that you need to #include  before
including any .h file from Gnulib. Nevertheless we strive to make the generated
.h files be as standalone (that means, independent from ) as possible.
The patch below catches up on this property.

[1] https://www.gnu.org/software/gnulib/manual/html_node/Source-changes.html


2021-08-22  Bruno Haible  

Make generated .in.h files as standalone as possible.
Reported by Jan Engelhardt .
* lib/stdlib.in.h (_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEALLOC_FREE,
_GL_ATTRIBUTE_MALLOC): Add fallback definitions.
* lib/dirent.in.h (_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC): Add
fallback definitions.
* lib/stdio.in.h (_GL_ATTRIBUTE_DEALLOC): Add fallback definition.
* lib/math.in.h (_GL_ATTRIBUTE_CONST): Add fallback definition.
* lib/pthread.in.h (_GL_ATTRIBUTE_PURE): Add fallback definition.
* lib/threads.in.h (_GL_ATTRIBUTE_PURE): Likewise.
* lib/uchar.in.h (_GL_ATTRIBUTE_PURE): Likewise.
* lib/string.in.h (_GL_ATTRIBUTE_PURE): Move definition, for consistency
with the other *.in.h files.
* lib/se-context.in.h (_GL_ATTRIBUTE_MAYBE_UNUSED): Add fallback
definition.
* lib/se-label.in.h (_GL_ATTRIBUTE_MAYBE_UNUSED): Likewise.
* lib/se-selinux.in.h (_GL_ATTRIBUTE_MAYBE_UNUSED): Likewise.
* lib/textstyle.in.h: Use _GL_ATTRIBUTE_MAYBE_UNUSED instead of
_GL_UNUSED.
(_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_MAYBE_UNUSED): Add
fallback definitions.

diff --git a/lib/dirent.in.h b/lib/dirent.in.h
index 5775edf09..4deb0cb46 100644
--- a/lib/dirent.in.h
+++ b/lib/dirent.in.h
@@ -55,6 +55,28 @@ typedef struct gl_directory DIR;
 # endif
 #endif
 
+/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
+   that can be freed by passing them as the Ith argument to the
+   function F.  */
+#ifndef _GL_ATTRIBUTE_DEALLOC
+# if __GNUC__ >= 11
+#  define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
+# else
+#  define _GL_ATTRIBUTE_DEALLOC(f, i)
+# endif
+#endif
+
+/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
+   allocated memory.  */
+/* Applies to: functions.  */
+#ifndef _GL_ATTRIBUTE_MALLOC
+# if __GNUC__ >= 3 || defined __clang__
+#  define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+#  define _GL_ATTRIBUTE_MALLOC
+# endif
+#endif
+
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
The attribute __pure__ was added in gcc 2.96.  */
 #ifndef _GL_ATTRIBUTE_PURE
diff --git a/lib/math.in.h b/lib/math.in.h
index 6a055fbf5..c87cc12fc 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -56,6 +56,16 @@ _GL_INLINE_HEADER_BEGIN
 # define _GL_MATH_INLINE _GL_INLINE
 #endif
 
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The attribute __const__ was added in gcc 2.95.  */
+#ifndef _GL_ATTRIBUTE_CONST
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) || defined 
__clang__
+#  define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
+# else
+#  define _GL_ATTRIBUTE_CONST /* empty */
+# endif
+#endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_ARG_NONNULL is copied here.  */
diff --git a/lib/pthread.in.h b/lib/pthread.in.h
index c4cd36c12..65693d5d1 100644
--- a/lib/pthread.in.h
+++ b/lib/pthread.in.h
@@ -69,6 +69,16 @@
 #include 
 #include 
 
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The attribute __pure__ was added in gcc 2.96.  */
+#ifndef _GL_ATTRIBUTE_PURE
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined 
__clang__
+#  define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
+# else
+#  define _GL_ATTRIBUTE_PURE /* empty */
+# endif
+#endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _Noreturn is copied here.  */
diff --git a/lib/se-context.in.h b/lib/se-context.in.h
index d4ed6a4c1..a6c178ad6 100644
--- a/lib/

Re: gnulib-common.m4: Make _GL_UNUSED_LABEL effective for clang

2021-08-22 Thread Bruno Haible
Paul Eggert wrote:
> Also, your example used C code, but this fix doesn't affect C code. So 
> can we assume the real problem was with C++ code?

Yes. I tried the example both with C and C++.

 foo.cc 
int foo (int x)
{
  x += 2;
  if (x & 1)
goto a;
b:
  x *= 3;
a:
  return x;
}

$ clang -Wall -S foo.cc
foo.cc:6:1: warning: unused label 'b' [-Wunused-label]
b:
^~
1 warning generated.
The same definition as for GCC works, however, with clang:

 foo.cc 
int foo (int x)
{
  x += 2;
  if (x & 1)
goto a;
b:
  __attribute__ ((__unused__));
  x *= 3;
a:
  return x;
}

$ clang -Wall -S foo.cc
(no warning)

> On 8/22/21 1:17 PM, Bruno Haible wrote:
> > -#if !defined __cplusplus || _GL_GNUC_PREREQ (4, 5)
> > +#if (!defined __cplusplus || _GL_GNUC_PREREQ (4, 5)) || defined __clang__
> 
> I got a bit confused by the extra parentheses, thinking that somehow GCC 
> and Clang differ with respect to C++. Perhaps remove the extra parens?

And I got confused by this boolean expression already before, and understood
it only after looking at the ChangeLog entry from 2014-06-01. This indicates
that a comment is needed. This one is clearer for me. For you as well?


2021-08-22  Bruno Haible  

gnulib-common.m4: Clarify logic behind _GL_UNUSED_LABEL.
Reported by Paul Eggert.
* m4/gnulib-common.m4 (gl_COMMON_BODY): Add comment and write the
condition in a way that is close to the comment.

diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 8a10e5bc1..639fa8567 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -418,7 +418,9 @@ AC_DEFUN([gl_COMMON_BODY], [
immediately preceding label is not used.  The compiler should not warn
if the label is not used.  */
 /* Applies to: label (both in C and C++).  */
-#if (!defined __cplusplus || _GL_GNUC_PREREQ (4, 5)) || defined __clang__
+/* Note that g++ < 4.5 does not support the '__attribute__ ((__unused__)) ;'
+   syntax.  But clang does.  */
+#if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang__
 # define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED
 #else
 # define _GL_UNUSED_LABEL






Re: bug#50098: Configuring --with-libsigsegv results in link error

2021-08-22 Thread Paul Eggert

On 8/22/21 4:19 AM, Evan Miller wrote:

c-stack.c: In function 'die':
c-stack.c:106:17: warning: implicit declaration of function 'mempcpy' 
[-Wimplicit-function-declaration]
char *p = mempcpy (buf, progname, prognamelen);


Evidently some dependencies were missing from the c-stack module. I 
installed the attached patch. Please try the same set of commands again.
>From 7a2a0d40e713c5cfd0b77abd3bdd897d9e72fa26 Mon Sep 17 00:00:00 2001
From: Paul Eggert 
Date: Sun, 22 Aug 2021 13:39:24 -0700
Subject: [PATCH] c-stack: depend on inttypes, mempcpy

* modules/c-stack (Depends-on): Add inttypes, mempcpy.
mempcpy problem reported by Evan Miller in:
https://debbugs.gnu.org/50098#31
---
 ChangeLog   | 7 +++
 modules/c-stack | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 196704808..a6e8d6e99 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2021-08-22  Paul Eggert  
+
+	c-stack: depend on inttypes, mempcpy
+	* modules/c-stack (Depends-on): Add inttypes, mempcpy.
+	mempcpy problem reported by Evan Miller in:
+	https://debbugs.gnu.org/50098#31
+
 2021-08-22  Bruno Haible  
 
 	mountlist: Use recommended syntax for _GL_UNUSED_LABEL.
diff --git a/modules/c-stack b/modules/c-stack
index 32a412041..812e3efca 100644
--- a/modules/c-stack
+++ b/modules/c-stack
@@ -14,6 +14,8 @@ getprogname
 gettext-h
 idx
 ignore-value
+inttypes
+mempcpy
 raise
 sigsegv
 stddef
-- 
2.30.2



mountlist: Use recommended syntax for _GL_UNUSED_LABEL

2021-08-22 Thread Bruno Haible
A semicolon is expected after _GL_UNUSED_LABEL, at least in C++ mode. See:

 foo.c 
int foo (int x)
{
  x += 2;
  if (x & 1)
goto a;
b:
  __attribute__ ((__unused__))
  {
x *= 3;
  }
a:
  return x;
}
===

$ gcc -Wall -S foo.c
$ clang -Wall -S foo.c
$ gcc -Wall -S -x c++ foo.c
foo.c: In function 'int foo(int)':
foo.c:8:3: error: expected primary-expression before '{' token
8 |   {
  |   ^
foo.c:6:1: warning: label 'b' defined but not used [-Wunused-label]
6 | b:
  | ^
$ clang -Wall -S -x c++ foo.c
foo.c:8:3: error: expected ';' after __attribute__
  {
  ^
1 error generated.

Therefore, don't set a bad precedent by writing _GL_UNUSED_LABEL without
semicolon, even in C-only code.


2021-08-22  Bruno Haible  

mountlist: Use recommended syntax for _GL_UNUSED_LABEL.
* lib/mountlist.c (read_file_system_list): Add semicolon after
_GL_UNUSED_LABEL.

diff --git a/lib/mountlist.c b/lib/mountlist.c
index adc8740bf..352b35f35 100644
--- a/lib/mountlist.c
+++ b/lib/mountlist.c
@@ -1089,7 +1089,7 @@ read_file_system_list (bool need_fs_type)
   return mount_list;
 
 
- free_then_fail: _GL_UNUSED_LABEL
+ free_then_fail: _GL_UNUSED_LABEL;
   {
 int saved_errno = errno;
 *mtail = NULL;






Re: gnulib-common.m4: Make _GL_UNUSED_LABEL effective for clang

2021-08-22 Thread Paul Eggert

On 8/22/21 1:17 PM, Bruno Haible wrote:

-#if !defined __cplusplus || _GL_GNUC_PREREQ (4, 5)
+#if (!defined __cplusplus || _GL_GNUC_PREREQ (4, 5)) || defined __clang__


I got a bit confused by the extra parentheses, thinking that somehow GCC 
and Clang differ with respect to C++. Perhaps remove the extra parens?


Also, your example used C code, but this fix doesn't affect C code. So 
can we assume the real problem was with C++ code?




gnulib-common.m4: Make _GL_UNUSED_LABEL effective for clang

2021-08-22 Thread Bruno Haible
So far, _GL_UNUSED_LABEL works for GCC but not for clang. See:

 foo.c 
int foo (int x)
{
  x += 2;
  if (x & 1)
goto a;
b:
  x *= 3;
a:
  return x;
}
===
$ clang -Wall -S foo.c
foo.c:6:1: warning: unused label 'b' [-Wunused-label]
b:
^~
1 warning generated.

The same definition as for GCC works, however, with clang:

 foo.c 
int foo (int x)
{
  x += 2;
  if (x & 1)
goto a;
b:
  __attribute__ ((__unused__));
  x *= 3;
a:
  return x;
}
===
$ clang -Wall -S foo.c
(no warning)

This patch makes _GL_UNUSED_LABEL work also for clang.


2021-08-22  Bruno Haible  

gnulib-common.m4: Make _GL_UNUSED_LABEL effective for clang.
* m4/gnulib-common.m4 (gl_COMMON_BODY): Make _GL_UNUSED_LABEL use
_GL_ATTRIBUTE_UNUSED also for clang.

diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 801c7127b..8a10e5bc1 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -418,7 +418,7 @@ AC_DEFUN([gl_COMMON_BODY], [
immediately preceding label is not used.  The compiler should not warn
if the label is not used.  */
 /* Applies to: label (both in C and C++).  */
-#if !defined __cplusplus || _GL_GNUC_PREREQ (4, 5)
+#if (!defined __cplusplus || _GL_GNUC_PREREQ (4, 5)) || defined __clang__
 # define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED
 #else
 # define _GL_UNUSED_LABEL






gnulib-common.m4: Use C2x [[maybe_unused]] when possible

2021-08-22 Thread Bruno Haible
Paul Eggert wrote:
> > I'm OK with moving all _GL_UNUSED from after
> > the parameter declaration to before the parameter declaration. Then
> > we can continue to have
> >#define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
> 
> Yes, this sounds like a win. It's a lot simpler than my proposal. 
> Although it loses a bit of information when the arg is definitely 
> unused, perhaps that's not worth worrying about.

Done through this patch.


2021-08-22  Bruno Haible  

gnulib-common.m4: Use C2x [[maybe_unused]] when possible.
* m4/gnulib-common.m4 (gl_COMMON_BODY): Define _GL_UNUSED as an alias of
_GL_ATTRIBUTE_MAYBE_UNUSED, not of _GL_ATTRIBUTE_UNUSED.
* lib/binary-io.h (__gl_setmode): Put _GL_UNUSED before, not after, the
declaration.
* lib/c-stack.c (null_action, segv_handler, overflow_handler,
c_stack_action): Likewise.
* lib/chown.c (chown): Likewise.
* lib/clean-temp-simple.c (cleanup_action): Likewise.
* lib/fts.c (dirent_inode_sort_may_be_useful, leaf_optimization,
fts_set): Likewise.
* lib/getgroups.c (getgroups): Likewise.
* lib/getopt.c (_getopt_initialize): Likewise.
* lib/getugroups.c (getugroups): Likewise.
* lib/localename.c (gl_locale_name_thread_unsafe, gl_locale_name_thread,
gl_locale_name_posix, gl_locale_name_environ): Likewise.
* lib/mkdir.c (rpl_mkdir): Likewise.
* lib/mkfifo.c (mkfifo): Likewise.
* lib/mkfifoat.c (mkfifoat): Likewise.
* lib/mknod.c (mknod): Likewise.
* lib/mknodat.c (mknodat): Likewise.
* lib/mountlist.c (me_remote): Likewise.
* lib/openpty.c (openpty): Likewise.
* lib/parse-datetime.y (yyerror): Likewise.
* lib/passfd.c (sendfd, recvfd): Likewise.
* lib/pthread-cond.c (pthread_condattr_destroy, pthread_cond_init,
pthread_cond_wait, pthread_cond_timedwait, pthread_cond_signal,
pthread_cond_broadcast, pthread_cond_destroy): Likewise.
* lib/pthread-mutex.c (pthread_mutexattr_destroy, pthread_mutex_init,
pthread_mutex_lock, pthread_mutex_trylock, pthread_mutex_timedlock,
pthread_mutex_unlock, pthread_mutex_destroy): Likewise.
* lib/pthread-rwlock.c (pthread_rwlockattr_destroy, pthread_rwlock_init,
pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock): Likewise.
* lib/pthread-spin.c (pthread_spin_init, pthread_spin_lock,
pthread_spin_trylock, pthread_spin_unlock, pthread_spin_destroy):
Likewise.
* lib/pthread-thread.c (pthread_attr_destroy): Likewise.
* lib/readlink.c (readlink): Likewise.
* lib/rename.c (rpl_rename): Likewise.
* lib/set-permissions.c (set_permissions): Likewise.
* lib/sockets.c (gl_sockets_startup): Likewise.
* lib/stat-time.h (get_stat_birthtime_ns, get_stat_birthtime,
stat_time_normalize): Likewise.
* lib/strptime.c (__strptime_internal): Likewise.
* lib/strtod.c (LDEXP): Likewise.
* lib/symlink.c (symlink): Likewise.
* lib/symlinkat.c (symlinkat): Likewise.
* lib/tempname.c (try_dir, try_nocreate): Likewise.
* lib/textstyle.in.h (styled_ostream_begin_use_class,
styled_ostream_end_use_class, styled_ostream_get_hyperlink_ref,
styled_ostream_get_hyperlink_id, styled_ostream_set_hyperlink,
styled_ostream_flush_to_current_style, fd_ostream_create,
term_ostream_get_color, term_ostream_set_color,
term_ostream_get_bgcolor, term_ostream_set_bgcolor,
term_ostream_get_weight, term_ostream_set_weight,
term_ostream_get_posture, term_ostream_set_posture,
term_ostream_get_underline, term_ostream_set_underline,
term_ostream_get_hyperlink_ref, term_ostream_get_hyperlink_id,
term_ostream_set_hyperlink, term_ostream_create,
term_styled_ostream_create, html_styled_ostream_create,
handle_color_option, handle_style_option, style_file_prepare,
styled_ostream_create, libtextstyle_set_failure_exit_code): Likewise.
* lib/unicodeio.c (exit_failure_callback, fallback_failure_callback):
Likewise.
* lib/wait-process.c (cleanup_slaves_action): Likewise.
* tests/signature.h (SIGNATURE_CHECK2): Likewise.
* tests/test-areadlink.c (do_areadlink): Likewise.
* tests/test-areadlinkat.c (do_areadlinkat): Likewise.
* tests/test-ceilf-ieee.c (main): Likewise.
* tests/test-ceilf1.c (main): Likewise.
* tests/test-dirent.c (dir): Likewise.
* tests/test-fchownat.c (main): Likewise.
* tests/test-fdopendir.c (main): Likewise.
* tests/test-filenamecat.c (main): Likewise.
* tests/test-floor1.c (main): Likewise.
* tests/test-floorf-ieee.c (main): Likewise.
* tests/test-floorf1.c (main): Likewise.
* tests/test-fseeko.c (main): Likewise.
* tests/test-fstatat.c (main): Likewise.
  

gnulib-common.m4: Document the gnulib-internal _GL_ATTRIBUTE_* macros

2021-08-22 Thread Bruno Haible
When we use the _GL_ATTRIBUTE_* macros, neither the GCC documentation nor
the attribute.h comments directly apply, because of different syntax.

Therefore, this patch adds documentation to these macros.


2021-08-22  Bruno Haible  

gnulib-common.m4: Document the gnulib-internal _GL_ATTRIBUTE_* macros.
* m4/gnulib-common.m4 (gl_COMMON_BODY): Add comments to the
_GL_ATTRIBUTE_* macros, based on lib/attribute.h.

diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index c801b3de9..174113b28 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -111,24 +111,39 @@ AC_DEFUN([gl_COMMON_BODY], [
 
 ]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's _Alignas instead.
 [
+/* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the 
function
+   is the size of the returned memory block.
+   _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied
+   by the Nth argument of the function is the size of the returned memory 
block.
+ */
+/* Applies to: function, pointer to function, function types.  */
 #if _GL_HAS_ATTRIBUTE (alloc_size)
 # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
 #else
 # define _GL_ATTRIBUTE_ALLOC_SIZE(args)
 #endif
 
+/* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the
+   function and report an error if it cannot do so.  */
+/* Applies to: function.  */
 #if _GL_HAS_ATTRIBUTE (always_inline)
 # define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__))
 #else
 # define _GL_ATTRIBUTE_ALWAYS_INLINE
 #endif
 
+/* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show
+in stack traces when debugging.  The compiler should omit the function from
+stack traces.  */
+/* Applies to: function.  */
 #if _GL_HAS_ATTRIBUTE (artificial)
 # define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__))
 #else
 # define _GL_ATTRIBUTE_ARTIFICIAL
 #endif
 
+/* _GL_ATTRIBUTE_COLD declares that the function is rarely executed.  */
+/* Applies to: functions.  */
 /* Avoid __attribute__ ((cold)) on MinGW; see thread starting at
.
Also, Oracle Studio 12.6 requires 'cold' not '__cold__'.  */
@@ -142,18 +157,25 @@ AC_DEFUN([gl_COMMON_BODY], [
 # define _GL_ATTRIBUTE_COLD
 #endif
 
+/* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate
+   calls to the function with the same arguments.
+   This attribute is safe for a function that neither depends on nor affects
+   observable state, and always returns exactly once - e.g., does not loop
+   forever, and does not call longjmp.
+   (This attribute is stricter than _GL_ATTRIBUTE_PURE.)  */
+/* Applies to: functions.  */
 #if _GL_HAS_ATTRIBUTE (const)
 # define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
 #else
 # define _GL_ATTRIBUTE_CONST
 #endif
 
-/* _GL_ATTRIBUTE_DEALLOC (F, I) is for functions returning pointers
+/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
that can be freed by passing them as the Ith argument to the
-   function F.  _GL_ATTRIBUTE_DEALLOC_FREE is for functions that
-   return pointers that can be freed via 'free'; it can be used
-   only after including stdlib.h.  These macros cannot be used on
-   inline functions.  */
+   function F.
+   _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
+   can be freed via 'free'; it can be used only after including .  */
+/* Applies to: functions.  Cannot be used on inline functions.  */
 #if _GL_GNUC_PREREQ (11, 0)
 # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
 #else
@@ -161,6 +183,14 @@ AC_DEFUN([gl_COMMON_BODY], [
 #endif
 #define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
 
+/* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated.
+   The compiler may warn if the entity is used.  */
+/* Applies to:
+ - function, variable,
+ - struct, union, struct/union member,
+ - enumeration, enumeration item,
+ - typedef,
+   in C++ also: namespace, class, template specialization.  */
 #if _GL_HAS_C_ATTRIBUTE (deprecated)
 # define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
 #elif _GL_HAS_ATTRIBUTE (deprecated)
@@ -169,6 +199,11 @@ AC_DEFUN([gl_COMMON_BODY], [
 # define _GL_ATTRIBUTE_DEPRECATED
 #endif
 
+/* _GL_ATTRIBUTE_ERROR(msg) requests an error if a function is called and
+   the function call is not optimized away.
+   _GL_ATTRIBUTE_WARNING(msg) requests a warning if a function is called and
+   the function call is not optimized away.  */
+/* Applies to: functions.  */
 #if _GL_HAS_ATTRIBUTE (error)
 # define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg)))
 # define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg)))
@@ -180,13 +215,20 @@ AC_DEFUN([gl_COMMON_BODY], [
 # define _GL_ATTRIBUTE_WARNING(msg)
 #endif
 
+/* _GL_ATTRIBUTE_EXTERNALLY_VISIBLE declares that the entity should remain
+   visible 

Re: mkstemps is not listed alphabetically in the manual

2021-08-22 Thread Bernhard Voelker
On 8/22/21 11:54 AM, Benno Schulenberg wrote:
> Hi,
> 
> On 
> https://www.gnu.org/software/gnulib/manual/html_node/Glibc-stdlib_002eh.html
> the entry for 'mkstemps' is out of alphabetical order.  This is confusing.
> 
> (I had downloaded the PDF of the manual, searched for mkstemps, paged up a 
> bit,
> and then -- scrolling back down -- wondered where mkstemps went, expecting it 
> to
> be after mkostemps.)
> 
> Benno

mkstemps _does_ come after mkostemps, but the mrand48_r function sneaked
between the two.  I pushed the attached fix.

Thanks for reporting this.

Have a nice day,
Berny
>From e2a4a093d2d759644a1b5740d5427b53d73f5ab7 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker 
Date: Sun, 22 Aug 2021 16:06:47 +0200
Subject: [PATCH] doc: fix order of stdlib functions

* doc/gnulib.texi (node Glibc stdlib.h): Move mrand48_r after mkstemps.
Reported by Benno Schulenberg.
---
 ChangeLog   | 6 ++
 doc/gnulib.texi | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 732b6f1fff..ef28c2b3d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-08-22  Bernhard Voelker  
+
+	doc: fix order of stdlib functions
+	* doc/gnulib.texi (node Glibc stdlib.h): Move mrand48_r after mkstemps.
+	Reported by Benno Schulenberg.
+
 2021-08-21  Bruno Haible  
 
 	c-stack: Test for libsigsegv once, not twice.
diff --git a/doc/gnulib.texi b/doc/gnulib.texi
index 3a39d0fc20..58d9dab479 100644
--- a/doc/gnulib.texi
+++ b/doc/gnulib.texi
@@ -5786,8 +5786,8 @@ This list of functions is sorted according to the header that declares them.
 * lrand48_r::
 * mkostemp::
 * mkostemps::
-* mrand48_r::
 * mkstemps::
+* mrand48_r::
 * nrand48_r::
 * on_exit::
 * ptsname_r::
@@ -5831,8 +5831,8 @@ This list of functions is sorted according to the header that declares them.
 @include glibc-functions/lrand48_r.texi
 @include glibc-functions/mkostemp.texi
 @include glibc-functions/mkostemps.texi
-@include glibc-functions/mrand48_r.texi
 @include glibc-functions/mkstemps.texi
+@include glibc-functions/mrand48_r.texi
 @include glibc-functions/nrand48_r.texi
 @include glibc-functions/on_exit.texi
 @include glibc-functions/ptsname_r.texi
-- 
2.32.0



Re: Using C2x attributes more effectively in Gnulib

2021-08-22 Thread Bruno Haible
Paul Eggert wrote:
> >> Also, draft C2x lets one write the above function without naming the
> >> parameters, as follows:
> >>
> >> SE_SELINUX_INLINE int
> >> fsetfilecon (int, char const *)
> >>   { errno = ENOTSUP; return -1; }
> >>
> >> This is nicer than [[maybe_unused]], because it says the arguments are
> >> *definitely* unused instead of merely *maybe* unused, and that allows a
> >> bit more checking of the code.
> > 
> > I disagree on this one. For a human reader who wants to understand the code,
> > the parameter name is more important than its type.
> 
> OK, perhaps this would do instead (assuming C2x):
> 
>  SE_SELINUX_INLINE int
>  fsetfilecon (int /*fd*/, char const * /*context*/)
>{ errno = ENOTSUP; return -1; }

Yes, this style is fine with me. The human reader understands what each
argument designates.

> > they have designed
> > this language feature from the perspective what the compiler needs in
> > order to generate machine code
> 
> It's more than just machine code. It's telling the reader that the 
> arguments are definitely unused. This gives the reader more information 
> than [[maybe_unused]] does.

True. But I dislike that there is no [[unused]] / [[definitely_unused]] marker;
they have picked a completely different syntax for the unused parameter than
for [[maybe_unused]].

Also, I think/hope that [[maybe_unused]] will not be used in .h files, only
in .c files. Then, in .c files we can #include "attributes.h".

> It's a C2x feature I find helpful from a readability point of view, 
> since I find the names to be clutter in situations like these. Indeed, 
> I'd rather see something like this:
> 
>SE_SELINUX_INLINE fsetfilecon { errno = ENOTSUP; return -1; }
> 
> since setfilecon's signature (which I can easily navigate to, or ask 
> about) tells me all I need to know about the API that doesn't matter here.

This syntax — defining a function without specifying its prototype — looks
quite odd in C.

By the way, the "which I can easily navigate to" idea is fallacious: It leads
to programming languages that _depend_ on a development environment. Yes, in
a development environment you can easily navigate between declaration and
definition. However, it is frequent to consider patch files sent by mail,
to do temporary edits on remote machines where no development environment is
installed, or [not in GNU, but elsewhere] to perform code reviews through
a web-based interface. In these cases the user doesn't have a development
environment.

> > I have personally used mixed-case macro names in GNU clisp, and I can
> > assert (in hindsight) that it did *not* contribute to maintainability.
> 
> Fair enough; let's stick to uppercase.

Thanks.

> > I'm OK with moving all _GL_UNUSED from after
> > the parameter declaration to before the parameter declaration. Then
> > we can continue to have
> >#define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
> 
> Yes, this sounds like a win. It's a lot simpler than my proposal. 
> Although it loses a bit of information when the arg is definitely 
> unused, perhaps that's not worth worrying about.

OK, I'll do that.

> >> * Remove the snippet/unused-parameter module as it's not used now.
> > 
> > Indeed, this module is unused in gnulib. It may be used in packages that
> > use gnulib; therefore I vote for marking it 'obsolete' and remove it only
> > in a year or two.
> 
> Sounds good to me too.

I'll do that too.

Bruno






Re: bug#50098: Configuring --with-libsigsegv results in link error

2021-08-22 Thread Evan Miller


> On Aug 21, 2021, at 19:46, Bruno Haible  wrote:
> 
>  Run these commands:
> 
>  ./gnulib-tool --create-testdir --dir=testdir1 --single-configure c-stack
>  cd testdir1
>  ./configure
>  make
>  make check
> 
> If they fail, then you do need the libsigsegv library.

FWIW the first step fails produces a warning:

executing aclocal -I glm4
executing autoconf
executing autoheader
executing touch config.h.in
executing automake --add-missing --copy
configure.ac:8: installing 'build-aux/compile'
configure.ac:4: installing 'build-aux/install-sh'
configure.ac:4: installing 'build-aux/missing'
gllib/Makefile.am: installing 'build-aux/depcomp'
parallel-tests: installing 'build-aux/test-driver'
patching file build-aux/test-driver
Hunk #1 FAILED at 109.
1 out of 1 hunk FAILED -- saving rejects to file build-aux/test-driver.rej
patching file build-aux/test-driver


Powering through, "make" emits an undeclared function warning:

gcc-mp-7 -DHAVE_CONFIG_H -I. -I..  -DGNULIB_STRICT_CHECKING=1   -g -O2 -MT 
c-stack.o -MD -MP -MF .deps/c-stack.Tpo -c -o c-stack.o c-stack.c
c-stack.c: In function 'die':
c-stack.c:106:17: warning: implicit declaration of function 'mempcpy' 
[-Wimplicit-function-declaration]
   char *p = mempcpy (buf, progname, prognamelen);
 ^~~
c-stack.c:106:17: warning: incompatible implicit declaration of built-in 
function 'mempcpy'


Then ends with an unresolved symbol error:

gcc-mp-7  -Wno-error -g -O2   -o test-c-stack test-c-stack.o libtests.a 
../gllib/libgnu.a libtests.a ../gllib/libgnu.a libtests.a
Undefined symbols:
  "_mempcpy", referenced from:
  _die in libgnu.a(c-stack.o)
  _die in libgnu.a(c-stack.o)
ld: symbol(s) not found


I will note that "sigaltstack" is available on 10.4 so perhaps there is hope 
once the undeclared function is sorted out.

Evan





mkstemps is not listed alphabetically in the manual

2021-08-22 Thread Benno Schulenberg

Hi,

On https://www.gnu.org/software/gnulib/manual/html_node/Glibc-stdlib_002eh.html
the entry for 'mkstemps' is out of alphabetical order.  This is confusing.

(I had downloaded the PDF of the manual, searched for mkstemps, paged up a bit,
and then -- scrolling back down -- wondered where mkstemps went, expecting it to
be after mkostemps.)

Benno



OpenPGP_signature
Description: OpenPGP digital signature