mailing list of musl libc
 help / color / mirror / code / Atom feed
From: John Scott <jscott@posteo.net>
To: musl@lists.openwall.com
Subject: [musl] [PATCH] Expose the fopencookie() data types more generally
Date: Fri, 31 Mar 2023 00:35:36 +0000	[thread overview]
Message-ID: <0e96cffef26b0a5b689e6d316211829f6ed1a1cf.camel@posteo.net> (raw)

[-- 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 --]

             reply	other threads:[~2023-03-31  0:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31  0:35 John Scott [this message]
2023-04-08  0:49 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0e96cffef26b0a5b689e6d316211829f6ed1a1cf.camel@posteo.net \
    --to=jscott@posteo.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).