mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] Expose the fopencookie() data types more generally
@ 2023-03-31  0:35 John Scott
  2023-04-08  0:49 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: John Scott @ 2023-03-31  0:35 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1922 bytes --]

Hi,

We're allowed to expose these data types in POSIX-conforming applications since they're implementation-reserved, and I think it's a good idea. My use case is that I want to check for fopencookie() via dlsym() without defining _GNU_SOURCE, and having the definition of cookie_io_functions_t would be helpful for its usage.

You may pull the signed commit from https://git.sr.ht/~jscott/musl-libc or use the following patch

From f5f6db0d02db40dde067a3ad0a7fbd74f6019dd4 Mon Sep 17 00:00:00 2001
From: John Scott <jscott@posteo.net>
Date: Thu, 30 Mar 2023 20:26:13 -0400
Subject: [PATCH] Expose the fopencookie() data types more generally

These data types end in _t and so can be exposed even when strict POSIX conformance is sought. This might be useful for an application that doesn't want other side effects of defining _GNU_SOURCE, but which still wants to use fopencookie().
---
 include/stdio.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/stdio.h b/include/stdio.h
index cb858618..a5206316 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -189,7 +189,11 @@ int vasprintf(char **, const char *, __isoc_va_list);
 #ifdef _GNU_SOURCE
 char *fgets_unlocked(char *, int, FILE *);
 int fputs_unlocked(const char *, FILE *);
+#endif
 
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
 typedef ssize_t (cookie_read_function_t)(void *, char *, size_t);
 typedef ssize_t (cookie_write_function_t)(void *, const char *, size_t);
 typedef int (cookie_seek_function_t)(void *, off_t *, int);
@@ -201,7 +205,9 @@ typedef struct _IO_cookie_io_functions_t {
 	cookie_seek_function_t *seek;
 	cookie_close_function_t *close;
 } cookie_io_functions_t;
+#endif
 
+#ifdef _GNU_SOURCE
 FILE *fopencookie(void *, const char *, cookie_io_functions_t);
 #endif
 
-- 
2.35.1


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-08  0:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-31  0:35 [musl] [PATCH] Expose the fopencookie() data types more generally John Scott
2023-04-08  0:49 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).