[v2] gcc.c-torture/execute/builtins/fputs.c: fputs_unlocked prototype

Message ID 874jihybsu.fsf@oldenburg.str.redhat.com
State Accepted
Headers
Series [v2] gcc.c-torture/execute/builtins/fputs.c: fputs_unlocked prototype |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Florian Weimer Oct. 23, 2023, 8:37 a.m. UTC
  Current glibc headers only declare fputs_unlocked for _GNU_SOURCE,
so define it to obtain an official prototype.

Add a fallback prototype declaration for other systems that do not
have fputs_unlocked.  This seems to the most straightforward approach
to avoid an implicit function declaration, without reducing test
coverage and introducing ongoing maintenance requirements (e.g.g,
FreeBSD added fputs_unlocked support fairly recently).

gcc/testsuite/

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

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


base-commit: 0e29c6f65523dad20068ba69cd03d8f6f82cab41
  

Comments

Jeff Law Oct. 27, 2023, 7:50 p.m. UTC | #1
On 10/23/23 02:37, Florian Weimer wrote:
> Current glibc headers only declare fputs_unlocked for _GNU_SOURCE,
> so define it to obtain an official prototype.
> 
> Add a fallback prototype declaration for other systems that do not
> have fputs_unlocked.  This seems to the most straightforward approach
> to avoid an implicit function declaration, without reducing test
> coverage and introducing ongoing maintenance requirements (e.g.g,
> FreeBSD added fputs_unlocked support fairly recently).
> 
> gcc/testsuite/
> 
> 	* gcc.c-torture/execute/builtins/fputs.c (_GNU_SOURCE):
> 	Define.
> 	(fputs_unlocked): Declare.
This approach is fine too.  OK.
jeff
  

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..a94ea993364 100644
--- a/gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c
+++ b/gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c
@@ -5,9 +5,13 @@ 
 
    Written by Kaveh R. Ghazi, 10/30/2000.  */
 
+#define _GNU_SOURCE /* For fputs_unlocked.  */
 #include <stdio.h>
 extern void abort(void);
 
+/* Not all systems have fputs_unlocked.  See fputs-lib.c.  */
+extern int (fputs_unlocked) (const char *, FILE *);
+
 int i;
 
 void