1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00

Update gnulib to 0.1.5414-8204d and add posix_spawn, posix_spawnp.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Josselin Poiret 2022-09-05 08:48:13 +02:00 committed by Ludovic Courtès
parent fe2a0c54ac
commit edfca3b7e5
531 changed files with 16245 additions and 3306 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
/* A C macro for declaring that a function does not return.
Copyright (C) 2011-2021 Free Software Foundation, Inc.
Copyright (C) 2011-2022 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published

View file

@ -1,6 +1,6 @@
/* accept.c --- wrappers for Windows accept function
Copyright (C) 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2008-2022 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

View file

@ -1,9 +1,9 @@
/* Accept a connection on a socket, with specific opening flags.
Copyright (C) 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2009-2022 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
published by the Free Software Foundation; either version 3 of the
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,

31
lib/access.c Normal file
View file

@ -0,0 +1,31 @@
/* Test the access rights of a file.
Copyright (C) 2019-2022 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
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <unistd.h>
#include <fcntl.h>
#include <io.h>
int
access (const char *file, int mode)
{
if ((mode & X_OK) != 0)
mode = (mode & ~X_OK) | R_OK;
return _access (file, mode);
}

View file

@ -1,5 +1,5 @@
/* Determine alignment of types.
Copyright (C) 2003-2004, 2006, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2003-2004, 2006, 2009-2022 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

View file

@ -30,17 +30,6 @@
#include <string.h>
#include <stdlib.h>
#ifdef emacs
# include "lisp.h"
# include "blockinput.h"
# ifdef EMACS_FREE
# undef free
# define free EMACS_FREE
# endif
#else
# define memory_full() abort ()
#endif
/* If compiling with GCC or clang, this file is not needed. */
#if !(defined __GNUC__ || defined __clang__)
@ -48,22 +37,6 @@
there must be some other way alloca is supposed to work. */
# ifndef alloca
# ifdef emacs
# ifdef static
/* actually, only want this if static is defined as ""
-- this is for usg, in which emacs must undefine static
in order to make unexec workable
*/
# ifndef STACK_DIRECTION
you
lose
-- must know STACK_DIRECTION at compile-time
/* Using #error here is not wise since this file should work for
old and obscure compilers. */
# endif /* STACK_DIRECTION undefined */
# endif /* static */
# endif /* emacs */
/* Define STACK_DIRECTION if you know the direction of stack
growth for your system; otherwise it will be automatically
deduced at run-time.
@ -145,10 +118,6 @@ alloca (size_t size)
{
register header *hp; /* Traverses linked list. */
# ifdef emacs
BLOCK_INPUT;
# endif
for (hp = last_alloca_header; hp != NULL;)
if ((STACK_DIR > 0 && hp->h.deep > depth)
|| (STACK_DIR < 0 && hp->h.deep < depth))
@ -163,10 +132,6 @@ alloca (size_t size)
break; /* Rest are not deeper. */
last_alloca_header = hp; /* -> last valid storage. */
# ifdef emacs
UNBLOCK_INPUT;
# endif
}
if (size == 0)

View file

@ -1,6 +1,6 @@
/* Memory allocation on the stack.
Copyright (C) 1995, 1999, 2001-2004, 2006-2021 Free Software Foundation,
Copyright (C) 1995, 1999, 2001-2004, 2006-2022 Free Software Foundation,
Inc.
This file is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* A C macro for declaring that specific arguments must not be NULL.
Copyright (C) 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2009-2022 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published

View file

@ -1,6 +1,6 @@
/* A GNU-like <arpa/inet.h>.
Copyright (C) 2005-2006, 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2005-2006, 2008-2022 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

View file

@ -1,5 +1,5 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002, 2006, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 1999, 2002, 2006, 2009-2022 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

View file

@ -1,6 +1,6 @@
/* Run-time assert-like macros.
Copyright (C) 2014-2021 Free Software Foundation, Inc.
Copyright (C) 2014-2022 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

View file

@ -1,6 +1,6 @@
/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers
Copyright 2020-2021 Free Software Foundation, Inc.
Copyright 2020-2022 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
@ -76,6 +76,14 @@
/* Applies to: function, pointer to function, function types. */
#define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args)
/* ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
that can be freed by passing them as the Ith argument to the
function F.
ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
can be freed via 'free'; it can be used only after declaring 'free'. */
/* Applies to: functions. Cannot be used on inline functions. */
#define ATTRIBUTE_DEALLOC(f, i) _GL_ATTRIBUTE_DEALLOC(f, i)
#define ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC_FREE
/* Attributes for variadic functions. */

View file

@ -1,6 +1,6 @@
/* basename.c -- return the last element in a file name
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2021 Free Software
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* Extract the last component (base name) of a file name.
Copyright (C) 1998, 2001, 2003-2006, 2009-2021 Free Software Foundation,
Copyright (C) 1998, 2001, 2003-2006, 2009-2022 Free Software Foundation,
Inc.
This file is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* Binary mode I/O.
Copyright 2017-2021 Free Software Foundation, Inc.
Copyright 2017-2022 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

View file

@ -1,5 +1,5 @@
/* Binary mode I/O.
Copyright (C) 2001, 2003, 2005, 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2001, 2003, 2005, 2008-2022 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
@ -47,7 +47,7 @@ _GL_INLINE_HEADER_BEGIN
/* Use a function rather than a macro, to avoid gcc warnings
"warning: statement with no effect". */
BINARY_IO_INLINE int
__gl_setmode (int fd _GL_UNUSED, int mode _GL_UNUSED)
__gl_setmode (_GL_UNUSED int fd, _GL_UNUSED int mode)
{
return O_BINARY;
}

View file

@ -1,6 +1,6 @@
/* bind.c --- wrappers for Windows bind function
Copyright (C) 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2008-2022 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

View file

@ -1,5 +1,5 @@
/* Convert unibyte character to wide character.
Copyright (C) 2008, 2010-2021 Free Software Foundation, Inc.
Copyright (C) 2008, 2010-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This file is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* byteswap.h - Byte swapping
Copyright (C) 2005, 2007, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2005, 2007, 2009-2022 Free Software Foundation, Inc.
Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005.
This file is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* C++ compatible function declaration macros.
Copyright (C) 2010-2021 Free Software Foundation, Inc.
Copyright (C) 2010-2022 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published

View file

@ -1,6 +1,6 @@
/* Character handling in C locale.
Copyright (C) 2003-2021 Free Software Foundation, Inc.
Copyright (C) 2003-2022 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

View file

@ -5,7 +5,7 @@
<ctype.h> functions' behaviour depends on the current locale set via
setlocale.
Copyright (C) 2000-2003, 2006, 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2000-2003, 2006, 2008-2022 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

View file

@ -1,5 +1,5 @@
/* Case-insensitive string comparison functions in C locale.
Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2021 Free Software
Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* c-strcasecmp.c -- case insensitive string comparator in C locale
Copyright (C) 1998-1999, 2005-2006, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 1998-1999, 2005-2006, 2009-2022 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

View file

@ -1,5 +1,5 @@
/* Optimized case-insensitive string comparison in C locale.
Copyright (C) 2001-2002, 2007, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2001-2002, 2007, 2009-2022 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

View file

@ -1,5 +1,5 @@
/* c-strncasecmp.c -- case insensitive string comparator in C locale
Copyright (C) 1998-1999, 2005-2006, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 1998-1999, 2005-2006, 2009-2022 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

View file

@ -1,5 +1,5 @@
/* Return the canonical absolute name of a given file.
Copyright (C) 1996-2021 Free Software Foundation, Inc.
Copyright (C) 1996-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or

View file

@ -1,4 +1,5 @@
/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
/* Copyright (C) 1992-2022 Free Software Foundation, Inc.
Copyright The GNU Toolchain Authors.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -40,7 +41,9 @@
Similarly for __has_builtin, etc. */
#if (defined __has_attribute \
&& (!defined __clang_minor__ \
|| 3 < __clang_major__ + (5 <= __clang_minor__)))
|| (defined __apple_build_version__ \
? 6000000 <= __apple_build_version__ \
: 3 < __clang_major__ + (5 <= __clang_minor__))))
# define __glibc_has_attribute(attr) __has_attribute (attr)
#else
# define __glibc_has_attribute(attr) 0
@ -142,7 +145,8 @@
#define __bos0(ptr) __builtin_object_size (ptr, 0)
/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
#if __USE_FORTIFY_LEVEL == 3 && __glibc_clang_prereq (9, 0)
#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \
|| __GNUC_PREREQ (12, 0))
# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
#else
@ -150,6 +154,53 @@
# define __glibc_objsize(__o) __bos (__o)
#endif
/* Compile time conditions to choose between the regular, _chk and _chk_warn
variants. These conditions should get evaluated to constant and optimized
away. */
#define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s))
#define __glibc_unsigned_or_positive(__l) \
((__typeof (__l)) 0 < (__typeof (__l)) -1 \
|| (__builtin_constant_p (__l) && (__l) > 0))
/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
condition can be folded to a constant and if it is true, or unknown (-1) */
#define __glibc_safe_or_unknown_len(__l, __s, __osz) \
((__osz) == (__SIZE_TYPE__) -1 \
|| (__glibc_unsigned_or_positive (__l) \
&& __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
(__s), (__osz))) \
&& __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), (__s), (__osz))))
/* Conversely, we know at compile time that the length is unsafe if the
__L * __S <= __OBJSZ condition can be folded to a constant and if it is
false. */
#define __glibc_unsafe_len(__l, __s, __osz) \
(__glibc_unsigned_or_positive (__l) \
&& __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
__s, __osz)) \
&& !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be
declared. */
#define __glibc_fortify(f, __l, __s, __osz, ...) \
(__glibc_safe_or_unknown_len (__l, __s, __osz) \
? __ ## f ## _alias (__VA_ARGS__) \
: (__glibc_unsafe_len (__l, __s, __osz) \
? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \
: __ ## f ## _chk (__VA_ARGS__, __osz))) \
/* Fortify function f, where object size argument passed to f is the number of
elements and not total size. */
#define __glibc_fortify_n(f, __l, __s, __osz, ...) \
(__glibc_safe_or_unknown_len (__l, __s, __osz) \
? __ ## f ## _alias (__VA_ARGS__) \
: (__glibc_unsafe_len (__l, __s, __osz) \
? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \
: __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \
#if __GNUC_PREREQ (4,3)
# define __warnattr(msg) __attribute__((__warning__ (msg)))
# define __errordecl(name, msg) \
@ -243,6 +294,15 @@
# define __attribute_alloc_size__(params) /* Ignore. */
#endif
/* Tell the compiler which argument to an allocation function
indicates the alignment of the allocation. */
#if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__alloc_align__)
# define __attribute_alloc_align__(param) \
__attribute__ ((__alloc_align__ param))
#else
# define __attribute_alloc_align__(param) /* Ignore. */
#endif
/* At some point during the gcc 2.96 development the `pure' attribute
for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings. */
@ -605,12 +665,22 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
size-index is not provided:
access (access-mode, <ref-index> [, <size-index>]) */
# define __attr_access(x) __attribute__ ((__access__ x))
/* For _FORTIFY_SOURCE == 3 we use __builtin_dynamic_object_size, which may
use the access attribute to get object sizes from function definition
arguments, so we can't use them on functions we fortify. Drop the object
size hints for such functions. */
# if __USE_FORTIFY_LEVEL == 3
# define __fortified_attr_access(a, o, s) __attribute__ ((__access__ (a, o)))
# else
# define __fortified_attr_access(a, o, s) __attr_access ((a, o, s))
# endif
# if __GNUC_PREREQ (11, 0)
# define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno)))
# else
# define __attr_access_none(argno)
# endif
#else
# define __fortified_attr_access(a, o, s)
# define __attr_access(x)
# define __attr_access_none(argno)
#endif

View file

@ -1,9 +1,9 @@
/* Round towards positive infinity.
Copyright (C) 2007, 2010-2021 Free Software Foundation, Inc.
Copyright (C) 2007, 2010-2022 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
published by the Free Software Foundation; either version 3 of the
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,

View file

@ -1,6 +1,6 @@
/* cloexec.c - set or clear the close-on-exec descriptor flag
Copyright (C) 1991, 2004-2006, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 1991, 2004-2006, 2009-2022 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

View file

@ -1,6 +1,6 @@
/* cloexec.c - set or clear the close-on-exec descriptor flag
Copyright (C) 2004, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2004, 2009-2022 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

View file

@ -1,5 +1,5 @@
/* close replacement.
Copyright (C) 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2008-2022 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

73
lib/concat-filename.c Normal file
View file

@ -0,0 +1,73 @@
/* Construct a full filename from a directory and a relative filename.
Copyright (C) 2001-2004, 2006-2022 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
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <haible@clisp.cons.org>. */
#include <config.h>
/* Specification. */
#include "concat-filename.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "filename.h"
/* Concatenate a directory filename, a relative filename and an optional
suffix. The directory may end with the directory separator. The second
argument may not start with the directory separator (it is relative).
Return a freshly allocated filename. Return NULL and set errno
upon memory allocation failure. */
char *
concatenated_filename (const char *directory, const char *filename,
const char *suffix)
{
char *result;
char *p;
if (strcmp (directory, ".") == 0)
{
/* No need to prepend the directory. */
result = (char *) malloc (strlen (filename)
+ (suffix != NULL ? strlen (suffix) : 0)
+ 1);
if (result == NULL)
return NULL; /* errno is set here */
p = result;
}
else
{
size_t directory_len = strlen (directory);
int need_slash =
(directory_len > FILE_SYSTEM_PREFIX_LEN (directory)
&& !ISSLASH (directory[directory_len - 1]));
result = (char *) malloc (directory_len + need_slash
+ strlen (filename)
+ (suffix != NULL ? strlen (suffix) : 0)
+ 1);
if (result == NULL)
return NULL; /* errno is set here */
memcpy (result, directory, directory_len);
p = result + directory_len;
if (need_slash)
*p++ = '/';
}
p = stpcpy (p, filename);
if (suffix != NULL)
stpcpy (p, suffix);
return result;
}

46
lib/concat-filename.h Normal file
View file

@ -0,0 +1,46 @@
/* Construct a full filename from a directory and a relative filename.
Copyright (C) 2001-2004, 2007-2022 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
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _CONCAT_FILENAME_H
#define _CONCAT_FILENAME_H
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Concatenate a directory filename, a relative filename and an optional
suffix. Return a freshly allocated filename. Return NULL and set errno
upon memory allocation failure. */
extern char *concatenated_filename (const char *directory,
const char *filename, const char *suffix)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
/* Concatenate a directory filename, a relative filename and an optional
suffix. Return a freshly allocated filename. */
extern char *xconcatenated_filename (const char *directory,
const char *filename, const char *suffix)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
_GL_ATTRIBUTE_RETURNS_NONNULL;
#ifdef __cplusplus
}
#endif
#endif /* _CONCAT_FILENAME_H */

View file

@ -1,6 +1,6 @@
/* connect.c --- wrappers for Windows connect function
Copyright (C) 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2008-2022 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

View file

@ -1,9 +1,9 @@
/* Copy sign into another 'double' number.
Copyright (C) 2011-2021 Free Software Foundation, Inc.
Copyright (C) 2011-2022 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
published by the Free Software Foundation; either version 3 of the
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,

View file

@ -1,5 +1,5 @@
/* A GNU-like <dirent.h>.
Copyright (C) 2006-2021 Free Software Foundation, Inc.
Copyright (C) 2006-2022 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
@ -55,6 +55,28 @@ typedef struct gl_directory DIR;
# endif
#endif
/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
that can be freed by passing them as the Ith argument to the
function F. */
#ifndef _GL_ATTRIBUTE_DEALLOC
# if __GNUC__ >= 11
# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
# else
# define _GL_ATTRIBUTE_DEALLOC(f, i)
# endif
#endif
/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
allocated memory. */
/* Applies to: functions. */
#ifndef _GL_ATTRIBUTE_MALLOC
# if __GNUC__ >= 3 || defined __clang__
# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
# else
# define _GL_ATTRIBUTE_MALLOC
# endif
#endif
/* The __attribute__ feature is available in gcc versions 2.5 and later.
The attribute __pure__ was added in gcc 2.96. */
#ifndef _GL_ATTRIBUTE_PURE

View file

@ -1,6 +1,6 @@
/* dirfd.c -- return the file descriptor associated with an open DIR*
Copyright (C) 2001, 2006, 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2001, 2006, 2008-2022 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

View file

@ -1,6 +1,6 @@
/* dirname.c -- return all but the last element in a file name
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2021 Free Software
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* Take file names apart into directory and base names.
Copyright (C) 1998, 2001, 2003-2006, 2009-2021 Free Software Foundation,
Copyright (C) 1998, 2001, 2003-2006, 2009-2022 Free Software Foundation,
Inc.
This file is free software: you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* Duplicate an open file descriptor to a specified file descriptor.
Copyright (C) 1999, 2004-2007, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 1999, 2004-2007, 2009-2022 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

View file

@ -1,9 +1,9 @@
/* Duplicate a locale object.
Copyright (C) 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2009-2022 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
published by the Free Software Foundation; either version 3 of the
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,

View file

@ -1,5 +1,5 @@
/* Type-safe arrays which grow dynamically.
Copyright 2021 Free Software Foundation, Inc.
Copyright 2021-2022 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

View file

@ -1,5 +1,5 @@
/* Threshold at which to diagnose ELOOP. Generic version.
Copyright (C) 2012-2021 Free Software Foundation, Inc.
Copyright (C) 2012-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or

View file

@ -1,6 +1,6 @@
/* A POSIX-like <errno.h>.
Copyright (C) 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2008-2022 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

View file

@ -1,6 +1,6 @@
/* Provide file descriptor control.
Copyright (C) 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2009-2022 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

View file

@ -1,6 +1,6 @@
/* Like <fcntl.h>, but with non-working flags defined to 0.
Copyright (C) 2006-2021 Free Software Foundation, Inc.
Copyright (C) 2006-2022 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
@ -435,6 +435,10 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
# define AT_EACCESS 4
#endif
/* Ignore this flag if not supported. */
#ifndef AT_NO_AUTOMOUNT
# define AT_NO_AUTOMOUNT 0
#endif
#endif /* _@GUARD_PREFIX@_FCNTL_H */
#endif /* _@GUARD_PREFIX@_FCNTL_H */

View file

@ -1,5 +1,5 @@
/* Hook for making file descriptor functions close(), ioctl() extensible.
Copyright (C) 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2009-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This file is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* Hook for making file descriptor functions close(), ioctl() extensible.
Copyright (C) 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2009-2022 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

View file

@ -1,5 +1,5 @@
/* Basic filename support macros.
Copyright (C) 2001-2004, 2007-2021 Free Software Foundation, Inc.
Copyright (C) 2001-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or

399
lib/findprog-in.c Normal file
View file

@ -0,0 +1,399 @@
/* Locating a program in a given path.
Copyright (C) 2001-2004, 2006-2022 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001, 2019.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include "findprog.h"
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include "filename.h"
#include "concat-filename.h"
#if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
/* Native Windows, OS/2, DOS */
# define NATIVE_SLASH '\\'
#else
/* Unix */
# define NATIVE_SLASH '/'
#endif
/* Separator in PATH like lists of pathnames. */
#if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
/* Native Windows, OS/2, DOS */
# define PATH_SEPARATOR ';'
#else
/* Unix */
# define PATH_SEPARATOR ':'
#endif
/* The list of suffixes that the execlp/execvp function tries when searching
for the program. */
static const char * const suffixes[] =
{
#if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
"", ".com", ".exe", ".bat", ".cmd"
/* Note: Files without any suffix are not considered executable. */
/* Note: The cmd.exe program does a different lookup: It searches according
to the PATHEXT environment variable.
See <https://stackoverflow.com/questions/7839150/>.
Also, it executes files ending in .bat and .cmd directly without letting
the kernel interpret the program file. */
#elif defined __CYGWIN__
"", ".exe", ".com"
#elif defined __EMX__
"", ".exe"
#elif defined __DJGPP__
"", ".com", ".exe", ".bat"
#else /* Unix */
""
#endif
};
const char *
find_in_given_path (const char *progname, const char *path,
const char *directory, bool optimize_for_exec)
{
{
bool has_slash = false;
{
const char *p;
for (p = progname; *p != '\0'; p++)
if (ISSLASH (*p))
{
has_slash = true;
break;
}
}
if (has_slash)
{
/* If progname contains a slash, it is either absolute or relative to
the current directory. PATH is not used. */
if (optimize_for_exec)
/* The execl/execv/execlp/execvp functions will try the various
suffixes anyway and fail if no executable is found. */
return progname;
else
{
/* Try the various suffixes and see whether one of the files
with such a suffix is actually executable. */
int failure_errno;
size_t i;
const char *directory_as_prefix =
(directory != NULL && IS_RELATIVE_FILE_NAME (progname)
? directory
: "");
#if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
const char *progbasename;
{
const char *p;
progbasename = progname;
for (p = progname; *p != '\0'; p++)
if (ISSLASH (*p))
progbasename = p + 1;
}
bool progbasename_has_dot = (strchr (progbasename, '.') != NULL);
#endif
/* Try all platform-dependent suffixes. */
failure_errno = ENOENT;
for (i = 0; i < sizeof (suffixes) / sizeof (suffixes[0]); i++)
{
const char *suffix = suffixes[i];
#if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
/* File names without a '.' are not considered executable, and
for file names with a '.' no additional suffix is tried. */
if ((*suffix != '\0') != progbasename_has_dot)
#endif
{
/* Concatenate directory_as_prefix, progname, suffix. */
char *progpathname =
concatenated_filename (directory_as_prefix, progname,
suffix);
if (progpathname == NULL)
return NULL; /* errno is set here */
/* On systems which have the eaccess() system call, let's
use it. On other systems, let's hope that this program
is not installed setuid or setgid, so that it is ok to
call access() despite its design flaw. */
if (eaccess (progpathname, X_OK) == 0)
{
/* Check that the progpathname does not point to a
directory. */
struct stat statbuf;
if (stat (progpathname, &statbuf) >= 0)
{
if (! S_ISDIR (statbuf.st_mode))
{
/* Found! */
if (strcmp (progpathname, progname) == 0)
{
free (progpathname);
return progname;
}
else
return progpathname;
}
errno = EACCES;
}
}
if (errno != ENOENT)
failure_errno = errno;
free (progpathname);
}
}
#if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
if (failure_errno == ENOENT && !progbasename_has_dot)
{
/* In the loop above, we skipped suffix = "". Do this loop
round now, merely to provide a better errno than ENOENT. */
char *progpathname =
concatenated_filename (directory_as_prefix, progname, "");
if (progpathname == NULL)
return NULL; /* errno is set here */
if (eaccess (progpathname, X_OK) == 0)
{
struct stat statbuf;
if (stat (progpathname, &statbuf) >= 0)
{
if (! S_ISDIR (statbuf.st_mode))
errno = ENOEXEC;
else
errno = EACCES;
}
}
failure_errno = errno;
free (progpathname);
}
#endif
errno = failure_errno;
return NULL;
}
}
}
if (path == NULL)
/* If PATH is not set, the default search path is implementation dependent.
In practice, it is treated like an empty PATH. */
path = "";
{
/* Make a copy, to prepare for destructive modifications. */
char *path_copy = strdup (path);
if (path_copy == NULL)
return NULL; /* errno is set here */
int failure_errno;
char *path_rest;
char *cp;
#if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
bool progname_has_dot = (strchr (progname, '.') != NULL);
#endif
failure_errno = ENOENT;
for (path_rest = path_copy; ; path_rest = cp + 1)
{
const char *dir;
bool last;
char *dir_as_prefix_to_free;
const char *dir_as_prefix;
size_t i;
/* Extract next directory in PATH. */
dir = path_rest;
for (cp = path_rest; *cp != '\0' && *cp != PATH_SEPARATOR; cp++)
;
last = (*cp == '\0');
*cp = '\0';
/* Empty PATH components designate the current directory. */
if (dir == cp)
dir = ".";
/* Concatenate directory and dir. */
if (directory != NULL && IS_RELATIVE_FILE_NAME (dir))
{
dir_as_prefix_to_free =
concatenated_filename (directory, dir, NULL);
if (dir_as_prefix_to_free == NULL)
{
/* errno is set here. */
failure_errno = errno;
goto failed;
}
dir_as_prefix = dir_as_prefix_to_free;
}
else
{
dir_as_prefix_to_free = NULL;
dir_as_prefix = dir;
}
/* Try all platform-dependent suffixes. */
for (i = 0; i < sizeof (suffixes) / sizeof (suffixes[0]); i++)
{
const char *suffix = suffixes[i];
#if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
/* File names without a '.' are not considered executable, and
for file names with a '.' no additional suffix is tried. */
if ((*suffix != '\0') != progname_has_dot)
#endif
{
/* Concatenate dir_as_prefix, progname, and suffix. */
char *progpathname =
concatenated_filename (dir_as_prefix, progname, suffix);
if (progpathname == NULL)
{
/* errno is set here. */
failure_errno = errno;
free (dir_as_prefix_to_free);
goto failed;
}
/* On systems which have the eaccess() system call, let's
use it. On other systems, let's hope that this program
is not installed setuid or setgid, so that it is ok to
call access() despite its design flaw. */
if (eaccess (progpathname, X_OK) == 0)
{
/* Check that the progpathname does not point to a
directory. */
struct stat statbuf;
if (stat (progpathname, &statbuf) >= 0)
{
if (! S_ISDIR (statbuf.st_mode))
{
/* Found! */
if (strcmp (progpathname, progname) == 0)
{
free (progpathname);
/* Add the "./" prefix for real, that
concatenated_filename() optimized away.
This avoids a second PATH search when the
caller uses execl/execv/execlp/execvp. */
progpathname =
(char *) malloc (2 + strlen (progname) + 1);
if (progpathname == NULL)
{
/* errno is set here. */
failure_errno = errno;
free (dir_as_prefix_to_free);
goto failed;
}
progpathname[0] = '.';
progpathname[1] = NATIVE_SLASH;
memcpy (progpathname + 2, progname,
strlen (progname) + 1);
}
free (dir_as_prefix_to_free);
free (path_copy);
return progpathname;
}
errno = EACCES;
}
}
if (errno != ENOENT)
failure_errno = errno;
free (progpathname);
}
}
#if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
if (failure_errno == ENOENT && !progname_has_dot)
{
/* In the loop above, we skipped suffix = "". Do this loop
round now, merely to provide a better errno than ENOENT. */
char *progpathname =
concatenated_filename (dir_as_prefix, progname, "");
if (progpathname == NULL)
{
/* errno is set here. */
failure_errno = errno;
free (dir_as_prefix_to_free);
goto failed;
}
if (eaccess (progpathname, X_OK) == 0)
{
struct stat statbuf;
if (stat (progpathname, &statbuf) >= 0)
{
if (! S_ISDIR (statbuf.st_mode))
errno = ENOEXEC;
else
errno = EACCES;
}
}
failure_errno = errno;
free (progpathname);
}
#endif
free (dir_as_prefix_to_free);
if (last)
break;
}
failed:
/* Not found in PATH. */
free (path_copy);
errno = failure_errno;
return NULL;
}
}

77
lib/findprog.h Normal file
View file

@ -0,0 +1,77 @@
/* Locating a program in PATH.
Copyright (C) 2001-2003, 2009-2022 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _FINDPROG_H
#define _FINDPROG_H
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Looks up a program in the PATH.
Attempts to determine the pathname that would be called by execlp/execvp
of PROGNAME. If successful, it returns a pathname containing a slash
(either absolute or relative to the current directory). Otherwise, it
returns PROGNAME unmodified.
Because of the latter case, callers should use execlp/execvp, not
execl/execv on the returned pathname.
The returned string is freshly malloc()ed if it is != PROGNAME. */
extern const char *find_in_path (const char *progname);
/* Looks up a program in the given PATH-like string.
The PATH argument consists of a list of directories, separated by ':' or
(on native Windows) by ';'. An empty PATH element designates the current
directory. A null PATH is equivalent to an empty PATH, that is, to the
singleton list that contains only the current directory.
If DIRECTORY is not NULL, all relative filenames (i.e. PROGNAME when it
contains a slash, and the PATH elements) are considered relative to
DIRECTORY instead of relative to the current directory of this process.
Determines the pathname that would be called by execlp/execvp of PROGNAME.
- If successful, it returns a pathname containing a slash (either absolute
or relative to the current directory). The returned string can be used
with either execl/execv or execlp/execvp. It is freshly malloc()ed if it
is != PROGNAME.
- Otherwise, it sets errno and returns NULL.
Specific errno values include:
- ENOENT: means that the program's file was not found.
- EACCES: means that the program's file cannot be accessed (due to some
issue with one of the ancestor directories) or lacks the execute
permissions.
- ENOMEM: means out of memory.
If OPTIMIZE_FOR_EXEC is true, the function saves some work, under the
assumption that the resulting pathname will not be accessed directly,
only through execl/execv or execlp/execvp.
Here, a "slash" means:
- On POSIX systems excluding Cygwin: a '/',
- On Windows, OS/2, DOS platforms: a '/' or '\'. */
extern const char *find_in_given_path (const char *progname, const char *path,
const char *directory,
bool optimize_for_exec);
#ifdef __cplusplus
}
#endif
#endif /* _FINDPROG_H */

View file

@ -1,6 +1,6 @@
/* Sizes of structs with flexible array members.
Copyright 2016-2021 Free Software Foundation, Inc.
Copyright 2016-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.

View file

@ -1,5 +1,5 @@
/* Supplemental information about the floating-point formats.
Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2007.
This file is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* Auxiliary definitions for <float.h>.
Copyright (C) 2011-2021 Free Software Foundation, Inc.
Copyright (C) 2011-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This file is free software: you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* A correct <float.h>.
Copyright (C) 2007-2021 Free Software Foundation, Inc.
Copyright (C) 2007-2022 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

View file

@ -6,7 +6,7 @@
Written by Richard W.M. Jones <rjones.at.redhat.com>
Copyright (C) 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2008-2022 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public

View file

@ -1,9 +1,9 @@
/* Round towards negative infinity.
Copyright (C) 2007, 2010-2021 Free Software Foundation, Inc.
Copyright (C) 2007, 2010-2022 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
published by the Free Software Foundation; either version 3 of the
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,

View file

@ -1,6 +1,6 @@
/* Make free() preserve errno.
Copyright (C) 2003, 2006, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2003, 2006, 2009-2022 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

View file

@ -1,5 +1,5 @@
/* Split a double into fraction and mantissa.
Copyright (C) 2007-2021 Free Software Foundation, Inc.
Copyright (C) 2007-2022 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

View file

@ -1,5 +1,5 @@
/* fstat() replacement.
Copyright (C) 2011-2021 Free Software Foundation, Inc.
Copyright (C) 2011-2022 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

View file

@ -7,7 +7,7 @@
Written by Richard W.M. Jones <rjones.at.redhat.com>
Copyright (C) 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2008-2022 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

View file

@ -1,5 +1,5 @@
/* An interface to read that retries after partial reads and interrupts.
Copyright (C) 2002-2003, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2002-2003, 2009-2022 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

View file

@ -1,6 +1,6 @@
/* An interface to read() that reads all it is asked to read.
Copyright (C) 2002, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2002, 2009-2022 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

View file

@ -1,6 +1,6 @@
/* An interface to read and write that retries (if necessary) until complete.
Copyright (C) 1993-1994, 1997-2006, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 1993-1994, 1997-2006, 2009-2022 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

View file

@ -1,6 +1,6 @@
/* An interface to write() that writes all it is asked to write.
Copyright (C) 2002-2003, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2002-2003, 2009-2022 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

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2021 Free Software
/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2022 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.

View file

@ -1,5 +1,5 @@
/* Get address information (partial implementation).
Copyright (C) 1997, 2001-2002, 2004-2021 Free Software Foundation, Inc.
Copyright (C) 1997, 2001-2002, 2004-2022 Free Software Foundation, Inc.
Contributed by Simon Josefsson <simon@josefsson.org>.
This file is free software: you can redistribute it and/or modify

View file

@ -1,5 +1,5 @@
/* getdtablesize() function: Return maximum possible file descriptor value + 1.
Copyright (C) 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2008-2022 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This file is free software: you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* Provide a working getlogin for systems which lack it.
Copyright (C) 2010-2021 Free Software Foundation, Inc.
Copyright (C) 2010-2022 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

View file

@ -1,6 +1,6 @@
/* getpeername.c --- wrappers for Windows getpeername function
Copyright (C) 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2008-2022 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

View file

@ -1,6 +1,6 @@
/* Obtain a series of random bytes.
Copyright 2020-2021 Free Software Foundation, Inc.
Copyright 2020-2022 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

View file

@ -1,6 +1,6 @@
/* getsockname.c --- wrappers for Windows getsockname function
Copyright (C) 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2008-2022 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

View file

@ -1,6 +1,6 @@
/* getsockopt.c --- wrappers for Windows getsockopt function
Copyright (C) 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2008-2022 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

View file

@ -1,5 +1,5 @@
/* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2021 Free Software
Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify
@ -138,7 +138,7 @@
#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
#ifdef __GNUC__
#if defined __GNUC__ || defined __clang__
__inline
#else
#ifdef __cplusplus
@ -157,7 +157,7 @@ pgettext_aux (const char *domain,
return translation;
}
#ifdef __GNUC__
#if defined __GNUC__ || defined __clang__
__inline
#else
#ifdef __cplusplus
@ -191,9 +191,8 @@ npgettext_aux (const char *domain,
or may have security implications due to non-deterministic stack usage. */
#if (!defined GNULIB_NO_VLA \
&& (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
/* || (__STDC_VERSION__ == 199901L && !defined __HP_cc)
|| (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ ))
&& defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \
&& !defined __STDC_NO_VLA__)
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
#else
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
@ -208,7 +207,7 @@ npgettext_aux (const char *domain,
#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
#ifdef __GNUC__
#if defined __GNUC__ || defined __clang__
__inline
#else
#ifdef __cplusplus
@ -255,7 +254,7 @@ dcpgettext_expr (const char *domain,
#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
#ifdef __GNUC__
#if defined __GNUC__ || defined __clang__
__inline
#else
#ifdef __cplusplus

View file

@ -1,6 +1,6 @@
/* hard-locale.c -- Determine whether a locale is hard.
Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2021 Free Software
Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2022 Free Software
Foundation, Inc.
This file is free software: you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* Determine whether a locale is hard.
Copyright (C) 1999, 2003-2004, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 1999, 2003-2004, 2009-2022 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

View file

@ -1,5 +1,5 @@
/* Character set conversion.
Copyright (C) 1999-2001, 2007, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 1999-2001, 2007, 2009-2022 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

View file

@ -1,6 +1,6 @@
/* A GNU-like <iconv.h>.
Copyright (C) 2007-2021 Free Software Foundation, Inc.
Copyright (C) 2007-2022 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

View file

@ -1,5 +1,5 @@
/* Character set conversion.
Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2007, 2009-2022 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

View file

@ -1,5 +1,5 @@
/* Character set conversion.
Copyright (C) 2007, 2020-2021 Free Software Foundation, Inc.
Copyright (C) 2007, 2020-2022 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

View file

@ -1,5 +1,5 @@
/* Character set conversion.
Copyright (C) 2007, 2020-2021 Free Software Foundation, Inc.
Copyright (C) 2007, 2020-2022 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

View file

@ -1,5 +1,5 @@
/* Character set conversion.
Copyright (C) 2007, 2020-2021 Free Software Foundation, Inc.
Copyright (C) 2007, 2020-2022 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

View file

@ -1,5 +1,5 @@
/* Character set conversion.
Copyright (C) 2007, 2020-2021 Free Software Foundation, Inc.
Copyright (C) 2007, 2020-2022 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

View file

@ -1,5 +1,5 @@
/* Character set conversion.
Copyright (C) 2007, 2009, 2020-2021 Free Software Foundation, Inc.
Copyright (C) 2007, 2009, 2020-2022 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

View file

@ -1,5 +1,5 @@
/* Character set conversion.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Copyright (C) 2019-2022 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

329
lib/iconv_open-zos.h Normal file
View file

@ -0,0 +1,329 @@
/* ANSI-C code produced by gperf version 3.1 */
/* Command-line: gperf -m 10 ./iconv_open-zos.gperf */
/* Computed positions: -k'4,$' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
/* The character set is not based on ISO-646. */
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
#endif
#line 17 "./iconv_open-zos.gperf"
struct mapping { int standard_name; const char vendor_name[10 + 1]; };
#define TOTAL_KEYWORDS 49
#define MIN_WORD_LENGTH 3
#define MAX_WORD_LENGTH 11
#define MIN_HASH_VALUE 3
#define MAX_HASH_VALUE 64
/* maximum key range = 62, duplicates = 0 */
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static unsigned int
mapping_hash (register const char *str, register size_t len)
{
static const unsigned char asso_values[] =
{
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 16, 38,
14, 1, 32, 22, 29, 3, 0, 7, 40, 2,
5, 18, 23, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 0, 65, 0, 65, 65, 65, 0,
43, 65, 1, 65, 65, 8, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
65, 65
};
register unsigned int hval = len;
switch (hval)
{
default:
hval += asso_values[(unsigned char)str[3]+6];
/*FALLTHROUGH*/
case 3:
break;
}
return hval + asso_values[(unsigned char)str[len - 1]];
}
struct stringpool_t
{
char stringpool_str3[sizeof("GBK")];
char stringpool_str5[sizeof("ASCII")];
char stringpool_str7[sizeof("CP1253")];
char stringpool_str8[sizeof("EUC-KR")];
char stringpool_str9[sizeof("CP1257")];
char stringpool_str10[sizeof("CP857")];
char stringpool_str11[sizeof("ISO-8859-8")];
char stringpool_str12[sizeof("ISO-8859-3")];
char stringpool_str13[sizeof("ISO-8859-13")];
char stringpool_str14[sizeof("ISO-8859-7")];
char stringpool_str15[sizeof("CP437")];
char stringpool_str16[sizeof("CP1129")];
char stringpool_str17[sizeof("CP869")];
char stringpool_str18[sizeof("ISO-8859-9")];
char stringpool_str19[sizeof("CP922")];
char stringpool_str20[sizeof("CP1252")];
char stringpool_str21[sizeof("CP852")];
char stringpool_str22[sizeof("CP1250")];
char stringpool_str23[sizeof("CP850")];
char stringpool_str24[sizeof("CP862")];
char stringpool_str25[sizeof("ISO-8859-2")];
char stringpool_str26[sizeof("CP932")];
char stringpool_str27[sizeof("GB2312")];
char stringpool_str28[sizeof("CP1255")];
char stringpool_str29[sizeof("CP855")];
char stringpool_str30[sizeof("KOI8-R")];
char stringpool_str31[sizeof("CP1125")];
char stringpool_str32[sizeof("CP865")];
char stringpool_str33[sizeof("ISO-8859-5")];
char stringpool_str34[sizeof("ISO-8859-15")];
char stringpool_str35[sizeof("CP1256")];
char stringpool_str36[sizeof("CP856")];
char stringpool_str37[sizeof("KOI8-U")];
char stringpool_str38[sizeof("CP1254")];
char stringpool_str39[sizeof("CP866")];
char stringpool_str40[sizeof("ISO-8859-6")];
char stringpool_str41[sizeof("CP1124")];
char stringpool_str42[sizeof("CP864")];
char stringpool_str43[sizeof("ISO-8859-4")];
char stringpool_str44[sizeof("CP1251")];
char stringpool_str45[sizeof("CP775")];
char stringpool_str46[sizeof("CP943")];
char stringpool_str47[sizeof("CP1131")];
char stringpool_str48[sizeof("CP861")];
char stringpool_str49[sizeof("ISO-8859-1")];
char stringpool_str50[sizeof("EUC-JP")];
char stringpool_str52[sizeof("CP949")];
char stringpool_str55[sizeof("CP874")];
char stringpool_str64[sizeof("CP1046")];
};
static const struct stringpool_t stringpool_contents =
{
"GBK",
"ASCII",
"CP1253",
"EUC-KR",
"CP1257",
"CP857",
"ISO-8859-8",
"ISO-8859-3",
"ISO-8859-13",
"ISO-8859-7",
"CP437",
"CP1129",
"CP869",
"ISO-8859-9",
"CP922",
"CP1252",
"CP852",
"CP1250",
"CP850",
"CP862",
"ISO-8859-2",
"CP932",
"GB2312",
"CP1255",
"CP855",
"KOI8-R",
"CP1125",
"CP865",
"ISO-8859-5",
"ISO-8859-15",
"CP1256",
"CP856",
"KOI8-U",
"CP1254",
"CP866",
"ISO-8859-6",
"CP1124",
"CP864",
"ISO-8859-4",
"CP1251",
"CP775",
"CP943",
"CP1131",
"CP861",
"ISO-8859-1",
"EUC-JP",
"CP949",
"CP874",
"CP1046"
};
#define stringpool ((const char *) &stringpool_contents)
static const struct mapping mappings[] =
{
{-1}, {-1}, {-1},
#line 76 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str3, "IBM-1386"},
{-1},
#line 28 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str5, "00367"},
{-1},
#line 68 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str7, "IBM-5349"},
#line 75 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str8, "IBM-eucKR"},
#line 72 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str9, "09449"},
#line 48 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str10, "00857"},
#line 36 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str11, "05012"},
#line 31 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str12, "00913"},
#line 38 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str13, "ISO8859-13"},
#line 35 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str14, "ISO8859-7"},
#line 42 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str15, "IBM-437"},
#line 63 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str16, "01129"},
#line 54 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str17, "IBM-869"},
#line 37 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str18, "ISO8859-9"},
#line 56 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str19, "IBM-922"},
#line 67 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str20, "IBM-5348"},
#line 45 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str21, "IBM-852"},
#line 65 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str22, "IBM-5346"},
#line 44 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str23, "09042"},
#line 50 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str24, "IBM-862"},
#line 30 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str25, "ISO8859-2"},
#line 57 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str26, "IBM-943"},
#line 73 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str27, "IBM-eucCN"},
#line 70 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str28, "09447"},
#line 46 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str29, "13143"},
#line 40 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str30, "00878"},
#line 62 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str31, "IBM-1125"},
#line 52 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str32, "00865"},
#line 33 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str33, "ISO8859-5"},
#line 39 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str34, "ISO8859-15"},
#line 71 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str35, "09448"},
#line 47 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str36, "IBM-856"},
#line 41 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str37, "01168"},
#line 69 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str38, "IBM-5350"},
#line 53 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str39, "04962"},
#line 34 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str40, "ISO8859-6"},
#line 61 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str41, "IBM-1124"},
#line 51 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str42, "IBM-864"},
#line 32 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str43, "ISO8859-4"},
#line 66 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str44, "IBM-5347"},
#line 43 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str45, "00775"},
#line 58 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str46, "IBM-943"},
#line 64 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str47, "01131"},
#line 49 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str48, "IBM-861"},
#line 29 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str49, "ISO8859-1"},
#line 74 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str50, "01350"},
{-1},
#line 59 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str52, "IBM-1363"},
{-1}, {-1},
#line 55 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str55, "TIS-620"},
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
#line 60 "./iconv_open-zos.gperf"
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str64, "IBM-1046"}
};
const struct mapping *
mapping_lookup (register const char *str, register size_t len)
{
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register unsigned int key = mapping_hash (str, len);
if (key <= MAX_HASH_VALUE)
{
register int o = mappings[key].standard_name;
if (o >= 0)
{
register const char *s = o + stringpool;
if (*str == *s && !strcmp (str + 1, s + 1))
return &mappings[key];
}
}
}
return 0;
}

View file

@ -1,5 +1,5 @@
/* Character set conversion.
Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2007, 2009-2022 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

View file

@ -1,5 +1,5 @@
/* Character set conversion handler type.
Copyright (C) 2001-2007, 2009-2021 Free Software Foundation, Inc.
Copyright (C) 2001-2007, 2009-2022 Free Software Foundation, Inc.
Written by Bruno Haible.
This file is free software: you can redistribute it and/or modify
@ -29,7 +29,10 @@ enum iconv_ilseq_handler
{
iconveh_error, /* return and set errno = EILSEQ */
iconveh_question_mark, /* use one '?' per unconvertible character */
iconveh_escape_sequence /* use escape sequence \uxxxx or \Uxxxxxxxx */
iconveh_escape_sequence, /* use escape sequence \uxxxx or \Uxxxxxxxx */
iconveh_replacement_character /* use one U+FFFD per unconvertible character
if that fits in the target encoding,
otherwise one '?' */
};

View file

@ -1,5 +1,5 @@
/* A type for indices and sizes.
Copyright (C) 2020-2021 Free Software Foundation, Inc.
Copyright (C) 2020-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -56,6 +56,26 @@
* Because 'size_t' is an unsigned type, and a signed type is better.
See above.
Why not use 'ssize_t'?
* 'ptrdiff_t' is more portable; it is standardized by ISO C
whereas 'ssize_t' is standardized only by POSIX.
* 'ssize_t' is not required to be as wide as 'size_t', and some
now-obsolete POSIX platforms had 'size_t' wider than 'ssize_t'.
* Conversely, some now-obsolete platforms had 'ptrdiff_t' wider
than 'size_t', which can be a win and conforms to POSIX.
Won't this cause a problem with objects larger than PTRDIFF_MAX?
* Typical modern or large platforms do not allocate such objects,
so this is not much of a problem in practice; for example, you
can safely write 'idx_t len = strlen (s);'. To port to older
small platforms where allocations larger than PTRDIFF_MAX could
in theory be a problem, you can use Gnulib's ialloc module, or
functions like ximalloc in Gnulib's xalloc module.
Why not use 'ptrdiff_t' directly?
* Maintainability: When reading and modifying code, it helps to know that

View file

@ -1,6 +1,6 @@
/* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
Copyright (C) 2005-2006, 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2005-2006, 2008-2022 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

View file

@ -1,6 +1,6 @@
/* inet_pton.c -- convert IPv4 and IPv6 addresses from text to binary form
Copyright (C) 2006, 2008-2021 Free Software Foundation, Inc.
Copyright (C) 2006, 2008-2022 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

392
lib/intprops-internal.h Normal file
View file

@ -0,0 +1,392 @@
/* intprops-internal.h -- properties of integer types not visible to users
Copyright (C) 2001-2022 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_INTPROPS_INTERNAL_H
#define _GL_INTPROPS_INTERNAL_H
#include <limits.h>
/* Return a value with the common real type of E and V and the value of V.
Do not evaluate E. */
#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v))
/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
<https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */
#define _GL_INT_NEGATE_CONVERT(e, v) ((1 ? 0 : (e)) - (v))
/* The extra casts in the following macros work around compiler bugs,
e.g., in Cray C 5.0.3.0. */
/* True if the real type T is signed. */
#define _GL_TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* Return 1 if the real expression E, after promotion, has a
signed or floating type. Do not evaluate E. */
#define _GL_EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
/* Minimum and maximum values for integer types and expressions. */
/* The width in bits of the integer type or expression T.
Do not evaluate T. T must not be a bit-field expression.
Padding bits are not supported; this is checked at compile-time below. */
#define _GL_TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
/* The maximum and minimum values for the type of the expression E,
after integer promotion. E is not evaluated. */
#define _GL_INT_MINIMUM(e) \
(_GL_EXPR_SIGNED (e) \
? ~ _GL_SIGNED_INT_MAXIMUM (e) \
: _GL_INT_CONVERT (e, 0))
#define _GL_INT_MAXIMUM(e) \
(_GL_EXPR_SIGNED (e) \
? _GL_SIGNED_INT_MAXIMUM (e) \
: _GL_INT_NEGATE_CONVERT (e, 1))
#define _GL_SIGNED_INT_MAXIMUM(e) \
(((_GL_INT_CONVERT (e, 1) << (_GL_TYPE_WIDTH (+ (e)) - 2)) - 1) * 2 + 1)
/* Work around OpenVMS incompatibility with C99. */
#if !defined LLONG_MAX && defined __INT64_MAX
# define LLONG_MAX __INT64_MAX
# define LLONG_MIN __INT64_MIN
#endif
/* This include file assumes that signed types are two's complement without
padding bits; the above macros have undefined behavior otherwise.
If this is a problem for you, please let us know how to fix it for your host.
This assumption is tested by the intprops-tests module. */
/* Does the __typeof__ keyword work? This could be done by
'configure', but for now it's easier to do it by hand. */
#if (2 <= __GNUC__ \
|| (4 <= __clang_major__) \
|| (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
|| (0x5110 <= __SUNPRO_C && !__STDC__))
# define _GL_HAVE___TYPEOF__ 1
#else
# define _GL_HAVE___TYPEOF__ 0
#endif
/* Return 1 if the integer type or expression T might be signed. Return 0
if it is definitely unsigned. T must not be a bit-field expression.
This macro does not evaluate its argument, and expands to an
integer constant expression. */
#if _GL_HAVE___TYPEOF__
# define _GL_SIGNED_TYPE_OR_EXPR(t) _GL_TYPE_SIGNED (__typeof__ (t))
#else
# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
#endif
/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
A should not have side effects, and A's type should be an
integer with minimum value MIN and maximum MAX. */
#define _GL_INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
((min) < 0 ? (a) < - (max) : 0 < (a))
/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow
(A, B, P) work when P is non-null. */
#ifdef __EDG__
/* EDG-based compilers like nvc 22.1 cannot add 64-bit signed to unsigned
<https://bugs.gnu.org/53256>. */
# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
#elif defined __has_builtin
# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)
/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x,
see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */
#elif 7 <= __GNUC__
# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
#else
# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
#endif
/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */
#if defined __clang_major__ && __clang_major__ < 14
/* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */
# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0
#else
# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW
#endif
/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
__builtin_sub_overflow_p and __builtin_mul_overflow_p. */
#ifdef __EDG__
/* In EDG-based compilers like ICC 2021.3 and earlier,
__builtin_add_overflow_p etc. are not treated as integral constant
expressions even when all arguments are. */
# define _GL_HAS_BUILTIN_OVERFLOW_P 0
#elif defined __has_builtin
# define _GL_HAS_BUILTIN_OVERFLOW_P __has_builtin (__builtin_mul_overflow_p)
#else
# define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
#endif
#if (!defined _GL_STDCKDINT_H && 202311 <= __STDC_VERSION__ \
&& ! (_GL_HAS_BUILTIN_ADD_OVERFLOW && _GL_HAS_BUILTIN_MUL_OVERFLOW))
# include <stdckdint.h>
#endif
/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
Return 1 if the result overflows. Arguments should not have side
effects and A, B and *R can be of any integer type other than char,
bool, a bit-precise integer type, or an enumeration type. */
#if _GL_HAS_BUILTIN_ADD_OVERFLOW
# define _GL_INT_ADD_WRAPV(a, b, r) __builtin_add_overflow (a, b, r)
# define _GL_INT_SUBTRACT_WRAPV(a, b, r) __builtin_sub_overflow (a, b, r)
#elif defined ckd_add && defined ckd_sub && !defined _GL_STDCKDINT_H
# define _GL_INT_ADD_WRAPV(a, b, r) ckd_add (r, + (a), + (b))
# define _GL_INT_SUBTRACT_WRAPV(a, b, r) ckd_sub (r, + (a), + (b))
#else
# define _GL_INT_ADD_WRAPV(a, b, r) \
_GL_INT_OP_WRAPV (a, b, r, +, _GL_INT_ADD_RANGE_OVERFLOW)
# define _GL_INT_SUBTRACT_WRAPV(a, b, r) \
_GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW)
#endif
#if _GL_HAS_BUILTIN_MUL_OVERFLOW
# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \
|| (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \
&& !defined __EDG__)
# define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r)
# else
/* Work around GCC bug 91450. */
# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \
((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && _GL_EXPR_SIGNED (a) && _GL_EXPR_SIGNED (b) \
&& _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
? ((void) __builtin_mul_overflow (a, b, r), 1) \
: __builtin_mul_overflow (a, b, r))
# endif
#elif defined ckd_mul && !defined _GL_STDCKDINT_H
# define _GL_INT_MULTIPLY_WRAPV(a, b, r) ckd_mul (r, + (a), + (b))
#else
# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \
_GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW)
#endif
/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
https://llvm.org/bugs/show_bug.cgi?id=25390
For now, assume all versions of GCC-like compilers generate bogus
warnings for _Generic. This matters only for compilers that
lack relevant builtins. */
#if __GNUC__ || defined __clang__
# define _GL__GENERIC_BOGUS 1
#else
# define _GL__GENERIC_BOGUS 0
#endif
/* Store the low-order bits of A <op> B into *R, where OP specifies
the operation and OVERFLOW the overflow predicate. Return 1 if the
result overflows. Arguments should not have side effects,
and A, B and *R can be of any integer type other than char, bool, a
bit-precise integer type, or an enumeration type. */
#if 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
(_Generic \
(*(r), \
signed char: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
signed char, SCHAR_MIN, SCHAR_MAX), \
unsigned char: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
unsigned char, 0, UCHAR_MAX), \
short int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
short int, SHRT_MIN, SHRT_MAX), \
unsigned short int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
unsigned short int, 0, USHRT_MAX), \
int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
int, INT_MIN, INT_MAX), \
unsigned int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
unsigned int, 0, UINT_MAX), \
long int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
long int, LONG_MIN, LONG_MAX), \
unsigned long int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
unsigned long int, 0, ULONG_MAX), \
long long int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
long long int, LLONG_MIN, LLONG_MAX), \
unsigned long long int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
unsigned long long int, 0, ULLONG_MAX)))
#else
/* Store the low-order bits of A <op> B into *R, where OP specifies
the operation and OVERFLOW the overflow predicate. If *R is
signed, its type is ST with bounds SMIN..SMAX; otherwise its type
is UT with bounds U..UMAX. ST and UT are narrower than int.
Return 1 if the result overflows. Arguments should not have side
effects, and A, B and *R can be of any integer type other than
char, bool, a bit-precise integer type, or an enumeration type. */
# if _GL_HAVE___TYPEOF__
# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
(_GL_TYPE_SIGNED (__typeof__ (*(r))) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, st, smin, smax) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, ut, 0, umax))
# else
# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
(overflow (a, b, smin, smax) \
? (overflow (a, b, 0, umax) \
? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 1) \
: (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) < 0) \
: (overflow (a, b, 0, umax) \
? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) >= 0 \
: (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 0)))
# endif
# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
(sizeof *(r) == sizeof (signed char) \
? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
signed char, SCHAR_MIN, SCHAR_MAX, \
unsigned char, UCHAR_MAX) \
: sizeof *(r) == sizeof (short int) \
? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
short int, SHRT_MIN, SHRT_MAX, \
unsigned short int, USHRT_MAX) \
: sizeof *(r) == sizeof (int) \
? (_GL_EXPR_SIGNED (*(r)) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
int, INT_MIN, INT_MAX) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
unsigned int, 0, UINT_MAX)) \
: _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
# ifdef LLONG_MAX
# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
(sizeof *(r) == sizeof (long int) \
? (_GL_EXPR_SIGNED (*(r)) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
long int, LONG_MIN, LONG_MAX) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
unsigned long int, 0, ULONG_MAX)) \
: (_GL_EXPR_SIGNED (*(r)) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
long long int, LLONG_MIN, LLONG_MAX) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
unsigned long long int, 0, ULLONG_MAX)))
# else
# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
(_GL_EXPR_SIGNED (*(r)) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
long int, LONG_MIN, LONG_MAX) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
unsigned long int, 0, ULONG_MAX))
# endif
#endif
/* Store the low-order bits of A <op> B into *R, where the operation
is given by OP. Use the unsigned type UT for calculation to avoid
overflow problems. *R's type is T, with extrema TMIN and TMAX.
T can be any signed integer type other than char, bool, a
bit-precise integer type, or an enumeration type.
Return 1 if the result overflows. */
#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
(overflow (a, b, tmin, tmax) \
? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \
: (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0))
/* Return 1 if the integer expressions A - B and -A would overflow,
respectively. Arguments should not have side effects,
and can be any signed integer type other than char, bool, a
bit-precise integer type, or an enumeration type.
These macros are tuned for their last input argument being a constant. */
#if _GL_HAS_BUILTIN_OVERFLOW_P
# define _GL_INT_NEGATE_OVERFLOW(a) \
__builtin_sub_overflow_p (0, a, (__typeof__ (- (a))) 0)
#else
# define _GL_INT_NEGATE_OVERFLOW(a) \
_GL_INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
#endif
/* Return the low-order bits of A <op> B, where the operation is given
by OP. Use the unsigned type UT for calculation to avoid undefined
behavior on signed integer overflow, and convert the result to type T.
UT is at least as wide as T and is no narrower than unsigned int,
T is two's complement, and there is no padding or trap representations.
Assume that converting UT to T yields the low-order bits, as is
done in all known two's-complement C compilers. E.g., see:
https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
According to the C standard, converting UT to T yields an
implementation-defined result or signal for values outside T's
range. However, code that works around this theoretical problem
runs afoul of a compiler bug in Oracle Studio 12.3 x86. See:
https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html
As the compiler bug is real, don't try to work around the
theoretical problem. */
#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \
((t) ((ut) (a) op (ut) (b)))
/* Return true if the numeric values A + B, A - B, A * B fall outside
the range TMIN..TMAX. Arguments should not have side effects
and can be any integer type other than char, bool,
a bit-precise integer type, or an enumeration type.
TMIN should be signed and nonpositive.
TMAX should be positive, and should be signed unless TMIN is zero. */
#define _GL_INT_ADD_RANGE_OVERFLOW(a, b, tmin, tmax) \
((b) < 0 \
? (((tmin) \
? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, (tmin) - (b))) || (b) < (tmin)) \
&& (a) < (tmin) - (b)) \
: (a) <= -1 - (b)) \
|| ((_GL_EXPR_SIGNED (a) ? 0 <= (a) : (tmax) < (a)) && (tmax) < (a) + (b))) \
: (a) < 0 \
? (((tmin) \
? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (b, (tmin) - (a))) || (a) < (tmin)) \
&& (b) < (tmin) - (a)) \
: (b) <= -1 - (a)) \
|| ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, b)) || (tmax) < (b)) \
&& (tmax) < (a) + (b))) \
: (tmax) < (b) || (tmax) - (b) < (a))
#define _GL_INT_SUBTRACT_RANGE_OVERFLOW(a, b, tmin, tmax) \
(((a) < 0) == ((b) < 0) \
? ((a) < (b) \
? !(tmin) || -1 - (tmin) < (b) - (a) - 1 \
: (tmax) < (a) - (b)) \
: (a) < 0 \
? ((!_GL_EXPR_SIGNED (_GL_INT_CONVERT ((a) - (tmin), b)) && (a) - (tmin) < 0) \
|| (a) - (tmin) < (b)) \
: ((! (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
&& _GL_EXPR_SIGNED (_GL_INT_CONVERT ((tmax) + (b), a))) \
&& (tmax) <= -1 - (b)) \
|| (tmax) + (b) < (a)))
#define _GL_INT_MULTIPLY_RANGE_OVERFLOW(a, b, tmin, tmax) \
((b) < 0 \
? ((a) < 0 \
? (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
? (a) < (tmax) / (b) \
: ((_GL_INT_NEGATE_OVERFLOW (b) \
? _GL_INT_CONVERT (b, tmax) >> (_GL_TYPE_WIDTH (+ (b)) - 1) \
: (tmax) / -(b)) \
<= -1 - (a))) \
: _GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (b, tmin)) && (b) == -1 \
? (_GL_EXPR_SIGNED (a) \
? 0 < (a) + (tmin) \
: 0 < (a) && -1 - (tmin) < (a) - 1) \
: (tmin) / (b) < (a)) \
: (b) == 0 \
? 0 \
: ((a) < 0 \
? (_GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (a, tmin)) && (a) == -1 \
? (_GL_EXPR_SIGNED (b) ? 0 < (b) + (tmin) : -1 - (tmin) < (b) - 1) \
: (tmin) / (a) < (b)) \
: (tmax) / (b) < (a)))
#endif /* _GL_INTPROPS_INTERNAL_H */

View file

@ -1,6 +1,6 @@
/* intprops.h -- properties of integer types
Copyright (C) 2001-2021 Free Software Foundation, Inc.
Copyright (C) 2001-2022 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
@ -15,20 +15,10 @@
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
#ifndef _GL_INTPROPS_H
#define _GL_INTPROPS_H
#include <limits.h>
/* Return a value with the common real type of E and V and the value of V.
Do not evaluate E. */
#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v))
/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
<https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */
#define _GL_INT_NEGATE_CONVERT(e, v) ((1 ? 0 : (e)) - (v))
#include "intprops-internal.h"
/* The extra casts in the following macros work around compiler bugs,
e.g., in Cray C 5.0.3.0. */
@ -38,11 +28,11 @@
#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
/* True if the real type T is signed. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
#define TYPE_SIGNED(t) _GL_TYPE_SIGNED (t)
/* Return 1 if the real expression E, after promotion, has a
signed or floating type. Do not evaluate E. */
#define EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
#define EXPR_SIGNED(e) _GL_EXPR_SIGNED (e)
/* Minimum and maximum values for integer types and expressions. */
@ -50,7 +40,7 @@
/* The width in bits of the integer type or expression T.
Do not evaluate T. T must not be a bit-field expression.
Padding bits are not supported; this is checked at compile-time below. */
#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
#define TYPE_WIDTH(t) _GL_TYPE_WIDTH (t)
/* The maximum and minimum values for the integer type T. */
#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
@ -59,51 +49,6 @@
? (t) -1 \
: ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1)))
/* The maximum and minimum values for the type of the expression E,
after integer promotion. E is not evaluated. */
#define _GL_INT_MINIMUM(e) \
(EXPR_SIGNED (e) \
? ~ _GL_SIGNED_INT_MAXIMUM (e) \
: _GL_INT_CONVERT (e, 0))
#define _GL_INT_MAXIMUM(e) \
(EXPR_SIGNED (e) \
? _GL_SIGNED_INT_MAXIMUM (e) \
: _GL_INT_NEGATE_CONVERT (e, 1))
#define _GL_SIGNED_INT_MAXIMUM(e) \
(((_GL_INT_CONVERT (e, 1) << (TYPE_WIDTH (+ (e)) - 2)) - 1) * 2 + 1)
/* Work around OpenVMS incompatibility with C99. */
#if !defined LLONG_MAX && defined __INT64_MAX
# define LLONG_MAX __INT64_MAX
# define LLONG_MIN __INT64_MIN
#endif
/* This include file assumes that signed types are two's complement without
padding bits; the above macros have undefined behavior otherwise.
If this is a problem for you, please let us know how to fix it for your host.
This assumption is tested by the intprops-tests module. */
/* Does the __typeof__ keyword work? This could be done by
'configure', but for now it's easier to do it by hand. */
#if (2 <= __GNUC__ \
|| (4 <= __clang_major__) \
|| (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
|| (0x5110 <= __SUNPRO_C && !__STDC__))
# define _GL_HAVE___TYPEOF__ 1
#else
# define _GL_HAVE___TYPEOF__ 0
#endif
/* Return 1 if the integer type or expression T might be signed. Return 0
if it is definitely unsigned. T must not be a bit-field expression.
This macro does not evaluate its argument, and expands to an
integer constant expression. */
#if _GL_HAVE___TYPEOF__
# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t))
#else
# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
#endif
/* Bound on length of the string representing an unsigned integer
value representable in B bits. log10 (2.0) < 146/485. The
smallest value of B where this bound is not tight is 2621. */
@ -130,12 +75,11 @@
/* Range overflow checks.
The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C
operators might not yield numerically correct answers due to
arithmetic overflow. They do not rely on undefined or
implementation-defined behavior. Their implementations are simple
and straightforward, but they are harder to use and may be less
efficient than the INT_<op>_WRAPV, INT_<op>_OK, and
INT_<op>_OVERFLOW macros described below.
operators overflow arithmetically when given the same arguments.
These macros do not rely on undefined or implementation-defined behavior.
Although their implementations are simple and straightforward,
they are harder to use and may be less efficient than the
INT_<op>_WRAPV, INT_<op>_OK, and INT_<op>_OVERFLOW macros described below.
Example usage:
@ -182,9 +126,7 @@
/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
See above for restrictions. */
#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
((min) < 0 \
? (a) < - (max) \
: 0 < (a))
_GL_INT_NEGATE_RANGE_OVERFLOW (a, min, max)
/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. Avoid && and || as they tickle
@ -228,40 +170,6 @@
? (a) < (min) >> (b) \
: (max) >> (b) < (a))
/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow
(A, B, P) work when P is non-null. */
/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x,
see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */
#if 7 <= __GNUC__ && !defined __ICC
# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
#elif defined __has_builtin
# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)
#else
# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
#endif
/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */
#ifdef __clang__
/* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */
# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0
#else
# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW
#endif
/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
__builtin_sub_overflow_p and __builtin_mul_overflow_p. */
#if defined __clang__ || defined __ICC
/* Clang 11 lacks __builtin_mul_overflow_p, and even if it did it
would presumably run afoul of Clang bug 16404. ICC 2021.1's
__builtin_add_overflow_p etc. are not treated as integral constant
expressions even when all arguments are. */
# define _GL_HAS_BUILTIN_OVERFLOW_P 0
#elif defined __has_builtin
# define _GL_HAS_BUILTIN_OVERFLOW_P __has_builtin (__builtin_mul_overflow_p)
#else
# define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
#endif
/* The _GL*_OVERFLOW macros have the same restrictions as the
*_RANGE_OVERFLOW macros, except that they do not assume that operands
(e.g., A and B) have the same type as MIN and MAX. Instead, they assume
@ -348,13 +256,18 @@
Because the WRAPV macros convert the result, they report overflow
in different circumstances than the OVERFLOW macros do. For
example, in the typical case with 16-bit 'short' and 32-bit 'int',
if A, B and R are all of type 'short' then INT_ADD_OVERFLOW (A, B)
if A, B and *R are all of type 'short' then INT_ADD_OVERFLOW (A, B)
returns false because the addition cannot overflow after A and B
are converted to 'int', whereas INT_ADD_WRAPV (A, B, &R) returns
are converted to 'int', whereas INT_ADD_WRAPV (A, B, R) returns
true or false depending on whether the sum fits into 'short'.
These macros are tuned for their last input argument being a constant.
A, B, and *R should be integers; they need not be the same type,
and they need not be all signed or all unsigned.
However, none of the integer types should be bit-precise,
and *R's type should not be char, bool, or an enumeration type.
Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B,
A % B, and A << B would overflow, respectively. */
@ -362,12 +275,7 @@
_GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
#define INT_SUBTRACT_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
#if _GL_HAS_BUILTIN_OVERFLOW_P
# define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a)
#else
# define INT_NEGATE_OVERFLOW(a) \
INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
#endif
#define INT_NEGATE_OVERFLOW(a) _GL_INT_NEGATE_OVERFLOW (a)
#define INT_MULTIPLY_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
#define INT_DIVIDE_OVERFLOW(a, b) \
@ -389,224 +297,9 @@
/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
Return 1 if the result overflows. See above for restrictions. */
#if _GL_HAS_BUILTIN_ADD_OVERFLOW
# define INT_ADD_WRAPV(a, b, r) __builtin_add_overflow (a, b, r)
# define INT_SUBTRACT_WRAPV(a, b, r) __builtin_sub_overflow (a, b, r)
#else
# define INT_ADD_WRAPV(a, b, r) \
_GL_INT_OP_WRAPV (a, b, r, +, _GL_INT_ADD_RANGE_OVERFLOW)
# define INT_SUBTRACT_WRAPV(a, b, r) \
_GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW)
#endif
#if _GL_HAS_BUILTIN_MUL_OVERFLOW
# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \
|| (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \
&& !defined __ICC)
# define INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r)
# else
/* Work around GCC bug 91450. */
# define INT_MULTIPLY_WRAPV(a, b, r) \
((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && EXPR_SIGNED (a) && EXPR_SIGNED (b) \
&& _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
? ((void) __builtin_mul_overflow (a, b, r), 1) \
: __builtin_mul_overflow (a, b, r))
# endif
#else
# define INT_MULTIPLY_WRAPV(a, b, r) \
_GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW)
#endif
/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
https://llvm.org/bugs/show_bug.cgi?id=25390
For now, assume all versions of GCC-like compilers generate bogus
warnings for _Generic. This matters only for compilers that
lack relevant builtins. */
#if __GNUC__ || defined __clang__
# define _GL__GENERIC_BOGUS 1
#else
# define _GL__GENERIC_BOGUS 0
#endif
/* Store the low-order bits of A <op> B into *R, where OP specifies
the operation and OVERFLOW the overflow predicate. Return 1 if the
result overflows. See above for restrictions. */
#if 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
(_Generic \
(*(r), \
signed char: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
signed char, SCHAR_MIN, SCHAR_MAX), \
unsigned char: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
unsigned char, 0, UCHAR_MAX), \
short int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
short int, SHRT_MIN, SHRT_MAX), \
unsigned short int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
unsigned short int, 0, USHRT_MAX), \
int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
int, INT_MIN, INT_MAX), \
unsigned int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
unsigned int, 0, UINT_MAX), \
long int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
long int, LONG_MIN, LONG_MAX), \
unsigned long int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
unsigned long int, 0, ULONG_MAX), \
long long int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
long long int, LLONG_MIN, LLONG_MAX), \
unsigned long long int: \
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
unsigned long long int, 0, ULLONG_MAX)))
#else
/* Store the low-order bits of A <op> B into *R, where OP specifies
the operation and OVERFLOW the overflow predicate. If *R is
signed, its type is ST with bounds SMIN..SMAX; otherwise its type
is UT with bounds U..UMAX. ST and UT are narrower than int.
Return 1 if the result overflows. See above for restrictions. */
# if _GL_HAVE___TYPEOF__
# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
(TYPE_SIGNED (__typeof__ (*(r))) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, st, smin, smax) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, ut, 0, umax))
# else
# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
(overflow (a, b, smin, smax) \
? (overflow (a, b, 0, umax) \
? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 1) \
: (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) < 0) \
: (overflow (a, b, 0, umax) \
? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) >= 0 \
: (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 0)))
# endif
# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
(sizeof *(r) == sizeof (signed char) \
? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
signed char, SCHAR_MIN, SCHAR_MAX, \
unsigned char, UCHAR_MAX) \
: sizeof *(r) == sizeof (short int) \
? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
short int, SHRT_MIN, SHRT_MAX, \
unsigned short int, USHRT_MAX) \
: sizeof *(r) == sizeof (int) \
? (EXPR_SIGNED (*(r)) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
int, INT_MIN, INT_MAX) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
unsigned int, 0, UINT_MAX)) \
: _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
# ifdef LLONG_MAX
# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
(sizeof *(r) == sizeof (long int) \
? (EXPR_SIGNED (*(r)) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
long int, LONG_MIN, LONG_MAX) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
unsigned long int, 0, ULONG_MAX)) \
: (EXPR_SIGNED (*(r)) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
long long int, LLONG_MIN, LLONG_MAX) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
unsigned long long int, 0, ULLONG_MAX)))
# else
# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
(EXPR_SIGNED (*(r)) \
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
long int, LONG_MIN, LONG_MAX) \
: _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
unsigned long int, 0, ULONG_MAX))
# endif
#endif
/* Store the low-order bits of A <op> B into *R, where the operation
is given by OP. Use the unsigned type UT for calculation to avoid
overflow problems. *R's type is T, with extrema TMIN and TMAX.
T must be a signed integer type. Return 1 if the result overflows. */
#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
(overflow (a, b, tmin, tmax) \
? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \
: (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0))
/* Return the low-order bits of A <op> B, where the operation is given
by OP. Use the unsigned type UT for calculation to avoid undefined
behavior on signed integer overflow, and convert the result to type T.
UT is at least as wide as T and is no narrower than unsigned int,
T is two's complement, and there is no padding or trap representations.
Assume that converting UT to T yields the low-order bits, as is
done in all known two's-complement C compilers. E.g., see:
https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
According to the C standard, converting UT to T yields an
implementation-defined result or signal for values outside T's
range. However, code that works around this theoretical problem
runs afoul of a compiler bug in Oracle Studio 12.3 x86. See:
https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html
As the compiler bug is real, don't try to work around the
theoretical problem. */
#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \
((t) ((ut) (a) op (ut) (b)))
/* Return true if the numeric values A + B, A - B, A * B fall outside
the range TMIN..TMAX. Arguments should be integer expressions
without side effects. TMIN should be signed and nonpositive.
TMAX should be positive, and should be signed unless TMIN is zero. */
#define _GL_INT_ADD_RANGE_OVERFLOW(a, b, tmin, tmax) \
((b) < 0 \
? (((tmin) \
? ((EXPR_SIGNED (_GL_INT_CONVERT (a, (tmin) - (b))) || (b) < (tmin)) \
&& (a) < (tmin) - (b)) \
: (a) <= -1 - (b)) \
|| ((EXPR_SIGNED (a) ? 0 <= (a) : (tmax) < (a)) && (tmax) < (a) + (b))) \
: (a) < 0 \
? (((tmin) \
? ((EXPR_SIGNED (_GL_INT_CONVERT (b, (tmin) - (a))) || (a) < (tmin)) \
&& (b) < (tmin) - (a)) \
: (b) <= -1 - (a)) \
|| ((EXPR_SIGNED (_GL_INT_CONVERT (a, b)) || (tmax) < (b)) \
&& (tmax) < (a) + (b))) \
: (tmax) < (b) || (tmax) - (b) < (a))
#define _GL_INT_SUBTRACT_RANGE_OVERFLOW(a, b, tmin, tmax) \
(((a) < 0) == ((b) < 0) \
? ((a) < (b) \
? !(tmin) || -1 - (tmin) < (b) - (a) - 1 \
: (tmax) < (a) - (b)) \
: (a) < 0 \
? ((!EXPR_SIGNED (_GL_INT_CONVERT ((a) - (tmin), b)) && (a) - (tmin) < 0) \
|| (a) - (tmin) < (b)) \
: ((! (EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
&& EXPR_SIGNED (_GL_INT_CONVERT ((tmax) + (b), a))) \
&& (tmax) <= -1 - (b)) \
|| (tmax) + (b) < (a)))
#define _GL_INT_MULTIPLY_RANGE_OVERFLOW(a, b, tmin, tmax) \
((b) < 0 \
? ((a) < 0 \
? (EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
? (a) < (tmax) / (b) \
: ((INT_NEGATE_OVERFLOW (b) \
? _GL_INT_CONVERT (b, tmax) >> (TYPE_WIDTH (+ (b)) - 1) \
: (tmax) / -(b)) \
<= -1 - (a))) \
: INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (b, tmin)) && (b) == -1 \
? (EXPR_SIGNED (a) \
? 0 < (a) + (tmin) \
: 0 < (a) && -1 - (tmin) < (a) - 1) \
: (tmin) / (b) < (a)) \
: (b) == 0 \
? 0 \
: ((a) < 0 \
? (INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (a, tmin)) && (a) == -1 \
? (EXPR_SIGNED (b) ? 0 < (b) + (tmin) : -1 - (tmin) < (b) - 1) \
: (tmin) / (a) < (b)) \
: (tmax) / (b) < (a)))
#define INT_ADD_WRAPV(a, b, r) _GL_INT_ADD_WRAPV (a, b, r)
#define INT_SUBTRACT_WRAPV(a, b, r) _GL_INT_SUBTRACT_WRAPV (a, b, r)
#define INT_MULTIPLY_WRAPV(a, b, r) _GL_INT_MULTIPLY_WRAPV (a, b, r)
/* The following macros compute A + B, A - B, and A * B, respectively.
If no overflow occurs, they set *R to the result and return 1;
@ -622,6 +315,8 @@
A, B, and *R should be integers; they need not be the same type,
and they need not be all signed or all unsigned.
However, none of the integer types should be bit-precise,
and *R's type should not be char, bool, or an enumeration type.
These macros work correctly on all known practical hosts, and do not rely
on undefined behavior due to signed arithmetic overflow.
@ -633,8 +328,8 @@
These macros are tuned for B being a constant. */
#define INT_ADD_OK(a, b, r) ! INT_ADD_WRAPV (a, b, r)
#define INT_SUBTRACT_OK(a, b, r) ! INT_SUBTRACT_WRAPV (a, b, r)
#define INT_MULTIPLY_OK(a, b, r) ! INT_MULTIPLY_WRAPV (a, b, r)
#define INT_ADD_OK(a, b, r) (! INT_ADD_WRAPV (a, b, r))
#define INT_SUBTRACT_OK(a, b, r) (! INT_SUBTRACT_WRAPV (a, b, r))
#define INT_MULTIPLY_OK(a, b, r) (! INT_MULTIPLY_WRAPV (a, b, r))
#endif /* _GL_INTPROPS_H */

1509
lib/inttypes.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2006-2021 Free Software Foundation, Inc.
/* Copyright (C) 2006-2022 Free Software Foundation, Inc.
Written by Paul Eggert, Bruno Haible, Derek Price.
This file is part of gnulib.

View file

@ -1,9 +1,9 @@
/* Test for finite value (zero, subnormal, or normal, and not infinite or NaN).
Copyright (C) 2007-2021 Free Software Foundation, Inc.
Copyright (C) 2007-2022 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
published by the Free Software Foundation; either version 3 of the
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,

View file

@ -1,9 +1,9 @@
/* Test for positive or negative infinity.
Copyright (C) 2007-2021 Free Software Foundation, Inc.
Copyright (C) 2007-2022 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
published by the Free Software Foundation; either version 3 of the
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,

View file

@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
Copyright (C) 2007-2021 Free Software Foundation, Inc.
Copyright (C) 2007-2022 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

Some files were not shown because too many files have changed in this diff Show more