Mercurial > gnulib
annotate lib/fseeko.c @ 17363:5a51fb7777a9
sys_select, sys_time: port 2013-01-30 Solaris 2.6 fix to Cygwin
Problem reported by Marco Atzeri in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00000.html>.
* lib/sys_select.in.h [HAVE_SYS_SELECT_H && _CYGWIN_SYS_TIME_H]:
Simply delegate to the system <sys/select.h> in this case too.
Also, pay attention to _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H only
if OSF/1, since otherwise Cygwin breaks, and it doesn't seem to
be needed on Solaris either.
* lib/sys_time.in.h [_CYGWIN_SYS_TIME_H]:
Simply delgate to the system <sys/time.h> in this case.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 19 Mar 2013 09:08:47 -0700 |
parents | e542fd46ad6f |
children | 161070f4cae7 |
rev | line source |
---|---|
8883 | 1 /* An fseeko() function that, together with fflush(), is POSIX compliant. |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16935
diff
changeset
|
2 Copyright (C) 2007-2013 Free Software Foundation, Inc. |
8713
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 This program is free software; you can redistribute it and/or modify |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 the Free Software Foundation; either version 2, or (at your option) |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 any later version. |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License along |
16366
bb182ee4a09d
maint: replace FSF snail-mail addresses with URLs
Paul Eggert <eggert@cs.ucla.edu>
parents:
16344
diff
changeset
|
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ |
8713
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 #include <config.h> |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 /* Specification. */ |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 #include <stdio.h> |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 /* Get off_t and lseek. */ |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 #include <unistd.h> |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 |
9980
2c1ba629f5d5
New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
9928
diff
changeset
|
25 #include "stdio-impl.h" |
2c1ba629f5d5
New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
9928
diff
changeset
|
26 |
13121
472aa3de0fbb
fseeko: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
27 int |
472aa3de0fbb
fseeko: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
28 fseeko (FILE *fp, off_t offset, int whence) |
8713
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 #undef fseeko |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 #if !HAVE_FSEEKO |
8872 | 31 # undef fseek |
8713
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 # define fseeko fseek |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 #endif |
16795
6a9ea5d7b466
Large File Support for native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents:
16366
diff
changeset
|
34 #if _GL_WINDOWS_64_BIT_OFF_T |
6a9ea5d7b466
Large File Support for native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents:
16366
diff
changeset
|
35 # undef fseeko |
6a9ea5d7b466
Large File Support for native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents:
16366
diff
changeset
|
36 # if HAVE__FSEEKI64 /* msvc, mingw64 */ |
6a9ea5d7b466
Large File Support for native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents:
16366
diff
changeset
|
37 # define fseeko _fseeki64 |
6a9ea5d7b466
Large File Support for native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents:
16366
diff
changeset
|
38 # else /* mingw */ |
6a9ea5d7b466
Large File Support for native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents:
16366
diff
changeset
|
39 # define fseeko fseeko64 |
6a9ea5d7b466
Large File Support for native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents:
16366
diff
changeset
|
40 # endif |
6a9ea5d7b466
Large File Support for native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents:
16366
diff
changeset
|
41 #endif |
8713
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 { |
8872 | 43 #if LSEEK_PIPE_BROKEN |
44 /* mingw gives bogus answers rather than failure on non-seekable files. */ | |
45 if (lseek (fileno (fp), 0, SEEK_CUR) == -1) | |
46 return EOF; | |
47 #endif | |
48 | |
8713
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 /* These tests are based on fpurge.c. */ |
10780 | 50 #if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
8713
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 if (fp->_IO_read_end == fp->_IO_read_ptr |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
52 && fp->_IO_write_ptr == fp->_IO_write_base |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
53 && fp->_IO_save_base == NULL) |
16935
498a2211d839
Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents:
16795
diff
changeset
|
54 #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ |
8868
90e71310a07f
Fix fseeko/ftello on cygwin 1.5.24.
Eric Blake <ebb9@byu.net>
parents:
8759
diff
changeset
|
55 # if defined __SL64 && defined __SCLE /* Cygwin */ |
90e71310a07f
Fix fseeko/ftello on cygwin 1.5.24.
Eric Blake <ebb9@byu.net>
parents:
8759
diff
changeset
|
56 if ((fp->_flags & __SL64) == 0) |
90e71310a07f
Fix fseeko/ftello on cygwin 1.5.24.
Eric Blake <ebb9@byu.net>
parents:
8759
diff
changeset
|
57 { |
90e71310a07f
Fix fseeko/ftello on cygwin 1.5.24.
Eric Blake <ebb9@byu.net>
parents:
8759
diff
changeset
|
58 /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11732
diff
changeset
|
59 mode; but has an fseeko that requires 64-bit mode. */ |
8868
90e71310a07f
Fix fseeko/ftello on cygwin 1.5.24.
Eric Blake <ebb9@byu.net>
parents:
8759
diff
changeset
|
60 FILE *tmp = fopen ("/dev/null", "r"); |
90e71310a07f
Fix fseeko/ftello on cygwin 1.5.24.
Eric Blake <ebb9@byu.net>
parents:
8759
diff
changeset
|
61 if (!tmp) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11732
diff
changeset
|
62 return -1; |
8868
90e71310a07f
Fix fseeko/ftello on cygwin 1.5.24.
Eric Blake <ebb9@byu.net>
parents:
8759
diff
changeset
|
63 fp->_flags |= __SL64; |
90e71310a07f
Fix fseeko/ftello on cygwin 1.5.24.
Eric Blake <ebb9@byu.net>
parents:
8759
diff
changeset
|
64 fp->_seek64 = tmp->_seek64; |
90e71310a07f
Fix fseeko/ftello on cygwin 1.5.24.
Eric Blake <ebb9@byu.net>
parents:
8759
diff
changeset
|
65 fclose (tmp); |
90e71310a07f
Fix fseeko/ftello on cygwin 1.5.24.
Eric Blake <ebb9@byu.net>
parents:
8759
diff
changeset
|
66 } |
90e71310a07f
Fix fseeko/ftello on cygwin 1.5.24.
Eric Blake <ebb9@byu.net>
parents:
8759
diff
changeset
|
67 # endif |
9981
e3d6988a9347
Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents:
9980
diff
changeset
|
68 if (fp_->_p == fp_->_bf._base |
e3d6988a9347
Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents:
9980
diff
changeset
|
69 && fp_->_r == 0 |
e3d6988a9347
Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents:
9980
diff
changeset
|
70 && fp_->_w == ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11732
diff
changeset
|
71 ? fp_->_bf._size |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11732
diff
changeset
|
72 : 0) |
8713
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
73 && fp_ub._base == NULL) |
9881
e21211210418
Port the extended stdio functions to emx+gcc.
Bruno Haible <bruno@clisp.org>
parents:
9876
diff
changeset
|
74 #elif defined __EMX__ /* emx+gcc */ |
e21211210418
Port the extended stdio functions to emx+gcc.
Bruno Haible <bruno@clisp.org>
parents:
9876
diff
changeset
|
75 if (fp->_ptr == fp->_buffer |
e21211210418
Port the extended stdio functions to emx+gcc.
Bruno Haible <bruno@clisp.org>
parents:
9876
diff
changeset
|
76 && fp->_rcount == 0 |
e21211210418
Port the extended stdio functions to emx+gcc.
Bruno Haible <bruno@clisp.org>
parents:
9876
diff
changeset
|
77 && fp->_wcount == 0 |
e21211210418
Port the extended stdio functions to emx+gcc.
Bruno Haible <bruno@clisp.org>
parents:
9876
diff
changeset
|
78 && fp->_ungetc_count == 0) |
15485
20a2699b8a90
stdioext: Add support for Minix.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
79 #elif defined __minix /* Minix */ |
20a2699b8a90
stdioext: Add support for Minix.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
80 if (fp_->_ptr == fp_->_buf |
20a2699b8a90
stdioext: Add support for Minix.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
81 && (fp_->_ptr == NULL || fp_->_count == 0)) |
13997
6fa9f46e6153
Port extended stdio modules to HP NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
13121
diff
changeset
|
82 #elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */ |
8713
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
83 if (fp_->_ptr == fp_->_base |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
84 && (fp_->_ptr == NULL || fp_->_cnt == 0)) |
8926
1d4c80b053f0
Add support for uClibc 0.9.29.
Bruno Haible <bruno@clisp.org>
parents:
8883
diff
changeset
|
85 #elif defined __UCLIBC__ /* uClibc */ |
1d4c80b053f0
Add support for uClibc 0.9.29.
Bruno Haible <bruno@clisp.org>
parents:
8883
diff
changeset
|
86 if (((fp->__modeflags & __FLAG_WRITING) == 0 |
1d4c80b053f0
Add support for uClibc 0.9.29.
Bruno Haible <bruno@clisp.org>
parents:
8883
diff
changeset
|
87 || fp->__bufpos == fp->__bufstart) |
1d4c80b053f0
Add support for uClibc 0.9.29.
Bruno Haible <bruno@clisp.org>
parents:
8883
diff
changeset
|
88 && ((fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) == 0 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11732
diff
changeset
|
89 || fp->__bufpos == fp->__bufread)) |
9280
a1f6fe4c68c1
Add support for QNX (untested).
Bruno Haible <bruno@clisp.org>
parents:
9155
diff
changeset
|
90 #elif defined __QNX__ /* QNX */ |
11732
867a6671ca00
Make fseeko.c compile on QNX.
Matt Kraai <mkraai@beckman.com>
parents:
11242
diff
changeset
|
91 if ((fp->_Mode & 0x2000 /* _MWRITE */ ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend) |
9280
a1f6fe4c68c1
Add support for QNX (untested).
Bruno Haible <bruno@clisp.org>
parents:
9155
diff
changeset
|
92 && fp->_Rback == fp->_Back + sizeof (fp->_Back) |
a1f6fe4c68c1
Add support for QNX (untested).
Bruno Haible <bruno@clisp.org>
parents:
9155
diff
changeset
|
93 && fp->_Rsave == NULL) |
11236
d4475bf2a2bf
Add tentative support for FreeMiNT.
Bruno Haible <bruno@clisp.org>
parents:
11017
diff
changeset
|
94 #elif defined __MINT__ /* Atari FreeMiNT */ |
d4475bf2a2bf
Add tentative support for FreeMiNT.
Bruno Haible <bruno@clisp.org>
parents:
11017
diff
changeset
|
95 if (fp->__bufp == fp->__buffer |
d4475bf2a2bf
Add tentative support for FreeMiNT.
Bruno Haible <bruno@clisp.org>
parents:
11017
diff
changeset
|
96 && fp->__get_limit == fp->__bufp |
d4475bf2a2bf
Add tentative support for FreeMiNT.
Bruno Haible <bruno@clisp.org>
parents:
11017
diff
changeset
|
97 && fp->__put_limit == fp->__bufp |
d4475bf2a2bf
Add tentative support for FreeMiNT.
Bruno Haible <bruno@clisp.org>
parents:
11017
diff
changeset
|
98 && !fp->__pushed_back) |
16344
ecfc57537d99
stdioext: Add tentative support for Plan9.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
99 #elif defined EPLAN9 /* Plan9 */ |
ecfc57537d99
stdioext: Add tentative support for Plan9.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
100 if (fp->rp == fp->buf |
ecfc57537d99
stdioext: Add tentative support for Plan9.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
101 && fp->wp == fp->buf) |
8713
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
102 #else |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
103 #error "Please port gnulib fseeko.c to your platform! Look at the code in fpurge.c, then report this to bug-gnulib." |
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
104 #endif |
8717
3afefd650c3a
On BSD implementations, when we call lseek(), we must also update or disable
Bruno Haible <bruno@clisp.org>
parents:
8713
diff
changeset
|
105 { |
15506
72af71b55124
fseeko: remove unneeded hack
Eric Blake <eblake@redhat.com>
parents:
15505
diff
changeset
|
106 /* We get here when an fflush() call immediately preceded this one (or |
72af71b55124
fseeko: remove unneeded hack
Eric Blake <eblake@redhat.com>
parents:
15505
diff
changeset
|
107 if ftell() has created buffers but no I/O has occurred on a |
72af71b55124
fseeko: remove unneeded hack
Eric Blake <eblake@redhat.com>
parents:
15505
diff
changeset
|
108 newly-opened stream). We know there are no buffers. */ |
72af71b55124
fseeko: remove unneeded hack
Eric Blake <eblake@redhat.com>
parents:
15505
diff
changeset
|
109 off_t pos = lseek (fileno (fp), offset, whence); |
8717
3afefd650c3a
On BSD implementations, when we call lseek(), we must also update or disable
Bruno Haible <bruno@clisp.org>
parents:
8713
diff
changeset
|
110 if (pos == -1) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11732
diff
changeset
|
111 { |
16935
498a2211d839
Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents:
16795
diff
changeset
|
112 #if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11732
diff
changeset
|
113 fp_->_flags &= ~__SOFF; |
8717
3afefd650c3a
On BSD implementations, when we call lseek(), we must also update or disable
Bruno Haible <bruno@clisp.org>
parents:
8713
diff
changeset
|
114 #endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11732
diff
changeset
|
115 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11732
diff
changeset
|
116 } |
11017
95eb3a6eb21d
Make fflush-after-ungetc POSIX compliant on glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
10780
diff
changeset
|
117 |
95eb3a6eb21d
Make fflush-after-ungetc POSIX compliant on glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
10780
diff
changeset
|
118 #if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
95eb3a6eb21d
Make fflush-after-ungetc POSIX compliant on glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
10780
diff
changeset
|
119 fp->_flags &= ~_IO_EOF_SEEN; |
15505 | 120 fp->_offset = pos; |
16935
498a2211d839
Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents:
16795
diff
changeset
|
121 #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ |
12459 | 122 # if defined __CYGWIN__ |
123 /* fp_->_offset is typed as an integer. */ | |
124 fp_->_offset = pos; | |
125 # else | |
126 /* fp_->_offset is an fpos_t. */ | |
12452
cc0faab513a7
fflush: avoid compilation error on NetBSD
Eric Blake <ebb9@byu.net>
parents:
12421
diff
changeset
|
127 { |
cc0faab513a7
fflush: avoid compilation error on NetBSD
Eric Blake <ebb9@byu.net>
parents:
12421
diff
changeset
|
128 /* Use a union, since on NetBSD, the compilation flags |
cc0faab513a7
fflush: avoid compilation error on NetBSD
Eric Blake <ebb9@byu.net>
parents:
12421
diff
changeset
|
129 determine whether fpos_t is typedef'd to off_t or a struct |
cc0faab513a7
fflush: avoid compilation error on NetBSD
Eric Blake <ebb9@byu.net>
parents:
12421
diff
changeset
|
130 containing a single off_t member. */ |
cc0faab513a7
fflush: avoid compilation error on NetBSD
Eric Blake <ebb9@byu.net>
parents:
12421
diff
changeset
|
131 union |
cc0faab513a7
fflush: avoid compilation error on NetBSD
Eric Blake <ebb9@byu.net>
parents:
12421
diff
changeset
|
132 { |
cc0faab513a7
fflush: avoid compilation error on NetBSD
Eric Blake <ebb9@byu.net>
parents:
12421
diff
changeset
|
133 fpos_t f; |
cc0faab513a7
fflush: avoid compilation error on NetBSD
Eric Blake <ebb9@byu.net>
parents:
12421
diff
changeset
|
134 off_t o; |
cc0faab513a7
fflush: avoid compilation error on NetBSD
Eric Blake <ebb9@byu.net>
parents:
12421
diff
changeset
|
135 } u; |
cc0faab513a7
fflush: avoid compilation error on NetBSD
Eric Blake <ebb9@byu.net>
parents:
12421
diff
changeset
|
136 u.o = pos; |
cc0faab513a7
fflush: avoid compilation error on NetBSD
Eric Blake <ebb9@byu.net>
parents:
12421
diff
changeset
|
137 fp_->_offset = u.f; |
cc0faab513a7
fflush: avoid compilation error on NetBSD
Eric Blake <ebb9@byu.net>
parents:
12421
diff
changeset
|
138 } |
12459 | 139 # endif |
11017
95eb3a6eb21d
Make fflush-after-ungetc POSIX compliant on glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
10780
diff
changeset
|
140 fp_->_flags |= __SOFF; |
95eb3a6eb21d
Make fflush-after-ungetc POSIX compliant on glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
10780
diff
changeset
|
141 fp_->_flags &= ~__SEOF; |
9881
e21211210418
Port the extended stdio functions to emx+gcc.
Bruno Haible <bruno@clisp.org>
parents:
9876
diff
changeset
|
142 #elif defined __EMX__ /* emx+gcc */ |
11017
95eb3a6eb21d
Make fflush-after-ungetc POSIX compliant on glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
10780
diff
changeset
|
143 fp->_flags &= ~_IOEOF; |
13997
6fa9f46e6153
Port extended stdio modules to HP NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
13121
diff
changeset
|
144 #elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */ |
11017
95eb3a6eb21d
Make fflush-after-ungetc POSIX compliant on glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
10780
diff
changeset
|
145 fp->_flag &= ~_IOEOF; |
11242
4a120b892043
More support for FreeMiNT.
Bruno Haible <bruno@clisp.org>
parents:
11236
diff
changeset
|
146 #elif defined __MINT__ /* Atari FreeMiNT */ |
4a120b892043
More support for FreeMiNT.
Bruno Haible <bruno@clisp.org>
parents:
11236
diff
changeset
|
147 fp->__offset = pos; |
4a120b892043
More support for FreeMiNT.
Bruno Haible <bruno@clisp.org>
parents:
11236
diff
changeset
|
148 fp->__eof = 0; |
8717
3afefd650c3a
On BSD implementations, when we call lseek(), we must also update or disable
Bruno Haible <bruno@clisp.org>
parents:
8713
diff
changeset
|
149 #endif |
15506
72af71b55124
fseeko: remove unneeded hack
Eric Blake <eblake@redhat.com>
parents:
15505
diff
changeset
|
150 return 0; |
8717
3afefd650c3a
On BSD implementations, when we call lseek(), we must also update or disable
Bruno Haible <bruno@clisp.org>
parents:
8713
diff
changeset
|
151 } |
11017
95eb3a6eb21d
Make fflush-after-ungetc POSIX compliant on glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
10780
diff
changeset
|
152 return fseeko (fp, offset, whence); |
8713
aad7ea346fbf
Make the combination of fflush and fseek/fseeko POSIX compliant.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
153 } |