summaryrefslogtreecommitdiffstats
path: root/gl/stdio-impl.h
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-12-28 12:50:39 +0100
committerGitHub <noreply@github.com>2025-12-28 12:50:39 +0100
commite7dd07c8025b169b7b43b955066a7200d9cdf244 (patch)
tree6e8c927cfc67f3708b91ac79df07707af26e4929 /gl/stdio-impl.h
parent828a9720b10814c5836d03aa35af05d196c4104b (diff)
parentb0afb8fe0ff1d87165af9df61501197a06240dda (diff)
downloadmonitoring-plugins-e7dd07c8025b169b7b43b955066a7200d9cdf244.tar.gz
Merge pull request #2213 from RincewindsHat/update/gnulib
Sync with Gnulib stable-202507 code (a8ac9f9ce5)
Diffstat (limited to 'gl/stdio-impl.h')
-rw-r--r--gl/stdio-impl.h116
1 files changed, 103 insertions, 13 deletions
diff --git a/gl/stdio-impl.h b/gl/stdio-impl.h
index 63ebf7c6..e4a69a8d 100644
--- a/gl/stdio-impl.h
+++ b/gl/stdio-impl.h
@@ -1,5 +1,5 @@
1/* Implementation details of FILE streams. 1/* Implementation details of FILE streams.
2 Copyright (C) 2007-2008, 2010-2024 Free Software Foundation, Inc. 2 Copyright (C) 2007-2008, 2010-2025 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -30,6 +30,49 @@
30# endif 30# endif
31#endif 31#endif
32 32
33/* Haiku stdio implementation. */
34#if defined __HAIKU__
35# include <stdint.h>
36/* This FILE structure was made into an incomplete type in 2025.
37 See <https://cgit.haiku-os.org/haiku/tree/src/system/libroot/posix/glibc/libio/libio.h>. */
38# define fp_ ((struct { int _flags; \
39 char *_IO_read_ptr; \
40 char *_IO_read_end; \
41 char *_IO_read_base; \
42 char *_IO_write_base; \
43 char *_IO_write_ptr; \
44 char *_IO_write_end; \
45 char *_IO_buf_base; \
46 char *_IO_buf_end; \
47 char *_IO_save_base; \
48 char *_IO_backup_base; \
49 char *_IO_save_end; \
50 void *_markers; \
51 void *_chain; \
52 int _fileno; \
53 int _flags2; \
54 off_t _old_offset; \
55 unsigned short _cur_column; \
56 signed char _vtable_offset; \
57 char _shortbuf[1]; \
58 void *_lock; \
59 int64_t _offset; \
60 /* More fields, not relevant here. */ \
61 } *) fp)
62# if !defined _IO_UNBUFFERED
63# define _IO_UNBUFFERED 0x2
64# endif
65# if !defined _IO_EOF_SEEN
66# define _IO_EOF_SEEN 0x10
67# endif
68# if !defined _IO_IN_BACKUP
69# define _IO_IN_BACKUP 0x100
70# endif
71# if !defined _IO_LINE_BUF
72# define _IO_LINE_BUF 0x200
73# endif
74#endif
75
33/* BSD stdio derived implementations. */ 76/* BSD stdio derived implementations. */
34 77
35#if defined __NetBSD__ /* NetBSD */ 78#if defined __NetBSD__ /* NetBSD */
@@ -39,7 +82,7 @@
39 82
40#include <errno.h> /* For detecting Plan9. */ 83#include <errno.h> /* For detecting Plan9. */
41 84
42#if defined __sferror || defined __DragonFly__ || defined __ANDROID__ 85#if defined __sferror || defined __OpenBSD__ || defined __DragonFly__ || defined __ANDROID__
43 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ 86 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
44 87
45# if defined __DragonFly__ /* DragonFly */ 88# if defined __DragonFly__ /* DragonFly */
@@ -65,13 +108,59 @@
65# define _flags pub._flags 108# define _flags pub._flags
66# define _r pub._r 109# define _r pub._r
67# define _w pub._w 110# define _w pub._w
68# elif defined __ANDROID__ /* Android */ 111# elif defined __OpenBSD__ /* OpenBSD */
69# ifdef __LP64__ 112# if defined __sferror /* OpenBSD <= 7.7 */
113# define _gl_flags_file_t short
114# else /* OpenBSD >= 7.8 */
115# define _gl_flags_file_t int
116# endif
117 /* Up to this commit from 2025-07-16
118 <https://github.com/openbsd/src/commit/b7f6c2eb760a2da367dd51d539ef06f5f3553790>
119 the innards of FILE were public. After this commit, the innards of FILE
120 are hidden. In this commit
121 <https://github.com/openbsd/src/commit/9063a2f1ec94013fb0e2c7ec851495108e788a6e>
122 they were reshuffled. */
123# if defined __sferror /* OpenBSD <= 7.7 */
124# define fp_ ((struct { unsigned char *_p; \
125 int _r; \
126 int _w; \
127 _gl_flags_file_t _flags; \
128 _gl_flags_file_t _file; \
129 struct { unsigned char *_base; size_t _size; } _bf; \
130 int _lbfsize; \
131 void *_cookie; \
132 void *_close; \
133 void *_read; \
134 void *_seek; \
135 void *_write; \
136 struct { unsigned char *_base; size_t _size; } _ext; \
137 unsigned char *_up; \
138 int _ur; \
139 unsigned char _ubuf[3]; \
140 unsigned char _nbuf[1]; \
141 struct { unsigned char *_base; size_t _size; } _lb; \
142 int _blksize; \
143 fpos_t _offset; \
144 /* More fields, not relevant here. */ \
145 } *) fp)
146# else /* OpenBSD >= 7.8 */
147# define fp_ ((struct { _gl_flags_file_t _flags; \
148 _gl_flags_file_t _file; \
149 unsigned char *_p; \
150 int _r; \
151 int _w; \
152 struct { unsigned char *_base; size_t _size; } _bf; \
153 int _lbfsize; \
154 /* More fields, not relevant here. */ \
155 } *) fp)
156# endif
157# elif defined __ANDROID__ /* Android */
158# if defined __LP64__
70# define _gl_flags_file_t int 159# define _gl_flags_file_t int
71# else 160# else
72# define _gl_flags_file_t short 161# define _gl_flags_file_t short
73# endif 162# endif
74# ifdef __LP64__ 163# if defined __LP64__
75# define _gl_file_offset_t int64_t 164# define _gl_file_offset_t int64_t
76# else 165# else
77 /* see https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md */ 166 /* see https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md */
@@ -79,7 +168,7 @@
79# endif 168# endif
80 /* Up to this commit from 2015-10-12 169 /* Up to this commit from 2015-10-12
81 <https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a> 170 <https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a>
82 the innards of FILE were public, and fp_ub could be defined like for OpenBSD, 171 the innards of FILE were public,
83 see <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/fileext.h> 172 see <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/fileext.h>
84 and <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/local.h>. 173 and <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/local.h>.
85 After this commit, the innards of FILE are hidden. */ 174 After this commit, the innards of FILE are hidden. */
@@ -109,9 +198,8 @@
109# define fp_ fp 198# define fp_ fp
110# endif 199# endif
111 200
112# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */ 201# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __minix /* NetBSD >= 1.5ZA, Minix 3 */
113 /* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> 202 /* See <https://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
114 and <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
115 and <https://github.com/Stichting-MINIX-Research-Foundation/minix/blob/master/lib/libc/stdio/fileext.h> */ 203 and <https://github.com/Stichting-MINIX-Research-Foundation/minix/blob/master/lib/libc/stdio/fileext.h> */
116 struct __sfileext 204 struct __sfileext
117 { 205 {
@@ -119,7 +207,7 @@
119 /* More fields, not relevant here. */ 207 /* More fields, not relevant here. */
120 }; 208 };
121# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub 209# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
122# elif defined __ANDROID__ /* Android */ 210# elif defined __ANDROID__ || defined __OpenBSD__ /* Android, OpenBSD */
123 struct __sfileext 211 struct __sfileext
124 { 212 {
125 struct { unsigned char *_base; size_t _size; } _ub; /* ungetc buffer */ 213 struct { unsigned char *_base; size_t _size; } _ub; /* ungetc buffer */
@@ -132,9 +220,11 @@
132 220
133# define HASUB(fp) (fp_ub._base != NULL) 221# define HASUB(fp) (fp_ub._base != NULL)
134 222
135# if defined __ANDROID__ /* Android */ 223# if defined __ANDROID__ || defined __OpenBSD__ /* Android, OpenBSD */
136 /* Needed after this commit from 2016-01-25 224 /* Needed after this Android commit from 2016-01-25
137 <https://android.googlesource.com/platform/bionic.git/+/e70e0e9267d069bf56a5078c99307e08a7280de7> */ 225 <https://android.googlesource.com/platform/bionic.git/+/e70e0e9267d069bf56a5078c99307e08a7280de7>
226 And after this OpenBSD commit from 2025-07-16
227 <https://github.com/openbsd/src/commit/b7f6c2eb760a2da367dd51d539ef06f5f3553790>. */
138# ifndef __SEOF 228# ifndef __SEOF
139# define __SLBF 1 229# define __SLBF 1
140# define __SNBF 2 230# define __SNBF 2