<signal.h>: Make bsd_signal available with _GNU_SOURCE

Message ID 8735a3tlg9.fsf@oldenburg.str.redhat.com
State New
Headers
Series <signal.h>: Make bsd_signal available with _GNU_SOURCE |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Florian Weimer Nov. 28, 2022, 10:36 a.m. UTC
  The declaration does not conflict with anything.  This simplifies
porting older software to C99 compilers which do not support implicit
function declarations and which need -D_GNU_SOURCE for other function
declarations.  Using __USE_MISC does not seem appropriate here because
other systems (e.g., FreeBSD) do not declare bsd_signal.

---
 signal/signal.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


base-commit: f704192911c6c7b65a54beab3ab369fca7609a5d
  

Comments

Adhemerval Zanella Netto Dec. 8, 2022, 5:11 p.m. UTC | #1
On 28/11/22 07:36, Florian Weimer via Libc-alpha wrote:
> The declaration does not conflict with anything.  This simplifies
> porting older software to C99 compilers which do not support implicit
> function declarations and which need -D_GNU_SOURCE for other function
> declarations.  Using __USE_MISC does not seem appropriate here because
> other systems (e.g., FreeBSD) do not declare bsd_signal.

I am not sure about this, bsd_signal is a POSIX deprecated and I think
old software should really move to sigaction or define the correct flags
to explicit use it.

> 
> ---
>  signal/signal.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/signal/signal.h b/signal/signal.h
> index 78d0d819aa..d175d7c3c4 100644
> --- a/signal/signal.h
> +++ b/signal/signal.h
> @@ -98,7 +98,8 @@ extern __sighandler_t __REDIRECT_NTH (signal,
>  # endif
>  #endif
>  
> -#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8
> +#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \
> +  || defined __USE_GNU
>  /* The X/Open definition of `signal' conflicts with the BSD version.
>     So they defined another function `bsd_signal'.  */
>  extern __sighandler_t bsd_signal (int __sig, __sighandler_t __handler)
> 
> base-commit: f704192911c6c7b65a54beab3ab369fca7609a5d
>
  
Florian Weimer Dec. 8, 2022, 6:10 p.m. UTC | #2
* Adhemerval Zanella Netto:

> On 28/11/22 07:36, Florian Weimer via Libc-alpha wrote:
>> The declaration does not conflict with anything.  This simplifies
>> porting older software to C99 compilers which do not support implicit
>> function declarations and which need -D_GNU_SOURCE for other function
>> declarations.  Using __USE_MISC does not seem appropriate here because
>> other systems (e.g., FreeBSD) do not declare bsd_signal.
>
> I am not sure about this, bsd_signal is a POSIX deprecated and I think
> old software should really move to sigaction or define the correct flags
> to explicit use it.

And I thought this was the least controversial patch. 8-/

If -D_GNU_SOURCE is not the superset of all functionalities, it gets
more difficult to obtain all function prototypes, as needed for building
with stricter C99 compilers.  Currently, with default GCC flags, this
builds anyway due to an implicit function declaration, and I'd like to
preserve this behavior with GCC 14.

What about adding a deprecation warning?

Thanks,
Florian
  
Adhemerval Zanella Netto Dec. 8, 2022, 6:23 p.m. UTC | #3
On 08/12/22 15:10, Florian Weimer wrote:
> * Adhemerval Zanella Netto:
> 
>> On 28/11/22 07:36, Florian Weimer via Libc-alpha wrote:
>>> The declaration does not conflict with anything.  This simplifies
>>> porting older software to C99 compilers which do not support implicit
>>> function declarations and which need -D_GNU_SOURCE for other function
>>> declarations.  Using __USE_MISC does not seem appropriate here because
>>> other systems (e.g., FreeBSD) do not declare bsd_signal.
>>
>> I am not sure about this, bsd_signal is a POSIX deprecated and I think
>> old software should really move to sigaction or define the correct flags
>> to explicit use it.
> 
> And I thought this was the least controversial patch. 8-/
> 
> If -D_GNU_SOURCE is not the superset of all functionalities, it gets
> more difficult to obtain all function prototypes, as needed for building
> with stricter C99 compilers.  Currently, with default GCC flags, this
> builds anyway due to an implicit function declaration, and I'd like to
> preserve this behavior with GCC 14.
> 
> What about adding a deprecation warning?

I think deprecation works better here, I kind reluctant because moving it
to _GNU_SOURCE means that we are 'promoting' a symbol where there is
already a replacement.
  

Patch

diff --git a/signal/signal.h b/signal/signal.h
index 78d0d819aa..d175d7c3c4 100644
--- a/signal/signal.h
+++ b/signal/signal.h
@@ -98,7 +98,8 @@  extern __sighandler_t __REDIRECT_NTH (signal,
 # endif
 #endif
 
-#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8
+#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \
+  || defined __USE_GNU
 /* The X/Open definition of `signal' conflicts with the BSD version.
    So they defined another function `bsd_signal'.  */
 extern __sighandler_t bsd_signal (int __sig, __sighandler_t __handler)