From b0afb8fe0ff1d87165af9df61501197a06240dda Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 28 Dec 2025 12:13:40 +0100 Subject: Sync with Gnulib stable-202507 code (a8ac9f9ce5) --- gl/stdio-impl.h | 116 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 103 insertions(+), 13 deletions(-) (limited to 'gl/stdio-impl.h') 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 @@ /* 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 +/* This FILE structure was made into an incomplete type in 2025. + See . */ +# 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 /* 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,59 @@ # define _flags pub._flags # define _r pub._r # define _w pub._w -# elif defined __ANDROID__ /* Android */ -# ifdef __LP64__ +# elif defined __OpenBSD__ /* OpenBSD */ +# if defined __sferror /* OpenBSD <= 7.7 */ +# define _gl_flags_file_t short +# else /* OpenBSD >= 7.8 */ +# define _gl_flags_file_t int +# endif + /* Up to this commit from 2025-07-16 + + the innards of FILE were public. After this commit, the innards of FILE + are hidden. In this commit + + they were reshuffled. */ +# if defined __sferror /* OpenBSD <= 7.7 */ +# define fp_ ((struct { unsigned char *_p; \ + int _r; \ + int _w; \ + _gl_flags_file_t _flags; \ + _gl_flags_file_t _file; \ + struct { unsigned char *_base; size_t _size; } _bf; \ + int _lbfsize; \ + void *_cookie; \ + void *_close; \ + void *_read; \ + void *_seek; \ + void *_write; \ + struct { unsigned char *_base; size_t _size; } _ext; \ + unsigned char *_up; \ + int _ur; \ + unsigned char _ubuf[3]; \ + unsigned char _nbuf[1]; \ + struct { unsigned char *_base; size_t _size; } _lb; \ + int _blksize; \ + fpos_t _offset; \ + /* More fields, not relevant here. */ \ + } *) fp) +# else /* OpenBSD >= 7.8 */ +# define fp_ ((struct { _gl_flags_file_t _flags; \ + _gl_flags_file_t _file; \ + unsigned char *_p; \ + int _r; \ + int _w; \ + struct { unsigned char *_base; size_t _size; } _bf; \ + int _lbfsize; \ + /* More fields, not relevant here. */ \ + } *) fp) +# endif +# elif defined __ANDROID__ /* Android */ +# if defined __LP64__ # define _gl_flags_file_t int # else # define _gl_flags_file_t short # endif -# ifdef __LP64__ +# if defined __LP64__ # define _gl_file_offset_t int64_t # else /* see https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md */ @@ -79,7 +168,7 @@ # endif /* Up to this commit from 2015-10-12 - the innards of FILE were public, and fp_ub could be defined like for OpenBSD, + the innards of FILE were public, see and . After this commit, the innards of FILE are hidden. */ @@ -109,9 +198,8 @@ # define fp_ fp # endif -# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */ - /* See - and +# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __minix /* NetBSD >= 1.5ZA, Minix 3 */ + /* See and */ struct __sfileext { @@ -119,7 +207,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 +220,11 @@ # define HASUB(fp) (fp_ub._base != NULL) -# if defined __ANDROID__ /* Android */ - /* Needed after this commit from 2016-01-25 - */ +# if defined __ANDROID__ || defined __OpenBSD__ /* Android, OpenBSD */ + /* Needed after this Android commit from 2016-01-25 + + And after this OpenBSD commit from 2025-07-16 + . */ # ifndef __SEOF # define __SLBF 1 # define __SNBF 2 -- cgit v1.2.3-74-g34f1