From 58195177985347cff52d402622d264daa2f8e179 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Sun, 6 Apr 2025 19:19:35 -0700 Subject: [PATCH] fseeko: Port to recent Haiku snapshots. * lib/stdio-impl.h (fp_) [__HAIKU__]: Define to FILE which is an incomplete type on Haiku. (_IO_EOF_SEEN) [__HAIKU__]: Define macro. * lib/fseeko.c (fp_) [!__HAIKU__]: Define to fp. (fseeko): Use fp_ instead of fp. --- ChangeLog | 9 +++++++++ lib/fseeko.c | 13 ++++++++----- lib/stdio-impl.h | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 53db9e00a0..d2fe415247 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2025-04-06 Collin Funk + + fseeko: Port to recent Haiku snapshots. + * lib/stdio-impl.h (fp_) [__HAIKU__]: Define to FILE which is an + incomplete type on Haiku. + (_IO_EOF_SEEN) [__HAIKU__]: Define macro. + * lib/fseeko.c (fp_) [!__HAIKU__]: Define to fp. + (fseeko): Use fp_ instead of fp. + 2025-04-04 Eric Blake tests: Better name in init.sh usage. diff --git a/lib/fseeko.c b/lib/fseeko.c index c15b9e210f..b39099c4a0 100644 --- a/lib/fseeko.c +++ b/lib/fseeko.c @@ -48,10 +48,13 @@ fseeko (FILE *fp, off_t offset, int whence) /* These tests are based on fpurge.c. */ #if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 +# if !defined __HAIKU__ +# define fp_ fp +# endif /* GNU libc, BeOS, Haiku, Linux libc5 */ - if (fp->_IO_read_end == fp->_IO_read_ptr - && fp->_IO_write_ptr == fp->_IO_write_base - && fp->_IO_save_base == NULL) + if (fp_->_IO_read_end == fp_->_IO_read_ptr + && fp_->_IO_write_ptr == fp_->_IO_write_base + && fp_->_IO_save_base == NULL) #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ # if defined __SL64 && defined __SCLE /* Cygwin */ @@ -126,8 +129,8 @@ fseeko (FILE *fp, off_t offset, int whence) #if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ - fp->_flags &= ~_IO_EOF_SEEN; - fp->_offset = pos; + fp_->_flags &= ~_IO_EOF_SEEN; + fp_->_offset = pos; #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ # if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h index 878e9f8c97..b6be050676 100644 --- a/lib/stdio-impl.h +++ b/lib/stdio-impl.h @@ -30,6 +30,40 @@ # 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_EOF_SEEN +# define _IO_EOF_SEEN 0x10 +# endif +#endif + /* BSD stdio derived implementations. */ #if defined __NetBSD__ /* NetBSD */ -- 2.39.5