diff mbox series

gcc.c-torture/execute/builtins/fputs.c: Define _GNU_SOURCE

Message ID 87zg0bhzep.fsf@oldenburg.str.redhat.com
State New
Headers show
Series gcc.c-torture/execute/builtins/fputs.c: Define _GNU_SOURCE | expand

Commit Message

Florian Weimer Oct. 22, 2023, 7:47 a.m. UTC
Current glibc headers only declare fputs_unlocked for _GNU_SOURCE.
Defining the macro avoids an implicit function declaration.

gcc/testsuite/

	* gcc.c-torture/execute/builtins/fputs.c (_GNU_SOURCE):
	Define.

---
 gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Jeff Law Oct. 22, 2023, 1:44 p.m. UTC | #1
On 10/22/23 01:47, Florian Weimer wrote:
> Current glibc headers only declare fputs_unlocked for _GNU_SOURCE.
> Defining the macro avoids an implicit function declaration.
> 
> gcc/testsuite/
> 
> 	* gcc.c-torture/execute/builtins/fputs.c (_GNU_SOURCE):
> 	Define.
OK
jeff
Andrew Pinski Oct. 22, 2023, 4:09 p.m. UTC | #2
On Sun, Oct 22, 2023 at 12:47 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> Current glibc headers only declare fputs_unlocked for _GNU_SOURCE.
> Defining the macro avoids an implicit function declaration.

This does not help targets that don't use glibc though.
Note for builtins testsuite there is a lib-fputs.c file which will
define a fputs_unlock which is how it will link even if the libc does
not define a fputs_unlock.

Thanks,
Andrew Pinski

>
> gcc/testsuite/
>
>         * gcc.c-torture/execute/builtins/fputs.c (_GNU_SOURCE):
>         Define.
>
> ---
>  gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c b/gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c
> index 93fa9736449..13e30724355 100644
> --- a/gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c
> +++ b/gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c
> @@ -5,6 +5,7 @@
>
>     Written by Kaveh R. Ghazi, 10/30/2000.  */
>
> +#define _GNU_SOURCE /* For fputs_unlocked.  */
>  #include <stdio.h>
>  extern void abort(void);
>
>
Jeff Law Oct. 22, 2023, 7:45 p.m. UTC | #3
On 10/22/23 10:09, Andrew Pinski wrote:
> On Sun, Oct 22, 2023 at 12:47 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> Current glibc headers only declare fputs_unlocked for _GNU_SOURCE.
>> Defining the macro avoids an implicit function declaration.
> 
> This does not help targets that don't use glibc though.
> Note for builtins testsuite there is a lib-fputs.c file which will
> define a fputs_unlock which is how it will link even if the libc does
> not define a fputs_unlock.
But isn't fputs_unlocked glibc specific to begin with?  ie, the test 
really doesn't make sense AFAICT on non-glibc targets.

Jeff
Bernhard Reutner-Fischer Oct. 22, 2023, 8:02 p.m. UTC | #4
On 22 October 2023 21:45:12 CEST, Jeff Law <jeffreyalaw@gmail.com> wrote:
>
>
>On 10/22/23 10:09, Andrew Pinski wrote:
>> On Sun, Oct 22, 2023 at 12:47 AM Florian Weimer <fweimer@redhat.com> wrote:
>>> 
>>> Current glibc headers only declare fputs_unlocked for _GNU_SOURCE.
>>> Defining the macro avoids an implicit function declaration.
>> 
>> This does not help targets that don't use glibc though.
>> Note for builtins testsuite there is a lib-fputs.c file which will
>> define a fputs_unlock which is how it will link even if the libc does
>> not define a fputs_unlock.
>But isn't fputs_unlocked glibc specific to begin with?  ie, the test really doesn't make sense AFAICT on non-glibc targets.

I think uClibc had it too, at least at one point in the past.
Eric Gallager Oct. 23, 2023, 5:57 a.m. UTC | #5
On Sun, Oct 22, 2023 at 4:03 PM <rep.dot.nop@gmail.com> wrote:
>
> On 22 October 2023 21:45:12 CEST, Jeff Law <jeffreyalaw@gmail.com> wrote:
> >
> >
> >On 10/22/23 10:09, Andrew Pinski wrote:
> >> On Sun, Oct 22, 2023 at 12:47 AM Florian Weimer <fweimer@redhat.com> wrote:
> >>>
> >>> Current glibc headers only declare fputs_unlocked for _GNU_SOURCE.
> >>> Defining the macro avoids an implicit function declaration.
> >>
> >> This does not help targets that don't use glibc though.
> >> Note for builtins testsuite there is a lib-fputs.c file which will
> >> define a fputs_unlock which is how it will link even if the libc does
> >> not define a fputs_unlock.
> >But isn't fputs_unlocked glibc specific to begin with?  ie, the test really doesn't make sense AFAICT on non-glibc targets.
>
> I think uClibc had it too, at least at one point in the past.
>

gnulib has these portability notes about fputs_unlocked:
https://www.gnu.org/software/gnulib/manual/html_node/fputs_005funlocked.html
Unfortunately, it only lists the platforms that *don't* have it, not
the ones that *do* have it, so I'm afraid its notes aren't actually
that helpful after all... oh well, never mind...
Florian Weimer Oct. 23, 2023, 8:39 a.m. UTC | #6
* Andrew Pinski:

> On Sun, Oct 22, 2023 at 12:47 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> Current glibc headers only declare fputs_unlocked for _GNU_SOURCE.
>> Defining the macro avoids an implicit function declaration.
>
> This does not help targets that don't use glibc though.
> Note for builtins testsuite there is a lib-fputs.c file which will
> define a fputs_unlock which is how it will link even if the libc does
> not define a fputs_unlock.

That's a good point.  I've sent a v2 which also adds a prototype
declaration in addition to _GNU_SOURCE.  I've thought about it for a bit
and it seems to be the least intrusive option.

Thanks,
Florian
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c b/gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c
index 93fa9736449..13e30724355 100644
--- a/gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c
+++ b/gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c
@@ -5,6 +5,7 @@ 
 
    Written by Kaveh R. Ghazi, 10/30/2000.  */
 
+#define _GNU_SOURCE /* For fputs_unlocked.  */
 #include <stdio.h>
 extern void abort(void);