]> Savannah Git Hosting - gnulib.git/commitdiff
fseeko: Port to recent Haiku snapshots.
authorCollin Funk <collin.funk1@gmail.com>
Mon, 7 Apr 2025 02:19:35 +0000 (19:19 -0700)
committerBruno Haible <bruno@clisp.org>
Mon, 14 Apr 2025 22:34:39 +0000 (00:34 +0200)
* 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
lib/fseeko.c
lib/stdio-impl.h

index db1bfd9a9dc87a51c83cd937a33c4d0235fdc316..0c8cf026163e390b9afcfb9d273a94be3c725b8a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-04-06  Collin Funk  <collin.funk1@gmail.com>
+
+       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  Simon Josefsson  <simon@josefsson.org>
 
        maintainer-makefile: Work with modern LCOV versions.
index c15b9e210f6ab15ed1cf6c30a67f709125237920..b39099c4a00ce4ba4a7c640fae4ddc207992fe2b 100644 (file)
@@ -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
index 878e9f8c97d8ba7cb247a7705b6313a3e0c0087e..b6be0506766d66670d8e2032586b807adb8268df 100644 (file)
 # 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_EOF_SEEN
+#  define _IO_EOF_SEEN 0x10
+# endif
+#endif
+
 /* BSD stdio derived implementations.  */
 
 #if defined __NetBSD__                         /* NetBSD */