Update from Gnulib

This incorporates:
2020-08-12 stdint: port intptr_t to more-recent MinGW
2020-08-11 Use __restrict also on clang
2020-08-11 Use flexible array syntax also on clang
2020-08-11 fcntl: On native Windows, use _setmode, not setmode
* lib/binary-io.h, lib/cdefs.h, lib/fcntl.c, lib/regex.h:
* lib/stdint.in.h: Copy from Gnulib.
This commit is contained in:
Paul Eggert 2020-08-12 11:37:52 -07:00
parent 9102ecc63b
commit e697ca1525
5 changed files with 26 additions and 17 deletions

View file

@ -56,7 +56,7 @@ __gl_setmode (int fd _GL_UNUSED, int mode _GL_UNUSED)
/* Set FD's mode to MODE, which should be either O_TEXT or O_BINARY.
Return the old mode if successful, -1 (setting errno) on failure.
Ordinarily this function would be called 'setmode', since that is
its name on MS-Windows, but it is called 'set_binary_mode' here
its old name on MS-Windows, but it is called 'set_binary_mode' here
to avoid colliding with a BSD function of another name. */
#if defined __DJGPP__ || defined __EMX__

View file

@ -167,8 +167,8 @@
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc
# define __flexarr []
# define __glibc_c99_flexarr_available 1
#elif __GNUC_PREREQ (2,97)
/* GCC 2.97 supports C99 flexible array members as an extension,
#elif __GNUC_PREREQ (2,97) || defined __clang__
/* GCC 2.97 and clang support C99 flexible array members as an extension,
even when in C89 mode or compiling C++ (any version). */
# define __flexarr []
# define __glibc_c99_flexarr_available 1
@ -399,8 +399,10 @@
# define __extension__ /* Ignore */
#endif
/* __restrict is known in EGCS 1.2 and above. */
#if !__GNUC_PREREQ (2,92)
/* __restrict is known in EGCS 1.2 and above, and in clang.
It works also in C++ mode (outside of arrays), but only when spelled
as '__restrict', not 'restrict'. */
#if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3)
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
# define __restrict restrict
# else
@ -410,8 +412,9 @@
/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
array_name[restrict]
GCC 3.1 supports this. */
#if __GNUC_PREREQ (3,1) && !defined __GNUG__
GCC 3.1 and clang support this.
This syntax is not usable in C++ mode. */
#if (__GNUC_PREREQ (3,1) || __clang_major__ >= 3) && !defined __cplusplus
# define __restrict_arr __restrict
#else
# ifdef __GNUC__

View file

@ -70,14 +70,14 @@ dupfd (int oldfd, int newfd, int flags)
return -1;
}
if (old_handle == INVALID_HANDLE_VALUE
|| (mode = setmode (oldfd, O_BINARY)) == -1)
|| (mode = _setmode (oldfd, O_BINARY)) == -1)
{
/* oldfd is not open, or is an unassigned standard file
descriptor. */
errno = EBADF;
return -1;
}
setmode (oldfd, mode);
_setmode (oldfd, mode);
flags |= mode;
for (;;)

View file

@ -612,7 +612,9 @@ extern int re_exec (const char *);
'configure' might #define 'restrict' to those words, so pick a
different name. */
#ifndef _Restrict_
# if defined __restrict || 2 < __GNUC__ + (95 <= __GNUC_MINOR__)
# if defined __restrict \
|| 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \
|| __clang_major__ >= 3
# define _Restrict_ __restrict
# elif 199901L <= __STDC_VERSION__ || defined restrict
# define _Restrict_ restrict
@ -620,13 +622,18 @@ extern int re_exec (const char *);
# define _Restrict_
# endif
#endif
/* For [restrict], use glibc's __restrict_arr if available.
Otherwise, GCC 3.1 (not in C++ mode) and C99 support [restrict]. */
/* For the ISO C99 syntax
array_name[restrict]
use glibc's __restrict_arr if available.
Otherwise, GCC 3.1 and clang support this syntax (but not in C++ mode).
Other ISO C99 compilers support it as well. */
#ifndef _Restrict_arr_
# ifdef __restrict_arr
# define _Restrict_arr_ __restrict_arr
# elif ((199901L <= __STDC_VERSION__ || 3 < __GNUC__ + (1 <= __GNUC_MINOR__)) \
&& !defined __GNUG__)
# elif ((199901L <= __STDC_VERSION__ \
|| 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \
|| __clang_major__ >= 3) \
&& !defined __cplusplus)
# define _Restrict_arr_ _Restrict_
# else
# define _Restrict_arr_

View file

@ -302,12 +302,11 @@ typedef gl_uint_fast32_t gl_uint_fast16_t;
/* kLIBC's <stdint.h> defines _INTPTR_T_DECLARED and needs its own
definitions of intptr_t and uintptr_t (which use int and unsigned)
to avoid clashes with declarations of system functions like sbrk.
Similarly, mingw 5.22 <crtdefs.h> defines _INTPTR_T_DEFINED and
_UINTPTR_T_DEFINED and needs its own definitions of intptr_t and
Similarly, MinGW WSL-5.4.1 <stdint.h> needs its own intptr_t and
uintptr_t to avoid conflicting declarations of system functions like
_findclose in <io.h>. */
# if !((defined __KLIBC__ && defined _INTPTR_T_DECLARED) \
|| (defined __MINGW32__ && defined _INTPTR_T_DEFINED && defined _UINTPTR_T_DEFINED))
|| defined __MINGW32__)
# undef intptr_t
# undef uintptr_t
# ifdef _WIN64