summaryrefslogtreecommitdiffstats
path: root/gl/fseeko.c
diff options
context:
space:
mode:
Diffstat (limited to 'gl/fseeko.c')
-rw-r--r--gl/fseeko.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/gl/fseeko.c b/gl/fseeko.c
index 2c3b053a..f6cd7cba 100644
--- a/gl/fseeko.c
+++ b/gl/fseeko.c
@@ -1,5 +1,5 @@
1/* An fseeko() function that, together with fflush(), is POSIX compliant. 1/* An fseeko() function that, together with fflush(), is POSIX compliant.
2 Copyright (C) 2007-2024 Free Software Foundation, Inc. 2 Copyright (C) 2007-2026 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
@@ -48,12 +48,15 @@ fseeko (FILE *fp, off_t offset, int whence)
48 48
49 /* These tests are based on fpurge.c. */ 49 /* These tests are based on fpurge.c. */
50#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 50#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
51# if !defined __HAIKU__
52# define fp_ fp
53# endif
51 /* GNU libc, BeOS, Haiku, Linux libc5 */ 54 /* GNU libc, BeOS, Haiku, Linux libc5 */
52 if (fp->_IO_read_end == fp->_IO_read_ptr 55 if (fp_->_IO_read_end == fp_->_IO_read_ptr
53 && fp->_IO_write_ptr == fp->_IO_write_base 56 && fp_->_IO_write_ptr == fp_->_IO_write_base
54 && fp->_IO_save_base == NULL) 57 && fp_->_IO_save_base == NULL)
55#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ 58#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
56 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ 59 /* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
57# if defined __SL64 && defined __SCLE /* Cygwin */ 60# if defined __SL64 && defined __SCLE /* Cygwin */
58 if ((fp->_flags & __SL64) == 0) 61 if ((fp->_flags & __SL64) == 0)
59 { 62 {
@@ -81,7 +84,7 @@ fseeko (FILE *fp, off_t offset, int whence)
81#elif defined __minix /* Minix */ 84#elif defined __minix /* Minix */
82 if (fp_->_ptr == fp_->_buf 85 if (fp_->_ptr == fp_->_buf
83 && (fp_->_ptr == NULL || fp_->_count == 0)) 86 && (fp_->_ptr == NULL || fp_->_count == 0))
84#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */ 87#elif defined _IOERR /* AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
85 if (fp_->_ptr == fp_->_base 88 if (fp_->_ptr == fp_->_base
86 && (fp_->_ptr == NULL || fp_->_cnt == 0)) 89 && (fp_->_ptr == NULL || fp_->_cnt == 0))
87#elif defined __UCLIBC__ /* uClibc */ 90#elif defined __UCLIBC__ /* uClibc */
@@ -101,6 +104,9 @@ fseeko (FILE *fp, off_t offset, int whence)
101#elif defined EPLAN9 /* Plan9 */ 104#elif defined EPLAN9 /* Plan9 */
102 if (fp->rp == fp->buf 105 if (fp->rp == fp->buf
103 && fp->wp == fp->buf) 106 && fp->wp == fp->buf)
107#elif defined __OpenBSD__ && !defined __sferror /* OpenBSD >= 7.8 */
108 /* fseeko and fflush work as advertised. */
109 if (0)
104#elif FUNC_FFLUSH_STDIN < 0 && 200809 <= _POSIX_VERSION 110#elif FUNC_FFLUSH_STDIN < 0 && 200809 <= _POSIX_VERSION
105 /* Cross-compiling to some other system advertising conformance to 111 /* Cross-compiling to some other system advertising conformance to
106 POSIX.1-2008 or later. Assume fseeko and fflush work as advertised. 112 POSIX.1-2008 or later. Assume fseeko and fflush work as advertised.
@@ -118,7 +124,7 @@ fseeko (FILE *fp, off_t offset, int whence)
118 if (pos == -1) 124 if (pos == -1)
119 { 125 {
120#if defined __sferror || defined __DragonFly__ || defined __ANDROID__ 126#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
121 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ 127 /* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
122 fp_->_flags &= ~__SOFF; 128 fp_->_flags &= ~__SOFF;
123#endif 129#endif
124 return -1; 130 return -1;
@@ -126,10 +132,10 @@ fseeko (FILE *fp, off_t offset, int whence)
126 132
127#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 133#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
128 /* GNU libc, BeOS, Haiku, Linux libc5 */ 134 /* GNU libc, BeOS, Haiku, Linux libc5 */
129 fp->_flags &= ~_IO_EOF_SEEN; 135 fp_->_flags &= ~_IO_EOF_SEEN;
130 fp->_offset = pos; 136 fp_->_offset = pos;
131#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ 137#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
132 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ 138 /* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
133# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix 139# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix
134 /* fp_->_offset is typed as an integer. */ 140 /* fp_->_offset is typed as an integer. */
135 fp_->_offset = pos; 141 fp_->_offset = pos;
@@ -152,7 +158,7 @@ fseeko (FILE *fp, off_t offset, int whence)
152 fp_->_flags &= ~__SEOF; 158 fp_->_flags &= ~__SEOF;
153#elif defined __EMX__ /* emx+gcc */ 159#elif defined __EMX__ /* emx+gcc */
154 fp->_flags &= ~_IOEOF; 160 fp->_flags &= ~_IOEOF;
155#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */ 161#elif defined _IOERR /* AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
156 fp_->_flag &= ~_IOEOF; 162 fp_->_flag &= ~_IOEOF;
157#elif defined __MINT__ /* Atari FreeMiNT */ 163#elif defined __MINT__ /* Atari FreeMiNT */
158 fp->__offset = pos; 164 fp->__offset = pos;