Skip to content

Commit d9e6afa

Browse files
committed
Replace hacky win_sdk10 exceprts with backport from upstream
This is ported from upstream. commit_hash:18fa64042d1b1b0dfaaadd90d4b3c0b6e256fce5
1 parent b2bf123 commit d9e6afa

File tree

8 files changed

+205
-132
lines changed

8 files changed

+205
-132
lines changed

contrib/tools/m4/lib/config-win.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/* lib/config.h. Generated from config.hin by configure. */
22
/* lib/config.hin. Generated from configure.ac by autoheader. */
33

4-
#include "win_sdk10.h"
5-
64
/* Define if building universal (internal helper macro) */
75
/* #undef AC_APPLE_UNIVERSAL_BUILD */
86

contrib/tools/m4/lib/fpending.c

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* fpending.c -- return the number of pending output bytes on a stream
2-
Copyright (C) 2000, 2004, 2006-2007, 2009-2013 Free Software Foundation,
2+
Copyright (C) 2000, 2004, 2006-2007, 2009-2021 Free Software Foundation,
33
Inc.
44
55
This program is free software: you can redistribute it and/or modify
@@ -13,22 +13,51 @@
1313
GNU General Public License for more details.
1414
1515
You should have received a copy of the GNU General Public License
16-
along with this program. If not, see <http://www.gnu.org/licenses/>. */
16+
along with this program. If not, see <https://www.gnu.org/licenses/>. */
1717

1818
/* Written by Jim Meyering. */
1919

2020
#include <config.h>
2121

22+
/* Specification. */
2223
#include "fpending.h"
2324

25+
#include "stdio-impl.h"
26+
27+
/* This file is not used on systems that already have the __fpending function,
28+
namely glibc >= 2.2, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.34,
29+
Android API >= 23. */
30+
2431
/* Return the number of pending (aka buffered, unflushed)
2532
bytes on the stream, FP, that is open for writing. */
2633
size_t
2734
__fpending (FILE *fp)
2835
{
29-
#if defined(PENDING_OUTPUT_N_BYTES)
30-
return PENDING_OUTPUT_N_BYTES;
36+
/* Most systems provide FILE as a struct and the necessary bitmask in
37+
<stdio.h>, because they need it for implementing getc() and putc() as
38+
fast macros. */
39+
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
40+
/* GNU libc, BeOS, Haiku, Linux libc5 */
41+
return fp->_IO_write_ptr - fp->_IO_write_base;
42+
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
43+
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin < 1.7.34, Minix 3, Android */
44+
return fp->_p - fp->_bf._base;
45+
#elif defined __EMX__ /* emx+gcc */
46+
return fp->_ptr - fp->_buffer;
47+
#elif defined __minix /* Minix */
48+
return fp_->_ptr - fp_->_buf;
49+
#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
50+
return (fp_->_ptr ? fp_->_ptr - fp_->_base : 0);
51+
#elif defined __UCLIBC__ /* uClibc */
52+
return (fp->__modeflags & __FLAG_WRITING ? fp->__bufpos - fp->__bufstart : 0);
53+
#elif defined __QNX__ /* QNX */
54+
return (fp->_Mode & 0x2000 /*_MWRITE*/ ? fp->_Next - fp->_Buf : 0);
55+
#elif defined __MINT__ /* Atari FreeMiNT */
56+
return fp->__bufp - fp->__buffer;
57+
#elif defined EPLAN9 /* Plan9 */
58+
return fp->wp - fp->buf;
59+
#else
60+
# error "Please port gnulib fpending.c to your platform!"
61+
return 1;
3162
#endif
32-
33-
return 0;
3463
}

contrib/tools/m4/lib/fpurge.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Flushing buffers of a FILE stream.
2-
Copyright (C) 2007-2013 Free Software Foundation, Inc.
2+
Copyright (C) 2007-2021 Free Software Foundation, Inc.
33
44
This program is free software: you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -12,15 +12,17 @@
1212
GNU General Public License for more details.
1313
1414
You should have received a copy of the GNU General Public License
15-
along with this program. If not, see <http://www.gnu.org/licenses/>. */
15+
along with this program. If not, see <https://www.gnu.org/licenses/>. */
1616

1717
#include <config.h>
1818

1919
/* Specification. */
2020
#include <stdio.h>
2121

22-
#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7 */
23-
# include <stdio_ext.h>
22+
#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.10, Android API >= 23, musl libc */
23+
# if HAVE_STDIO_EXT_H
24+
# include <stdio_ext.h>
25+
# endif
2426
#endif
2527
#include <stdlib.h>
2628

@@ -29,21 +31,22 @@
2931
int
3032
fpurge (FILE *fp)
3133
{
32-
#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7, musl libc */
34+
#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.10, Android API >= 23, musl libc */
3335

3436
__fpurge (fp);
3537
/* The __fpurge function does not have a return value. */
3638
return 0;
3739

38-
#elif HAVE_FPURGE /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin 1.7 */
40+
#elif HAVE_FPURGE /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin >= 1.7 */
3941

4042
/* Call the system's fpurge function. */
4143
# undef fpurge
4244
# if !HAVE_DECL_FPURGE
4345
extern int fpurge (FILE *);
4446
# endif
4547
int result = fpurge (fp);
46-
# if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
48+
# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
49+
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
4750
if (result == 0)
4851
/* Correct the invariants that fpurge broke.
4952
<stdio.h> on BSD systems says:
@@ -61,7 +64,8 @@ fpurge (FILE *fp)
6164
/* Most systems provide FILE as a struct and the necessary bitmask in
6265
<stdio.h>, because they need it for implementing getc() and putc() as
6366
fast macros. */
64-
# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
67+
# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
68+
/* GNU libc, BeOS, Haiku, Linux libc5 */
6569
fp->_IO_read_end = fp->_IO_read_ptr;
6670
fp->_IO_write_ptr = fp->_IO_write_base;
6771
/* Avoid memory leak when there is an active ungetc buffer. */
@@ -71,7 +75,8 @@ fpurge (FILE *fp)
7175
fp->_IO_save_base = NULL;
7276
}
7377
return 0;
74-
# elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
78+
# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
79+
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
7580
fp_->_p = fp_->_bf._base;
7681
fp_->_r = 0;
7782
fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
@@ -96,15 +101,10 @@ fpurge (FILE *fp)
96101
if (fp->_ptr != NULL)
97102
fp->_count = 0;
98103
return 0;
99-
# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
100-
fp->_ptr = fp->_base;
101-
if (fp->_ptr != NULL)
102-
fp->_cnt = 0;
103-
return 0;
104-
# elif WIN_SDK10
105-
((TWinSdk10File*)fp)->_ptr = ((TWinSdk10File*)fp)->_base;
106-
if (((TWinSdk10File*)fp)->_ptr != NULL)
107-
((TWinSdk10File*)fp)->_cnt = 0;
104+
# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
105+
fp_->_ptr = fp_->_base;
106+
if (fp_->_ptr != NULL)
107+
fp_->_cnt = 0;
108108
return 0;
109109
# elif defined __UCLIBC__ /* uClibc */
110110
# ifdef __STDIO_BUFFERS

contrib/tools/m4/lib/freadahead.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Retrieve information about a FILE stream.
2-
Copyright (C) 2007-2013 Free Software Foundation, Inc.
2+
Copyright (C) 2007-2021 Free Software Foundation, Inc.
33
44
This program is free software: you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
1212
GNU General Public License for more details.
1313
1414
You should have received a copy of the GNU General Public License
15-
along with this program. If not, see <http://www.gnu.org/licenses/>. */
15+
along with this program. If not, see <https://www.gnu.org/licenses/>. */
1616

1717
#include <config.h>
1818

@@ -22,16 +22,26 @@
2222
#include <stdlib.h>
2323
#include "stdio-impl.h"
2424

25+
#if defined __DragonFly__
26+
/* Defined in libc, but not declared in <stdio.h>. */
27+
extern size_t __sreadahead (FILE *);
28+
#endif
29+
30+
/* This file is not used on systems that have the __freadahead function,
31+
namely musl libc. */
32+
2533
size_t
2634
freadahead (FILE *fp)
2735
{
28-
#if defined _IO_EOF_SEEN || defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
36+
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
37+
/* GNU libc, BeOS, Haiku, Linux libc5 */
2938
if (fp->_IO_write_ptr > fp->_IO_write_base)
3039
return 0;
3140
return (fp->_IO_read_end - fp->_IO_read_ptr)
3241
+ (fp->_flags & _IO_IN_BACKUP ? fp->_IO_save_end - fp->_IO_save_base :
3342
0);
34-
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
43+
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
44+
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
3545
if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0)
3646
return 0;
3747
# if defined __DragonFly__
@@ -52,14 +62,10 @@ freadahead (FILE *fp)
5262
if ((fp_->_flags & _IOWRITING) != 0)
5363
return 0;
5464
return fp_->_count;
55-
#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
65+
#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
5666
if ((fp_->_flag & _IOWRT) != 0)
5767
return 0;
5868
return fp_->_cnt;
59-
#elif WIN_SDK10
60-
if ((((TWinSdk10File*)fp)->_flags & WIN_SDK10_IOWRITE) != 0)
61-
return 0;
62-
return ((TWinSdk10File*)fp)->_cnt;
6369
#elif defined __UCLIBC__ /* uClibc */
6470
# ifdef __STDIO_BUFFERS
6571
if (fp->__modeflags & __FLAG_WRITING)

contrib/tools/m4/lib/freading.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Retrieve information about a FILE stream.
2-
Copyright (C) 2007-2013 Free Software Foundation, Inc.
2+
Copyright (C) 2007-2021 Free Software Foundation, Inc.
33
44
This program is free software: you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
1212
GNU General Public License for more details.
1313
1414
You should have received a copy of the GNU General Public License
15-
along with this program. If not, see <http://www.gnu.org/licenses/>. */
15+
along with this program. If not, see <https://www.gnu.org/licenses/>. */
1616

1717
#include <config.h>
1818

@@ -22,7 +22,7 @@
2222
#include "stdio-impl.h"
2323

2424
/* Don't use glibc's __freading function in glibc < 2.7, see
25-
<http://sourceware.org/bugzilla/show_bug.cgi?id=4359> */
25+
<https://sourceware.org/bugzilla/show_bug.cgi?id=4359> */
2626
#if !(HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)))
2727

2828
bool
@@ -31,24 +31,24 @@ freading (FILE *fp)
3131
/* Most systems provide FILE as a struct and the necessary bitmask in
3232
<stdio.h>, because they need it for implementing getc() and putc() as
3333
fast macros. */
34-
# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
34+
# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
35+
/* GNU libc, BeOS, Haiku, Linux libc5 */
3536
return ((fp->_flags & _IO_NO_WRITES) != 0
3637
|| ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
3738
&& fp->_IO_read_base != NULL));
38-
# elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
39+
# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
40+
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin < 1.7.34, Minix 3, Android */
3941
return (fp_->_flags & __SRD) != 0;
4042
# elif defined __EMX__ /* emx+gcc */
4143
return (fp->_flags & _IOREAD) != 0;
4244
# elif defined __minix /* Minix */
4345
return (fp->_flags & _IOREADING) != 0;
44-
# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
46+
# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
4547
# if defined __sun /* Solaris */
46-
return (fp->_flag & _IOREAD) != 0 && (fp->_flag & _IOWRT) == 0;
48+
return (fp_->_flag & _IOREAD) != 0 && (fp_->_flag & _IOWRT) == 0;
4749
# else
48-
return (fp->_flag & _IOREAD) != 0;
50+
return (fp_->_flag & _IOREAD) != 0;
4951
# endif
50-
# elif WIN_SDK10
51-
return (((TWinSdk10File*)fp)->_flags & WIN_SDK10_IOREAD) != 0;
5252
# elif defined __UCLIBC__ /* uClibc */
5353
return (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) != 0;
5454
# elif defined __QNX__ /* QNX */

contrib/tools/m4/lib/fseeko.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* An fseeko() function that, together with fflush(), is POSIX compliant.
2-
Copyright (C) 2007-2013 Free Software Foundation, Inc.
2+
Copyright (C) 2007-2021 Free Software Foundation, Inc.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
1212
GNU General Public License for more details.
1313
1414
You should have received a copy of the GNU General Public License along
15-
with this program; if not, see <http://www.gnu.org/licenses/>. */
15+
with this program; if not, see <https://www.gnu.org/licenses/>. */
1616

1717
#include <config.h>
1818

@@ -33,9 +33,9 @@ fseeko (FILE *fp, off_t offset, int whence)
3333
#endif
3434
#if _GL_WINDOWS_64_BIT_OFF_T
3535
# undef fseeko
36-
# if HAVE__FSEEKI64 /* msvc, mingw64 */
36+
# if HAVE__FSEEKI64 && HAVE_DECL__FSEEKI64 /* msvc, mingw since msvcrt8.0, mingw64 */
3737
# define fseeko _fseeki64
38-
# else /* mingw */
38+
# else /* mingw before msvcrt8.0 */
3939
# define fseeko fseeko64
4040
# endif
4141
#endif
@@ -47,11 +47,13 @@ fseeko (FILE *fp, off_t offset, int whence)
4747
#endif
4848

4949
/* These tests are based on fpurge.c. */
50-
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
50+
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
51+
/* GNU libc, BeOS, Haiku, Linux libc5 */
5152
if (fp->_IO_read_end == fp->_IO_read_ptr
5253
&& fp->_IO_write_ptr == fp->_IO_write_base
5354
&& fp->_IO_save_base == NULL)
54-
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
55+
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
56+
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
5557
# if defined __SL64 && defined __SCLE /* Cygwin */
5658
if ((fp->_flags & __SL64) == 0)
5759
{
@@ -79,12 +81,9 @@ fseeko (FILE *fp, off_t offset, int whence)
7981
#elif defined __minix /* Minix */
8082
if (fp_->_ptr == fp_->_buf
8183
&& (fp_->_ptr == NULL || fp_->_count == 0))
82-
#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
84+
#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
8385
if (fp_->_ptr == fp_->_base
8486
&& (fp_->_ptr == NULL || fp_->_cnt == 0))
85-
#elif WIN_SDK10
86-
if (((TWinSdk10File*)fp)->_ptr == ((TWinSdk10File*)fp)->_base
87-
&& (((TWinSdk10File*)fp)->_ptr == NULL || ((TWinSdk10File*)fp)->_cnt == 0))
8887
#elif defined __UCLIBC__ /* uClibc */
8988
if (((fp->__modeflags & __FLAG_WRITING) == 0
9089
|| fp->__bufpos == fp->__bufstart)
@@ -118,17 +117,20 @@ fseeko (FILE *fp, off_t offset, int whence)
118117
off_t pos = lseek (fileno (fp), offset, whence);
119118
if (pos == -1)
120119
{
121-
#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
120+
#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
121+
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
122122
fp_->_flags &= ~__SOFF;
123123
#endif
124124
return -1;
125125
}
126126

127-
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
127+
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
128+
/* GNU libc, BeOS, Haiku, Linux libc5 */
128129
fp->_flags &= ~_IO_EOF_SEEN;
129130
fp->_offset = pos;
130-
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
131-
# if defined __CYGWIN__
131+
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
132+
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
133+
# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix
132134
/* fp_->_offset is typed as an integer. */
133135
fp_->_offset = pos;
134136
# else
@@ -150,8 +152,8 @@ fseeko (FILE *fp, off_t offset, int whence)
150152
fp_->_flags &= ~__SEOF;
151153
#elif defined __EMX__ /* emx+gcc */
152154
fp->_flags &= ~_IOEOF;
153-
#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
154-
fp->_flag &= ~_IOEOF;
155+
#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
156+
fp_->_flag &= ~_IOEOF;
155157
#elif defined __MINT__ /* Atari FreeMiNT */
156158
fp->__offset = pos;
157159
fp->__eof = 0;

0 commit comments

Comments
 (0)