Hi Dennis,

Dennis Clarke via "GNU gzip discussion and bug reports."
<[email protected]> writes:

> make[3]: *** [Makefile:2940: libgzip_a-fseeko.o] Error 1
> make[3]: Leaving directory
> '/opt/bw/build/gzip-1.14_OpenBSD_alpha_21164.001/lib'
> make[2]: *** [Makefile:2266: all] Error 2
> make[2]: Leaving directory
> '/opt/bw/build/gzip-1.14_OpenBSD_alpha_21164.001/lib'
> make[1]: *** [Makefile:2110: all-recursive] Error 1
> make[1]: Leaving directory '/opt/bw/build/gzip-1.14_OpenBSD_alpha_21164.001'
> make: *** [Makefile:1891: all] Error 2
>
> Why?
>
> This is the code in fseek.c :

I think you meant to look at fseeko.c, which is the one that failed to
compile.

> So what is the problem here ?  Non-portable gzip ?

OpenBSD 7.8, which I assume you are using, made the FILE type incomplete
and hid some internal macros. That is why the file fails to compile.
This is fixed in git, but not in the 1.14 release tarball which predates
that change.

I have attached a patch with the fix. You can apply it with:

    $ patch -p0 < openbsd-stdio.patch

I can build it with that change.

Collin

--- lib/fseeko.c.orig	Fri Jan  3 17:36:44 2025
+++ lib/fseeko.c	Sat Mar 28 21:46:50 2026
@@ -1,5 +1,5 @@
 /* An fseeko() function that, together with fflush(), is POSIX compliant.
-   Copyright (C) 2007-2025 Free Software Foundation, Inc.
+   Copyright (C) 2007-2026 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
@@ -48,12 +48,15 @@
 
   /* 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 */
+  /* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
 # if defined __SL64 && defined __SCLE /* Cygwin */
   if ((fp->_flags & __SL64) == 0)
     {
@@ -81,7 +84,7 @@
 #elif defined __minix               /* Minix */
   if (fp_->_ptr == fp_->_buf
       && (fp_->_ptr == NULL || fp_->_count == 0))
-#elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
+#elif defined _IOERR                /* AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
   if (fp_->_ptr == fp_->_base
       && (fp_->_ptr == NULL || fp_->_cnt == 0))
 #elif defined __UCLIBC__            /* uClibc */
@@ -101,6 +104,9 @@
 #elif defined EPLAN9                /* Plan9 */
   if (fp->rp == fp->buf
       && fp->wp == fp->buf)
+#elif defined __OpenBSD__ && !defined __sferror /* OpenBSD >= 7.8 */
+  /* fseeko and fflush work as advertised.  */
+  if (0)
 #elif FUNC_FFLUSH_STDIN < 0 && 200809 <= _POSIX_VERSION
   /* Cross-compiling to some other system advertising conformance to
      POSIX.1-2008 or later.  Assume fseeko and fflush work as advertised.
@@ -118,7 +124,7 @@
       if (pos == -1)
         {
 #if defined __sferror || defined __DragonFly__ || defined __ANDROID__
-          /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
+          /* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
           fp_->_flags &= ~__SOFF;
 #endif
           return -1;
@@ -126,10 +132,10 @@
 
 #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 */
+      /* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
 # if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix
       /* fp_->_offset is typed as an integer.  */
       fp_->_offset = pos;
@@ -152,7 +158,7 @@
       fp_->_flags &= ~__SEOF;
 #elif defined __EMX__               /* emx+gcc */
       fp->_flags &= ~_IOEOF;
-#elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
+#elif defined _IOERR                /* AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
       fp_->_flag &= ~_IOEOF;
 #elif defined __MINT__              /* Atari FreeMiNT */
       fp->__offset = pos;
       

Reply via email to