summaryrefslogtreecommitdiff
path: root/lib/stdio-impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stdio-impl.h')
-rw-r--r--lib/stdio-impl.h76
1 files changed, 62 insertions, 14 deletions
diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
index 63ebf7c6..4abf9e68 100644
--- a/lib/stdio-impl.h
+++ b/lib/stdio-impl.h
@@ -1,5 +1,5 @@
/* Implementation details of FILE streams.
- Copyright (C) 2007-2008, 2010-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2008, 2010-2025 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -30,6 +30,49 @@
# endif
#endif
+/* Haiku stdio implementation. */
+#if defined __HAIKU__
+# include <stdint.h>
+/* This FILE structure was made into an incomplete type in 2025.
+ See <https://cgit.haiku-os.org/haiku/tree/src/system/libroot/posix/glibc/libio/libio.h>. */
+# define fp_ ((struct { int _flags; \
+ char *_IO_read_ptr; \
+ char *_IO_read_end; \
+ char *_IO_read_base; \
+ char *_IO_write_base; \
+ char *_IO_write_ptr; \
+ char *_IO_write_end; \
+ char *_IO_buf_base; \
+ char *_IO_buf_end; \
+ char *_IO_save_base; \
+ char *_IO_backup_base; \
+ char *_IO_save_end; \
+ void *_markers; \
+ void *_chain; \
+ int _fileno; \
+ int _flags2; \
+ off_t _old_offset; \
+ unsigned short _cur_column; \
+ signed char _vtable_offset; \
+ char _shortbuf[1]; \
+ void *_lock; \
+ int64_t _offset; \
+ /* More fields, not relevant here. */ \
+ } *) fp)
+# if !defined _IO_UNBUFFERED
+# define _IO_UNBUFFERED 0x2
+# endif
+# if !defined _IO_EOF_SEEN
+# define _IO_EOF_SEEN 0x10
+# endif
+# if !defined _IO_IN_BACKUP
+# define _IO_IN_BACKUP 0x100
+# endif
+# if !defined _IO_LINE_BUF
+# define _IO_LINE_BUF 0x200
+# endif
+#endif
+
/* BSD stdio derived implementations. */
#if defined __NetBSD__ /* NetBSD */
@@ -39,7 +82,7 @@
#include <errno.h> /* For detecting Plan9. */
-#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
+#if defined __sferror || defined __OpenBSD__ || defined __DragonFly__ || defined __ANDROID__
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
# if defined __DragonFly__ /* DragonFly */
@@ -65,13 +108,15 @@
# define _flags pub._flags
# define _r pub._r
# define _w pub._w
-# elif defined __ANDROID__ /* Android */
-# ifdef __LP64__
+# elif defined __ANDROID__ || defined __OpenBSD__ /* Android, OpenBSD */
+# if defined __LP64__ && !defined __OpenBSD__
# define _gl_flags_file_t int
# else
# define _gl_flags_file_t short
# endif
-# ifdef __LP64__
+# if defined __OpenBSD__
+# define _gl_file_offset_t fpos_t
+# elif defined __LP64__
# define _gl_file_offset_t int64_t
# else
/* see https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md */
@@ -79,10 +124,12 @@
# endif
/* Up to this commit from 2015-10-12
<https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a>
- the innards of FILE were public, and fp_ub could be defined like for OpenBSD,
+ the innards of FILE were public,
see <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/fileext.h>
and <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/local.h>.
- After this commit, the innards of FILE are hidden. */
+ After this commit, the innards of FILE are hidden. Likewise for OpenBSD
+ up to this commit from 2025-07-16
+ <https://github.com/openbsd/src/commit/b7f6c2eb760a2da367dd51d539ef06f5f3553790>. */
# define fp_ ((struct { unsigned char *_p; \
int _r; \
int _w; \
@@ -109,9 +156,8 @@
# define fp_ fp
# endif
-# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */
- /* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
- and <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
+# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __minix /* NetBSD >= 1.5ZA, Minix 3 */
+ /* See <https://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
and <https://github.com/Stichting-MINIX-Research-Foundation/minix/blob/master/lib/libc/stdio/fileext.h> */
struct __sfileext
{
@@ -119,7 +165,7 @@
/* More fields, not relevant here. */
};
# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
-# elif defined __ANDROID__ /* Android */
+# elif defined __ANDROID__ || defined __OpenBSD__ /* Android, OpenBSD */
struct __sfileext
{
struct { unsigned char *_base; size_t _size; } _ub; /* ungetc buffer */
@@ -132,9 +178,11 @@
# define HASUB(fp) (fp_ub._base != NULL)
-# if defined __ANDROID__ /* Android */
- /* Needed after this commit from 2016-01-25
- <https://android.googlesource.com/platform/bionic.git/+/e70e0e9267d069bf56a5078c99307e08a7280de7> */
+# if defined __ANDROID__ || defined __OpenBSD__ /* Android, OpenBSD */
+ /* Needed after this Android commit from 2016-01-25
+ <https://android.googlesource.com/platform/bionic.git/+/e70e0e9267d069bf56a5078c99307e08a7280de7>
+ And after this OpenBSD commit from 2025-07-16
+ <https://github.com/openbsd/src/commit/b7f6c2eb760a2da367dd51d539ef06f5f3553790>. */
# ifndef __SEOF
# define __SLBF 1
# define __SNBF 2