summaryrefslogtreecommitdiffstats
path: root/contrib/tools/bison/lib
diff options
context:
space:
mode:
authorthegeorg <[email protected]>2024-06-29 21:48:22 +0300
committerthegeorg <[email protected]>2024-06-29 21:59:59 +0300
commitb21e05a2e32e36ae9cc9826acf98084ca4b52d7d (patch)
tree20d654fb0156f50e150944fc8108a3cada8ca6ec /contrib/tools/bison/lib
parent0cf48e974f5542c3e65398c01b9b6baf8aa6c260 (diff)
Update contrib/tools/bison to 3.3.2
6215035f251de2d87363064fb4f07a2b14a3b4c8
Diffstat (limited to 'contrib/tools/bison/lib')
-rw-r--r--contrib/tools/bison/lib/allocator.c5
-rw-r--r--contrib/tools/bison/lib/allocator.h58
-rw-r--r--contrib/tools/bison/lib/areadlink.c56
-rw-r--r--contrib/tools/bison/lib/areadlink.h33
-rw-r--r--contrib/tools/bison/lib/arg-nonnull.h2
-rw-r--r--contrib/tools/bison/lib/argmatch.c2
-rw-r--r--contrib/tools/bison/lib/argmatch.h2
-rw-r--r--contrib/tools/bison/lib/asnprintf.c2
-rw-r--r--contrib/tools/bison/lib/basename-lgpl.c2
-rw-r--r--contrib/tools/bison/lib/basename.c2
-rw-r--r--contrib/tools/bison/lib/binary-io.c2
-rw-r--r--contrib/tools/bison/lib/binary-io.h2
-rw-r--r--contrib/tools/bison/lib/bitrotate.h2
-rw-r--r--contrib/tools/bison/lib/bitset.c31
-rw-r--r--contrib/tools/bison/lib/bitset.h15
-rw-r--r--contrib/tools/bison/lib/bitset/array.c (renamed from contrib/tools/bison/lib/abitset.c)4
-rw-r--r--contrib/tools/bison/lib/bitset/array.h (renamed from contrib/tools/bison/lib/abitset.h)6
-rw-r--r--contrib/tools/bison/lib/bitset/base.h (renamed from contrib/tools/bison/lib/bbitset.h)12
-rw-r--r--contrib/tools/bison/lib/bitset/list.c (renamed from contrib/tools/bison/lib/lbitset.c)4
-rw-r--r--contrib/tools/bison/lib/bitset/list.h (renamed from contrib/tools/bison/lib/lbitset.h)6
-rw-r--r--contrib/tools/bison/lib/bitset/stats.c (renamed from contrib/tools/bison/lib/bitset_stats.c)21
-rw-r--r--contrib/tools/bison/lib/bitset/stats.h (renamed from contrib/tools/bison/lib/bitset_stats.h)5
-rw-r--r--contrib/tools/bison/lib/bitset/table.c (renamed from contrib/tools/bison/lib/ebitset.c)415
-rw-r--r--contrib/tools/bison/lib/bitset/table.h (renamed from contrib/tools/bison/lib/ebitset.h)14
-rw-r--r--contrib/tools/bison/lib/bitset/vector.c (renamed from contrib/tools/bison/lib/vbitset.c)17
-rw-r--r--contrib/tools/bison/lib/bitset/vector.h (renamed from contrib/tools/bison/lib/vbitset.h)6
-rw-r--r--contrib/tools/bison/lib/bitsetv-print.c70
-rw-r--r--contrib/tools/bison/lib/bitsetv-print.h29
-rw-r--r--contrib/tools/bison/lib/bitsetv.c52
-rw-r--r--contrib/tools/bison/lib/bitsetv.h5
-rw-r--r--contrib/tools/bison/lib/c-ctype.h2
-rw-r--r--contrib/tools/bison/lib/c-strcase.h2
-rw-r--r--contrib/tools/bison/lib/c-strcasecmp.c2
-rw-r--r--contrib/tools/bison/lib/c-strcaseeq.h2
-rw-r--r--contrib/tools/bison/lib/c-strncasecmp.c2
-rw-r--r--contrib/tools/bison/lib/careadlinkat.c160
-rw-r--r--contrib/tools/bison/lib/careadlinkat.h67
-rw-r--r--contrib/tools/bison/lib/cloexec.c2
-rw-r--r--contrib/tools/bison/lib/cloexec.h2
-rw-r--r--contrib/tools/bison/lib/close-stream.c2
-rw-r--r--contrib/tools/bison/lib/close.c2
-rw-r--r--contrib/tools/bison/lib/closeout.c2
-rw-r--r--contrib/tools/bison/lib/closeout.h2
-rw-r--r--contrib/tools/bison/lib/concat-filename.c2
-rw-r--r--contrib/tools/bison/lib/concat-filename.h2
-rw-r--r--contrib/tools/bison/lib/config-linux.h129
-rw-r--r--contrib/tools/bison/lib/config-win.h6
-rw-r--r--contrib/tools/bison/lib/configmake-linux.h52
-rw-r--r--contrib/tools/bison/lib/dirname-lgpl.c2
-rw-r--r--contrib/tools/bison/lib/dirname.c2
-rw-r--r--contrib/tools/bison/lib/dirname.h2
-rw-r--r--contrib/tools/bison/lib/dosname.h2
-rw-r--r--contrib/tools/bison/lib/dup-safer-flag.c2
-rw-r--r--contrib/tools/bison/lib/dup-safer.c2
-rw-r--r--contrib/tools/bison/lib/dup2.c2
-rw-r--r--contrib/tools/bison/lib/error.c2
-rw-r--r--contrib/tools/bison/lib/error.h2
-rw-r--r--contrib/tools/bison/lib/exitfail.c2
-rw-r--r--contrib/tools/bison/lib/exitfail.h2
-rw-r--r--contrib/tools/bison/lib/fatal-signal.c2
-rw-r--r--contrib/tools/bison/lib/fatal-signal.h2
-rw-r--r--contrib/tools/bison/lib/fcntl.c4
-rw-r--r--contrib/tools/bison/lib/fd-hook.c2
-rw-r--r--contrib/tools/bison/lib/fd-hook.h2
-rw-r--r--contrib/tools/bison/lib/fd-safer-flag.c2
-rw-r--r--contrib/tools/bison/lib/fd-safer.c2
-rw-r--r--contrib/tools/bison/lib/filename.h2
-rw-r--r--contrib/tools/bison/lib/float+.h2
-rw-r--r--contrib/tools/bison/lib/fopen-safer.c2
-rw-r--r--contrib/tools/bison/lib/fpending.c2
-rw-r--r--contrib/tools/bison/lib/fpending.h2
-rw-r--r--contrib/tools/bison/lib/fpucw.h2
-rw-r--r--contrib/tools/bison/lib/fseterr.c2
-rw-r--r--contrib/tools/bison/lib/fseterr.h2
-rw-r--r--contrib/tools/bison/lib/get-errno.c4
-rw-r--r--contrib/tools/bison/lib/get-errno.h3
-rw-r--r--contrib/tools/bison/lib/getdtablesize.c2
-rw-r--r--contrib/tools/bison/lib/gethrxtime.c2
-rw-r--r--contrib/tools/bison/lib/gethrxtime.h2
-rw-r--r--contrib/tools/bison/lib/getopt.c2
-rw-r--r--contrib/tools/bison/lib/getopt1.c2
-rw-r--r--contrib/tools/bison/lib/getopt_int.h2
-rw-r--r--contrib/tools/bison/lib/getprogname.c2
-rw-r--r--contrib/tools/bison/lib/getprogname.h2
-rw-r--r--contrib/tools/bison/lib/gettext.h15
-rw-r--r--contrib/tools/bison/lib/gl_array_list.c680
-rw-r--r--contrib/tools/bison/lib/gl_array_list.h34
-rw-r--r--contrib/tools/bison/lib/gl_list.c3
-rw-r--r--contrib/tools/bison/lib/gl_list.h843
-rw-r--r--contrib/tools/bison/lib/gl_xlist.c3
-rw-r--r--contrib/tools/bison/lib/gl_xlist.h177
-rw-r--r--contrib/tools/bison/lib/glthread/lock.c1221
-rw-r--r--contrib/tools/bison/lib/glthread/lock.h985
-rw-r--r--contrib/tools/bison/lib/glthread/threadlib.c73
-rw-r--r--contrib/tools/bison/lib/hard-locale.c2
-rw-r--r--contrib/tools/bison/lib/hard-locale.h2
-rw-r--r--contrib/tools/bison/lib/hash.c2
-rw-r--r--contrib/tools/bison/lib/hash.h2
-rw-r--r--contrib/tools/bison/lib/intprops.h455
-rw-r--r--contrib/tools/bison/lib/isnand-nolibm.h2
-rw-r--r--contrib/tools/bison/lib/isnanl-nolibm.h2
-rw-r--r--contrib/tools/bison/lib/localcharset.c2
-rw-r--r--contrib/tools/bison/lib/localcharset.h2
-rw-r--r--contrib/tools/bison/lib/localtime-buffer.c58
-rw-r--r--contrib/tools/bison/lib/localtime-buffer.h27
-rw-r--r--contrib/tools/bison/lib/malloca.c105
-rw-r--r--contrib/tools/bison/lib/malloca.h127
-rw-r--r--contrib/tools/bison/lib/mbrtowc.c2
-rw-r--r--contrib/tools/bison/lib/mbswidth.c2
-rw-r--r--contrib/tools/bison/lib/mbswidth.h2
-rw-r--r--contrib/tools/bison/lib/minmax.h2
-rw-r--r--contrib/tools/bison/lib/msvc-inval.c2
-rw-r--r--contrib/tools/bison/lib/msvc-inval.h2
-rw-r--r--contrib/tools/bison/lib/msvc-nothrow.c2
-rw-r--r--contrib/tools/bison/lib/msvc-nothrow.h2
-rw-r--r--contrib/tools/bison/lib/obstack.c2
-rw-r--r--contrib/tools/bison/lib/obstack.h4
-rw-r--r--contrib/tools/bison/lib/obstack_printf.c2
-rw-r--r--contrib/tools/bison/lib/open.c2
-rw-r--r--contrib/tools/bison/lib/path-join.c2
-rw-r--r--contrib/tools/bison/lib/path-join.h2
-rw-r--r--contrib/tools/bison/lib/pipe-safer.c2
-rw-r--r--contrib/tools/bison/lib/pipe2-safer.c2
-rw-r--r--contrib/tools/bison/lib/pipe2.c2
-rw-r--r--contrib/tools/bison/lib/printf-args.c2
-rw-r--r--contrib/tools/bison/lib/printf-args.h2
-rw-r--r--contrib/tools/bison/lib/printf-frexp.c2
-rw-r--r--contrib/tools/bison/lib/printf-frexp.h2
-rw-r--r--contrib/tools/bison/lib/printf-frexpl.c2
-rw-r--r--contrib/tools/bison/lib/printf-frexpl.h2
-rw-r--r--contrib/tools/bison/lib/printf-parse.c2
-rw-r--r--contrib/tools/bison/lib/printf-parse.h2
-rw-r--r--contrib/tools/bison/lib/progname.c2
-rw-r--r--contrib/tools/bison/lib/progname.h2
-rw-r--r--contrib/tools/bison/lib/quote.h2
-rw-r--r--contrib/tools/bison/lib/quotearg.c2
-rw-r--r--contrib/tools/bison/lib/quotearg.h2
-rw-r--r--contrib/tools/bison/lib/raise.c2
-rw-r--r--contrib/tools/bison/lib/relocatable.h101
-rw-r--r--contrib/tools/bison/lib/sig-handler.h2
-rw-r--r--contrib/tools/bison/lib/sigaction.c2
-rw-r--r--contrib/tools/bison/lib/sigprocmask.c2
-rw-r--r--contrib/tools/bison/lib/spawn-pipe.c2
-rw-r--r--contrib/tools/bison/lib/spawn-pipe.h2
-rw-r--r--contrib/tools/bison/lib/stat-time.c3
-rw-r--r--contrib/tools/bison/lib/stat-time.h252
-rw-r--r--contrib/tools/bison/lib/stdio-impl.h11
-rw-r--r--contrib/tools/bison/lib/stdio-safer.h2
-rw-r--r--contrib/tools/bison/lib/stpcpy.c2
-rw-r--r--contrib/tools/bison/lib/streq.h2
-rw-r--r--contrib/tools/bison/lib/stripslash.c2
-rw-r--r--contrib/tools/bison/lib/strndup.c2
-rw-r--r--contrib/tools/bison/lib/strverscmp.c2
-rw-r--r--contrib/tools/bison/lib/timespec.h2
-rw-r--r--contrib/tools/bison/lib/timevar.c2
-rw-r--r--contrib/tools/bison/lib/timevar.def4
-rw-r--r--contrib/tools/bison/lib/timevar.h2
-rw-r--r--contrib/tools/bison/lib/unistd-safer.h2
-rw-r--r--contrib/tools/bison/lib/unitypes.h2
-rw-r--r--contrib/tools/bison/lib/uniwidth.h2
-rw-r--r--contrib/tools/bison/lib/uniwidth/cjk.h2
-rw-r--r--contrib/tools/bison/lib/uniwidth/width.c2
-rw-r--r--contrib/tools/bison/lib/unlocked-io.h2
-rw-r--r--contrib/tools/bison/lib/vasnprintf.c11
-rw-r--r--contrib/tools/bison/lib/vasnprintf.h2
-rw-r--r--contrib/tools/bison/lib/verify.h8
-rw-r--r--contrib/tools/bison/lib/w32spawn.h2
-rw-r--r--contrib/tools/bison/lib/wait-process.c2
-rw-r--r--contrib/tools/bison/lib/wait-process.h2
-rw-r--r--contrib/tools/bison/lib/waitpid.c2
-rw-r--r--contrib/tools/bison/lib/wcwidth.c2
-rw-r--r--contrib/tools/bison/lib/xalloc-die.c2
-rw-r--r--contrib/tools/bison/lib/xalloc-oversized.h2
-rw-r--r--contrib/tools/bison/lib/xalloc.h2
-rw-r--r--contrib/tools/bison/lib/xconcat-filename.c2
-rw-r--r--contrib/tools/bison/lib/xmalloc.c2
-rw-r--r--contrib/tools/bison/lib/xmemdup0.c2
-rw-r--r--contrib/tools/bison/lib/xmemdup0.h9
-rw-r--r--contrib/tools/bison/lib/xreadlink.c44
-rw-r--r--contrib/tools/bison/lib/xreadlink.h25
-rw-r--r--contrib/tools/bison/lib/xsize.h2
-rw-r--r--contrib/tools/bison/lib/xstrndup.c2
-rw-r--r--contrib/tools/bison/lib/xstrndup.h2
-rw-r--r--contrib/tools/bison/lib/xtime.h2
-rw-r--r--contrib/tools/bison/lib/ya.make29
185 files changed, 2944 insertions, 3910 deletions
diff --git a/contrib/tools/bison/lib/allocator.c b/contrib/tools/bison/lib/allocator.c
new file mode 100644
index 00000000000..2c1a3da03aa
--- /dev/null
+++ b/contrib/tools/bison/lib/allocator.c
@@ -0,0 +1,5 @@
+#define _GL_USE_STDLIB_ALLOC 1
+#include <config.h>
+#include "allocator.h"
+#include <stdlib.h>
+struct allocator const stdlib_allocator = { malloc, realloc, free, NULL };
diff --git a/contrib/tools/bison/lib/allocator.h b/contrib/tools/bison/lib/allocator.h
new file mode 100644
index 00000000000..5a632ba6ff3
--- /dev/null
+++ b/contrib/tools/bison/lib/allocator.h
@@ -0,0 +1,58 @@
+/* Memory allocators such as malloc+free.
+
+ Copyright (C) 2011-2019 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#ifndef _GL_ALLOCATOR_H
+#define _GL_ALLOCATOR_H
+
+#include <stddef.h>
+
+/* An object describing a memory allocator family. */
+
+struct allocator
+{
+ /* Do not use GCC attributes such as __attribute__ ((malloc)) with
+ the function types pointed at by these members, because these
+ attributes do not work with pointers to functions. See
+ <https://lists.gnu.org/r/bug-gnulib/2011-04/msg00007.html>. */
+
+ /* Call ALLOCATE to allocate memory, like 'malloc'. On failure ALLOCATE
+ should return NULL, though not necessarily set errno. When given
+ a zero size it may return NULL even if successful. */
+ void *(*allocate) (size_t);
+
+ /* If nonnull, call REALLOCATE to reallocate memory, like 'realloc'.
+ On failure REALLOCATE should return NULL, though not necessarily set
+ errno. When given a zero size it may return NULL even if
+ successful. */
+ void *(*reallocate) (void *, size_t);
+
+ /* Call FREE to free memory, like 'free'. */
+ void (*free) (void *);
+
+ /* If nonnull, call DIE (SIZE) if MALLOC (SIZE) or REALLOC (...,
+ SIZE) fails. DIE should not return. SIZE should equal SIZE_MAX
+ if size_t overflow was detected while calculating sizes to be
+ passed to MALLOC or REALLOC. */
+ void (*die) (size_t);
+};
+
+/* An allocator using the stdlib functions and a null DIE function. */
+extern struct allocator const stdlib_allocator;
+
+#endif /* _GL_ALLOCATOR_H */
diff --git a/contrib/tools/bison/lib/areadlink.c b/contrib/tools/bison/lib/areadlink.c
new file mode 100644
index 00000000000..059435624db
--- /dev/null
+++ b/contrib/tools/bison/lib/areadlink.c
@@ -0,0 +1,56 @@
+/* areadlink.c -- readlink wrapper to return the link name in malloc'd storage
+ Unlike xreadlink and xreadlink_with_size, don't ever call exit.
+
+ Copyright (C) 2001, 2003-2007, 2009-2019 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Jim Meyering <[email protected]>
+ and Bruno Haible <[email protected]>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "areadlink.h"
+
+#include "careadlinkat.h"
+
+#include <stdlib.h>
+#include <unistd.h>
+
+/* Get the symbolic link value of FILENAME and put it into BUFFER, with
+ size BUFFER_SIZE. This function acts like readlink but has
+ readlinkat's signature. */
+static ssize_t
+careadlinkatcwd (int fd, char const *filename, char *buffer,
+ size_t buffer_size)
+{
+ /* FD must be AT_FDCWD here, otherwise the caller is using this
+ function in contexts it was not meant for. */
+ if (fd != AT_FDCWD)
+ abort ();
+ return readlink (filename, buffer, buffer_size);
+}
+
+/* Call readlink to get the symbolic link value of FILENAME.
+ Return a pointer to that NUL-terminated string in malloc'd storage.
+ If readlink fails, return NULL and set errno.
+ If allocation fails, or if the link value is longer than SIZE_MAX :-),
+ return NULL and set errno to ENOMEM. */
+
+char *
+areadlink (char const *filename)
+{
+ return careadlinkat (AT_FDCWD, filename, NULL, 0, NULL, careadlinkatcwd);
+}
diff --git a/contrib/tools/bison/lib/areadlink.h b/contrib/tools/bison/lib/areadlink.h
new file mode 100644
index 00000000000..ddcd06d7d7a
--- /dev/null
+++ b/contrib/tools/bison/lib/areadlink.h
@@ -0,0 +1,33 @@
+/* Read symbolic links without size limitation.
+
+ Copyright (C) 2001, 2003-2004, 2007, 2009-2019 Free Software Foundation,
+ Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Jim Meyering <[email protected]> */
+
+#include <stddef.h>
+
+extern char *areadlink (char const *filename);
+extern char *areadlink_with_size (char const *filename, size_t size_hint);
+
+#if GNULIB_AREADLINKAT
+extern char *areadlinkat (int fd, char const *filename);
+#endif
+
+#if GNULIB_AREADLINKAT_WITH_SIZE
+extern char *areadlinkat_with_size (int fd, char const *filename,
+ size_t size_hint);
+#endif
diff --git a/contrib/tools/bison/lib/arg-nonnull.h b/contrib/tools/bison/lib/arg-nonnull.h
index 5f034083129..ad8c26c225e 100644
--- a/contrib/tools/bison/lib/arg-nonnull.h
+++ b/contrib/tools/bison/lib/arg-nonnull.h
@@ -1,5 +1,5 @@
/* A C macro for declaring that specific arguments must not be NULL.
- Copyright (C) 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
diff --git a/contrib/tools/bison/lib/argmatch.c b/contrib/tools/bison/lib/argmatch.c
index 5c2202b4d26..b9a3e400c41 100644
--- a/contrib/tools/bison/lib/argmatch.c
+++ b/contrib/tools/bison/lib/argmatch.c
@@ -1,6 +1,6 @@
/* argmatch.c -- find a match for a string in an array
- Copyright (C) 1990, 1998-1999, 2001-2007, 2009-2018 Free Software
+ Copyright (C) 1990, 1998-1999, 2001-2007, 2009-2019 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/argmatch.h b/contrib/tools/bison/lib/argmatch.h
index e6b4c48f06c..51d2885879d 100644
--- a/contrib/tools/bison/lib/argmatch.h
+++ b/contrib/tools/bison/lib/argmatch.h
@@ -1,6 +1,6 @@
/* argmatch.h -- definitions and prototypes for argmatch.c
- Copyright (C) 1990, 1998-1999, 2001-2002, 2004-2005, 2009-2018 Free Software
+ Copyright (C) 1990, 1998-1999, 2001-2002, 2004-2005, 2009-2019 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/asnprintf.c b/contrib/tools/bison/lib/asnprintf.c
index 2298455b4a5..d2a8c097205 100644
--- a/contrib/tools/bison/lib/asnprintf.c
+++ b/contrib/tools/bison/lib/asnprintf.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 1999, 2002, 2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/basename-lgpl.c b/contrib/tools/bison/lib/basename-lgpl.c
index 33f9994f22e..0ae04ee5722 100644
--- a/contrib/tools/bison/lib/basename-lgpl.c
+++ b/contrib/tools/bison/lib/basename-lgpl.c
@@ -1,6 +1,6 @@
/* basename.c -- return the last element in a file name
- Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2018 Free Software
+ Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2019 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/basename.c b/contrib/tools/bison/lib/basename.c
index 02adb8c3d17..1b6e0ea59bd 100644
--- a/contrib/tools/bison/lib/basename.c
+++ b/contrib/tools/bison/lib/basename.c
@@ -1,6 +1,6 @@
/* basename.c -- return the last element in a file name
- Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2018 Free Software
+ Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2019 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/binary-io.c b/contrib/tools/bison/lib/binary-io.c
index f9cc4dd2ec6..01e0bf64765 100644
--- a/contrib/tools/bison/lib/binary-io.c
+++ b/contrib/tools/bison/lib/binary-io.c
@@ -1,5 +1,5 @@
/* Binary mode I/O.
- Copyright 2017-2018 Free Software Foundation, Inc.
+ Copyright 2017-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/binary-io.h b/contrib/tools/bison/lib/binary-io.h
index 7d3c4dfbaaa..100ac3011c1 100644
--- a/contrib/tools/bison/lib/binary-io.h
+++ b/contrib/tools/bison/lib/binary-io.h
@@ -1,5 +1,5 @@
/* Binary mode I/O.
- Copyright (C) 2001, 2003, 2005, 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2005, 2008-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/bitrotate.h b/contrib/tools/bison/lib/bitrotate.h
index 9eb6a6f42d7..862331e204b 100644
--- a/contrib/tools/bison/lib/bitrotate.h
+++ b/contrib/tools/bison/lib/bitrotate.h
@@ -1,5 +1,5 @@
/* bitrotate.h - Rotate bits in integers
- Copyright (C) 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2008-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/bitset.c b/contrib/tools/bison/lib/bitset.c
index 325213777b9..cccb1e83476 100644
--- a/contrib/tools/bison/lib/bitset.c
+++ b/contrib/tools/bison/lib/bitset.c
@@ -1,7 +1,6 @@
/* General bitsets.
- Copyright (C) 2002-2006, 2009-2015, 2018 Free Software Foundation,
- Inc.
+ Copyright (C) 2002-2006, 2009-2015, 2018-2019 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
@@ -27,11 +26,11 @@
#include "obstack.h"
-#include "abitset.h"
-#include "lbitset.h"
-#include "ebitset.h"
-#include "vbitset.h"
-#include "bitset_stats.h"
+#include "bitset/array.h"
+#include "bitset/list.h"
+#include "bitset/stats.h"
+#include "bitset/table.h"
+#include "bitset/vector.h"
const char * const bitset_type_names[] = BITSET_TYPE_NAMES;
@@ -56,9 +55,9 @@ bitset_bytes (enum bitset_type type, bitset_bindex n_bits)
return lbitset_bytes (n_bits);
case BITSET_TABLE:
- return ebitset_bytes (n_bits);
+ return tbitset_bytes (n_bits);
- case BITSET_VARRAY:
+ case BITSET_VECTOR:
return vbitset_bytes (n_bits);
}
}
@@ -83,9 +82,9 @@ bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
return lbitset_init (bset, n_bits);
case BITSET_TABLE:
- return ebitset_init (bset, n_bits);
+ return tbitset_init (bset, n_bits);
- case BITSET_VARRAY:
+ case BITSET_VECTOR:
return vbitset_init (bset, n_bits);
}
}
@@ -109,7 +108,7 @@ bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned attr)
/* If no attributes selected, choose a good compromise. */
if (!attr)
- return BITSET_VARRAY;
+ return BITSET_VECTOR;
if (attr & BITSET_SPARSE)
return BITSET_LIST;
@@ -120,7 +119,7 @@ bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned attr)
if (attr & BITSET_GREEDY)
return BITSET_TABLE;
- return BITSET_VARRAY;
+ return BITSET_VECTOR;
}
@@ -308,7 +307,7 @@ void
bitset_release_memory (void)
{
lbitset_release_memory ();
- ebitset_release_memory ();
+ tbitset_release_memory ();
}
@@ -374,9 +373,7 @@ bitset_copy_ (bitset dst, bitset src)
is large enough to hold the SRC bitset. */
bitset_zero (dst);
BITSET_FOR_EACH (iter, src, i, 0)
- {
- bitset_set (dst, i);
- }
+ bitset_set (dst, i);
return true;
}
diff --git a/contrib/tools/bison/lib/bitset.h b/contrib/tools/bison/lib/bitset.h
index f7b2cd0bfa0..32d08e7aa97 100644
--- a/contrib/tools/bison/lib/bitset.h
+++ b/contrib/tools/bison/lib/bitset.h
@@ -1,7 +1,6 @@
/* Generic bitsets.
- Copyright (C) 2002-2004, 2009-2015, 2018 Free Software Foundation,
- Inc.
+ Copyright (C) 2002-2004, 2009-2015, 2018-2019 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
@@ -18,8 +17,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef _BITSET_H
-#define _BITSET_H
+#ifndef _GL_BITSET_H
+#define _GL_BITSET_H
/* This file is the public interface to the bitset abstract data type.
Only use the functions and macros defined in this file. */
@@ -29,7 +28,7 @@
# include "unlocked-io.h"
#endif
-#include "bbitset.h"
+#include "bitset/base.h"
#include "obstack.h"
/* Attributes used to select a bitset implementation. */
@@ -58,11 +57,11 @@ union bitset_union
bitset_word words[1]; /* The array of bits. */
} a;
- struct ebitset_struct
+ struct tbitset_struct
{
struct bbitset_struct b;
bitset_windex size; /* Number of elements. */
- struct ebitset_elt_struct **elts; /* Expanding array of ptrs to elts. */
+ struct tbitset_elt_struct **elts; /* Expanding array of ptrs to elts. */
} e;
struct lbitset_struct
@@ -386,4 +385,4 @@ void debug_bitset (bitset);
/* Function to debug bitset stats from debugger. */
void debug_bitset_stats (void);
-#endif /* _BITSET_H */
+#endif /* _GL_BITSET_H */
diff --git a/contrib/tools/bison/lib/abitset.c b/contrib/tools/bison/lib/bitset/array.c
index 0d6b9a5d8a4..fde9fa24f56 100644
--- a/contrib/tools/bison/lib/abitset.c
+++ b/contrib/tools/bison/lib/bitset/array.c
@@ -1,6 +1,6 @@
/* Array bitsets.
- Copyright (C) 2002-2003, 2006, 2009-2015, 2018 Free Software
+ Copyright (C) 2002-2003, 2006, 2009-2015, 2018-2019 Free Software
Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
@@ -20,7 +20,7 @@
#include <config.h>
-#include "abitset.h"
+#include "bitset/array.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
diff --git a/contrib/tools/bison/lib/abitset.h b/contrib/tools/bison/lib/bitset/array.h
index 821eed9d96c..6f49a2e0474 100644
--- a/contrib/tools/bison/lib/abitset.h
+++ b/contrib/tools/bison/lib/bitset/array.h
@@ -1,6 +1,6 @@
/* Functions to support abitsets.
- Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation,
+ Copyright (C) 2002, 2004, 2009-2015, 2018-2019 Free Software Foundation,
Inc.
Contributed by Michael Hayes ([email protected]).
@@ -18,8 +18,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef _ABITSET_H
-#define _ABITSET_H
+#ifndef _BITSET_ARRAY_H
+#define _BITSET_ARRAY_H
#include "bitset.h"
diff --git a/contrib/tools/bison/lib/bbitset.h b/contrib/tools/bison/lib/bitset/base.h
index 29502a5b1d6..4fcafac8b67 100644
--- a/contrib/tools/bison/lib/bbitset.h
+++ b/contrib/tools/bison/lib/bitset/base.h
@@ -1,6 +1,6 @@
/* Base bitset stuff.
- Copyright (C) 2002-2004, 2006, 2009-2015, 2018 Free Software
+ Copyright (C) 2002-2004, 2006, 2009-2015, 2018-2019 Free Software
Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
@@ -18,8 +18,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef _BBITSET_H
-#define _BBITSET_H
+#ifndef _BITSET_BASE_H
+#define _BITSET_BASE_H
#include <limits.h>
#include <stdbool.h>
@@ -44,14 +44,14 @@
BITSET_TABLE: Expandable table of pointers to arrays of bits
(variable size, less storage for large sparse sets).
Faster than BITSET_LIST for random access.
- BITSET_VARRAY: Variable array of bits (variable size, fast for
+ BITSET_VECTOR: Variable array of bits (variable size, fast for
dense bitsets).
BITSET_STATS: Wrapper bitset for internal use only. Used for gathering
statistics and/or better run-time checking.
*/
-enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_VARRAY,
+enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_VECTOR,
BITSET_TYPE_NUM, BITSET_STATS};
-#define BITSET_TYPE_NAMES {"abitset", "lbitset", "ebitset", "vbitset"}
+#define BITSET_TYPE_NAMES {"abitset", "lbitset", "tbitset", "vbitset"}
extern const char * const bitset_type_names[];
diff --git a/contrib/tools/bison/lib/lbitset.c b/contrib/tools/bison/lib/bitset/list.c
index 705000929f7..f42edb8ea3e 100644
--- a/contrib/tools/bison/lib/lbitset.c
+++ b/contrib/tools/bison/lib/bitset/list.c
@@ -1,6 +1,6 @@
/* Functions to support link list bitsets.
- Copyright (C) 2002-2004, 2006, 2009-2015, 2018 Free Software
+ Copyright (C) 2002-2004, 2006, 2009-2015, 2018-2019 Free Software
Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
@@ -20,7 +20,7 @@
#include <config.h>
-#include "lbitset.h"
+#include "bitset/list.h"
#include <stddef.h>
#include <stdio.h>
diff --git a/contrib/tools/bison/lib/lbitset.h b/contrib/tools/bison/lib/bitset/list.h
index b9d266dafb5..a0fc09f8c6d 100644
--- a/contrib/tools/bison/lib/lbitset.h
+++ b/contrib/tools/bison/lib/bitset/list.h
@@ -1,6 +1,6 @@
/* Functions to support lbitsets.
- Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation,
+ Copyright (C) 2002, 2004, 2009-2015, 2018-2019 Free Software Foundation,
Inc.
Contributed by Michael Hayes ([email protected]).
@@ -18,8 +18,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef _LBITSET_H
-#define _LBITSET_H
+#ifndef _BITSET_LIST_H
+#define _BITSET_LIST_H
#include "bitset.h"
diff --git a/contrib/tools/bison/lib/bitset_stats.c b/contrib/tools/bison/lib/bitset/stats.c
index d0967348e7a..da73cdcac52 100644
--- a/contrib/tools/bison/lib/bitset_stats.c
+++ b/contrib/tools/bison/lib/bitset/stats.c
@@ -1,7 +1,6 @@
/* Bitset statistics.
- Copyright (C) 2002-2006, 2009-2015, 2018 Free Software Foundation,
- Inc.
+ Copyright (C) 2002-2006, 2009-2015, 2018-2019 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
@@ -27,7 +26,7 @@
#include <config.h>
-#include "bitset_stats.h"
+#include "bitset/stats.h"
#include <stdio.h>
#include <stdlib.h>
@@ -36,11 +35,11 @@
#include "gettext.h"
#define _(Msgid) gettext (Msgid)
-#include "abitset.h"
-#include "bbitset.h"
-#include "ebitset.h"
-#include "lbitset.h"
-#include "vbitset.h"
+#include "bitset/array.h"
+#include "bitset/base.h"
+#include "bitset/list.h"
+#include "bitset/table.h"
+#include "bitset/vector.h"
/* Configuration macros. */
#define BITSET_STATS_FILE "bitset.dat"
@@ -710,13 +709,13 @@ bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
case BITSET_TABLE:
{
- size_t bytes = ebitset_bytes (n_bits);
+ size_t bytes = tbitset_bytes (n_bits);
bset->s.bset = xcalloc (1, bytes);
- ebitset_init (bset->s.bset, n_bits);
+ tbitset_init (bset->s.bset, n_bits);
}
break;
- case BITSET_VARRAY:
+ case BITSET_VECTOR:
{
size_t bytes = vbitset_bytes (n_bits);
bset->s.bset = xcalloc (1, bytes);
diff --git a/contrib/tools/bison/lib/bitset_stats.h b/contrib/tools/bison/lib/bitset/stats.h
index 3a12ab36801..95e64dc4e51 100644
--- a/contrib/tools/bison/lib/bitset_stats.h
+++ b/contrib/tools/bison/lib/bitset/stats.h
@@ -1,7 +1,6 @@
/* Functions to support bitset statistics.
- Copyright (C) 2002-2004, 2009-2015, 2018 Free Software Foundation,
- Inc.
+ Copyright (C) 2002-2004, 2009-2015, 2018-2019 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
@@ -21,7 +20,7 @@
#ifndef _BITSET_STATS_H
#define _BITSET_STATS_H
-#include "bbitset.h"
+#include "bitset/base.h"
extern bool bitset_stats_enabled;
diff --git a/contrib/tools/bison/lib/ebitset.c b/contrib/tools/bison/lib/bitset/table.c
index 561816b132d..8351cf78482 100644
--- a/contrib/tools/bison/lib/ebitset.c
+++ b/contrib/tools/bison/lib/bitset/table.c
@@ -1,7 +1,6 @@
/* Functions to support expandable bitsets.
- Copyright (C) 2002-2006, 2009-2015, 2018 Free Software Foundation,
- Inc.
+ Copyright (C) 2002-2006, 2009-2015, 2018-2019 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
@@ -20,7 +19,7 @@
#include <config.h>
-#include "ebitset.h"
+#include "bitset/table.h"
#include <stdlib.h>
#include <string.h>
@@ -56,19 +55,19 @@
((unsigned) (EBITSET_ELT_WORDS * BITSET_WORD_BITS))
/* Ebitset element. We use an array of bits. */
-typedef struct ebitset_elt_struct
+typedef struct tbitset_elt_struct
{
union
{
bitset_word words[EBITSET_ELT_WORDS]; /* Bits that are set. */
- struct ebitset_elt_struct *next;
+ struct tbitset_elt_struct *next;
}
u;
}
-ebitset_elt;
+tbitset_elt;
-typedef ebitset_elt *ebitset_elts;
+typedef tbitset_elt *tbitset_elts;
/* Number of elements to initially allocate. */
@@ -78,15 +77,15 @@ typedef ebitset_elt *ebitset_elts;
#endif
-enum ebitset_find_mode
+enum tbitset_find_mode
{ EBITSET_FIND, EBITSET_CREATE, EBITSET_SUBST };
-static ebitset_elt ebitset_zero_elts[1]; /* Elements of all zero bits. */
+static tbitset_elt tbitset_zero_elts[1]; /* Elements of all zero bits. */
/* Obstack to allocate bitset elements from. */
-static struct obstack ebitset_obstack;
-static bool ebitset_obstack_init = false;
-static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
+static struct obstack tbitset_obstack;
+static bool tbitset_obstack_init = false;
+static tbitset_elt *tbitset_free_list; /* Free list of bitset elements. */
#define EBITSET_N_ELTS(N) (((N) + EBITSET_ELT_BITS - 1) / EBITSET_ELT_BITS)
#define EBITSET_ELTS(BSET) ((BSET)->e.elts)
@@ -122,7 +121,7 @@ static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
#define max(a, b) ((a) > (b) ? (a) : (b))
static bitset_bindex
-ebitset_resize (bitset src, bitset_bindex n_bits)
+tbitset_resize (bitset src, bitset_bindex n_bits)
{
if (n_bits == BITSET_NBITS_ (src))
return n_bits;
@@ -143,12 +142,12 @@ ebitset_resize (bitset src, bitset_bindex n_bits)
bitset_windex size = oldsize == 0 ? newsize : newsize + newsize / 4;
EBITSET_ELTS (src)
- = realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *));
+ = realloc (EBITSET_ELTS (src), size * sizeof (tbitset_elt *));
EBITSET_ASIZE (src) = size;
}
memset (EBITSET_ELTS (src) + oldsize, 0,
- (newsize - oldsize) * sizeof (ebitset_elt *));
+ (newsize - oldsize) * sizeof (tbitset_elt *));
}
else
{
@@ -157,7 +156,7 @@ ebitset_resize (bitset src, bitset_bindex n_bits)
if ((oldsize - newsize) >= oldsize / 2)
{
EBITSET_ELTS (src)
- = realloc (EBITSET_ELTS (src), newsize * sizeof (ebitset_elt *));
+ = realloc (EBITSET_ELTS (src), newsize * sizeof (tbitset_elt *));
EBITSET_ASIZE (src) = newsize;
}
@@ -169,22 +168,22 @@ ebitset_resize (bitset src, bitset_bindex n_bits)
}
-/* Allocate a ebitset element. The bits are not cleared. */
-static inline ebitset_elt *
-ebitset_elt_alloc (void)
+/* Allocate a tbitset element. The bits are not cleared. */
+static inline tbitset_elt *
+tbitset_elt_alloc (void)
{
- ebitset_elt *elt;
+ tbitset_elt *elt;
- if (ebitset_free_list != 0)
+ if (tbitset_free_list != 0)
{
- elt = ebitset_free_list;
- ebitset_free_list = EBITSET_NEXT (elt);
+ elt = tbitset_free_list;
+ tbitset_free_list = EBITSET_NEXT (elt);
}
else
{
- if (!ebitset_obstack_init)
+ if (!tbitset_obstack_init)
{
- ebitset_obstack_init = true;
+ tbitset_obstack_init = true;
/* Let particular systems override the size of a chunk. */
@@ -206,57 +205,57 @@ ebitset_elt_alloc (void)
#define __alignof__(type) 0
#endif
- obstack_specify_allocation (&ebitset_obstack, OBSTACK_CHUNK_SIZE,
- __alignof__ (ebitset_elt),
+ obstack_specify_allocation (&tbitset_obstack, OBSTACK_CHUNK_SIZE,
+ __alignof__ (tbitset_elt),
OBSTACK_CHUNK_ALLOC,
OBSTACK_CHUNK_FREE);
}
/* Perhaps we should add a number of new elements to the free
list. */
- elt = (ebitset_elt *) obstack_alloc (&ebitset_obstack,
- sizeof (ebitset_elt));
+ elt = (tbitset_elt *) obstack_alloc (&tbitset_obstack,
+ sizeof (tbitset_elt));
}
return elt;
}
-/* Allocate a ebitset element. The bits are cleared. */
-static inline ebitset_elt *
-ebitset_elt_calloc (void)
+/* Allocate a tbitset element. The bits are cleared. */
+static inline tbitset_elt *
+tbitset_elt_calloc (void)
{
- ebitset_elt *elt = ebitset_elt_alloc ();
+ tbitset_elt *elt = tbitset_elt_alloc ();
memset (EBITSET_WORDS (elt), 0, sizeof (EBITSET_WORDS (elt)));
return elt;
}
static inline void
-ebitset_elt_free (ebitset_elt *elt)
+tbitset_elt_free (tbitset_elt *elt)
{
- EBITSET_NEXT (elt) = ebitset_free_list;
- ebitset_free_list = elt;
+ EBITSET_NEXT (elt) = tbitset_free_list;
+ tbitset_free_list = elt;
}
/* Remove element with index EINDEX from bitset BSET. */
static inline void
-ebitset_elt_remove (bitset bset, bitset_windex eindex)
+tbitset_elt_remove (bitset bset, bitset_windex eindex)
{
- ebitset_elts *elts = EBITSET_ELTS (bset);
- ebitset_elt *elt = elts[eindex];
+ tbitset_elts *elts = EBITSET_ELTS (bset);
+ tbitset_elt *elt = elts[eindex];
elts[eindex] = 0;
- ebitset_elt_free (elt);
+ tbitset_elt_free (elt);
}
/* Add ELT into elts at index EINDEX of bitset BSET. */
static inline void
-ebitset_elt_add (bitset bset, ebitset_elt *elt, bitset_windex eindex)
+tbitset_elt_add (bitset bset, tbitset_elt *elt, bitset_windex eindex)
{
- ebitset_elts *elts = EBITSET_ELTS (bset);
+ tbitset_elts *elts = EBITSET_ELTS (bset);
/* Assume that the elts entry not allocated. */
elts[eindex] = elt;
}
@@ -264,7 +263,7 @@ ebitset_elt_add (bitset bset, ebitset_elt *elt, bitset_windex eindex)
/* Are all bits in an element zero? */
static inline bool
-ebitset_elt_zero_p (ebitset_elt *elt)
+tbitset_elt_zero_p (tbitset_elt *elt)
{
for (int i = 0; i < EBITSET_ELT_WORDS; i++)
if (EBITSET_WORDS (elt)[i])
@@ -273,18 +272,18 @@ ebitset_elt_zero_p (ebitset_elt *elt)
}
-static ebitset_elt *
-ebitset_elt_find (bitset bset, bitset_bindex bindex,
- enum ebitset_find_mode mode)
+static tbitset_elt *
+tbitset_elt_find (bitset bset, bitset_bindex bindex,
+ enum tbitset_find_mode mode)
{
bitset_windex eindex = bindex / EBITSET_ELT_BITS;
- ebitset_elts *elts = EBITSET_ELTS (bset);
+ tbitset_elts *elts = EBITSET_ELTS (bset);
bitset_windex size = EBITSET_SIZE (bset);
if (eindex < size)
{
- ebitset_elt *elt = elts[eindex];
+ tbitset_elt *elt = elts[eindex];
if (elt)
{
if (EBITSET_WORDS (elt) != bset->b.cdata)
@@ -305,41 +304,41 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
case EBITSET_CREATE:
if (eindex >= size)
- ebitset_resize (bset, bindex);
+ tbitset_resize (bset, bindex);
/* Create a new element. */
{
- ebitset_elt *elt = ebitset_elt_calloc ();
- ebitset_elt_add (bset, elt, eindex);
+ tbitset_elt *elt = tbitset_elt_calloc ();
+ tbitset_elt_add (bset, elt, eindex);
EBITSET_CACHE_SET (bset, eindex);
return elt;
}
case EBITSET_SUBST:
- return &ebitset_zero_elts[0];
+ return &tbitset_zero_elts[0];
}
}
/* Weed out the zero elements from the elts. */
static inline bitset_windex
-ebitset_weed (bitset bset)
+tbitset_weed (bitset bset)
{
if (EBITSET_ZERO_P (bset))
return 0;
- ebitset_elts *elts = EBITSET_ELTS (bset);
+ tbitset_elts *elts = EBITSET_ELTS (bset);
bitset_windex count = 0;
bitset_windex j;
for (j = 0; j < EBITSET_SIZE (bset); j++)
{
- ebitset_elt *elt = elts[j];
+ tbitset_elt *elt = elts[j];
if (elt)
{
- if (ebitset_elt_zero_p (elt))
+ if (tbitset_elt_zero_p (elt))
{
- ebitset_elt_remove (bset, j);
+ tbitset_elt_remove (bset, j);
count++;
}
}
@@ -363,17 +362,17 @@ ebitset_weed (bitset bset)
/* Set all bits in the bitset to zero. */
static inline void
-ebitset_zero (bitset bset)
+tbitset_zero (bitset bset)
{
if (EBITSET_ZERO_P (bset))
return;
- ebitset_elts *elts = EBITSET_ELTS (bset);
+ tbitset_elts *elts = EBITSET_ELTS (bset);
for (bitset_windex j = 0; j < EBITSET_SIZE (bset); j++)
{
- ebitset_elt *elt = elts[j];
+ tbitset_elt *elt = elts[j];
if (elt)
- ebitset_elt_remove (bset, j);
+ tbitset_elt_remove (bset, j);
}
/* All the bits are zero. We could shrink the elts.
@@ -383,24 +382,24 @@ ebitset_zero (bitset bset)
static inline bool
-ebitset_equal_p (bitset dst, bitset src)
+tbitset_equal_p (bitset dst, bitset src)
{
if (src == dst)
return true;
- ebitset_weed (dst);
- ebitset_weed (src);
+ tbitset_weed (dst);
+ tbitset_weed (src);
if (EBITSET_SIZE (src) != EBITSET_SIZE (dst))
return false;
- ebitset_elts *selts = EBITSET_ELTS (src);
- ebitset_elts *delts = EBITSET_ELTS (dst);
+ tbitset_elts *selts = EBITSET_ELTS (src);
+ tbitset_elts *delts = EBITSET_ELTS (dst);
for (bitset_windex j = 0; j < EBITSET_SIZE (src); j++)
{
- ebitset_elt *selt = selts[j];
- ebitset_elt *delt = delts[j];
+ tbitset_elt *selt = selts[j];
+ tbitset_elt *delt = delts[j];
if (!selt && !delt)
continue;
@@ -417,24 +416,24 @@ ebitset_equal_p (bitset dst, bitset src)
/* Copy bits from bitset SRC to bitset DST. */
static inline void
-ebitset_copy_ (bitset dst, bitset src)
+tbitset_copy_ (bitset dst, bitset src)
{
if (src == dst)
return;
- ebitset_zero (dst);
+ tbitset_zero (dst);
if (BITSET_NBITS_ (dst) != BITSET_NBITS_ (src))
- ebitset_resize (dst, BITSET_NBITS_ (src));
+ tbitset_resize (dst, BITSET_NBITS_ (src));
- ebitset_elts *selts = EBITSET_ELTS (src);
- ebitset_elts *delts = EBITSET_ELTS (dst);
+ tbitset_elts *selts = EBITSET_ELTS (src);
+ tbitset_elts *delts = EBITSET_ELTS (dst);
for (bitset_windex j = 0; j < EBITSET_SIZE (src); j++)
{
- ebitset_elt *selt = selts[j];
+ tbitset_elt *selt = selts[j];
if (selt)
{
- ebitset_elt *tmp = ebitset_elt_alloc ();
+ tbitset_elt *tmp = tbitset_elt_alloc ();
delts[j] = tmp;
memcpy (EBITSET_WORDS (tmp), EBITSET_WORDS (selt),
sizeof (EBITSET_WORDS (selt)));
@@ -447,32 +446,32 @@ ebitset_copy_ (bitset dst, bitset src)
/* Copy bits from bitset SRC to bitset DST. Return true if
bitsets different. */
static inline bool
-ebitset_copy_cmp (bitset dst, bitset src)
+tbitset_copy_cmp (bitset dst, bitset src)
{
if (src == dst)
return false;
if (EBITSET_ZERO_P (dst))
{
- ebitset_copy_ (dst, src);
+ tbitset_copy_ (dst, src);
return !EBITSET_ZERO_P (src);
}
- if (ebitset_equal_p (dst, src))
+ if (tbitset_equal_p (dst, src))
return false;
- ebitset_copy_ (dst, src);
+ tbitset_copy_ (dst, src);
return true;
}
/* Set bit BITNO in bitset DST. */
static void
-ebitset_set (bitset dst, bitset_bindex bitno)
+tbitset_set (bitset dst, bitset_bindex bitno)
{
bitset_windex windex = bitno / BITSET_WORD_BITS;
- ebitset_elt_find (dst, bitno, EBITSET_CREATE);
+ tbitset_elt_find (dst, bitno, EBITSET_CREATE);
dst->b.cdata[windex - dst->b.cindex] |=
(bitset_word) 1 << (bitno % BITSET_WORD_BITS);
@@ -481,11 +480,11 @@ ebitset_set (bitset dst, bitset_bindex bitno)
/* Reset bit BITNO in bitset DST. */
static void
-ebitset_reset (bitset dst, bitset_bindex bitno)
+tbitset_reset (bitset dst, bitset_bindex bitno)
{
bitset_windex windex = bitno / BITSET_WORD_BITS;
- if (!ebitset_elt_find (dst, bitno, EBITSET_FIND))
+ if (!tbitset_elt_find (dst, bitno, EBITSET_FIND))
return;
dst->b.cdata[windex - dst->b.cindex] &=
@@ -499,11 +498,11 @@ ebitset_reset (bitset dst, bitset_bindex bitno)
/* Test bit BITNO in bitset SRC. */
static bool
-ebitset_test (bitset src, bitset_bindex bitno)
+tbitset_test (bitset src, bitset_bindex bitno)
{
bitset_windex windex = bitno / BITSET_WORD_BITS;
- return (ebitset_elt_find (src, bitno, EBITSET_FIND)
+ return (tbitset_elt_find (src, bitno, EBITSET_FIND)
&& ((src->b.cdata[windex - src->b.cindex]
>> (bitno % BITSET_WORD_BITS))
& 1));
@@ -511,9 +510,9 @@ ebitset_test (bitset src, bitset_bindex bitno)
static void
-ebitset_free (bitset bset)
+tbitset_free (bitset bset)
{
- ebitset_zero (bset);
+ tbitset_zero (bset);
free (EBITSET_ELTS (bset));
}
@@ -522,7 +521,7 @@ ebitset_free (bitset bset)
*NEXT and store in array LIST. Return with actual number of bits
found and with *NEXT indicating where search stopped. */
static bitset_bindex
-ebitset_list_reverse (bitset bset, bitset_bindex *list,
+tbitset_list_reverse (bitset bset, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
{
if (EBITSET_ZERO_P (bset))
@@ -535,7 +534,7 @@ ebitset_list_reverse (bitset bset, bitset_bindex *list,
if (rbitno >= n_bits)
return 0;
- ebitset_elts *elts = EBITSET_ELTS (bset);
+ tbitset_elts *elts = EBITSET_ELTS (bset);
bitset_bindex bitno = n_bits - (rbitno + 1);
@@ -551,7 +550,7 @@ ebitset_list_reverse (bitset bset, bitset_bindex *list,
do
{
- ebitset_elt *elt = elts[eindex];
+ tbitset_elt *elt = elts[eindex];
if (elt)
{
bitset_word *srcp = EBITSET_WORDS (elt);
@@ -592,7 +591,7 @@ ebitset_list_reverse (bitset bset, bitset_bindex *list,
*NEXT and store in array LIST. Return with actual number of bits
found and with *NEXT indicating where search stopped. */
static bitset_bindex
-ebitset_list (bitset bset, bitset_bindex *list,
+tbitset_list (bitset bset, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
{
if (EBITSET_ZERO_P (bset))
@@ -601,7 +600,7 @@ ebitset_list (bitset bset, bitset_bindex *list,
bitset_bindex bitno = *next;
bitset_bindex count = 0;
- ebitset_elts *elts = EBITSET_ELTS (bset);
+ tbitset_elts *elts = EBITSET_ELTS (bset);
bitset_windex size = EBITSET_SIZE (bset);
bitset_windex eindex = bitno / EBITSET_ELT_BITS;
@@ -609,7 +608,7 @@ ebitset_list (bitset bset, bitset_bindex *list,
{
/* We need to start within an element. This is not very common. */
- ebitset_elt *elt = elts[eindex];
+ tbitset_elt *elt = elts[eindex];
if (elt)
{
bitset_windex woffset;
@@ -650,7 +649,7 @@ ebitset_list (bitset bset, bitset_bindex *list,
{
bitset_word *srcp;
- ebitset_elt *elt = elts[eindex];
+ tbitset_elt *elt = elts[eindex];
if (!elt)
continue;
@@ -763,18 +762,18 @@ ebitset_list (bitset bset, bitset_bindex *list,
/* Ensure that any unused bits within the last element are clear. */
static inline void
-ebitset_unused_clear (bitset dst)
+tbitset_unused_clear (bitset dst)
{
bitset_bindex n_bits = BITSET_NBITS_ (dst);
unsigned last_bit = n_bits % EBITSET_ELT_BITS;
if (last_bit)
{
- ebitset_elts *elts = EBITSET_ELTS (dst);
+ tbitset_elts *elts = EBITSET_ELTS (dst);
bitset_windex eindex = n_bits / EBITSET_ELT_BITS;
- ebitset_elt *elt = elts[eindex];
+ tbitset_elt *elt = elts[eindex];
if (elt)
{
bitset_word *srcp = EBITSET_WORDS (elt);
@@ -792,92 +791,92 @@ ebitset_unused_clear (bitset dst)
static void
-ebitset_ones (bitset dst)
+tbitset_ones (bitset dst)
{
for (bitset_windex j = 0; j < EBITSET_SIZE (dst); j++)
{
/* Create new elements if they cannot be found. Perhaps
we should just add pointers to a ones element? */
- ebitset_elt *elt =
- ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
+ tbitset_elt *elt =
+ tbitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
memset (EBITSET_WORDS (elt), -1, sizeof (EBITSET_WORDS (elt)));
}
EBITSET_NONZERO_SET (dst);
- ebitset_unused_clear (dst);
+ tbitset_unused_clear (dst);
}
static bool
-ebitset_empty_p (bitset dst)
+tbitset_empty_p (bitset dst)
{
if (EBITSET_ZERO_P (dst))
- return 1;
+ return true;
- ebitset_elts *elts = EBITSET_ELTS (dst);
+ tbitset_elts *elts = EBITSET_ELTS (dst);
for (bitset_windex j = 0; j < EBITSET_SIZE (dst); j++)
{
- ebitset_elt *elt = elts[j];
+ tbitset_elt *elt = elts[j];
if (elt)
{
- if (!ebitset_elt_zero_p (elt))
- return 0;
+ if (!tbitset_elt_zero_p (elt))
+ return false;
/* Do some weeding as we go. */
- ebitset_elt_remove (dst, j);
+ tbitset_elt_remove (dst, j);
}
}
/* All the bits are zero. We could shrink the elts.
For now just mark DST as known to be zero. */
EBITSET_ZERO_SET (dst);
- return 1;
+ return true;
}
static void
-ebitset_not (bitset dst, bitset src)
+tbitset_not (bitset dst, bitset src)
{
- ebitset_resize (dst, BITSET_NBITS_ (src));
+ tbitset_resize (dst, BITSET_NBITS_ (src));
for (bitset_windex j = 0; j < EBITSET_SIZE (src); j++)
{
/* Create new elements for dst if they cannot be found
or substitute zero elements if src elements not found. */
- ebitset_elt *selt =
- ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_SUBST);
- ebitset_elt *delt =
- ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
+ tbitset_elt *selt =
+ tbitset_elt_find (src, j * EBITSET_ELT_BITS, EBITSET_SUBST);
+ tbitset_elt *delt =
+ tbitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++)
EBITSET_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i];
}
EBITSET_NONZERO_SET (dst);
- ebitset_unused_clear (dst);
+ tbitset_unused_clear (dst);
}
/* Is DST == DST | SRC? */
static bool
-ebitset_subset_p (bitset dst, bitset src)
+tbitset_subset_p (bitset dst, bitset src)
{
- ebitset_elts *selts = EBITSET_ELTS (src);
- ebitset_elts *delts = EBITSET_ELTS (dst);
+ tbitset_elts *selts = EBITSET_ELTS (src);
+ tbitset_elts *delts = EBITSET_ELTS (dst);
bitset_windex ssize = EBITSET_SIZE (src);
bitset_windex dsize = EBITSET_SIZE (dst);
for (bitset_windex j = 0; j < ssize; j++)
{
- ebitset_elt *selt = j < ssize ? selts[j] : 0;
- ebitset_elt *delt = j < dsize ? delts[j] : 0;
+ tbitset_elt *selt = j < ssize ? selts[j] : 0;
+ tbitset_elt *delt = j < dsize ? delts[j] : 0;
if (!selt && !delt)
continue;
if (!selt)
- selt = &ebitset_zero_elts[0];
+ selt = &tbitset_zero_elts[0];
if (!delt)
- delt = &ebitset_zero_elts[0];
+ delt = &tbitset_zero_elts[0];
for (unsigned i = 0; i < EBITSET_ELT_WORDS; i++)
if (EBITSET_WORDS (delt)[i]
@@ -890,18 +889,18 @@ ebitset_subset_p (bitset dst, bitset src)
/* Is DST & SRC == 0? */
static bool
-ebitset_disjoint_p (bitset dst, bitset src)
+tbitset_disjoint_p (bitset dst, bitset src)
{
- ebitset_elts *selts = EBITSET_ELTS (src);
- ebitset_elts *delts = EBITSET_ELTS (dst);
+ tbitset_elts *selts = EBITSET_ELTS (src);
+ tbitset_elts *delts = EBITSET_ELTS (dst);
bitset_windex ssize = EBITSET_SIZE (src);
bitset_windex dsize = EBITSET_SIZE (dst);
for (bitset_windex j = 0; j < ssize; j++)
{
- ebitset_elt *selt = j < ssize ? selts[j] : 0;
- ebitset_elt *delt = j < dsize ? delts[j] : 0;
+ tbitset_elt *selt = j < ssize ? selts[j] : 0;
+ tbitset_elt *delt = j < dsize ? delts[j] : 0;
if (!selt || !delt)
continue;
@@ -916,11 +915,11 @@ ebitset_disjoint_p (bitset dst, bitset src)
static bool
-ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
+tbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
{
bool changed = false;
- ebitset_resize (dst, max (BITSET_NBITS_ (src1), BITSET_NBITS_ (src2)));
+ tbitset_resize (dst, max (BITSET_NBITS_ (src1), BITSET_NBITS_ (src2)));
bitset_windex ssize1 = EBITSET_SIZE (src1);
bitset_windex ssize2 = EBITSET_SIZE (src2);
@@ -929,33 +928,33 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
if (size < ssize2)
size = ssize2;
- ebitset_elts *selts1 = EBITSET_ELTS (src1);
- ebitset_elts *selts2 = EBITSET_ELTS (src2);
- ebitset_elts *delts = EBITSET_ELTS (dst);
+ tbitset_elts *selts1 = EBITSET_ELTS (src1);
+ tbitset_elts *selts2 = EBITSET_ELTS (src2);
+ tbitset_elts *delts = EBITSET_ELTS (dst);
bitset_windex j = 0;
for (j = 0; j < size; j++)
{
- ebitset_elt *selt1 = j < ssize1 ? selts1[j] : 0;
- ebitset_elt *selt2 = j < ssize2 ? selts2[j] : 0;
- ebitset_elt *delt = j < dsize ? delts[j] : 0;
+ tbitset_elt *selt1 = j < ssize1 ? selts1[j] : 0;
+ tbitset_elt *selt2 = j < ssize2 ? selts2[j] : 0;
+ tbitset_elt *delt = j < dsize ? delts[j] : 0;
if (!selt1 && !selt2)
{
if (delt)
{
changed = true;
- ebitset_elt_remove (dst, j);
+ tbitset_elt_remove (dst, j);
}
continue;
}
if (!selt1)
- selt1 = &ebitset_zero_elts[0];
+ selt1 = &tbitset_zero_elts[0];
if (!selt2)
- selt2 = &ebitset_zero_elts[0];
+ selt2 = &tbitset_zero_elts[0];
if (!delt)
- delt = ebitset_elt_calloc ();
+ delt = tbitset_elt_calloc ();
else
delts[j] = 0;
@@ -1020,13 +1019,13 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
break;
}
- if (!ebitset_elt_zero_p (delt))
+ if (!tbitset_elt_zero_p (delt))
{
- ebitset_elt_add (dst, delt, j);
+ tbitset_elt_add (dst, delt, j);
}
else
{
- ebitset_elt_free (delt);
+ tbitset_elt_free (delt);
}
}
@@ -1035,9 +1034,9 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
{
changed = true;
- ebitset_elt *delt = delts[j];
+ tbitset_elt *delt = delts[j];
if (delt)
- ebitset_elt_remove (dst, j);
+ tbitset_elt_remove (dst, j);
}
EBITSET_NONZERO_SET (dst);
@@ -1046,164 +1045,164 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
static bool
-ebitset_and_cmp (bitset dst, bitset src1, bitset src2)
+tbitset_and_cmp (bitset dst, bitset src1, bitset src2)
{
if (EBITSET_ZERO_P (src2))
{
- ebitset_weed (dst);
+ tbitset_weed (dst);
bool changed = EBITSET_ZERO_P (dst);
- ebitset_zero (dst);
+ tbitset_zero (dst);
return changed;
}
else if (EBITSET_ZERO_P (src1))
{
- ebitset_weed (dst);
+ tbitset_weed (dst);
bool changed = EBITSET_ZERO_P (dst);
- ebitset_zero (dst);
+ tbitset_zero (dst);
return changed;
}
- return ebitset_op3_cmp (dst, src1, src2, BITSET_OP_AND);
+ return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_AND);
}
static void
-ebitset_and (bitset dst, bitset src1, bitset src2)
+tbitset_and (bitset dst, bitset src1, bitset src2)
{
- ebitset_and_cmp (dst, src1, src2);
+ tbitset_and_cmp (dst, src1, src2);
}
static bool
-ebitset_andn_cmp (bitset dst, bitset src1, bitset src2)
+tbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
{
if (EBITSET_ZERO_P (src2))
{
- return ebitset_copy_cmp (dst, src1);
+ return tbitset_copy_cmp (dst, src1);
}
else if (EBITSET_ZERO_P (src1))
{
- ebitset_weed (dst);
+ tbitset_weed (dst);
bool changed = EBITSET_ZERO_P (dst);
- ebitset_zero (dst);
+ tbitset_zero (dst);
return changed;
}
- return ebitset_op3_cmp (dst, src1, src2, BITSET_OP_ANDN);
+ return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_ANDN);
}
static void
-ebitset_andn (bitset dst, bitset src1, bitset src2)
+tbitset_andn (bitset dst, bitset src1, bitset src2)
{
- ebitset_andn_cmp (dst, src1, src2);
+ tbitset_andn_cmp (dst, src1, src2);
}
static bool
-ebitset_or_cmp (bitset dst, bitset src1, bitset src2)
+tbitset_or_cmp (bitset dst, bitset src1, bitset src2)
{
if (EBITSET_ZERO_P (src2))
{
- return ebitset_copy_cmp (dst, src1);
+ return tbitset_copy_cmp (dst, src1);
}
else if (EBITSET_ZERO_P (src1))
{
- return ebitset_copy_cmp (dst, src2);
+ return tbitset_copy_cmp (dst, src2);
}
- return ebitset_op3_cmp (dst, src1, src2, BITSET_OP_OR);
+ return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_OR);
}
static void
-ebitset_or (bitset dst, bitset src1, bitset src2)
+tbitset_or (bitset dst, bitset src1, bitset src2)
{
- ebitset_or_cmp (dst, src1, src2);
+ tbitset_or_cmp (dst, src1, src2);
}
static bool
-ebitset_xor_cmp (bitset dst, bitset src1, bitset src2)
+tbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
{
if (EBITSET_ZERO_P (src2))
{
- return ebitset_copy_cmp (dst, src1);
+ return tbitset_copy_cmp (dst, src1);
}
else if (EBITSET_ZERO_P (src1))
{
- return ebitset_copy_cmp (dst, src2);
+ return tbitset_copy_cmp (dst, src2);
}
- return ebitset_op3_cmp (dst, src1, src2, BITSET_OP_XOR);
+ return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_XOR);
}
static void
-ebitset_xor (bitset dst, bitset src1, bitset src2)
+tbitset_xor (bitset dst, bitset src1, bitset src2)
{
- ebitset_xor_cmp (dst, src1, src2);
+ tbitset_xor_cmp (dst, src1, src2);
}
static void
-ebitset_copy (bitset dst, bitset src)
+tbitset_copy (bitset dst, bitset src)
{
if (BITSET_COMPATIBLE_ (dst, src))
- ebitset_copy_ (dst, src);
+ tbitset_copy_ (dst, src);
else
bitset_copy_ (dst, src);
}
/* Vector of operations for linked-list bitsets. */
-struct bitset_vtable ebitset_vtable = {
- ebitset_set,
- ebitset_reset,
+struct bitset_vtable tbitset_vtable = {
+ tbitset_set,
+ tbitset_reset,
bitset_toggle_,
- ebitset_test,
- ebitset_resize,
+ tbitset_test,
+ tbitset_resize,
bitset_size_,
bitset_count_,
- ebitset_empty_p,
- ebitset_ones,
- ebitset_zero,
- ebitset_copy,
- ebitset_disjoint_p,
- ebitset_equal_p,
- ebitset_not,
- ebitset_subset_p,
- ebitset_and,
- ebitset_and_cmp,
- ebitset_andn,
- ebitset_andn_cmp,
- ebitset_or,
- ebitset_or_cmp,
- ebitset_xor,
- ebitset_xor_cmp,
+ tbitset_empty_p,
+ tbitset_ones,
+ tbitset_zero,
+ tbitset_copy,
+ tbitset_disjoint_p,
+ tbitset_equal_p,
+ tbitset_not,
+ tbitset_subset_p,
+ tbitset_and,
+ tbitset_and_cmp,
+ tbitset_andn,
+ tbitset_andn_cmp,
+ tbitset_or,
+ tbitset_or_cmp,
+ tbitset_xor,
+ tbitset_xor_cmp,
bitset_and_or_,
bitset_and_or_cmp_,
bitset_andn_or_,
bitset_andn_or_cmp_,
bitset_or_and_,
bitset_or_and_cmp_,
- ebitset_list,
- ebitset_list_reverse,
- ebitset_free,
+ tbitset_list,
+ tbitset_list_reverse,
+ tbitset_free,
BITSET_TABLE
};
/* Return size of initial structure. */
size_t
-ebitset_bytes (bitset_bindex n_bits ATTRIBUTE_UNUSED)
+tbitset_bytes (bitset_bindex n_bits ATTRIBUTE_UNUSED)
{
- return sizeof (struct ebitset_struct);
+ return sizeof (struct tbitset_struct);
}
/* Initialize a bitset. */
bitset
-ebitset_init (bitset bset, bitset_bindex n_bits)
+tbitset_init (bitset bset, bitset_bindex n_bits)
{
- bset->b.vtable = &ebitset_vtable;
+ bset->b.vtable = &tbitset_vtable;
bset->b.csize = EBITSET_ELT_WORDS;
@@ -1211,19 +1210,19 @@ ebitset_init (bitset bset, bitset_bindex n_bits)
EBITSET_ASIZE (bset) = 0;
EBITSET_ELTS (bset) = 0;
- ebitset_resize (bset, n_bits);
+ tbitset_resize (bset, n_bits);
return bset;
}
void
-ebitset_release_memory (void)
+tbitset_release_memory (void)
{
- ebitset_free_list = 0;
- if (ebitset_obstack_init)
+ tbitset_free_list = 0;
+ if (tbitset_obstack_init)
{
- ebitset_obstack_init = false;
- obstack_free (&ebitset_obstack, NULL);
+ tbitset_obstack_init = false;
+ obstack_free (&tbitset_obstack, NULL);
}
}
diff --git a/contrib/tools/bison/lib/ebitset.h b/contrib/tools/bison/lib/bitset/table.h
index 97b9ee1522f..6c781adde35 100644
--- a/contrib/tools/bison/lib/ebitset.h
+++ b/contrib/tools/bison/lib/bitset/table.h
@@ -1,6 +1,6 @@
-/* Functions to support ebitsets.
+/* Functions to support tbitsets.
- Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation,
+ Copyright (C) 2002, 2004, 2009-2015, 2018-2019 Free Software Foundation,
Inc.
Contributed by Michael Hayes ([email protected]).
@@ -18,15 +18,15 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef _EBITSET_H
-#define _EBITSET_H
+#ifndef _BITSET_TABLE_H
+#define _BITSET_TABLE_H
#include "bitset.h"
-size_t ebitset_bytes (bitset_bindex);
+size_t tbitset_bytes (bitset_bindex);
-bitset ebitset_init (bitset, bitset_bindex);
+bitset tbitset_init (bitset, bitset_bindex);
-void ebitset_release_memory (void);
+void tbitset_release_memory (void);
#endif
diff --git a/contrib/tools/bison/lib/vbitset.c b/contrib/tools/bison/lib/bitset/vector.c
index f715f9b4f15..15d3e995677 100644
--- a/contrib/tools/bison/lib/vbitset.c
+++ b/contrib/tools/bison/lib/bitset/vector.c
@@ -1,7 +1,6 @@
/* Variable array bitsets.
- Copyright (C) 2002-2006, 2009-2015, 2018 Free Software Foundation,
- Inc.
+ Copyright (C) 2002-2006, 2009-2015, 2018-2019 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
@@ -20,7 +19,7 @@
#include <config.h>
-#include "vbitset.h"
+#include "bitset/vector.h"
#include <stdlib.h>
#include <string.h>
@@ -419,14 +418,12 @@ vbitset_subset_p (bitset dst, bitset src)
unsigned i;
for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++)
if (*dstp != (*srcp | *dstp))
- return 0;
+ return false;
if (ssize > dsize)
- {
- for (; i < ssize; i++)
- if (*srcp++)
- return false;
- }
+ for (; i < ssize; i++)
+ if (*srcp++)
+ return false;
return true;
}
@@ -966,7 +963,7 @@ struct bitset_vtable vbitset_vtable = {
vbitset_list,
vbitset_list_reverse,
NULL,
- BITSET_VARRAY
+ BITSET_VECTOR
};
diff --git a/contrib/tools/bison/lib/vbitset.h b/contrib/tools/bison/lib/bitset/vector.h
index 23b4652b87f..1f5b94dea09 100644
--- a/contrib/tools/bison/lib/vbitset.h
+++ b/contrib/tools/bison/lib/bitset/vector.h
@@ -1,6 +1,6 @@
/* Functions to support vbitsets.
- Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation,
+ Copyright (C) 2002, 2004, 2009-2015, 2018-2019 Free Software Foundation,
Inc.
Contributed by Michael Hayes ([email protected]).
@@ -18,8 +18,8 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef _VBITSET_H
-#define _VBITSET_H
+#ifndef _BITSET_VECTOR_H
+#define _BITSET_VECTOR_H
#include "bitset.h"
diff --git a/contrib/tools/bison/lib/bitsetv-print.c b/contrib/tools/bison/lib/bitsetv-print.c
deleted file mode 100644
index d229c7d6137..00000000000
--- a/contrib/tools/bison/lib/bitsetv-print.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Bitset vectors.
-
- Copyright (C) 2001-2002, 2004, 2006, 2009-2015, 2018 Free Software
- Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#include "bitsetv-print.h"
-
-#include <stdlib.h>
-
-/*--------------------------------------------------------.
-| Display the MATRIX array of SIZE bitsets of size SIZE. |
-`--------------------------------------------------------*/
-
-void
-bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
-{
- bitset_bindex hsize = bitset_size (bset[0]);
-
- /* Title. */
- fprintf (out, "%s BEGIN\n", title);
-
- /* Column numbers. */
- fputs (" ", out);
- for (bitset_bindex i = 0; i < hsize; ++i)
- putc (i / 10 ? '0' + i / 10 : ' ', out);
- putc ('\n', out);
- fputs (" ", out);
- for (bitset_bindex i = 0; i < hsize; ++i)
- fprintf (out, "%d", (int) (i % 10));
- putc ('\n', out);
-
- /* Bar. */
- fputs (" .", out);
- for (bitset_bindex i = 0; i < hsize; ++i)
- putc ('-', out);
- fputs (".\n", out);
-
- /* Contents. */
- for (bitset_bindex i = 0; bset[i]; ++i)
- {
- fprintf (out, "%2lu|", (unsigned long) i);
- for (bitset_bindex j = 0; j < hsize; ++j)
- fputs (bitset_test (bset[i], j) ? "1" : " ", out);
- fputs ("|\n", out);
- }
-
- /* Bar. */
- fputs (" `", out);
- for (bitset_bindex i = 0; i < hsize; ++i)
- putc ('-', out);
- fputs ("'\n", out);
-
- /* End title. */
- fprintf (out, "%s END\n\n", title);
-}
diff --git a/contrib/tools/bison/lib/bitsetv-print.h b/contrib/tools/bison/lib/bitsetv-print.h
deleted file mode 100644
index b706b04a8d3..00000000000
--- a/contrib/tools/bison/lib/bitsetv-print.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Bitset vectors.
-
- Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation,
- Inc.
-
- Contributed by Akim Demaille ([email protected]).
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef _BITSETV_PRINT_H
-#define _BITSETV_PRINT_H
-
-#include "bitsetv.h"
-
-/* Dump vector of bitsets as a matrix. */
-void bitsetv_matrix_dump (FILE *, const char *, bitsetv);
-
-#endif /* _BITSETV_H */
diff --git a/contrib/tools/bison/lib/bitsetv.c b/contrib/tools/bison/lib/bitsetv.c
index 7077795d6df..e3cc5845a76 100644
--- a/contrib/tools/bison/lib/bitsetv.c
+++ b/contrib/tools/bison/lib/bitsetv.c
@@ -1,6 +1,6 @@
/* Bitset vectors.
- Copyright (C) 2001-2002, 2004-2006, 2009-2015, 2018 Free Software
+ Copyright (C) 2001-2002, 2004-2006, 2009-2015, 2018-2019 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -22,6 +22,8 @@
#include <stdlib.h>
+#include "xalloc.h"
+
/* Create a vector of N_VECS bitsets, each of N_BITS, and of
type TYPE. */
@@ -146,3 +148,51 @@ debug_bitsetv (bitsetv bsetv)
fprintf (stderr, "\n");
}
+
+
+/*--------------------------------------------------------.
+| Display the MATRIX array of SIZE bitsets of size SIZE. |
+`--------------------------------------------------------*/
+
+void
+bitsetv_matrix_dump (FILE *out, const char *title, bitsetv bset)
+{
+ bitset_bindex hsize = bitset_size (bset[0]);
+
+ /* Title. */
+ fprintf (out, "%s BEGIN\n", title);
+
+ /* Column numbers. */
+ fputs (" ", out);
+ for (bitset_bindex i = 0; i < hsize; ++i)
+ putc (i / 10 ? '0' + i / 10 : ' ', out);
+ putc ('\n', out);
+ fputs (" ", out);
+ for (bitset_bindex i = 0; i < hsize; ++i)
+ fprintf (out, "%d", (int) (i % 10));
+ putc ('\n', out);
+
+ /* Bar. */
+ fputs (" .", out);
+ for (bitset_bindex i = 0; i < hsize; ++i)
+ putc ('-', out);
+ fputs (".\n", out);
+
+ /* Contents. */
+ for (bitset_bindex i = 0; bset[i]; ++i)
+ {
+ fprintf (out, "%2lu|", (unsigned long) i);
+ for (bitset_bindex j = 0; j < hsize; ++j)
+ fputs (bitset_test (bset[i], j) ? "1" : " ", out);
+ fputs ("|\n", out);
+ }
+
+ /* Bar. */
+ fputs (" `", out);
+ for (bitset_bindex i = 0; i < hsize; ++i)
+ putc ('-', out);
+ fputs ("'\n", out);
+
+ /* End title. */
+ fprintf (out, "%s END\n\n", title);
+}
diff --git a/contrib/tools/bison/lib/bitsetv.h b/contrib/tools/bison/lib/bitsetv.h
index 60777a21e03..798b70d9b42 100644
--- a/contrib/tools/bison/lib/bitsetv.h
+++ b/contrib/tools/bison/lib/bitsetv.h
@@ -1,6 +1,6 @@
/* Bitset vectors.
- Copyright (C) 2002, 2004, 2009-2015, 2018 Free Software Foundation,
+ Copyright (C) 2002, 2004, 2009-2015, 2018-2019 Free Software Foundation,
Inc.
Contributed by Michael Hayes ([email protected]).
@@ -58,4 +58,7 @@ void bitsetv_dump (FILE *, const char *, const char *, bitsetv);
/* Function to debug vector of bitsets from debugger. */
void debug_bitsetv (bitsetv);
+/* Dump vector of bitsets as a matrix. */
+void bitsetv_matrix_dump (FILE *, const char *, bitsetv);
+
#endif /* _BITSETV_H */
diff --git a/contrib/tools/bison/lib/c-ctype.h b/contrib/tools/bison/lib/c-ctype.h
index d55d4f64e4f..4d521763843 100644
--- a/contrib/tools/bison/lib/c-ctype.h
+++ b/contrib/tools/bison/lib/c-ctype.h
@@ -5,7 +5,7 @@
<ctype.h> functions' behaviour depends on the current locale set via
setlocale.
- Copyright (C) 2000-2003, 2006, 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2000-2003, 2006, 2008-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/c-strcase.h b/contrib/tools/bison/lib/c-strcase.h
index 41f439e8de7..b67c9b5da0e 100644
--- a/contrib/tools/bison/lib/c-strcase.h
+++ b/contrib/tools/bison/lib/c-strcase.h
@@ -1,5 +1,5 @@
/* Case-insensitive string comparison functions in C locale.
- Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2018 Free Software
+ Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2019 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/c-strcasecmp.c b/contrib/tools/bison/lib/c-strcasecmp.c
index 2b1ac99bb60..ec50f1abe76 100644
--- a/contrib/tools/bison/lib/c-strcasecmp.c
+++ b/contrib/tools/bison/lib/c-strcasecmp.c
@@ -1,5 +1,5 @@
/* c-strcasecmp.c -- case insensitive string comparator in C locale
- Copyright (C) 1998-1999, 2005-2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 1998-1999, 2005-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/c-strcaseeq.h b/contrib/tools/bison/lib/c-strcaseeq.h
index 9bde9de6afe..bcc81fc388d 100644
--- a/contrib/tools/bison/lib/c-strcaseeq.h
+++ b/contrib/tools/bison/lib/c-strcaseeq.h
@@ -1,5 +1,5 @@
/* Optimized case-insensitive string comparison in C locale.
- Copyright (C) 2001-2002, 2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2007, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
diff --git a/contrib/tools/bison/lib/c-strncasecmp.c b/contrib/tools/bison/lib/c-strncasecmp.c
index 8151c1a8340..513c353f6c2 100644
--- a/contrib/tools/bison/lib/c-strncasecmp.c
+++ b/contrib/tools/bison/lib/c-strncasecmp.c
@@ -1,5 +1,5 @@
/* c-strncasecmp.c -- case insensitive string comparator in C locale
- Copyright (C) 1998-1999, 2005-2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 1998-1999, 2005-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/careadlinkat.c b/contrib/tools/bison/lib/careadlinkat.c
new file mode 100644
index 00000000000..e56d5030856
--- /dev/null
+++ b/contrib/tools/bison/lib/careadlinkat.c
@@ -0,0 +1,160 @@
+/* Read symbolic links into a buffer without size limitation, relative to fd.
+
+ Copyright (C) 2001, 2003-2004, 2007, 2009-2019 Free Software Foundation,
+ Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
+
+#include <config.h>
+
+#include "careadlinkat.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <string.h>
+#include <unistd.h>
+
+/* Define this independently so that stdint.h is not a prerequisite. */
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
+#ifndef SSIZE_MAX
+# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
+#endif
+
+#include "allocator.h"
+
+/* Assuming the current directory is FD, get the symbolic link value
+ of FILENAME as a null-terminated string and put it into a buffer.
+ If FD is AT_FDCWD, FILENAME is interpreted relative to the current
+ working directory, as in openat.
+
+ If the link is small enough to fit into BUFFER put it there.
+ BUFFER's size is BUFFER_SIZE, and BUFFER can be null
+ if BUFFER_SIZE is zero.
+
+ If the link is not small, put it into a dynamically allocated
+ buffer managed by ALLOC. It is the caller's responsibility to free
+ the returned value if it is nonnull and is not BUFFER. A null
+ ALLOC stands for the standard allocator.
+
+ The PREADLINKAT function specifies how to read links. It operates
+ like POSIX readlinkat()
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>
+ but can assume that its first argument is the same as FD.
+
+ If successful, return the buffer address; otherwise return NULL and
+ set errno. */
+
+char *
+careadlinkat (int fd, char const *filename,
+ char *buffer, size_t buffer_size,
+ struct allocator const *alloc,
+ ssize_t (*preadlinkat) (int, char const *, char *, size_t))
+{
+ char *buf;
+ size_t buf_size;
+ size_t buf_size_max =
+ SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
+ char stack_buf[1024];
+
+ if (! alloc)
+ alloc = &stdlib_allocator;
+
+ if (! buffer_size)
+ {
+ /* Allocate the initial buffer on the stack. This way, in the
+ common case of a symlink of small size, we get away with a
+ single small malloc() instead of a big malloc() followed by a
+ shrinking realloc(). */
+ buffer = stack_buf;
+ buffer_size = sizeof stack_buf;
+ }
+
+ buf = buffer;
+ buf_size = buffer_size;
+
+ do
+ {
+ /* Attempt to read the link into the current buffer. */
+ ssize_t link_length = preadlinkat (fd, filename, buf, buf_size);
+ size_t link_size;
+ if (link_length < 0)
+ {
+ /* On AIX 5L v5.3 and HP-UX 11i v2 04/09, readlink returns -1
+ with errno == ERANGE if the buffer is too small. */
+ int readlinkat_errno = errno;
+ if (readlinkat_errno != ERANGE)
+ {
+ if (buf != buffer)
+ {
+ alloc->free (buf);
+ errno = readlinkat_errno;
+ }
+ return NULL;
+ }
+ }
+
+ link_size = link_length;
+
+ if (link_size < buf_size)
+ {
+ buf[link_size++] = '\0';
+
+ if (buf == stack_buf)
+ {
+ char *b = (char *) alloc->allocate (link_size);
+ buf_size = link_size;
+ if (! b)
+ break;
+ memcpy (b, buf, link_size);
+ buf = b;
+ }
+ else if (link_size < buf_size && buf != buffer && alloc->reallocate)
+ {
+ /* Shrink BUF before returning it. */
+ char *b = (char *) alloc->reallocate (buf, link_size);
+ if (b)
+ buf = b;
+ }
+
+ return buf;
+ }
+
+ if (buf != buffer)
+ alloc->free (buf);
+
+ if (buf_size <= buf_size_max / 2)
+ buf_size *= 2;
+ else if (buf_size < buf_size_max)
+ buf_size = buf_size_max;
+ else if (buf_size_max < SIZE_MAX)
+ {
+ errno = ENAMETOOLONG;
+ return NULL;
+ }
+ else
+ break;
+ buf = (char *) alloc->allocate (buf_size);
+ }
+ while (buf);
+
+ if (alloc->die)
+ alloc->die (buf_size);
+ errno = ENOMEM;
+ return NULL;
+}
diff --git a/contrib/tools/bison/lib/careadlinkat.h b/contrib/tools/bison/lib/careadlinkat.h
new file mode 100644
index 00000000000..68b69aa8893
--- /dev/null
+++ b/contrib/tools/bison/lib/careadlinkat.h
@@ -0,0 +1,67 @@
+/* Read symbolic links into a buffer without size limitation, relative to fd.
+
+ Copyright (C) 2011-2019 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
+
+#ifndef _GL_CAREADLINKAT_H
+#define _GL_CAREADLINKAT_H
+
+#include <fcntl.h>
+#include <unistd.h>
+
+struct allocator;
+
+/* Assuming the current directory is FD, get the symbolic link value
+ of FILENAME as a null-terminated string and put it into a buffer.
+ If FD is AT_FDCWD, FILENAME is interpreted relative to the current
+ working directory, as in openat.
+
+ If the link is small enough to fit into BUFFER put it there.
+ BUFFER's size is BUFFER_SIZE, and BUFFER can be null
+ if BUFFER_SIZE is zero.
+
+ If the link is not small, put it into a dynamically allocated
+ buffer managed by ALLOC. It is the caller's responsibility to free
+ the returned value if it is nonnull and is not BUFFER.
+
+ The PREADLINKAT function specifies how to read links. It operates
+ like POSIX readlinkat()
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>
+ but can assume that its first argument is the same as FD.
+
+ If successful, return the buffer address; otherwise return NULL and
+ set errno. */
+
+char *careadlinkat (int fd, char const *filename,
+ char *buffer, size_t buffer_size,
+ struct allocator const *alloc,
+ ssize_t (*preadlinkat) (int, char const *,
+ char *, size_t));
+
+/* Suitable value for careadlinkat's FD argument. */
+#if HAVE_READLINKAT
+/* AT_FDCWD is declared in <fcntl.h>. */
+#else
+/* Define AT_FDCWD independently, so that the careadlinkat module does
+ not depend on the fcntl-h module. We might as well use the same value
+ as fcntl-h. */
+# ifndef AT_FDCWD
+# define AT_FDCWD (-3041965)
+# endif
+#endif
+
+#endif /* _GL_CAREADLINKAT_H */
diff --git a/contrib/tools/bison/lib/cloexec.c b/contrib/tools/bison/lib/cloexec.c
index 238ab188866..db425766a0e 100644
--- a/contrib/tools/bison/lib/cloexec.c
+++ b/contrib/tools/bison/lib/cloexec.c
@@ -1,6 +1,6 @@
/* cloexec.c - set or clear the close-on-exec descriptor flag
- Copyright (C) 1991, 2004-2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 1991, 2004-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/cloexec.h b/contrib/tools/bison/lib/cloexec.h
index 59028058e6d..06ad945d8e2 100644
--- a/contrib/tools/bison/lib/cloexec.h
+++ b/contrib/tools/bison/lib/cloexec.h
@@ -1,6 +1,6 @@
/* cloexec.c - set or clear the close-on-exec descriptor flag
- Copyright (C) 2004, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/close-stream.c b/contrib/tools/bison/lib/close-stream.c
index 3d5a52ebd85..5458c4f29f3 100644
--- a/contrib/tools/bison/lib/close-stream.c
+++ b/contrib/tools/bison/lib/close-stream.c
@@ -1,6 +1,6 @@
/* Close a stream, with nicer error checking than fclose's.
- Copyright (C) 1998-2002, 2004, 2006-2018 Free Software Foundation, Inc.
+ Copyright (C) 1998-2002, 2004, 2006-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/close.c b/contrib/tools/bison/lib/close.c
index 01c326a28c7..40ce845bc33 100644
--- a/contrib/tools/bison/lib/close.c
+++ b/contrib/tools/bison/lib/close.c
@@ -1,5 +1,5 @@
/* close replacement.
- Copyright (C) 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2008-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/closeout.c b/contrib/tools/bison/lib/closeout.c
index 0672732b634..4a604ec35d4 100644
--- a/contrib/tools/bison/lib/closeout.c
+++ b/contrib/tools/bison/lib/closeout.c
@@ -1,6 +1,6 @@
/* Close standard output and standard error, exiting with a diagnostic on error.
- Copyright (C) 1998-2002, 2004, 2006, 2008-2018 Free Software Foundation,
+ Copyright (C) 1998-2002, 2004, 2006, 2008-2019 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/closeout.h b/contrib/tools/bison/lib/closeout.h
index 6629d499349..ac89f760a95 100644
--- a/contrib/tools/bison/lib/closeout.h
+++ b/contrib/tools/bison/lib/closeout.h
@@ -1,6 +1,6 @@
/* Close standard output and standard error.
- Copyright (C) 1998, 2000, 2003-2004, 2006, 2008-2018 Free Software
+ Copyright (C) 1998, 2000, 2003-2004, 2006, 2008-2019 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/concat-filename.c b/contrib/tools/bison/lib/concat-filename.c
index 578cb21fe35..df0e170a89c 100644
--- a/contrib/tools/bison/lib/concat-filename.c
+++ b/contrib/tools/bison/lib/concat-filename.c
@@ -1,5 +1,5 @@
/* Construct a full filename from a directory and a relative filename.
- Copyright (C) 2001-2004, 2006-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004, 2006-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/contrib/tools/bison/lib/concat-filename.h b/contrib/tools/bison/lib/concat-filename.h
index cca9597d074..4448b783fce 100644
--- a/contrib/tools/bison/lib/concat-filename.h
+++ b/contrib/tools/bison/lib/concat-filename.h
@@ -1,5 +1,5 @@
/* Construct a full filename from a directory and a relative filename.
- Copyright (C) 2001-2004, 2007-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004, 2007-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/config-linux.h b/contrib/tools/bison/lib/config-linux.h
index 7c6759f4636..9c4e201410b 100644
--- a/contrib/tools/bison/lib/config-linux.h
+++ b/contrib/tools/bison/lib/config-linux.h
@@ -54,6 +54,9 @@
language is requested. */
/* #undef ENABLE_NLS */
+/* Define to 1 if the package shall run at any location in the file system. */
+/* #undef ENABLE_RELOCATABLE */
+
/* Define this to 1 if F_DUPFD behavior does not match POSIX */
/* #undef FCNTL_DUPFD_BUGGY */
@@ -73,6 +76,10 @@
/* Define to 1 if fopen() fails to recognize a trailing slash. */
/* #undef FOPEN_TRAILING_SLASH_BUG */
+/* Define to 1 if realpath() can malloc memory, always gives an absolute path,
+ and handles trailing slash correctly. */
+#define FUNC_REALPATH_WORKS 1
+
/* Define if gettimeofday clobbers the localtime buffer. */
/* #undef GETTIMEOFDAY_CLOBBERS_LOCALTIME */
@@ -81,6 +88,10 @@
#define GETTIMEOFDAY_TIMEZONE void
/* Define to a C preprocessor expression that evaluates to 1 or 0, depending
+ whether the gnulib module canonicalize-lgpl shall be considered present. */
+#define GNULIB_CANONICALIZE_LGPL 1
+
+/* Define to a C preprocessor expression that evaluates to 1 or 0, depending
whether the gnulib module close-stream shall be considered present. */
#define GNULIB_CLOSE_STREAM 1
@@ -102,7 +113,7 @@
/* Define to a C preprocessor expression that evaluates to 1 or 0, depending
whether the gnulib module lock shall be considered present. */
-#define GNULIB_LOCK 1
+/* #undef GNULIB_LOCK */
/* Define to a C preprocessor expression that evaluates to 1 or 0, depending
whether the gnulib module malloc-gnu shall be considered present. */
@@ -134,11 +145,18 @@
/* Define to a C preprocessor expression that evaluates to 1 or 0, depending
whether the gnulib module strerror_r-posix shall be considered present. */
-#define GNULIB_STRERROR_R_POSIX 1
+/* #undef GNULIB_STRERROR_R_POSIX */
/* Define to 1 when the gnulib module calloc-posix should be tested. */
#define GNULIB_TEST_CALLOC_POSIX 1
+/* Define to 1 when the gnulib module canonicalize_file_name should be tested.
+ */
+#define GNULIB_TEST_CANONICALIZE_FILE_NAME 1
+
+/* Define to 1 when the gnulib module chdir should be tested. */
+/* #undef GNULIB_TEST_CHDIR */
+
/* Define to 1 when the gnulib module cloexec should be tested. */
#define GNULIB_TEST_CLOEXEC 1
@@ -167,7 +185,7 @@
#define GNULIB_TEST_FREXPL 1
/* Define to 1 when the gnulib module fstat should be tested. */
-#define GNULIB_TEST_FSTAT 1
+/* #undef GNULIB_TEST_FSTAT */
/* Define to 1 when the gnulib module getdtablesize should be tested. */
#define GNULIB_TEST_GETDTABLESIZE 1
@@ -194,7 +212,7 @@
#define GNULIB_TEST_LDEXPL 1
/* Define to 1 when the gnulib module lstat should be tested. */
-#define GNULIB_TEST_LSTAT 1
+/* #undef GNULIB_TEST_LSTAT */
/* Define to 1 when the gnulib module malloc-posix should be tested. */
#define GNULIB_TEST_MALLOC_POSIX 1
@@ -266,11 +284,23 @@
#define GNULIB_TEST_RAISE 1
/* Define to 1 when the gnulib module rawmemchr should be tested. */
-#define GNULIB_TEST_RAWMEMCHR 1
+/* #undef GNULIB_TEST_RAWMEMCHR */
+
+/* Define to 1 when the gnulib module readlink should be tested. */
+#define GNULIB_TEST_READLINK 1
/* Define to 1 when the gnulib module realloc-posix should be tested. */
#define GNULIB_TEST_REALLOC_POSIX 1
+/* Define to 1 when the gnulib module realpath should be tested. */
+#define GNULIB_TEST_REALPATH 1
+
+/* Define to 1 when the gnulib module rename should be tested. */
+#define GNULIB_TEST_RENAME 1
+
+/* Define to 1 when the gnulib module rmdir should be tested. */
+/* #undef GNULIB_TEST_RMDIR */
+
/* Define to 1 when the gnulib module sigaction should be tested. */
#define GNULIB_TEST_SIGACTION 1
@@ -287,13 +317,13 @@
#define GNULIB_TEST_SPRINTF_POSIX 1
/* Define to 1 when the gnulib module stat should be tested. */
-#define GNULIB_TEST_STAT 1
+/* #undef GNULIB_TEST_STAT */
/* Define to 1 when the gnulib module stpcpy should be tested. */
#define GNULIB_TEST_STPCPY 1
/* Define to 1 when the gnulib module strchrnul should be tested. */
-#define GNULIB_TEST_STRCHRNUL 1
+/* #undef GNULIB_TEST_STRCHRNUL */
/* Define to 1 when the gnulib module strdup should be tested. */
#define GNULIB_TEST_STRDUP 1
@@ -302,13 +332,13 @@
#define GNULIB_TEST_STRERROR 1
/* Define to 1 when the gnulib module strerror_r should be tested. */
-#define GNULIB_TEST_STRERROR_R 1
+/* #undef GNULIB_TEST_STRERROR_R */
/* Define to 1 when the gnulib module strndup should be tested. */
#define GNULIB_TEST_STRNDUP 1
/* Define to 1 when the gnulib module strnlen should be tested. */
-#define GNULIB_TEST_STRNLEN 1
+/* #undef GNULIB_TEST_STRNLEN */
/* Define to 1 when the gnulib module strverscmp should be tested. */
#define GNULIB_TEST_STRVERSCMP 1
@@ -351,6 +381,9 @@
/* Define if the 'calloc' function is POSIX compliant. */
#define HAVE_CALLOC_POSIX 1
+/* Define to 1 if you have the `canonicalize_file_name' function. */
+#define HAVE_CANONICALIZE_FILE_NAME 1
+
/* Define to 1 if you have the `catgets' function. */
#define HAVE_CATGETS 1
@@ -494,6 +527,10 @@
don't. */
#define HAVE_DECL_PUTC_UNLOCKED 1
+/* Define to 1 if you have the declaration of `setenv', and to 0 if you don't.
+ */
+#define HAVE_DECL_SETENV 1
+
/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
don't. */
#define HAVE_DECL_SNPRINTF 1
@@ -560,6 +597,9 @@
/* Define if the frexp function is available in libc. */
#define HAVE_FREXP_IN_LIBC 1
+/* Define to 1 if you have the `getcwd' function. */
+#define HAVE_GETCWD 1
+
/* Define to 1 if you have the `getdtablesize' function. */
#define HAVE_GETDTABLESIZE 1
@@ -604,7 +644,7 @@
#define HAVE_ISNAND_IN_LIBC 1
/* Define if the isnan(float) function is available in libc. */
-#define HAVE_ISNANF_IN_LIBC 1
+/* #undef HAVE_ISNANF_IN_LIBC */
/* Define if the isnan(long double) function is available in libc. */
#define HAVE_ISNANL_IN_LIBC 1
@@ -627,6 +667,9 @@
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
+/* Define to 1 if you have the `link' function. */
+#define HAVE_LINK 1
+
/* Define to 1 if you have the <locale.h> header file. */
#define HAVE_LOCALE_H 1
@@ -636,6 +679,9 @@
/* Define to 1 if you have the `lstat' function. */
#define HAVE_LSTAT 1
+/* Define to 1 if you have the <mach-o/dyld.h> header file. */
+/* #undef HAVE_MACH_O_DYLD_H */
+
/* Define to 1 if your system has a GNU libc compatible 'malloc' function, and
to 0 otherwise. */
#define HAVE_MALLOC_GNU 1
@@ -709,10 +755,10 @@
#define HAVE_POSIX_SPAWN_FILE_ACTIONS_T 1
/* Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE. */
-#define HAVE_PTHREAD_MUTEX_RECURSIVE 1
+/* #undef HAVE_PTHREAD_MUTEX_RECURSIVE */
/* Define if the POSIX multithreading library has read/write locks. */
-#define HAVE_PTHREAD_RWLOCK 1
+/* #undef HAVE_PTHREAD_RWLOCK */
/* Define if the 'pthread_rwlock_rdlock' function prefers a writer to a
reader. */
@@ -722,11 +768,20 @@
#define HAVE_RAISE 1
/* Define to 1 if you have the `rawmemchr' function. */
-#define HAVE_RAWMEMCHR 1
+/* #undef HAVE_RAWMEMCHR */
+
+/* Define to 1 if you have the `readlink' function. */
+#define HAVE_READLINK 1
+
+/* Define to 1 if you have the `readlinkat' function. */
+#define HAVE_READLINKAT 1
/* Define if the 'realloc' function is POSIX compliant. */
#define HAVE_REALLOC_POSIX 1
+/* Define to 1 if you have the `realpath' function. */
+#define HAVE_REALPATH 1
+
/* Define to 1 if 'long double' and 'double' have the same representation. */
/* #undef HAVE_SAME_LONG_DOUBLE_AS_DOUBLE */
@@ -739,12 +794,18 @@
/* Define to 1 if you have the `sched_setscheduler' function. */
/* #undef HAVE_SCHED_SETSCHEDULER */
+/* Define to 1 if you have the <search.h> header file. */
+#define HAVE_SEARCH_H 1
+
/* Define to 1 if you have the `setdtablesize' function. */
/* #undef HAVE_SETDTABLESIZE */
/* Define to 1 if you have the `setegid' function. */
/* #undef HAVE_SETEGID */
+/* Define to 1 if you have the `setenv' function. */
+#define HAVE_SETENV 1
+
/* Define to 1 if you have the `seteuid' function. */
/* #undef HAVE_SETEUID */
@@ -806,7 +867,7 @@
#define HAVE_STPCPY 1
/* Define to 1 if you have the `strchrnul' function. */
-#define HAVE_STRCHRNUL 1
+/* #undef HAVE_STRCHRNUL */
/* Define to 1 if you have the `strdup' function. */
#define HAVE_STRDUP 1
@@ -839,7 +900,7 @@
/* #undef HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC */
/* Define to 1 if `st_atim.tv_nsec' is a member of `struct stat'. */
-#define HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC 1
+/* #undef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC */
/* Define to 1 if `st_birthtimensec' is a member of `struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC */
@@ -898,6 +959,9 @@
/* Define to 1 if you have the `towlower' function. */
#define HAVE_TOWLOWER 1
+/* Define to 1 if you have the `tsearch' function. */
+#define HAVE_TSEARCH 1
+
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
@@ -958,6 +1022,9 @@
/* Define to 1 if the system has the type `_Bool'. */
#define HAVE__BOOL 1
+/* Define to 1 if you have the `_NSGetExecutablePath' function. */
+/* #undef HAVE__NSGETEXECUTABLEPATH */
+
/* Define to 1 if you have the `_set_invalid_parameter_handler' function. */
/* #undef HAVE__SET_INVALID_PARAMETER_HANDLER */
@@ -967,6 +1034,9 @@
/* Define to 1 if you have the `__xpg_strerror_r' function. */
#define HAVE___XPG_STRERROR_R 1
+/* Define to the value of ${prefix}, as a string. */
+#define INSTALLPREFIX "/var/empty/bison-3.3.2"
+
/* Define as the bit index in the word where to find bit 0 of the exponent of
'long double'. */
/* #undef LDBL_EXPBIT0_BIT */
@@ -1080,13 +1150,13 @@
#define PACKAGE_BUGREPORT "[email protected]"
/* The copyright year for this package */
-#define PACKAGE_COPYRIGHT_YEAR 2018
+#define PACKAGE_COPYRIGHT_YEAR 2019
/* Define to the full name of this package. */
#define PACKAGE_NAME "GNU Bison"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "GNU Bison 3.2.4"
+#define PACKAGE_STRING "GNU Bison 3.3.2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "bison"
@@ -1095,7 +1165,7 @@
#define PACKAGE_URL "http://www.gnu.org/software/bison/"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "3.2.4"
+#define PACKAGE_VERSION "3.3.2"
/* Define if <inttypes.h> exists and defines unusable PRI* macros. */
/* #undef PRI_MACROS_BROKEN */
@@ -1111,6 +1181,25 @@
'ptrdiff_t'. */
/* #undef PTRDIFF_T_SUFFIX */
+/* Define to 1 if readlink fails to recognize a trailing slash. */
+/* #undef READLINK_TRAILING_SLASH_BUG */
+
+/* Define if rename does not work when the destination file exists, as on
+ Cygwin 1.5 or Windows. */
+/* #undef RENAME_DEST_EXISTS_BUG */
+
+/* Define if rename fails to leave hard links alone, as on NetBSD 1.6 or
+ Cygwin 1.5. */
+/* #undef RENAME_HARD_LINK_BUG */
+
+/* Define if rename does not correctly handle slashes on the destination
+ argument, such as on Solaris 11 or NetBSD 1.6. */
+/* #undef RENAME_TRAILING_SLASH_DEST_BUG */
+
+/* Define if rename does not correctly handle slashes on the source argument,
+ such as on Solaris 9 or cygwin 1.5. */
+/* #undef RENAME_TRAILING_SLASH_SOURCE_BUG */
+
/* Define if fprintf is overridden by a POSIX compliant gnulib implementation.
*/
#define REPLACE_FPRINTF_POSIX 1
@@ -1178,7 +1267,7 @@
/* Define to 1 if the type of the st_atim member of a struct stat is struct
timespec. */
-#define TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC 1
+/* #undef TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC */
/* Define to 1 if unlink() on a parent directory may succeed */
/* #undef UNLINK_PARENT_BUG */
@@ -1290,7 +1379,7 @@
/* #undef USE_WINDOWS_THREADS */
/* Version number of package */
-#define VERSION "3.2.4"
+#define VERSION "3.3.2"
/* Define to 1 if unsetenv returns void instead of int. */
/* #undef VOID_UNSETENV */
diff --git a/contrib/tools/bison/lib/config-win.h b/contrib/tools/bison/lib/config-win.h
index 25076ea809a..4e3fc4ebfa9 100644
--- a/contrib/tools/bison/lib/config-win.h
+++ b/contrib/tools/bison/lib/config-win.h
@@ -1226,7 +1226,7 @@ char *strsignal (int signum);
/* #undef PACKAGE_PACKAGER_VERSION */
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "GNU Bison 3.2.4"
+#define PACKAGE_STRING "GNU Bison 3.3.2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "m4"
@@ -1235,7 +1235,7 @@ char *strsignal (int signum);
#define PACKAGE_URL "http://www.gnu.org/software/m4/"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "3.2.4"
+#define PACKAGE_VERSION "3.3.2"
/* Define if <inttypes.h> exists and defines unusable PRI* macros. */
/* #undef PRI_MACROS_BROKEN */
@@ -1398,7 +1398,7 @@ char *strsignal (int signum);
/* #undef USE_WINDOWS_THREADS */
/* Version number of package */
-#define VERSION "3.2.4"
+#define VERSION "3.3.2"
/* Define to 1 if unsetenv returns void instead of int. */
/* #undef VOID_UNSETENV */
diff --git a/contrib/tools/bison/lib/configmake-linux.h b/contrib/tools/bison/lib/configmake-linux.h
index bd096ef0053..14fe253583c 100644
--- a/contrib/tools/bison/lib/configmake-linux.h
+++ b/contrib/tools/bison/lib/configmake-linux.h
@@ -1,28 +1,28 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
-#define PREFIX "/var/empty/bison-3.2.4"
-#define EXEC_PREFIX "/var/empty/bison-3.2.4"
-#define BINDIR "/var/empty/bison-3.2.4/bin"
-#define SBINDIR "/var/empty/bison-3.2.4/sbin"
-#define LIBEXECDIR "/var/empty/bison-3.2.4/libexec"
-#define DATAROOTDIR "/var/empty/bison-3.2.4/share"
-#define DATADIR "/var/empty/bison-3.2.4/share"
-#define SYSCONFDIR "/var/empty/bison-3.2.4/etc"
-#define SHAREDSTATEDIR "/var/empty/bison-3.2.4/com"
-#define LOCALSTATEDIR "/var/empty/bison-3.2.4/var"
-#define RUNSTATEDIR "/var/empty/bison-3.2.4/var/run"
-#define INCLUDEDIR "/var/empty/bison-3.2.4/include"
+#define PREFIX "/var/empty/bison-3.3.2"
+#define EXEC_PREFIX "/var/empty/bison-3.3.2"
+#define BINDIR "/var/empty/bison-3.3.2/bin"
+#define SBINDIR "/var/empty/bison-3.3.2/sbin"
+#define LIBEXECDIR "/var/empty/bison-3.3.2/libexec"
+#define DATAROOTDIR "/var/empty/bison-3.3.2/share"
+#define DATADIR "/var/empty/bison-3.3.2/share"
+#define SYSCONFDIR "/var/empty/bison-3.3.2/etc"
+#define SHAREDSTATEDIR "/var/empty/bison-3.3.2/com"
+#define LOCALSTATEDIR "/var/empty/bison-3.3.2/var"
+#define RUNSTATEDIR "/var/empty/bison-3.3.2/var/run"
+#define INCLUDEDIR "/var/empty/bison-3.3.2/include"
#define OLDINCLUDEDIR "/usr/include"
-#define DOCDIR "/var/empty/bison-3.2.4/share/doc/bison"
-#define INFODIR "/var/empty/bison-3.2.4/share/info"
-#define HTMLDIR "/var/empty/bison-3.2.4/share/doc/bison"
-#define DVIDIR "/var/empty/bison-3.2.4/share/doc/bison"
-#define PDFDIR "/var/empty/bison-3.2.4/share/doc/bison"
-#define PSDIR "/var/empty/bison-3.2.4/share/doc/bison"
-#define LIBDIR "/var/empty/bison-3.2.4/lib"
-#define LISPDIR "/var/empty/bison-3.2.4/share/emacs/site-lisp"
-#define LOCALEDIR "/var/empty/bison-3.2.4/share/locale"
-#define MANDIR "/var/empty/bison-3.2.4/share/man"
-#define PKGDATADIR "/var/empty/bison-3.2.4/share/bison"
-#define PKGINCLUDEDIR "/var/empty/bison-3.2.4/include/bison"
-#define PKGLIBDIR "/var/empty/bison-3.2.4/lib/bison"
-#define PKGLIBEXECDIR "/var/empty/bison-3.2.4/libexec/bison"
+#define DOCDIR "/var/empty/bison-3.3.2/share/doc/bison"
+#define INFODIR "/var/empty/bison-3.3.2/share/info"
+#define HTMLDIR "/var/empty/bison-3.3.2/share/doc/bison"
+#define DVIDIR "/var/empty/bison-3.3.2/share/doc/bison"
+#define PDFDIR "/var/empty/bison-3.3.2/share/doc/bison"
+#define PSDIR "/var/empty/bison-3.3.2/share/doc/bison"
+#define LIBDIR "/var/empty/bison-3.3.2/lib"
+#define LISPDIR "/var/empty/bison-3.3.2/share/emacs/site-lisp"
+#define LOCALEDIR "/var/empty/bison-3.3.2/share/locale"
+#define MANDIR "/var/empty/bison-3.3.2/share/man"
+#define PKGDATADIR "/var/empty/bison-3.3.2/share/bison"
+#define PKGINCLUDEDIR "/var/empty/bison-3.3.2/include/bison"
+#define PKGLIBDIR "/var/empty/bison-3.3.2/lib/bison"
+#define PKGLIBEXECDIR "/var/empty/bison-3.3.2/libexec/bison"
diff --git a/contrib/tools/bison/lib/dirname-lgpl.c b/contrib/tools/bison/lib/dirname-lgpl.c
index a40f6a901fa..7cf89d8cf80 100644
--- a/contrib/tools/bison/lib/dirname-lgpl.c
+++ b/contrib/tools/bison/lib/dirname-lgpl.c
@@ -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-2018 Free Software
+ Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2019 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/dirname.c b/contrib/tools/bison/lib/dirname.c
index 766f862569c..1e042a5cdc9 100644
--- a/contrib/tools/bison/lib/dirname.c
+++ b/contrib/tools/bison/lib/dirname.c
@@ -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-2018 Free Software
+ Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2019 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/dirname.h b/contrib/tools/bison/lib/dirname.h
index 8b5111168d7..579165947f7 100644
--- a/contrib/tools/bison/lib/dirname.h
+++ b/contrib/tools/bison/lib/dirname.h
@@ -1,6 +1,6 @@
/* Take file names apart into directory and base names.
- Copyright (C) 1998, 2001, 2003-2006, 2009-2018 Free Software Foundation,
+ Copyright (C) 1998, 2001, 2003-2006, 2009-2019 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/dosname.h b/contrib/tools/bison/lib/dosname.h
index fef3b6daa1f..c0ab6848a58 100644
--- a/contrib/tools/bison/lib/dosname.h
+++ b/contrib/tools/bison/lib/dosname.h
@@ -1,6 +1,6 @@
/* File names on MS-DOS/Windows systems.
- Copyright (C) 2000-2001, 2004-2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2000-2001, 2004-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/dup-safer-flag.c b/contrib/tools/bison/lib/dup-safer-flag.c
index aa28194d535..485f7411bdb 100644
--- a/contrib/tools/bison/lib/dup-safer-flag.c
+++ b/contrib/tools/bison/lib/dup-safer-flag.c
@@ -1,7 +1,7 @@
/* Duplicate a file descriptor result, avoiding clobbering
STD{IN,OUT,ERR}_FILENO, with specific flags.
- Copyright (C) 2001, 2004-2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2004-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/dup-safer.c b/contrib/tools/bison/lib/dup-safer.c
index 1f1679ea18f..c0c5f2a914b 100644
--- a/contrib/tools/bison/lib/dup-safer.c
+++ b/contrib/tools/bison/lib/dup-safer.c
@@ -1,6 +1,6 @@
/* Invoke dup, but avoid some glitches.
- Copyright (C) 2001, 2004-2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2004-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/dup2.c b/contrib/tools/bison/lib/dup2.c
index ba417823e99..56a27944789 100644
--- a/contrib/tools/bison/lib/dup2.c
+++ b/contrib/tools/bison/lib/dup2.c
@@ -1,6 +1,6 @@
/* Duplicate an open file descriptor to a specified file descriptor.
- Copyright (C) 1999, 2004-2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2004-2007, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/error.c b/contrib/tools/bison/lib/error.c
index adc873391cb..7e532f0e486 100644
--- a/contrib/tools/bison/lib/error.c
+++ b/contrib/tools/bison/lib/error.c
@@ -1,5 +1,5 @@
/* Error handler for noninteractive utilities
- Copyright (C) 1990-1998, 2000-2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 1990-1998, 2000-2007, 2009-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/error.h b/contrib/tools/bison/lib/error.h
index 36401e1aa33..3759f8ad44e 100644
--- a/contrib/tools/bison/lib/error.h
+++ b/contrib/tools/bison/lib/error.h
@@ -1,5 +1,5 @@
/* Declaration for error-reporting function
- Copyright (C) 1995-1997, 2003, 2006, 2008-2018 Free Software Foundation,
+ Copyright (C) 1995-1997, 2003, 2006, 2008-2019 Free Software Foundation,
Inc.
This file is part of the GNU C Library.
diff --git a/contrib/tools/bison/lib/exitfail.c b/contrib/tools/bison/lib/exitfail.c
index 19c5cba049c..69b351372e5 100644
--- a/contrib/tools/bison/lib/exitfail.c
+++ b/contrib/tools/bison/lib/exitfail.c
@@ -1,6 +1,6 @@
/* Failure exit status
- Copyright (C) 2002-2003, 2005-2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2007, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/exitfail.h b/contrib/tools/bison/lib/exitfail.h
index a42057b11a9..480ad1a1663 100644
--- a/contrib/tools/bison/lib/exitfail.h
+++ b/contrib/tools/bison/lib/exitfail.h
@@ -1,6 +1,6 @@
/* Failure exit status
- Copyright (C) 2002, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/fatal-signal.c b/contrib/tools/bison/lib/fatal-signal.c
index 9d795f746db..1fe31d10f59 100644
--- a/contrib/tools/bison/lib/fatal-signal.c
+++ b/contrib/tools/bison/lib/fatal-signal.c
@@ -1,5 +1,5 @@
/* Emergency actions in case of a fatal signal.
- Copyright (C) 2003-2004, 2006-2018 Free Software Foundation, Inc.
+ Copyright (C) 2003-2004, 2006-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2003.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/fatal-signal.h b/contrib/tools/bison/lib/fatal-signal.h
index 41b4af7392b..a2e60d3a629 100644
--- a/contrib/tools/bison/lib/fatal-signal.h
+++ b/contrib/tools/bison/lib/fatal-signal.h
@@ -1,5 +1,5 @@
/* Emergency actions in case of a fatal signal.
- Copyright (C) 2003-2004, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2003-2004, 2009-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2003.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/fcntl.c b/contrib/tools/bison/lib/fcntl.c
index bdf1e5bbdae..e65f1b21c7d 100644
--- a/contrib/tools/bison/lib/fcntl.c
+++ b/contrib/tools/bison/lib/fcntl.c
@@ -1,6 +1,6 @@
/* Provide file descriptor control.
- Copyright (C) 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -545,7 +545,7 @@ rpl_fcntl_DUPFD_CLOEXEC (int fd, int target)
#ifdef __KLIBC__
static int
-klibc_fcntl (int fd, int action, /* arg */...);
+klibc_fcntl (int fd, int action, /* arg */...)
{
va_list arg_ptr;
int arg;
diff --git a/contrib/tools/bison/lib/fd-hook.c b/contrib/tools/bison/lib/fd-hook.c
index 95a0662bc04..78791198fa0 100644
--- a/contrib/tools/bison/lib/fd-hook.c
+++ b/contrib/tools/bison/lib/fd-hook.c
@@ -1,5 +1,5 @@
/* Hook for making file descriptor functions close(), ioctl() extensible.
- Copyright (C) 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2009-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2009.
This program is free software: you can redistribute it and/or modify it
diff --git a/contrib/tools/bison/lib/fd-hook.h b/contrib/tools/bison/lib/fd-hook.h
index dbc5b67a81a..bf07f0068b7 100644
--- a/contrib/tools/bison/lib/fd-hook.h
+++ b/contrib/tools/bison/lib/fd-hook.h
@@ -1,5 +1,5 @@
/* Hook for making file descriptor functions close(), ioctl() extensible.
- Copyright (C) 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
diff --git a/contrib/tools/bison/lib/fd-safer-flag.c b/contrib/tools/bison/lib/fd-safer-flag.c
index b7574848d72..7c026ef5415 100644
--- a/contrib/tools/bison/lib/fd-safer-flag.c
+++ b/contrib/tools/bison/lib/fd-safer-flag.c
@@ -1,7 +1,7 @@
/* Adjust a file descriptor result so that it avoids clobbering
STD{IN,OUT,ERR}_FILENO, with specific flags.
- Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/fd-safer.c b/contrib/tools/bison/lib/fd-safer.c
index 1ea9a4981dc..b5113e13673 100644
--- a/contrib/tools/bison/lib/fd-safer.c
+++ b/contrib/tools/bison/lib/fd-safer.c
@@ -1,6 +1,6 @@
/* Return a safer copy of a file descriptor.
- Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/filename.h b/contrib/tools/bison/lib/filename.h
index a7ad7e7e0c0..3ba31059f69 100644
--- a/contrib/tools/bison/lib/filename.h
+++ b/contrib/tools/bison/lib/filename.h
@@ -1,5 +1,5 @@
/* Basic filename support macros.
- Copyright (C) 2001-2004, 2007-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004, 2007-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/float+.h b/contrib/tools/bison/lib/float+.h
index 2cb858f6a84..5af861f7aeb 100644
--- a/contrib/tools/bison/lib/float+.h
+++ b/contrib/tools/bison/lib/float+.h
@@ -1,5 +1,5 @@
/* Supplemental information about the floating-point formats.
- Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2007.
This program is free software; you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/fopen-safer.c b/contrib/tools/bison/lib/fopen-safer.c
index faf7b664260..5d4a4a9e753 100644
--- a/contrib/tools/bison/lib/fopen-safer.c
+++ b/contrib/tools/bison/lib/fopen-safer.c
@@ -1,6 +1,6 @@
/* Invoke fopen, but avoid some glitches.
- Copyright (C) 2001, 2004-2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2004-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/fpending.c b/contrib/tools/bison/lib/fpending.c
index de370d4b10f..3c01285bb83 100644
--- a/contrib/tools/bison/lib/fpending.c
+++ b/contrib/tools/bison/lib/fpending.c
@@ -1,5 +1,5 @@
/* fpending.c -- return the number of pending output bytes on a stream
- Copyright (C) 2000, 2004, 2006-2007, 2009-2018 Free Software Foundation,
+ Copyright (C) 2000, 2004, 2006-2007, 2009-2019 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/fpending.h b/contrib/tools/bison/lib/fpending.h
index 2ff26bc6afc..097a3ef0717 100644
--- a/contrib/tools/bison/lib/fpending.h
+++ b/contrib/tools/bison/lib/fpending.h
@@ -1,6 +1,6 @@
/* Declare __fpending.
- Copyright (C) 2000, 2003, 2005-2006, 2009-2018 Free Software Foundation,
+ Copyright (C) 2000, 2003, 2005-2006, 2009-2019 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/fpucw.h b/contrib/tools/bison/lib/fpucw.h
index 0c048008857..caa51fe3bbb 100644
--- a/contrib/tools/bison/lib/fpucw.h
+++ b/contrib/tools/bison/lib/fpucw.h
@@ -1,5 +1,5 @@
/* Manipulating the FPU control word. -*- coding: utf-8 -*-
- Copyright (C) 2007-2018 Free Software Foundation, Inc.
+ Copyright (C) 2007-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2007.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/fseterr.c b/contrib/tools/bison/lib/fseterr.c
index 81f51edade3..8cd68e8ce7f 100644
--- a/contrib/tools/bison/lib/fseterr.c
+++ b/contrib/tools/bison/lib/fseterr.c
@@ -1,5 +1,5 @@
/* Set the error indicator of a stream.
- Copyright (C) 2007-2018 Free Software Foundation, Inc.
+ Copyright (C) 2007-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/fseterr.h b/contrib/tools/bison/lib/fseterr.h
index d61643313a1..7b57faa3d2e 100644
--- a/contrib/tools/bison/lib/fseterr.h
+++ b/contrib/tools/bison/lib/fseterr.h
@@ -1,5 +1,5 @@
/* Set the error indicator of a stream.
- Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/get-errno.c b/contrib/tools/bison/lib/get-errno.c
index fdce06586a5..36e07adaff7 100644
--- a/contrib/tools/bison/lib/get-errno.c
+++ b/contrib/tools/bison/lib/get-errno.c
@@ -1,7 +1,7 @@
/* get-errno.c - get and set errno.
- Copyright (C) 2002, 2006, 2009-2015, 2018 Free Software Foundation,
- Inc.
+ Copyright (C) 2002, 2006, 2009-2015, 2018-2019 Free Software
+ Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/get-errno.h b/contrib/tools/bison/lib/get-errno.h
index 39c9c8a1f74..c13ac6b319c 100644
--- a/contrib/tools/bison/lib/get-errno.h
+++ b/contrib/tools/bison/lib/get-errno.h
@@ -1,6 +1,7 @@
/* get-errno.h - get and set errno.
- Copyright (C) 2002, 2009-2015, 2018 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2009-2015, 2018-2019 Free Software Foundation,
+ Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/getdtablesize.c b/contrib/tools/bison/lib/getdtablesize.c
index ac05bc483cc..03a92435f0b 100644
--- a/contrib/tools/bison/lib/getdtablesize.c
+++ b/contrib/tools/bison/lib/getdtablesize.c
@@ -1,5 +1,5 @@
/* getdtablesize() function: Return maximum possible file descriptor value + 1.
- Copyright (C) 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2008-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2008.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/gethrxtime.c b/contrib/tools/bison/lib/gethrxtime.c
index 97e57ad577d..877596257a0 100644
--- a/contrib/tools/bison/lib/gethrxtime.c
+++ b/contrib/tools/bison/lib/gethrxtime.c
@@ -1,6 +1,6 @@
/* gethrxtime -- get high resolution real time
- Copyright (C) 2005-2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2005-2007, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/gethrxtime.h b/contrib/tools/bison/lib/gethrxtime.h
index bb781911e21..6491794554d 100644
--- a/contrib/tools/bison/lib/gethrxtime.h
+++ b/contrib/tools/bison/lib/gethrxtime.h
@@ -1,6 +1,6 @@
/* gethrxtime -- get high resolution real time
- Copyright (C) 2005, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/getopt.c b/contrib/tools/bison/lib/getopt.c
index 11e36eef815..8ee075a8091 100644
--- a/contrib/tools/bison/lib/getopt.c
+++ b/contrib/tools/bison/lib/getopt.c
@@ -1,5 +1,5 @@
/* Getopt for GNU.
- Copyright (C) 1987-2018 Free Software Foundation, Inc.
+ Copyright (C) 1987-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library and is also part of gnulib.
Patches to this file should be submitted to both projects.
diff --git a/contrib/tools/bison/lib/getopt1.c b/contrib/tools/bison/lib/getopt1.c
index 9c7fff4c73d..883aa6bbc91 100644
--- a/contrib/tools/bison/lib/getopt1.c
+++ b/contrib/tools/bison/lib/getopt1.c
@@ -1,5 +1,5 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
- Copyright (C) 1987-2018 Free Software Foundation, Inc.
+ Copyright (C) 1987-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library and is also part of gnulib.
Patches to this file should be submitted to both projects.
diff --git a/contrib/tools/bison/lib/getopt_int.h b/contrib/tools/bison/lib/getopt_int.h
index b0e9a6d0126..e63706f60ea 100644
--- a/contrib/tools/bison/lib/getopt_int.h
+++ b/contrib/tools/bison/lib/getopt_int.h
@@ -1,5 +1,5 @@
/* Internal declarations for getopt.
- Copyright (C) 1989-2018 Free Software Foundation, Inc.
+ Copyright (C) 1989-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library and is also part of gnulib.
Patches to this file should be submitted to both projects.
diff --git a/contrib/tools/bison/lib/getprogname.c b/contrib/tools/bison/lib/getprogname.c
index 284581da244..50fe23cb890 100644
--- a/contrib/tools/bison/lib/getprogname.c
+++ b/contrib/tools/bison/lib/getprogname.c
@@ -1,5 +1,5 @@
/* Program name management.
- Copyright (C) 2016-2018 Free Software Foundation, Inc.
+ Copyright (C) 2016-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/getprogname.h b/contrib/tools/bison/lib/getprogname.h
index ee6688fc2ae..1590b38d3f1 100644
--- a/contrib/tools/bison/lib/getprogname.h
+++ b/contrib/tools/bison/lib/getprogname.h
@@ -1,5 +1,5 @@
/* Program name management.
- Copyright (C) 2016-2018 Free Software Foundation, Inc.
+ Copyright (C) 2016-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/gettext.h b/contrib/tools/bison/lib/gettext.h
index f2d7458f4a8..c7c0fdb5311 100644
--- a/contrib/tools/bison/lib/gettext.h
+++ b/contrib/tools/bison/lib/gettext.h
@@ -1,5 +1,5 @@
/* Convenience header for conditional use of GNU <libintl.h>.
- Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2018 Free Software
+ Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2019 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -184,9 +184,16 @@ npgettext_aux (const char *domain,
#include <string.h>
-#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
- /* || __STDC_VERSION__ == 199901L
- || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ )
+/* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported.
+ This relates to the -Wvla and -Wvla-larger-than warnings, enabled in
+ the default GCC many warnings set. This allows programs to disable use
+ of VLAs, which may be unintended, or may be awkward to support portably,
+ 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__) */ ))
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
#else
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
diff --git a/contrib/tools/bison/lib/gl_array_list.c b/contrib/tools/bison/lib/gl_array_list.c
new file mode 100644
index 00000000000..4ac743fde4f
--- /dev/null
+++ b/contrib/tools/bison/lib/gl_array_list.c
@@ -0,0 +1,680 @@
+/* Sequential list data type implemented by an array.
+ Copyright (C) 2006-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <[email protected]>, 2006.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "gl_array_list.h"
+
+#include <stdlib.h>
+/* Get memcpy. */
+#include <string.h>
+
+/* Checked size_t computations. */
+#include "xsize.h"
+
+#ifndef uintptr_t
+# define uintptr_t unsigned long
+#endif
+
+/* -------------------------- gl_list_t Data Type -------------------------- */
+
+/* Concrete gl_list_impl type, valid for this file only. */
+struct gl_list_impl
+{
+ struct gl_list_impl_base base;
+ /* An array of ALLOCATED elements, of which the first COUNT are used.
+ 0 <= COUNT <= ALLOCATED. */
+ const void **elements;
+ size_t count;
+ size_t allocated;
+};
+
+/* struct gl_list_node_impl doesn't exist here. The pointers are actually
+ indices + 1. */
+#define INDEX_TO_NODE(index) (gl_list_node_t)(uintptr_t)(size_t)((index) + 1)
+#define NODE_TO_INDEX(node) ((uintptr_t)(node) - 1)
+
+static gl_list_t
+gl_array_nx_create_empty (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates)
+{
+ struct gl_list_impl *list =
+ (struct gl_list_impl *) malloc (sizeof (struct gl_list_impl));
+
+ if (list == NULL)
+ return NULL;
+
+ list->base.vtable = implementation;
+ list->base.equals_fn = equals_fn;
+ list->base.hashcode_fn = hashcode_fn;
+ list->base.dispose_fn = dispose_fn;
+ list->base.allow_duplicates = allow_duplicates;
+ list->elements = NULL;
+ list->count = 0;
+ list->allocated = 0;
+
+ return list;
+}
+
+static gl_list_t
+gl_array_nx_create (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates,
+ size_t count, const void **contents)
+{
+ struct gl_list_impl *list =
+ (struct gl_list_impl *) malloc (sizeof (struct gl_list_impl));
+
+ if (list == NULL)
+ return NULL;
+
+ list->base.vtable = implementation;
+ list->base.equals_fn = equals_fn;
+ list->base.hashcode_fn = hashcode_fn;
+ list->base.dispose_fn = dispose_fn;
+ list->base.allow_duplicates = allow_duplicates;
+ if (count > 0)
+ {
+ if (size_overflow_p (xtimes (count, sizeof (const void *))))
+ goto fail;
+ list->elements = (const void **) malloc (count * sizeof (const void *));
+ if (list->elements == NULL)
+ goto fail;
+ memcpy (list->elements, contents, count * sizeof (const void *));
+ }
+ else
+ list->elements = NULL;
+ list->count = count;
+ list->allocated = count;
+
+ return list;
+
+ fail:
+ free (list);
+ return NULL;
+}
+
+static size_t
+gl_array_size (gl_list_t list)
+{
+ return list->count;
+}
+
+static const void * _GL_ATTRIBUTE_PURE
+gl_array_node_value (gl_list_t list, gl_list_node_t node)
+{
+ uintptr_t index = NODE_TO_INDEX (node);
+ if (!(index < list->count))
+ /* Invalid argument. */
+ abort ();
+ return list->elements[index];
+}
+
+static int
+gl_array_node_nx_set_value (gl_list_t list, gl_list_node_t node,
+ const void *elt)
+{
+ uintptr_t index = NODE_TO_INDEX (node);
+ if (!(index < list->count))
+ /* Invalid argument. */
+ abort ();
+ list->elements[index] = elt;
+ return 0;
+}
+
+static gl_list_node_t _GL_ATTRIBUTE_PURE
+gl_array_next_node (gl_list_t list, gl_list_node_t node)
+{
+ uintptr_t index = NODE_TO_INDEX (node);
+ if (!(index < list->count))
+ /* Invalid argument. */
+ abort ();
+ index++;
+ if (index < list->count)
+ return INDEX_TO_NODE (index);
+ else
+ return NULL;
+}
+
+static gl_list_node_t _GL_ATTRIBUTE_PURE
+gl_array_previous_node (gl_list_t list, gl_list_node_t node)
+{
+ uintptr_t index = NODE_TO_INDEX (node);
+ if (!(index < list->count))
+ /* Invalid argument. */
+ abort ();
+ if (index > 0)
+ return INDEX_TO_NODE (index - 1);
+ else
+ return NULL;
+}
+
+static const void * _GL_ATTRIBUTE_PURE
+gl_array_get_at (gl_list_t list, size_t position)
+{
+ size_t count = list->count;
+
+ if (!(position < count))
+ /* Invalid argument. */
+ abort ();
+ return list->elements[position];
+}
+
+static gl_list_node_t
+gl_array_nx_set_at (gl_list_t list, size_t position, const void *elt)
+{
+ size_t count = list->count;
+
+ if (!(position < count))
+ /* Invalid argument. */
+ abort ();
+ list->elements[position] = elt;
+ return INDEX_TO_NODE (position);
+}
+
+static size_t
+gl_array_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index,
+ const void *elt)
+{
+ size_t count = list->count;
+
+ if (!(start_index <= end_index && end_index <= count))
+ /* Invalid arguments. */
+ abort ();
+
+ if (start_index < end_index)
+ {
+ gl_listelement_equals_fn equals = list->base.equals_fn;
+ if (equals != NULL)
+ {
+ size_t i;
+
+ for (i = start_index;;)
+ {
+ if (equals (elt, list->elements[i]))
+ return i;
+ i++;
+ if (i == end_index)
+ break;
+ }
+ }
+ else
+ {
+ size_t i;
+
+ for (i = start_index;;)
+ {
+ if (elt == list->elements[i])
+ return i;
+ i++;
+ if (i == end_index)
+ break;
+ }
+ }
+ }
+ return (size_t)(-1);
+}
+
+static gl_list_node_t
+gl_array_search_from_to (gl_list_t list, size_t start_index, size_t end_index,
+ const void *elt)
+{
+ size_t index = gl_array_indexof_from_to (list, start_index, end_index, elt);
+ return INDEX_TO_NODE (index);
+}
+
+/* Ensure that list->allocated > list->count.
+ Return 0 upon success, -1 upon out-of-memory. */
+static int
+grow (gl_list_t list)
+{
+ size_t new_allocated;
+ size_t memory_size;
+ const void **memory;
+
+ new_allocated = xtimes (list->allocated, 2);
+ new_allocated = xsum (new_allocated, 1);
+ memory_size = xtimes (new_allocated, sizeof (const void *));
+ if (size_overflow_p (memory_size))
+ /* Overflow, would lead to out of memory. */
+ return -1;
+ memory = (const void **) realloc (list->elements, memory_size);
+ if (memory == NULL)
+ /* Out of memory. */
+ return -1;
+ list->elements = memory;
+ list->allocated = new_allocated;
+ return 0;
+}
+
+static gl_list_node_t
+gl_array_nx_add_first (gl_list_t list, const void *elt)
+{
+ size_t count = list->count;
+ const void **elements;
+ size_t i;
+
+ if (count == list->allocated)
+ if (grow (list) < 0)
+ return NULL;
+ elements = list->elements;
+ for (i = count; i > 0; i--)
+ elements[i] = elements[i - 1];
+ elements[0] = elt;
+ list->count = count + 1;
+ return INDEX_TO_NODE (0);
+}
+
+static gl_list_node_t
+gl_array_nx_add_last (gl_list_t list, const void *elt)
+{
+ size_t count = list->count;
+
+ if (count == list->allocated)
+ if (grow (list) < 0)
+ return NULL;
+ list->elements[count] = elt;
+ list->count = count + 1;
+ return INDEX_TO_NODE (count);
+}
+
+static gl_list_node_t
+gl_array_nx_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
+{
+ size_t count = list->count;
+ uintptr_t index = NODE_TO_INDEX (node);
+ size_t position;
+ const void **elements;
+ size_t i;
+
+ if (!(index < count))
+ /* Invalid argument. */
+ abort ();
+ position = index;
+ if (count == list->allocated)
+ if (grow (list) < 0)
+ return NULL;
+ elements = list->elements;
+ for (i = count; i > position; i--)
+ elements[i] = elements[i - 1];
+ elements[position] = elt;
+ list->count = count + 1;
+ return INDEX_TO_NODE (position);
+}
+
+static gl_list_node_t
+gl_array_nx_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
+{
+ size_t count = list->count;
+ uintptr_t index = NODE_TO_INDEX (node);
+ size_t position;
+ const void **elements;
+ size_t i;
+
+ if (!(index < count))
+ /* Invalid argument. */
+ abort ();
+ position = index + 1;
+ if (count == list->allocated)
+ if (grow (list) < 0)
+ return NULL;
+ elements = list->elements;
+ for (i = count; i > position; i--)
+ elements[i] = elements[i - 1];
+ elements[position] = elt;
+ list->count = count + 1;
+ return INDEX_TO_NODE (position);
+}
+
+static gl_list_node_t
+gl_array_nx_add_at (gl_list_t list, size_t position, const void *elt)
+{
+ size_t count = list->count;
+ const void **elements;
+ size_t i;
+
+ if (!(position <= count))
+ /* Invalid argument. */
+ abort ();
+ if (count == list->allocated)
+ if (grow (list) < 0)
+ return NULL;
+ elements = list->elements;
+ for (i = count; i > position; i--)
+ elements[i] = elements[i - 1];
+ elements[position] = elt;
+ list->count = count + 1;
+ return INDEX_TO_NODE (position);
+}
+
+static bool
+gl_array_remove_node (gl_list_t list, gl_list_node_t node)
+{
+ size_t count = list->count;
+ uintptr_t index = NODE_TO_INDEX (node);
+ size_t position;
+ const void **elements;
+ size_t i;
+
+ if (!(index < count))
+ /* Invalid argument. */
+ abort ();
+ position = index;
+ elements = list->elements;
+ if (list->base.dispose_fn != NULL)
+ list->base.dispose_fn (elements[position]);
+ for (i = position + 1; i < count; i++)
+ elements[i - 1] = elements[i];
+ list->count = count - 1;
+ return true;
+}
+
+static bool
+gl_array_remove_at (gl_list_t list, size_t position)
+{
+ size_t count = list->count;
+ const void **elements;
+ size_t i;
+
+ if (!(position < count))
+ /* Invalid argument. */
+ abort ();
+ elements = list->elements;
+ if (list->base.dispose_fn != NULL)
+ list->base.dispose_fn (elements[position]);
+ for (i = position + 1; i < count; i++)
+ elements[i - 1] = elements[i];
+ list->count = count - 1;
+ return true;
+}
+
+static bool
+gl_array_remove (gl_list_t list, const void *elt)
+{
+ size_t position = gl_array_indexof_from_to (list, 0, list->count, elt);
+ if (position == (size_t)(-1))
+ return false;
+ else
+ return gl_array_remove_at (list, position);
+}
+
+static void
+gl_array_list_free (gl_list_t list)
+{
+ if (list->elements != NULL)
+ {
+ if (list->base.dispose_fn != NULL)
+ {
+ size_t count = list->count;
+
+ if (count > 0)
+ {
+ gl_listelement_dispose_fn dispose = list->base.dispose_fn;
+ const void **elements = list->elements;
+
+ do
+ dispose (*elements++);
+ while (--count > 0);
+ }
+ }
+ free (list->elements);
+ }
+ free (list);
+}
+
+/* --------------------- gl_list_iterator_t Data Type --------------------- */
+
+static gl_list_iterator_t
+gl_array_iterator (gl_list_t list)
+{
+ gl_list_iterator_t result;
+
+ result.vtable = list->base.vtable;
+ result.list = list;
+ result.count = list->count;
+ result.p = list->elements + 0;
+ result.q = list->elements + list->count;
+#if defined GCC_LINT || defined lint
+ result.i = 0;
+ result.j = 0;
+#endif
+
+ return result;
+}
+
+static gl_list_iterator_t
+gl_array_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index)
+{
+ gl_list_iterator_t result;
+
+ if (!(start_index <= end_index && end_index <= list->count))
+ /* Invalid arguments. */
+ abort ();
+ result.vtable = list->base.vtable;
+ result.list = list;
+ result.count = list->count;
+ result.p = list->elements + start_index;
+ result.q = list->elements + end_index;
+#if defined GCC_LINT || defined lint
+ result.i = 0;
+ result.j = 0;
+#endif
+
+ return result;
+}
+
+static bool
+gl_array_iterator_next (gl_list_iterator_t *iterator,
+ const void **eltp, gl_list_node_t *nodep)
+{
+ gl_list_t list = iterator->list;
+ if (iterator->count != list->count)
+ {
+ if (iterator->count != list->count + 1)
+ /* Concurrent modifications were done on the list. */
+ abort ();
+ /* The last returned element was removed. */
+ iterator->count--;
+ iterator->p = (const void **) iterator->p - 1;
+ iterator->q = (const void **) iterator->q - 1;
+ }
+ if (iterator->p < iterator->q)
+ {
+ const void **p = (const void **) iterator->p;
+ *eltp = *p;
+ if (nodep != NULL)
+ *nodep = INDEX_TO_NODE (p - list->elements);
+ iterator->p = p + 1;
+ return true;
+ }
+ else
+ return false;
+}
+
+static void
+gl_array_iterator_free (gl_list_iterator_t *iterator _GL_UNUSED)
+{
+}
+
+/* ---------------------- Sorted gl_list_t Data Type ---------------------- */
+
+static size_t
+gl_array_sortedlist_indexof_from_to (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ size_t low, size_t high,
+ const void *elt)
+{
+ if (!(low <= high && high <= list->count))
+ /* Invalid arguments. */
+ abort ();
+ if (low < high)
+ {
+ /* At each loop iteration, low < high; for indices < low the values
+ are smaller than ELT; for indices >= high the values are greater
+ than ELT. So, if the element occurs in the list, it is at
+ low <= position < high. */
+ do
+ {
+ size_t mid = low + (high - low) / 2; /* low <= mid < high */
+ int cmp = compar (list->elements[mid], elt);
+
+ if (cmp < 0)
+ low = mid + 1;
+ else if (cmp > 0)
+ high = mid;
+ else /* cmp == 0 */
+ {
+ /* We have an element equal to ELT at index MID. But we need
+ the minimal such index. */
+ high = mid;
+ /* At each loop iteration, low <= high and
+ compar (list->elements[high], elt) == 0,
+ and we know that the first occurrence of the element is at
+ low <= position <= high. */
+ while (low < high)
+ {
+ size_t mid2 = low + (high - low) / 2; /* low <= mid2 < high */
+ int cmp2 = compar (list->elements[mid2], elt);
+
+ if (cmp2 < 0)
+ low = mid2 + 1;
+ else if (cmp2 > 0)
+ /* The list was not sorted. */
+ abort ();
+ else /* cmp2 == 0 */
+ {
+ if (mid2 == low)
+ break;
+ high = mid2 - 1;
+ }
+ }
+ return low;
+ }
+ }
+ while (low < high);
+ /* Here low == high. */
+ }
+ return (size_t)(-1);
+}
+
+static size_t
+gl_array_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar,
+ const void *elt)
+{
+ return gl_array_sortedlist_indexof_from_to (list, compar, 0, list->count,
+ elt);
+}
+
+static gl_list_node_t
+gl_array_sortedlist_search_from_to (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ size_t low, size_t high,
+ const void *elt)
+{
+ size_t index =
+ gl_array_sortedlist_indexof_from_to (list, compar, low, high, elt);
+ return INDEX_TO_NODE (index);
+}
+
+static gl_list_node_t
+gl_array_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar,
+ const void *elt)
+{
+ size_t index =
+ gl_array_sortedlist_indexof_from_to (list, compar, 0, list->count, elt);
+ return INDEX_TO_NODE (index);
+}
+
+static gl_list_node_t
+gl_array_sortedlist_nx_add (gl_list_t list, gl_listelement_compar_fn compar,
+ const void *elt)
+{
+ size_t count = list->count;
+ size_t low = 0;
+ size_t high = count;
+
+ /* At each loop iteration, low <= high; for indices < low the values are
+ smaller than ELT; for indices >= high the values are greater than ELT. */
+ while (low < high)
+ {
+ size_t mid = low + (high - low) / 2; /* low <= mid < high */
+ int cmp = compar (list->elements[mid], elt);
+
+ if (cmp < 0)
+ low = mid + 1;
+ else if (cmp > 0)
+ high = mid;
+ else /* cmp == 0 */
+ {
+ low = mid;
+ break;
+ }
+ }
+ return gl_array_nx_add_at (list, low, elt);
+}
+
+static bool
+gl_array_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar,
+ const void *elt)
+{
+ size_t index = gl_array_sortedlist_indexof (list, compar, elt);
+ if (index == (size_t)(-1))
+ return false;
+ else
+ return gl_array_remove_at (list, index);
+}
+
+
+const struct gl_list_implementation gl_array_list_implementation =
+ {
+ gl_array_nx_create_empty,
+ gl_array_nx_create,
+ gl_array_size,
+ gl_array_node_value,
+ gl_array_node_nx_set_value,
+ gl_array_next_node,
+ gl_array_previous_node,
+ gl_array_get_at,
+ gl_array_nx_set_at,
+ gl_array_search_from_to,
+ gl_array_indexof_from_to,
+ gl_array_nx_add_first,
+ gl_array_nx_add_last,
+ gl_array_nx_add_before,
+ gl_array_nx_add_after,
+ gl_array_nx_add_at,
+ gl_array_remove_node,
+ gl_array_remove_at,
+ gl_array_remove,
+ gl_array_list_free,
+ gl_array_iterator,
+ gl_array_iterator_from_to,
+ gl_array_iterator_next,
+ gl_array_iterator_free,
+ gl_array_sortedlist_search,
+ gl_array_sortedlist_search_from_to,
+ gl_array_sortedlist_indexof,
+ gl_array_sortedlist_indexof_from_to,
+ gl_array_sortedlist_nx_add,
+ gl_array_sortedlist_remove
+ };
diff --git a/contrib/tools/bison/lib/gl_array_list.h b/contrib/tools/bison/lib/gl_array_list.h
new file mode 100644
index 00000000000..98158feb1b1
--- /dev/null
+++ b/contrib/tools/bison/lib/gl_array_list.h
@@ -0,0 +1,34 @@
+/* Sequential list data type implemented by an array.
+ Copyright (C) 2006, 2009-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <[email protected]>, 2006.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_ARRAY_LIST_H
+#define _GL_ARRAY_LIST_H
+
+#include "gl_list.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const struct gl_list_implementation gl_array_list_implementation;
+#define GL_ARRAY_LIST &gl_array_list_implementation
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GL_ARRAY_LIST_H */
diff --git a/contrib/tools/bison/lib/gl_list.c b/contrib/tools/bison/lib/gl_list.c
new file mode 100644
index 00000000000..8793298070b
--- /dev/null
+++ b/contrib/tools/bison/lib/gl_list.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define GL_LIST_INLINE _GL_EXTERN_INLINE
+#include "gl_list.h"
diff --git a/contrib/tools/bison/lib/gl_list.h b/contrib/tools/bison/lib/gl_list.h
new file mode 100644
index 00000000000..5f2cade22cc
--- /dev/null
+++ b/contrib/tools/bison/lib/gl_list.h
@@ -0,0 +1,843 @@
+/* Abstract sequential list data type. -*- coding: utf-8 -*-
+ Copyright (C) 2006-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <[email protected]>, 2006.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_LIST_H
+#define _GL_LIST_H
+
+#include <stdbool.h>
+#include <stddef.h>
+
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
+_GL_INLINE_HEADER_BEGIN
+#ifndef GL_LIST_INLINE
+# define GL_LIST_INLINE _GL_INLINE
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* gl_list is an abstract list data type. It can contain any number of
+ objects ('void *' or 'const void *' pointers) in any given order.
+ Duplicates are allowed, but can optionally be forbidden.
+
+ There are several implementations of this list datatype, optimized for
+ different operations or for memory. You can start using the simplest list
+ implementation, GL_ARRAY_LIST, and switch to a different implementation
+ later, when you realize which operations are performed the most frequently.
+ The API of the different implementations is exactly the same; when
+ switching to a different implementation, you only have to change the
+ gl_list_create call.
+
+ The implementations are:
+ GL_ARRAY_LIST a growable array
+ GL_CARRAY_LIST a growable circular array
+ GL_LINKED_LIST a linked list
+ GL_AVLTREE_LIST a binary tree (AVL tree)
+ GL_RBTREE_LIST a binary tree (red-black tree)
+ GL_LINKEDHASH_LIST a hash table with a linked list
+ GL_AVLTREEHASH_LIST a hash table with a binary tree (AVL tree)
+ GL_RBTREEHASH_LIST a hash table with a binary tree (red-black tree)
+
+ The memory consumption is asymptotically the same: O(1) for every object
+ in the list. When looking more closely at the average memory consumed
+ for an object, GL_ARRAY_LIST is the most compact representation, and
+ GL_LINKEDHASH_LIST and GL_TREEHASH_LIST need more memory.
+
+ The guaranteed average performance of the operations is, for a list of
+ n elements:
+
+ Operation ARRAY LINKED TREE LINKEDHASH TREEHASH
+ CARRAY with|without with|without
+ duplicates duplicates
+
+ gl_list_size O(1) O(1) O(1) O(1) O(1)
+ gl_list_node_value O(1) O(1) O(1) O(1) O(1)
+ gl_list_node_set_value O(1) O(1) O(1) O(1) O((log n)²)/O(1)
+ gl_list_next_node O(1) O(1) O(log n) O(1) O(log n)
+ gl_list_previous_node O(1) O(1) O(log n) O(1) O(log n)
+ gl_list_get_at O(1) O(n) O(log n) O(n) O(log n)
+ gl_list_set_at O(1) O(n) O(log n) O(n) O((log n)²)/O(log n)
+ gl_list_search O(n) O(n) O(n) O(n)/O(1) O(log n)/O(1)
+ gl_list_search_from O(n) O(n) O(n) O(n)/O(1) O((log n)²)/O(log n)
+ gl_list_search_from_to O(n) O(n) O(n) O(n)/O(1) O((log n)²)/O(log n)
+ gl_list_indexof O(n) O(n) O(n) O(n) O(log n)
+ gl_list_indexof_from O(n) O(n) O(n) O(n) O((log n)²)/O(log n)
+ gl_list_indexof_from_to O(n) O(n) O(n) O(n) O((log n)²)/O(log n)
+ gl_list_add_first O(n)/O(1) O(1) O(log n) O(1) O((log n)²)/O(log n)
+ gl_list_add_last O(1) O(1) O(log n) O(1) O((log n)²)/O(log n)
+ gl_list_add_before O(n) O(1) O(log n) O(1) O((log n)²)/O(log n)
+ gl_list_add_after O(n) O(1) O(log n) O(1) O((log n)²)/O(log n)
+ gl_list_add_at O(n) O(n) O(log n) O(n) O((log n)²)/O(log n)
+ gl_list_remove_node O(n) O(1) O(log n) O(n)/O(1) O((log n)²)/O(log n)
+ gl_list_remove_at O(n) O(n) O(log n) O(n) O((log n)²)/O(log n)
+ gl_list_remove O(n) O(n) O(n) O(n)/O(1) O((log n)²)/O(log n)
+ gl_list_iterator O(1) O(1) O(log n) O(1) O(log n)
+ gl_list_iterator_from_to O(1) O(n) O(log n) O(n) O(log n)
+ gl_list_iterator_next O(1) O(1) O(log n) O(1) O(log n)
+ gl_sortedlist_search O(log n) O(n) O(log n) O(n) O(log n)
+ gl_sortedlist_search_from O(log n) O(n) O(log n) O(n) O(log n)
+ gl_sortedlist_indexof O(log n) O(n) O(log n) O(n) O(log n)
+ gl_sortedlist_indexof_fro O(log n) O(n) O(log n) O(n) O(log n)
+ gl_sortedlist_add O(n) O(n) O(log n) O(n) O((log n)²)/O(log n)
+ gl_sortedlist_remove O(n) O(n) O(log n) O(n) O((log n)²)/O(log n)
+ */
+
+/* -------------------------- gl_list_t Data Type -------------------------- */
+
+/* Type of function used to compare two elements.
+ NULL denotes pointer comparison. */
+typedef bool (*gl_listelement_equals_fn) (const void *elt1, const void *elt2);
+
+/* Type of function used to compute a hash code.
+ NULL denotes a function that depends only on the pointer itself. */
+typedef size_t (*gl_listelement_hashcode_fn) (const void *elt);
+
+/* Type of function used to dispose an element once it's removed from a list.
+ NULL denotes a no-op. */
+typedef void (*gl_listelement_dispose_fn) (const void *elt);
+
+struct gl_list_impl;
+/* Type representing an entire list. */
+typedef struct gl_list_impl * gl_list_t;
+
+struct gl_list_node_impl;
+/* Type representing the position of an element in the list, in a way that
+ is more adapted to the list implementation than a plain index.
+ Note: It is invalidated by insertions and removals! */
+typedef struct gl_list_node_impl * gl_list_node_t;
+
+struct gl_list_implementation;
+/* Type representing a list datatype implementation. */
+typedef const struct gl_list_implementation * gl_list_implementation_t;
+
+#if 0 /* Unless otherwise specified, these are defined inline below. */
+
+/* Create an empty list.
+ IMPLEMENTATION is one of GL_ARRAY_LIST, GL_CARRAY_LIST, GL_LINKED_LIST,
+ GL_AVLTREE_LIST, GL_RBTREE_LIST, GL_LINKEDHASH_LIST, GL_AVLTREEHASH_LIST,
+ GL_RBTREEHASH_LIST.
+ EQUALS_FN is an element comparison function or NULL.
+ HASHCODE_FN is an element hash code function or NULL.
+ DISPOSE_FN is an element disposal function or NULL.
+ ALLOW_DUPLICATES is false if duplicate elements shall not be allowed in
+ the list. The implementation may verify this at runtime. */
+/* declared in gl_xlist.h */
+extern gl_list_t gl_list_create_empty (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates);
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_t gl_list_nx_create_empty (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates);
+
+/* Create a list with given contents.
+ IMPLEMENTATION is one of GL_ARRAY_LIST, GL_CARRAY_LIST, GL_LINKED_LIST,
+ GL_AVLTREE_LIST, GL_RBTREE_LIST, GL_LINKEDHASH_LIST, GL_AVLTREEHASH_LIST,
+ GL_RBTREEHASH_LIST.
+ EQUALS_FN is an element comparison function or NULL.
+ HASHCODE_FN is an element hash code function or NULL.
+ DISPOSE_FN is an element disposal function or NULL.
+ ALLOW_DUPLICATES is false if duplicate elements shall not be allowed in
+ the list. The implementation may verify this at runtime.
+ COUNT is the number of initial elements.
+ CONTENTS[0..COUNT-1] is the initial contents. */
+/* declared in gl_xlist.h */
+extern gl_list_t gl_list_create (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates,
+ size_t count, const void **contents);
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_t gl_list_nx_create (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates,
+ size_t count, const void **contents);
+
+/* Return the current number of elements in a list. */
+extern size_t gl_list_size (gl_list_t list);
+
+/* Return the element value represented by a list node. */
+extern const void * gl_list_node_value (gl_list_t list, gl_list_node_t node);
+
+/* Replace the element value represented by a list node. */
+/* declared in gl_xlist.h */
+extern void gl_list_node_set_value (gl_list_t list, gl_list_node_t node,
+ const void *elt);
+/* Likewise. Return 0 upon success, -1 upon out-of-memory. */
+extern int gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node,
+ const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
+
+/* Return the node immediately after the given node in the list, or NULL
+ if the given node is the last (rightmost) one in the list. */
+extern gl_list_node_t gl_list_next_node (gl_list_t list, gl_list_node_t node);
+
+/* Return the node immediately before the given node in the list, or NULL
+ if the given node is the first (leftmost) one in the list. */
+extern gl_list_node_t gl_list_previous_node (gl_list_t list, gl_list_node_t node);
+
+/* Return the element at a given position in the list.
+ POSITION must be >= 0 and < gl_list_size (list). */
+extern const void * gl_list_get_at (gl_list_t list, size_t position);
+
+/* Replace the element at a given position in the list.
+ POSITION must be >= 0 and < gl_list_size (list).
+ Return its node. */
+/* declared in gl_xlist.h */
+extern gl_list_node_t gl_list_set_at (gl_list_t list, size_t position,
+ const void *elt);
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_node_t gl_list_nx_set_at (gl_list_t list, size_t position,
+ const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
+
+/* Search whether an element is already in the list.
+ Return its node if found, or NULL if not present in the list. */
+extern gl_list_node_t gl_list_search (gl_list_t list, const void *elt);
+
+/* Search whether an element is already in the list,
+ at a position >= START_INDEX.
+ Return its node if found, or NULL if not present in the list. */
+extern gl_list_node_t gl_list_search_from (gl_list_t list, size_t start_index,
+ const void *elt);
+
+/* Search whether an element is already in the list,
+ at a position >= START_INDEX and < END_INDEX.
+ Return its node if found, or NULL if not present in the list. */
+extern gl_list_node_t gl_list_search_from_to (gl_list_t list,
+ size_t start_index,
+ size_t end_index,
+ const void *elt);
+
+/* Search whether an element is already in the list.
+ Return its position if found, or (size_t)(-1) if not present in the list. */
+extern size_t gl_list_indexof (gl_list_t list, const void *elt);
+
+/* Search whether an element is already in the list,
+ at a position >= START_INDEX.
+ Return its position if found, or (size_t)(-1) if not present in the list. */
+extern size_t gl_list_indexof_from (gl_list_t list, size_t start_index,
+ const void *elt);
+
+/* Search whether an element is already in the list,
+ at a position >= START_INDEX and < END_INDEX.
+ Return its position if found, or (size_t)(-1) if not present in the list. */
+extern size_t gl_list_indexof_from_to (gl_list_t list,
+ size_t start_index, size_t end_index,
+ const void *elt);
+
+/* Add an element as the first element of the list.
+ Return its node. */
+/* declared in gl_xlist.h */
+extern gl_list_node_t gl_list_add_first (gl_list_t list, const void *elt);
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_node_t gl_list_nx_add_first (gl_list_t list, const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
+
+/* Add an element as the last element of the list.
+ Return its node. */
+/* declared in gl_xlist.h */
+extern gl_list_node_t gl_list_add_last (gl_list_t list, const void *elt);
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_node_t gl_list_nx_add_last (gl_list_t list, const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
+
+/* Add an element before a given element node of the list.
+ Return its node. */
+/* declared in gl_xlist.h */
+extern gl_list_node_t gl_list_add_before (gl_list_t list, gl_list_node_t node,
+ const void *elt);
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_node_t gl_list_nx_add_before (gl_list_t list,
+ gl_list_node_t node,
+ const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
+
+/* Add an element after a given element node of the list.
+ Return its node. */
+/* declared in gl_xlist.h */
+extern gl_list_node_t gl_list_add_after (gl_list_t list, gl_list_node_t node,
+ const void *elt);
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_node_t gl_list_nx_add_after (gl_list_t list, gl_list_node_t node,
+ const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
+
+/* Add an element at a given position in the list.
+ POSITION must be >= 0 and <= gl_list_size (list). */
+/* declared in gl_xlist.h */
+extern gl_list_node_t gl_list_add_at (gl_list_t list, size_t position,
+ const void *elt);
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_node_t gl_list_nx_add_at (gl_list_t list, size_t position,
+ const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
+
+/* Remove an element from the list.
+ Return true. */
+extern bool gl_list_remove_node (gl_list_t list, gl_list_node_t node);
+
+/* Remove an element at a given position from the list.
+ POSITION must be >= 0 and < gl_list_size (list).
+ Return true. */
+extern bool gl_list_remove_at (gl_list_t list, size_t position);
+
+/* Search and remove an element from the list.
+ Return true if it was found and removed. */
+extern bool gl_list_remove (gl_list_t list, const void *elt);
+
+/* Free an entire list.
+ (But this call does not free the elements of the list. It only invokes
+ the DISPOSE_FN on each of the elements of the list, and only if the list
+ is not a sublist.) */
+extern void gl_list_free (gl_list_t list);
+
+#endif /* End of inline and gl_xlist.h-defined functions. */
+
+/* --------------------- gl_list_iterator_t Data Type --------------------- */
+
+/* Functions for iterating through a list. */
+
+/* Type of an iterator that traverses a list.
+ This is a fixed-size struct, so that creation of an iterator doesn't need
+ memory allocation on the heap. */
+typedef struct
+{
+ /* For fast dispatch of gl_list_iterator_next. */
+ const struct gl_list_implementation *vtable;
+ /* For detecting whether the last returned element was removed. */
+ gl_list_t list;
+ size_t count;
+ /* Other, implementation-private fields. */
+ void *p; void *q;
+ size_t i; size_t j;
+} gl_list_iterator_t;
+
+#if 0 /* These are defined inline below. */
+
+/* Create an iterator traversing a list.
+ The list contents must not be modified while the iterator is in use,
+ except for replacing or removing the last returned element. */
+extern gl_list_iterator_t gl_list_iterator (gl_list_t list);
+
+/* Create an iterator traversing the element with indices i,
+ start_index <= i < end_index, of a list.
+ The list contents must not be modified while the iterator is in use,
+ except for replacing or removing the last returned element. */
+extern gl_list_iterator_t gl_list_iterator_from_to (gl_list_t list,
+ size_t start_index,
+ size_t end_index);
+
+/* If there is a next element, store the next element in *ELTP, store its
+ node in *NODEP if NODEP is non-NULL, advance the iterator and return true.
+ Otherwise, return false. */
+extern bool gl_list_iterator_next (gl_list_iterator_t *iterator,
+ const void **eltp, gl_list_node_t *nodep);
+
+/* Free an iterator. */
+extern void gl_list_iterator_free (gl_list_iterator_t *iterator);
+
+#endif /* End of inline functions. */
+
+/* ---------------------- Sorted gl_list_t Data Type ---------------------- */
+
+/* The following functions are for lists without duplicates where the
+ order is given by a sort criterion. */
+
+/* Type of function used to compare two elements. Same as for qsort().
+ NULL denotes pointer comparison. */
+typedef int (*gl_listelement_compar_fn) (const void *elt1, const void *elt2);
+
+#if 0 /* Unless otherwise specified, these are defined inline below. */
+
+/* Search whether an element is already in the list.
+ The list is assumed to be sorted with COMPAR.
+ Return its node if found, or NULL if not present in the list.
+ If the list contains several copies of ELT, the node of the leftmost one is
+ returned. */
+extern gl_list_node_t gl_sortedlist_search (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ const void *elt);
+
+/* Search whether an element is already in the list.
+ The list is assumed to be sorted with COMPAR.
+ Only list elements with indices >= START_INDEX and < END_INDEX are
+ considered; the implementation uses these bounds to minimize the number
+ of COMPAR invocations.
+ Return its node if found, or NULL if not present in the list.
+ If the list contains several copies of ELT, the node of the leftmost one is
+ returned. */
+extern gl_list_node_t gl_sortedlist_search_from_to (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ size_t start_index,
+ size_t end_index,
+ const void *elt);
+
+/* Search whether an element is already in the list.
+ The list is assumed to be sorted with COMPAR.
+ Return its position if found, or (size_t)(-1) if not present in the list.
+ If the list contains several copies of ELT, the position of the leftmost one
+ is returned. */
+extern size_t gl_sortedlist_indexof (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ const void *elt);
+
+/* Search whether an element is already in the list.
+ The list is assumed to be sorted with COMPAR.
+ Only list elements with indices >= START_INDEX and < END_INDEX are
+ considered; the implementation uses these bounds to minimize the number
+ of COMPAR invocations.
+ Return its position if found, or (size_t)(-1) if not present in the list.
+ If the list contains several copies of ELT, the position of the leftmost one
+ is returned. */
+extern size_t gl_sortedlist_indexof_from_to (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ size_t start_index,
+ size_t end_index,
+ const void *elt);
+
+/* Add an element at the appropriate position in the list.
+ The list is assumed to be sorted with COMPAR.
+ Return its node. */
+/* declared in gl_xlist.h */
+extern gl_list_node_t gl_sortedlist_add (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ const void *elt);
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_node_t gl_sortedlist_nx_add (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
+
+/* Search and remove an element from the list.
+ The list is assumed to be sorted with COMPAR.
+ Return true if it was found and removed.
+ If the list contains several copies of ELT, only the leftmost one is
+ removed. */
+extern bool gl_sortedlist_remove (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ const void *elt);
+
+#endif /* End of inline and gl_xlist.h-defined functions. */
+
+/* ------------------------ Implementation Details ------------------------ */
+
+struct gl_list_implementation
+{
+ /* gl_list_t functions. */
+ gl_list_t (*nx_create_empty) (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates);
+ gl_list_t (*nx_create) (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates,
+ size_t count, const void **contents);
+ size_t (*size) (gl_list_t list);
+ const void * (*node_value) (gl_list_t list, gl_list_node_t node);
+ int (*node_nx_set_value) (gl_list_t list, gl_list_node_t node,
+ const void *elt);
+ gl_list_node_t (*next_node) (gl_list_t list, gl_list_node_t node);
+ gl_list_node_t (*previous_node) (gl_list_t list, gl_list_node_t node);
+ const void * (*get_at) (gl_list_t list, size_t position);
+ gl_list_node_t (*nx_set_at) (gl_list_t list, size_t position,
+ const void *elt);
+ gl_list_node_t (*search_from_to) (gl_list_t list, size_t start_index,
+ size_t end_index, const void *elt);
+ size_t (*indexof_from_to) (gl_list_t list, size_t start_index,
+ size_t end_index, const void *elt);
+ gl_list_node_t (*nx_add_first) (gl_list_t list, const void *elt);
+ gl_list_node_t (*nx_add_last) (gl_list_t list, const void *elt);
+ gl_list_node_t (*nx_add_before) (gl_list_t list, gl_list_node_t node,
+ const void *elt);
+ gl_list_node_t (*nx_add_after) (gl_list_t list, gl_list_node_t node,
+ const void *elt);
+ gl_list_node_t (*nx_add_at) (gl_list_t list, size_t position,
+ const void *elt);
+ bool (*remove_node) (gl_list_t list, gl_list_node_t node);
+ bool (*remove_at) (gl_list_t list, size_t position);
+ bool (*remove_elt) (gl_list_t list, const void *elt);
+ void (*list_free) (gl_list_t list);
+ /* gl_list_iterator_t functions. */
+ gl_list_iterator_t (*iterator) (gl_list_t list);
+ gl_list_iterator_t (*iterator_from_to) (gl_list_t list,
+ size_t start_index,
+ size_t end_index);
+ bool (*iterator_next) (gl_list_iterator_t *iterator,
+ const void **eltp, gl_list_node_t *nodep);
+ void (*iterator_free) (gl_list_iterator_t *iterator);
+ /* Sorted gl_list_t functions. */
+ gl_list_node_t (*sortedlist_search) (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ const void *elt);
+ gl_list_node_t (*sortedlist_search_from_to) (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ size_t start_index,
+ size_t end_index,
+ const void *elt);
+ size_t (*sortedlist_indexof) (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ const void *elt);
+ size_t (*sortedlist_indexof_from_to) (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ size_t start_index, size_t end_index,
+ const void *elt);
+ gl_list_node_t (*sortedlist_nx_add) (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ const void *elt);
+ bool (*sortedlist_remove) (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ const void *elt);
+};
+
+struct gl_list_impl_base
+{
+ const struct gl_list_implementation *vtable;
+ gl_listelement_equals_fn equals_fn;
+ gl_listelement_hashcode_fn hashcode_fn;
+ gl_listelement_dispose_fn dispose_fn;
+ bool allow_duplicates;
+};
+
+/* Define all functions of this file as accesses to the
+ struct gl_list_implementation. */
+
+GL_LIST_INLINE gl_list_t
+gl_list_nx_create_empty (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates)
+{
+ return implementation->nx_create_empty (implementation, equals_fn,
+ hashcode_fn, dispose_fn,
+ allow_duplicates);
+}
+
+GL_LIST_INLINE gl_list_t
+gl_list_nx_create (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates,
+ size_t count, const void **contents)
+{
+ return implementation->nx_create (implementation, equals_fn, hashcode_fn,
+ dispose_fn, allow_duplicates, count,
+ contents);
+}
+
+GL_LIST_INLINE size_t
+gl_list_size (gl_list_t list)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->size (list);
+}
+
+GL_LIST_INLINE const void *
+gl_list_node_value (gl_list_t list, gl_list_node_t node)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->node_value (list, node);
+}
+
+GL_LIST_INLINE int
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node,
+ const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->node_nx_set_value (list, node, elt);
+}
+
+GL_LIST_INLINE gl_list_node_t
+gl_list_next_node (gl_list_t list, gl_list_node_t node)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->next_node (list, node);
+}
+
+GL_LIST_INLINE gl_list_node_t
+gl_list_previous_node (gl_list_t list, gl_list_node_t node)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->previous_node (list, node);
+}
+
+GL_LIST_INLINE const void *
+gl_list_get_at (gl_list_t list, size_t position)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->get_at (list, position);
+}
+
+GL_LIST_INLINE gl_list_node_t
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+gl_list_nx_set_at (gl_list_t list, size_t position, const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->nx_set_at (list, position, elt);
+}
+
+GL_LIST_INLINE gl_list_node_t
+gl_list_search (gl_list_t list, const void *elt)
+{
+ size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->search_from_to (list, 0, size, elt);
+}
+
+GL_LIST_INLINE gl_list_node_t
+gl_list_search_from (gl_list_t list, size_t start_index, const void *elt)
+{
+ size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->search_from_to (list, start_index, size, elt);
+}
+
+GL_LIST_INLINE gl_list_node_t
+gl_list_search_from_to (gl_list_t list, size_t start_index, size_t end_index,
+ const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->search_from_to (list, start_index, end_index, elt);
+}
+
+GL_LIST_INLINE size_t
+gl_list_indexof (gl_list_t list, const void *elt)
+{
+ size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->indexof_from_to (list, 0, size, elt);
+}
+
+GL_LIST_INLINE size_t
+gl_list_indexof_from (gl_list_t list, size_t start_index, const void *elt)
+{
+ size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->indexof_from_to (list, start_index, size, elt);
+}
+
+GL_LIST_INLINE size_t
+gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index,
+ const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->indexof_from_to (list, start_index, end_index, elt);
+}
+
+GL_LIST_INLINE gl_list_node_t
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+gl_list_nx_add_first (gl_list_t list, const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->nx_add_first (list, elt);
+}
+
+GL_LIST_INLINE gl_list_node_t
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+gl_list_nx_add_last (gl_list_t list, const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->nx_add_last (list, elt);
+}
+
+GL_LIST_INLINE gl_list_node_t
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+gl_list_nx_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->nx_add_before (list, node, elt);
+}
+
+GL_LIST_INLINE gl_list_node_t
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+gl_list_nx_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->nx_add_after (list, node, elt);
+}
+
+GL_LIST_INLINE gl_list_node_t
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+gl_list_nx_add_at (gl_list_t list, size_t position, const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->nx_add_at (list, position, elt);
+}
+
+GL_LIST_INLINE bool
+gl_list_remove_node (gl_list_t list, gl_list_node_t node)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->remove_node (list, node);
+}
+
+GL_LIST_INLINE bool
+gl_list_remove_at (gl_list_t list, size_t position)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->remove_at (list, position);
+}
+
+GL_LIST_INLINE bool
+gl_list_remove (gl_list_t list, const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->remove_elt (list, elt);
+}
+
+GL_LIST_INLINE void
+gl_list_free (gl_list_t list)
+{
+ ((const struct gl_list_impl_base *) list)->vtable->list_free (list);
+}
+
+GL_LIST_INLINE gl_list_iterator_t
+gl_list_iterator (gl_list_t list)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->iterator (list);
+}
+
+GL_LIST_INLINE gl_list_iterator_t
+gl_list_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->iterator_from_to (list, start_index, end_index);
+}
+
+GL_LIST_INLINE bool
+gl_list_iterator_next (gl_list_iterator_t *iterator,
+ const void **eltp, gl_list_node_t *nodep)
+{
+ return iterator->vtable->iterator_next (iterator, eltp, nodep);
+}
+
+GL_LIST_INLINE void
+gl_list_iterator_free (gl_list_iterator_t *iterator)
+{
+ iterator->vtable->iterator_free (iterator);
+}
+
+GL_LIST_INLINE gl_list_node_t
+gl_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->sortedlist_search (list, compar, elt);
+}
+
+GL_LIST_INLINE gl_list_node_t
+gl_sortedlist_search_from_to (gl_list_t list, gl_listelement_compar_fn compar, size_t start_index, size_t end_index, const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->sortedlist_search_from_to (list, compar, start_index, end_index,
+ elt);
+}
+
+GL_LIST_INLINE size_t
+gl_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->sortedlist_indexof (list, compar, elt);
+}
+
+GL_LIST_INLINE size_t
+gl_sortedlist_indexof_from_to (gl_list_t list, gl_listelement_compar_fn compar, size_t start_index, size_t end_index, const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->sortedlist_indexof_from_to (list, compar, start_index, end_index,
+ elt);
+}
+
+GL_LIST_INLINE gl_list_node_t
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+gl_sortedlist_nx_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->sortedlist_nx_add (list, compar, elt);
+}
+
+GL_LIST_INLINE bool
+gl_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
+{
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->sortedlist_remove (list, compar, elt);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+_GL_INLINE_HEADER_END
+
+#endif /* _GL_LIST_H */
diff --git a/contrib/tools/bison/lib/gl_xlist.c b/contrib/tools/bison/lib/gl_xlist.c
new file mode 100644
index 00000000000..fe3c893396f
--- /dev/null
+++ b/contrib/tools/bison/lib/gl_xlist.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define GL_XLIST_INLINE _GL_EXTERN_INLINE
+#include "gl_xlist.h"
diff --git a/contrib/tools/bison/lib/gl_xlist.h b/contrib/tools/bison/lib/gl_xlist.h
new file mode 100644
index 00000000000..87885c33c81
--- /dev/null
+++ b/contrib/tools/bison/lib/gl_xlist.h
@@ -0,0 +1,177 @@
+/* Abstract sequential list data type, with out-of-memory checking.
+ Copyright (C) 2009-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <[email protected]>, 2009.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_XLIST_H
+#define _GL_XLIST_H
+
+#include "gl_list.h"
+#include "xalloc.h"
+
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
+_GL_INLINE_HEADER_BEGIN
+#ifndef GL_XLIST_INLINE
+# define GL_XLIST_INLINE _GL_INLINE
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* These functions are thin wrappers around the corresponding functions with
+ _nx_ infix from gl_list.h. Upon out-of-memory, they invoke xalloc_die (),
+ instead of returning an error indicator. */
+#if 0 /* These are defined inline below. */
+extern gl_list_t gl_list_create_empty (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates);
+extern gl_list_t gl_list_create (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates,
+ size_t count, const void **contents);
+extern void gl_list_node_set_value (gl_list_t list, gl_list_node_t node,
+ const void *elt);
+extern gl_list_node_t gl_list_set_at (gl_list_t list, size_t position,
+ const void *elt);
+extern gl_list_node_t gl_list_add_first (gl_list_t list, const void *elt);
+extern gl_list_node_t gl_list_add_last (gl_list_t list, const void *elt);
+extern gl_list_node_t gl_list_add_before (gl_list_t list, gl_list_node_t node,
+ const void *elt);
+extern gl_list_node_t gl_list_add_after (gl_list_t list, gl_list_node_t node,
+ const void *elt);
+extern gl_list_node_t gl_list_add_at (gl_list_t list, size_t position,
+ const void *elt);
+extern gl_list_node_t gl_sortedlist_add (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ const void *elt);
+#endif
+
+GL_XLIST_INLINE gl_list_t
+gl_list_create_empty (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates)
+{
+ gl_list_t result =
+ gl_list_nx_create_empty (implementation, equals_fn, hashcode_fn, dispose_fn,
+ allow_duplicates);
+ if (result == NULL)
+ xalloc_die ();
+ return result;
+}
+
+GL_XLIST_INLINE gl_list_t
+gl_list_create (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates,
+ size_t count, const void **contents)
+{
+ gl_list_t result =
+ gl_list_nx_create (implementation, equals_fn, hashcode_fn, dispose_fn,
+ allow_duplicates, count, contents);
+ if (result == NULL)
+ xalloc_die ();
+ return result;
+}
+
+GL_XLIST_INLINE void
+gl_list_node_set_value (gl_list_t list, gl_list_node_t node, const void *elt)
+{
+ int result = gl_list_node_nx_set_value (list, node, elt);
+ if (result < 0)
+ xalloc_die ();
+}
+
+GL_XLIST_INLINE gl_list_node_t
+gl_list_set_at (gl_list_t list, size_t position, const void *elt)
+{
+ gl_list_node_t result = gl_list_nx_set_at (list, position, elt);
+ if (result == NULL)
+ xalloc_die ();
+ return result;
+}
+
+GL_XLIST_INLINE gl_list_node_t
+gl_list_add_first (gl_list_t list, const void *elt)
+{
+ gl_list_node_t result = gl_list_nx_add_first (list, elt);
+ if (result == NULL)
+ xalloc_die ();
+ return result;
+}
+
+GL_XLIST_INLINE gl_list_node_t
+gl_list_add_last (gl_list_t list, const void *elt)
+{
+ gl_list_node_t result = gl_list_nx_add_last (list, elt);
+ if (result == NULL)
+ xalloc_die ();
+ return result;
+}
+
+GL_XLIST_INLINE gl_list_node_t
+gl_list_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
+{
+ gl_list_node_t result = gl_list_nx_add_before (list, node, elt);
+ if (result == NULL)
+ xalloc_die ();
+ return result;
+}
+
+GL_XLIST_INLINE gl_list_node_t
+gl_list_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
+{
+ gl_list_node_t result = gl_list_nx_add_after (list, node, elt);
+ if (result == NULL)
+ xalloc_die ();
+ return result;
+}
+
+GL_XLIST_INLINE gl_list_node_t
+gl_list_add_at (gl_list_t list, size_t position, const void *elt)
+{
+ gl_list_node_t result = gl_list_nx_add_at (list, position, elt);
+ if (result == NULL)
+ xalloc_die ();
+ return result;
+}
+
+GL_XLIST_INLINE gl_list_node_t
+gl_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar,
+ const void *elt)
+{
+ gl_list_node_t result = gl_sortedlist_nx_add (list, compar, elt);
+ if (result == NULL)
+ xalloc_die ();
+ return result;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+_GL_INLINE_HEADER_END
+
+#endif /* _GL_XLIST_H */
diff --git a/contrib/tools/bison/lib/glthread/lock.c b/contrib/tools/bison/lib/glthread/lock.c
deleted file mode 100644
index f166d7ca8cf..00000000000
--- a/contrib/tools/bison/lib/glthread/lock.c
+++ /dev/null
@@ -1,1221 +0,0 @@
-/* Locking in multithreaded situations.
- Copyright (C) 2005-2018 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <[email protected]>, 2005.
- Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
- gthr-win32.h. */
-
-#include <config.h>
-
-#include "glthread/lock.h"
-
-/* ========================================================================= */
-
-#if USE_POSIX_THREADS
-
-/* -------------------------- gl_lock_t datatype -------------------------- */
-
-/* ------------------------- gl_rwlock_t datatype ------------------------- */
-
-# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1)))
-
-# ifdef PTHREAD_RWLOCK_INITIALIZER
-
-# if !HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
- /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */
-
-int
-glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock)
-{
- pthread_rwlockattr_t attributes;
- int err;
-
- err = pthread_rwlockattr_init (&attributes);
- if (err != 0)
- return err;
- /* Note: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP is the only value that
- causes the writer to be preferred. PTHREAD_RWLOCK_PREFER_WRITER_NP does not
- do this; see
- http://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html */
- err = pthread_rwlockattr_setkind_np (&attributes,
- PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
- if (err == 0)
- err = pthread_rwlock_init(lock, &attributes);
- /* pthread_rwlockattr_destroy always returns 0. It cannot influence the
- return value. */
- pthread_rwlockattr_destroy (&attributes);
- return err;
-}
-
-# endif
-# else
-
-int
-glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
-{
- int err;
-
- err = pthread_rwlock_init (&lock->rwlock, NULL);
- if (err != 0)
- return err;
- lock->initialized = 1;
- return 0;
-}
-
-int
-glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
-{
- if (!lock->initialized)
- {
- int err;
-
- err = pthread_mutex_lock (&lock->guard);
- if (err != 0)
- return err;
- if (!lock->initialized)
- {
- err = glthread_rwlock_init_multithreaded (lock);
- if (err != 0)
- {
- pthread_mutex_unlock (&lock->guard);
- return err;
- }
- }
- err = pthread_mutex_unlock (&lock->guard);
- if (err != 0)
- return err;
- }
- return pthread_rwlock_rdlock (&lock->rwlock);
-}
-
-int
-glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
-{
- if (!lock->initialized)
- {
- int err;
-
- err = pthread_mutex_lock (&lock->guard);
- if (err != 0)
- return err;
- if (!lock->initialized)
- {
- err = glthread_rwlock_init_multithreaded (lock);
- if (err != 0)
- {
- pthread_mutex_unlock (&lock->guard);
- return err;
- }
- }
- err = pthread_mutex_unlock (&lock->guard);
- if (err != 0)
- return err;
- }
- return pthread_rwlock_wrlock (&lock->rwlock);
-}
-
-int
-glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
-{
- if (!lock->initialized)
- return EINVAL;
- return pthread_rwlock_unlock (&lock->rwlock);
-}
-
-int
-glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
-{
- int err;
-
- if (!lock->initialized)
- return EINVAL;
- err = pthread_rwlock_destroy (&lock->rwlock);
- if (err != 0)
- return err;
- lock->initialized = 0;
- return 0;
-}
-
-# endif
-
-# else
-
-int
-glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
-{
- int err;
-
- err = pthread_mutex_init (&lock->lock, NULL);
- if (err != 0)
- return err;
- err = pthread_cond_init (&lock->waiting_readers, NULL);
- if (err != 0)
- return err;
- err = pthread_cond_init (&lock->waiting_writers, NULL);
- if (err != 0)
- return err;
- lock->waiting_writers_count = 0;
- lock->runcount = 0;
- return 0;
-}
-
-int
-glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
-{
- int err;
-
- err = pthread_mutex_lock (&lock->lock);
- if (err != 0)
- return err;
- /* Test whether only readers are currently running, and whether the runcount
- field will not overflow, and whether no writer is waiting. The latter
- condition is because POSIX recommends that "write locks shall take
- precedence over read locks", to avoid "writer starvation". */
- while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0))
- {
- /* This thread has to wait for a while. Enqueue it among the
- waiting_readers. */
- err = pthread_cond_wait (&lock->waiting_readers, &lock->lock);
- if (err != 0)
- {
- pthread_mutex_unlock (&lock->lock);
- return err;
- }
- }
- lock->runcount++;
- return pthread_mutex_unlock (&lock->lock);
-}
-
-int
-glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
-{
- int err;
-
- err = pthread_mutex_lock (&lock->lock);
- if (err != 0)
- return err;
- /* Test whether no readers or writers are currently running. */
- while (!(lock->runcount == 0))
- {
- /* This thread has to wait for a while. Enqueue it among the
- waiting_writers. */
- lock->waiting_writers_count++;
- err = pthread_cond_wait (&lock->waiting_writers, &lock->lock);
- if (err != 0)
- {
- lock->waiting_writers_count--;
- pthread_mutex_unlock (&lock->lock);
- return err;
- }
- lock->waiting_writers_count--;
- }
- lock->runcount--; /* runcount becomes -1 */
- return pthread_mutex_unlock (&lock->lock);
-}
-
-int
-glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
-{
- int err;
-
- err = pthread_mutex_lock (&lock->lock);
- if (err != 0)
- return err;
- if (lock->runcount < 0)
- {
- /* Drop a writer lock. */
- if (!(lock->runcount == -1))
- {
- pthread_mutex_unlock (&lock->lock);
- return EINVAL;
- }
- lock->runcount = 0;
- }
- else
- {
- /* Drop a reader lock. */
- if (!(lock->runcount > 0))
- {
- pthread_mutex_unlock (&lock->lock);
- return EINVAL;
- }
- lock->runcount--;
- }
- if (lock->runcount == 0)
- {
- /* POSIX recommends that "write locks shall take precedence over read
- locks", to avoid "writer starvation". */
- if (lock->waiting_writers_count > 0)
- {
- /* Wake up one of the waiting writers. */
- err = pthread_cond_signal (&lock->waiting_writers);
- if (err != 0)
- {
- pthread_mutex_unlock (&lock->lock);
- return err;
- }
- }
- else
- {
- /* Wake up all waiting readers. */
- err = pthread_cond_broadcast (&lock->waiting_readers);
- if (err != 0)
- {
- pthread_mutex_unlock (&lock->lock);
- return err;
- }
- }
- }
- return pthread_mutex_unlock (&lock->lock);
-}
-
-int
-glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
-{
- int err;
-
- err = pthread_mutex_destroy (&lock->lock);
- if (err != 0)
- return err;
- err = pthread_cond_destroy (&lock->waiting_readers);
- if (err != 0)
- return err;
- err = pthread_cond_destroy (&lock->waiting_writers);
- if (err != 0)
- return err;
- return 0;
-}
-
-# endif
-
-/* --------------------- gl_recursive_lock_t datatype --------------------- */
-
-# if HAVE_PTHREAD_MUTEX_RECURSIVE
-
-# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-
-int
-glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
-{
- pthread_mutexattr_t attributes;
- int err;
-
- err = pthread_mutexattr_init (&attributes);
- if (err != 0)
- return err;
- err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
- if (err != 0)
- {
- pthread_mutexattr_destroy (&attributes);
- return err;
- }
- err = pthread_mutex_init (lock, &attributes);
- if (err != 0)
- {
- pthread_mutexattr_destroy (&attributes);
- return err;
- }
- err = pthread_mutexattr_destroy (&attributes);
- if (err != 0)
- return err;
- return 0;
-}
-
-# else
-
-int
-glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
-{
- pthread_mutexattr_t attributes;
- int err;
-
- err = pthread_mutexattr_init (&attributes);
- if (err != 0)
- return err;
- err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
- if (err != 0)
- {
- pthread_mutexattr_destroy (&attributes);
- return err;
- }
- err = pthread_mutex_init (&lock->recmutex, &attributes);
- if (err != 0)
- {
- pthread_mutexattr_destroy (&attributes);
- return err;
- }
- err = pthread_mutexattr_destroy (&attributes);
- if (err != 0)
- return err;
- lock->initialized = 1;
- return 0;
-}
-
-int
-glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
-{
- if (!lock->initialized)
- {
- int err;
-
- err = pthread_mutex_lock (&lock->guard);
- if (err != 0)
- return err;
- if (!lock->initialized)
- {
- err = glthread_recursive_lock_init_multithreaded (lock);
- if (err != 0)
- {
- pthread_mutex_unlock (&lock->guard);
- return err;
- }
- }
- err = pthread_mutex_unlock (&lock->guard);
- if (err != 0)
- return err;
- }
- return pthread_mutex_lock (&lock->recmutex);
-}
-
-int
-glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
-{
- if (!lock->initialized)
- return EINVAL;
- return pthread_mutex_unlock (&lock->recmutex);
-}
-
-int
-glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
-{
- int err;
-
- if (!lock->initialized)
- return EINVAL;
- err = pthread_mutex_destroy (&lock->recmutex);
- if (err != 0)
- return err;
- lock->initialized = 0;
- return 0;
-}
-
-# endif
-
-# else
-
-int
-glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
-{
- int err;
-
- err = pthread_mutex_init (&lock->mutex, NULL);
- if (err != 0)
- return err;
- lock->owner = (pthread_t) 0;
- lock->depth = 0;
- return 0;
-}
-
-int
-glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
-{
- pthread_t self = pthread_self ();
- if (lock->owner != self)
- {
- int err;
-
- err = pthread_mutex_lock (&lock->mutex);
- if (err != 0)
- return err;
- lock->owner = self;
- }
- if (++(lock->depth) == 0) /* wraparound? */
- {
- lock->depth--;
- return EAGAIN;
- }
- return 0;
-}
-
-int
-glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
-{
- if (lock->owner != pthread_self ())
- return EPERM;
- if (lock->depth == 0)
- return EINVAL;
- if (--(lock->depth) == 0)
- {
- lock->owner = (pthread_t) 0;
- return pthread_mutex_unlock (&lock->mutex);
- }
- else
- return 0;
-}
-
-int
-glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
-{
- if (lock->owner != (pthread_t) 0)
- return EBUSY;
- return pthread_mutex_destroy (&lock->mutex);
-}
-
-# endif
-
-/* -------------------------- gl_once_t datatype -------------------------- */
-
-static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT;
-
-int
-glthread_once_singlethreaded (pthread_once_t *once_control)
-{
- /* We don't know whether pthread_once_t is an integer type, a floating-point
- type, a pointer type, or a structure type. */
- char *firstbyte = (char *)once_control;
- if (*firstbyte == *(const char *)&fresh_once)
- {
- /* First time use of once_control. Invert the first byte. */
- *firstbyte = ~ *(const char *)&fresh_once;
- return 1;
- }
- else
- return 0;
-}
-
-#endif
-
-/* ========================================================================= */
-
-#if USE_PTH_THREADS
-
-/* Use the GNU Pth threads library. */
-
-/* -------------------------- gl_lock_t datatype -------------------------- */
-
-/* ------------------------- gl_rwlock_t datatype ------------------------- */
-
-# if !HAVE_PTH_RWLOCK_ACQUIRE_PREFER_WRITER
-
-int
-glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
-{
- if (!pth_mutex_init (&lock->lock))
- return errno;
- if (!pth_cond_init (&lock->waiting_readers))
- return errno;
- if (!pth_cond_init (&lock->waiting_writers))
- return errno;
- lock->waiting_writers_count = 0;
- lock->runcount = 0;
- lock->initialized = 1;
- return 0;
-}
-
-int
-glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
-{
- if (!lock->initialized)
- glthread_rwlock_init_multithreaded (lock);
- if (!pth_mutex_acquire (&lock->lock, 0, NULL))
- return errno;
- /* Test whether only readers are currently running, and whether the runcount
- field will not overflow, and whether no writer is waiting. The latter
- condition is because POSIX recommends that "write locks shall take
- precedence over read locks", to avoid "writer starvation". */
- while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0))
- {
- /* This thread has to wait for a while. Enqueue it among the
- waiting_readers. */
- if (!pth_cond_await (&lock->waiting_readers, &lock->lock, NULL))
- {
- int err = errno;
- pth_mutex_release (&lock->lock);
- return err;
- }
- }
- lock->runcount++;
- return (!pth_mutex_release (&lock->lock) ? errno : 0);
-}
-
-int
-glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
-{
- if (!lock->initialized)
- glthread_rwlock_init_multithreaded (lock);
- if (!pth_mutex_acquire (&lock->lock, 0, NULL))
- return errno;
- /* Test whether no readers or writers are currently running. */
- while (!(lock->runcount == 0))
- {
- /* This thread has to wait for a while. Enqueue it among the
- waiting_writers. */
- lock->waiting_writers_count++;
- if (!pth_cond_await (&lock->waiting_writers, &lock->lock, NULL))
- {
- int err = errno;
- lock->waiting_writers_count--;
- pth_mutex_release (&lock->lock);
- return err;
- }
- lock->waiting_writers_count--;
- }
- lock->runcount--; /* runcount becomes -1 */
- return (!pth_mutex_release (&lock->lock) ? errno : 0);
-}
-
-int
-glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
-{
- int err;
-
- if (!lock->initialized)
- return EINVAL;
- if (!pth_mutex_acquire (&lock->lock, 0, NULL))
- return errno;
- if (lock->runcount < 0)
- {
- /* Drop a writer lock. */
- if (!(lock->runcount == -1))
- {
- pth_mutex_release (&lock->lock);
- return EINVAL;
- }
- lock->runcount = 0;
- }
- else
- {
- /* Drop a reader lock. */
- if (!(lock->runcount > 0))
- {
- pth_mutex_release (&lock->lock);
- return EINVAL;
- }
- lock->runcount--;
- }
- if (lock->runcount == 0)
- {
- /* POSIX recommends that "write locks shall take precedence over read
- locks", to avoid "writer starvation". */
- if (lock->waiting_writers_count > 0)
- {
- /* Wake up one of the waiting writers. */
- if (!pth_cond_notify (&lock->waiting_writers, FALSE))
- {
- int err = errno;
- pth_mutex_release (&lock->lock);
- return err;
- }
- }
- else
- {
- /* Wake up all waiting readers. */
- if (!pth_cond_notify (&lock->waiting_readers, TRUE))
- {
- int err = errno;
- pth_mutex_release (&lock->lock);
- return err;
- }
- }
- }
- return (!pth_mutex_release (&lock->lock) ? errno : 0);
-}
-
-int
-glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
-{
- lock->initialized = 0;
- return 0;
-}
-
-# endif
-
-/* --------------------- gl_recursive_lock_t datatype --------------------- */
-
-/* -------------------------- gl_once_t datatype -------------------------- */
-
-static void
-glthread_once_call (void *arg)
-{
- void (**gl_once_temp_addr) (void) = (void (**) (void)) arg;
- void (*initfunction) (void) = *gl_once_temp_addr;
- initfunction ();
-}
-
-int
-glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void))
-{
- void (*temp) (void) = initfunction;
- return (!pth_once (once_control, glthread_once_call, &temp) ? errno : 0);
-}
-
-int
-glthread_once_singlethreaded (pth_once_t *once_control)
-{
- /* We know that pth_once_t is an integer type. */
- if (*once_control == PTH_ONCE_INIT)
- {
- /* First time use of once_control. Invert the marker. */
- *once_control = ~ PTH_ONCE_INIT;
- return 1;
- }
- else
- return 0;
-}
-
-#endif
-
-/* ========================================================================= */
-
-#if USE_SOLARIS_THREADS
-
-/* Use the old Solaris threads library. */
-
-/* -------------------------- gl_lock_t datatype -------------------------- */
-
-/* ------------------------- gl_rwlock_t datatype ------------------------- */
-
-/* --------------------- gl_recursive_lock_t datatype --------------------- */
-
-int
-glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
-{
- int err;
-
- err = mutex_init (&lock->mutex, USYNC_THREAD, NULL);
- if (err != 0)
- return err;
- lock->owner = (thread_t) 0;
- lock->depth = 0;
- return 0;
-}
-
-int
-glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
-{
- thread_t self = thr_self ();
- if (lock->owner != self)
- {
- int err;
-
- err = mutex_lock (&lock->mutex);
- if (err != 0)
- return err;
- lock->owner = self;
- }
- if (++(lock->depth) == 0) /* wraparound? */
- {
- lock->depth--;
- return EAGAIN;
- }
- return 0;
-}
-
-int
-glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
-{
- if (lock->owner != thr_self ())
- return EPERM;
- if (lock->depth == 0)
- return EINVAL;
- if (--(lock->depth) == 0)
- {
- lock->owner = (thread_t) 0;
- return mutex_unlock (&lock->mutex);
- }
- else
- return 0;
-}
-
-int
-glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
-{
- if (lock->owner != (thread_t) 0)
- return EBUSY;
- return mutex_destroy (&lock->mutex);
-}
-
-/* -------------------------- gl_once_t datatype -------------------------- */
-
-int
-glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void))
-{
- if (!once_control->inited)
- {
- int err;
-
- /* Use the mutex to guarantee that if another thread is already calling
- the initfunction, this thread waits until it's finished. */
- err = mutex_lock (&once_control->mutex);
- if (err != 0)
- return err;
- if (!once_control->inited)
- {
- once_control->inited = 1;
- initfunction ();
- }
- return mutex_unlock (&once_control->mutex);
- }
- else
- return 0;
-}
-
-int
-glthread_once_singlethreaded (gl_once_t *once_control)
-{
- /* We know that gl_once_t contains an integer type. */
- if (!once_control->inited)
- {
- /* First time use of once_control. Invert the marker. */
- once_control->inited = ~ 0;
- return 1;
- }
- else
- return 0;
-}
-
-#endif
-
-/* ========================================================================= */
-
-#if USE_WINDOWS_THREADS
-
-/* -------------------------- gl_lock_t datatype -------------------------- */
-
-void
-glthread_lock_init_func (gl_lock_t *lock)
-{
- InitializeCriticalSection (&lock->lock);
- lock->guard.done = 1;
-}
-
-int
-glthread_lock_lock_func (gl_lock_t *lock)
-{
- if (!lock->guard.done)
- {
- if (InterlockedIncrement (&lock->guard.started) == 0)
- /* This thread is the first one to need this lock. Initialize it. */
- glthread_lock_init (lock);
- else
- /* Yield the CPU while waiting for another thread to finish
- initializing this lock. */
- while (!lock->guard.done)
- Sleep (0);
- }
- EnterCriticalSection (&lock->lock);
- return 0;
-}
-
-int
-glthread_lock_unlock_func (gl_lock_t *lock)
-{
- if (!lock->guard.done)
- return EINVAL;
- LeaveCriticalSection (&lock->lock);
- return 0;
-}
-
-int
-glthread_lock_destroy_func (gl_lock_t *lock)
-{
- if (!lock->guard.done)
- return EINVAL;
- DeleteCriticalSection (&lock->lock);
- lock->guard.done = 0;
- return 0;
-}
-
-/* ------------------------- gl_rwlock_t datatype ------------------------- */
-
-/* In this file, the waitqueues are implemented as circular arrays. */
-#define gl_waitqueue_t gl_carray_waitqueue_t
-
-static void
-gl_waitqueue_init (gl_waitqueue_t *wq)
-{
- wq->array = NULL;
- wq->count = 0;
- wq->alloc = 0;
- wq->offset = 0;
-}
-
-/* Enqueues the current thread, represented by an event, in a wait queue.
- Returns INVALID_HANDLE_VALUE if an allocation failure occurs. */
-static HANDLE
-gl_waitqueue_add (gl_waitqueue_t *wq)
-{
- HANDLE event;
- unsigned int index;
-
- if (wq->count == wq->alloc)
- {
- unsigned int new_alloc = 2 * wq->alloc + 1;
- HANDLE *new_array =
- (HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE));
- if (new_array == NULL)
- /* No more memory. */
- return INVALID_HANDLE_VALUE;
- /* Now is a good opportunity to rotate the array so that its contents
- starts at offset 0. */
- if (wq->offset > 0)
- {
- unsigned int old_count = wq->count;
- unsigned int old_alloc = wq->alloc;
- unsigned int old_offset = wq->offset;
- unsigned int i;
- if (old_offset + old_count > old_alloc)
- {
- unsigned int limit = old_offset + old_count - old_alloc;
- for (i = 0; i < limit; i++)
- new_array[old_alloc + i] = new_array[i];
- }
- for (i = 0; i < old_count; i++)
- new_array[i] = new_array[old_offset + i];
- wq->offset = 0;
- }
- wq->array = new_array;
- wq->alloc = new_alloc;
- }
- /* Whether the created event is a manual-reset one or an auto-reset one,
- does not matter, since we will wait on it only once. */
- event = CreateEvent (NULL, TRUE, FALSE, NULL);
- if (event == INVALID_HANDLE_VALUE)
- /* No way to allocate an event. */
- return INVALID_HANDLE_VALUE;
- index = wq->offset + wq->count;
- if (index >= wq->alloc)
- index -= wq->alloc;
- wq->array[index] = event;
- wq->count++;
- return event;
-}
-
-/* Notifies the first thread from a wait queue and dequeues it. */
-static void
-gl_waitqueue_notify_first (gl_waitqueue_t *wq)
-{
- SetEvent (wq->array[wq->offset + 0]);
- wq->offset++;
- wq->count--;
- if (wq->count == 0 || wq->offset == wq->alloc)
- wq->offset = 0;
-}
-
-/* Notifies all threads from a wait queue and dequeues them all. */
-static void
-gl_waitqueue_notify_all (gl_waitqueue_t *wq)
-{
- unsigned int i;
-
- for (i = 0; i < wq->count; i++)
- {
- unsigned int index = wq->offset + i;
- if (index >= wq->alloc)
- index -= wq->alloc;
- SetEvent (wq->array[index]);
- }
- wq->count = 0;
- wq->offset = 0;
-}
-
-void
-glthread_rwlock_init_func (gl_rwlock_t *lock)
-{
- InitializeCriticalSection (&lock->lock);
- gl_waitqueue_init (&lock->waiting_readers);
- gl_waitqueue_init (&lock->waiting_writers);
- lock->runcount = 0;
- lock->guard.done = 1;
-}
-
-int
-glthread_rwlock_rdlock_func (gl_rwlock_t *lock)
-{
- if (!lock->guard.done)
- {
- if (InterlockedIncrement (&lock->guard.started) == 0)
- /* This thread is the first one to need this lock. Initialize it. */
- glthread_rwlock_init (lock);
- else
- /* Yield the CPU while waiting for another thread to finish
- initializing this lock. */
- while (!lock->guard.done)
- Sleep (0);
- }
- EnterCriticalSection (&lock->lock);
- /* Test whether only readers are currently running, and whether the runcount
- field will not overflow, and whether no writer is waiting. The latter
- condition is because POSIX recommends that "write locks shall take
- precedence over read locks", to avoid "writer starvation". */
- if (!(lock->runcount + 1 > 0 && lock->waiting_writers.count == 0))
- {
- /* This thread has to wait for a while. Enqueue it among the
- waiting_readers. */
- HANDLE event = gl_waitqueue_add (&lock->waiting_readers);
- if (event != INVALID_HANDLE_VALUE)
- {
- DWORD result;
- LeaveCriticalSection (&lock->lock);
- /* Wait until another thread signals this event. */
- result = WaitForSingleObject (event, INFINITE);
- if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
- abort ();
- CloseHandle (event);
- /* The thread which signalled the event already did the bookkeeping:
- removed us from the waiting_readers, incremented lock->runcount. */
- if (!(lock->runcount > 0))
- abort ();
- return 0;
- }
- else
- {
- /* Allocation failure. Weird. */
- do
- {
- LeaveCriticalSection (&lock->lock);
- Sleep (1);
- EnterCriticalSection (&lock->lock);
- }
- while (!(lock->runcount + 1 > 0));
- }
- }
- lock->runcount++;
- LeaveCriticalSection (&lock->lock);
- return 0;
-}
-
-int
-glthread_rwlock_wrlock_func (gl_rwlock_t *lock)
-{
- if (!lock->guard.done)
- {
- if (InterlockedIncrement (&lock->guard.started) == 0)
- /* This thread is the first one to need this lock. Initialize it. */
- glthread_rwlock_init (lock);
- else
- /* Yield the CPU while waiting for another thread to finish
- initializing this lock. */
- while (!lock->guard.done)
- Sleep (0);
- }
- EnterCriticalSection (&lock->lock);
- /* Test whether no readers or writers are currently running. */
- if (!(lock->runcount == 0))
- {
- /* This thread has to wait for a while. Enqueue it among the
- waiting_writers. */
- HANDLE event = gl_waitqueue_add (&lock->waiting_writers);
- if (event != INVALID_HANDLE_VALUE)
- {
- DWORD result;
- LeaveCriticalSection (&lock->lock);
- /* Wait until another thread signals this event. */
- result = WaitForSingleObject (event, INFINITE);
- if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
- abort ();
- CloseHandle (event);
- /* The thread which signalled the event already did the bookkeeping:
- removed us from the waiting_writers, set lock->runcount = -1. */
- if (!(lock->runcount == -1))
- abort ();
- return 0;
- }
- else
- {
- /* Allocation failure. Weird. */
- do
- {
- LeaveCriticalSection (&lock->lock);
- Sleep (1);
- EnterCriticalSection (&lock->lock);
- }
- while (!(lock->runcount == 0));
- }
- }
- lock->runcount--; /* runcount becomes -1 */
- LeaveCriticalSection (&lock->lock);
- return 0;
-}
-
-int
-glthread_rwlock_unlock_func (gl_rwlock_t *lock)
-{
- if (!lock->guard.done)
- return EINVAL;
- EnterCriticalSection (&lock->lock);
- if (lock->runcount < 0)
- {
- /* Drop a writer lock. */
- if (!(lock->runcount == -1))
- abort ();
- lock->runcount = 0;
- }
- else
- {
- /* Drop a reader lock. */
- if (!(lock->runcount > 0))
- {
- LeaveCriticalSection (&lock->lock);
- return EPERM;
- }
- lock->runcount--;
- }
- if (lock->runcount == 0)
- {
- /* POSIX recommends that "write locks shall take precedence over read
- locks", to avoid "writer starvation". */
- if (lock->waiting_writers.count > 0)
- {
- /* Wake up one of the waiting writers. */
- lock->runcount--;
- gl_waitqueue_notify_first (&lock->waiting_writers);
- }
- else
- {
- /* Wake up all waiting readers. */
- lock->runcount += lock->waiting_readers.count;
- gl_waitqueue_notify_all (&lock->waiting_readers);
- }
- }
- LeaveCriticalSection (&lock->lock);
- return 0;
-}
-
-int
-glthread_rwlock_destroy_func (gl_rwlock_t *lock)
-{
- if (!lock->guard.done)
- return EINVAL;
- if (lock->runcount != 0)
- return EBUSY;
- DeleteCriticalSection (&lock->lock);
- if (lock->waiting_readers.array != NULL)
- free (lock->waiting_readers.array);
- if (lock->waiting_writers.array != NULL)
- free (lock->waiting_writers.array);
- lock->guard.done = 0;
- return 0;
-}
-
-/* --------------------- gl_recursive_lock_t datatype --------------------- */
-
-void
-glthread_recursive_lock_init_func (gl_recursive_lock_t *lock)
-{
- lock->owner = 0;
- lock->depth = 0;
- InitializeCriticalSection (&lock->lock);
- lock->guard.done = 1;
-}
-
-int
-glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock)
-{
- if (!lock->guard.done)
- {
- if (InterlockedIncrement (&lock->guard.started) == 0)
- /* This thread is the first one to need this lock. Initialize it. */
- glthread_recursive_lock_init (lock);
- else
- /* Yield the CPU while waiting for another thread to finish
- initializing this lock. */
- while (!lock->guard.done)
- Sleep (0);
- }
- {
- DWORD self = GetCurrentThreadId ();
- if (lock->owner != self)
- {
- EnterCriticalSection (&lock->lock);
- lock->owner = self;
- }
- if (++(lock->depth) == 0) /* wraparound? */
- {
- lock->depth--;
- return EAGAIN;
- }
- }
- return 0;
-}
-
-int
-glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock)
-{
- if (lock->owner != GetCurrentThreadId ())
- return EPERM;
- if (lock->depth == 0)
- return EINVAL;
- if (--(lock->depth) == 0)
- {
- lock->owner = 0;
- LeaveCriticalSection (&lock->lock);
- }
- return 0;
-}
-
-int
-glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock)
-{
- if (lock->owner != 0)
- return EBUSY;
- DeleteCriticalSection (&lock->lock);
- lock->guard.done = 0;
- return 0;
-}
-
-/* -------------------------- gl_once_t datatype -------------------------- */
-
-void
-glthread_once_func (gl_once_t *once_control, void (*initfunction) (void))
-{
- if (once_control->inited <= 0)
- {
- if (InterlockedIncrement (&once_control->started) == 0)
- {
- /* This thread is the first one to come to this once_control. */
- InitializeCriticalSection (&once_control->lock);
- EnterCriticalSection (&once_control->lock);
- once_control->inited = 0;
- initfunction ();
- once_control->inited = 1;
- LeaveCriticalSection (&once_control->lock);
- }
- else
- {
- /* Undo last operation. */
- InterlockedDecrement (&once_control->started);
- /* Some other thread has already started the initialization.
- Yield the CPU while waiting for the other thread to finish
- initializing and taking the lock. */
- while (once_control->inited < 0)
- Sleep (0);
- if (once_control->inited <= 0)
- {
- /* Take the lock. This blocks until the other thread has
- finished calling the initfunction. */
- EnterCriticalSection (&once_control->lock);
- LeaveCriticalSection (&once_control->lock);
- if (!(once_control->inited > 0))
- abort ();
- }
- }
- }
-}
-
-#endif
-
-/* ========================================================================= */
diff --git a/contrib/tools/bison/lib/glthread/lock.h b/contrib/tools/bison/lib/glthread/lock.h
deleted file mode 100644
index 9c9e2f68409..00000000000
--- a/contrib/tools/bison/lib/glthread/lock.h
+++ /dev/null
@@ -1,985 +0,0 @@
-/* Locking in multithreaded situations.
- Copyright (C) 2005-2018 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <[email protected]>, 2005.
- Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
- gthr-win32.h. */
-
-/* This file contains locking primitives for use with a given thread library.
- It does not contain primitives for creating threads or for other
- synchronization primitives.
-
- Normal (non-recursive) locks:
- Type: gl_lock_t
- Declaration: gl_lock_define(extern, name)
- Initializer: gl_lock_define_initialized(, name)
- Initialization: gl_lock_init (name);
- Taking the lock: gl_lock_lock (name);
- Releasing the lock: gl_lock_unlock (name);
- De-initialization: gl_lock_destroy (name);
- Equivalent functions with control of error handling:
- Initialization: err = glthread_lock_init (&name);
- Taking the lock: err = glthread_lock_lock (&name);
- Releasing the lock: err = glthread_lock_unlock (&name);
- De-initialization: err = glthread_lock_destroy (&name);
-
- Read-Write (non-recursive) locks:
- Type: gl_rwlock_t
- Declaration: gl_rwlock_define(extern, name)
- Initializer: gl_rwlock_define_initialized(, name)
- Initialization: gl_rwlock_init (name);
- Taking the lock: gl_rwlock_rdlock (name);
- gl_rwlock_wrlock (name);
- Releasing the lock: gl_rwlock_unlock (name);
- De-initialization: gl_rwlock_destroy (name);
- Equivalent functions with control of error handling:
- Initialization: err = glthread_rwlock_init (&name);
- Taking the lock: err = glthread_rwlock_rdlock (&name);
- err = glthread_rwlock_wrlock (&name);
- Releasing the lock: err = glthread_rwlock_unlock (&name);
- De-initialization: err = glthread_rwlock_destroy (&name);
-
- Recursive locks:
- Type: gl_recursive_lock_t
- Declaration: gl_recursive_lock_define(extern, name)
- Initializer: gl_recursive_lock_define_initialized(, name)
- Initialization: gl_recursive_lock_init (name);
- Taking the lock: gl_recursive_lock_lock (name);
- Releasing the lock: gl_recursive_lock_unlock (name);
- De-initialization: gl_recursive_lock_destroy (name);
- Equivalent functions with control of error handling:
- Initialization: err = glthread_recursive_lock_init (&name);
- Taking the lock: err = glthread_recursive_lock_lock (&name);
- Releasing the lock: err = glthread_recursive_lock_unlock (&name);
- De-initialization: err = glthread_recursive_lock_destroy (&name);
-
- Once-only execution:
- Type: gl_once_t
- Initializer: gl_once_define(extern, name)
- Execution: gl_once (name, initfunction);
- Equivalent functions with control of error handling:
- Execution: err = glthread_once (&name, initfunction);
-*/
-
-
-#ifndef _LOCK_H
-#define _LOCK_H
-
-#include <errno.h>
-#include <stdlib.h>
-
-/* ========================================================================= */
-
-#if USE_POSIX_THREADS
-
-/* Use the POSIX threads library. */
-
-# include <pthread.h>
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-# if PTHREAD_IN_USE_DETECTION_HARD
-
-/* The pthread_in_use() detection needs to be done at runtime. */
-# define pthread_in_use() \
- glthread_in_use ()
-extern int glthread_in_use (void);
-
-# endif
-
-# if USE_POSIX_THREADS_WEAK
-
-/* Use weak references to the POSIX threads library. */
-
-/* Weak references avoid dragging in external libraries if the other parts
- of the program don't use them. Here we use them, because we don't want
- every program that uses libintl to depend on libpthread. This assumes
- that libpthread would not be loaded after libintl; i.e. if libintl is
- loaded first, by an executable that does not depend on libpthread, and
- then a module is dynamically loaded that depends on libpthread, libintl
- will not be multithread-safe. */
-
-/* The way to test at runtime whether libpthread is present is to test
- whether a function pointer's value, such as &pthread_mutex_init, is
- non-NULL. However, some versions of GCC have a bug through which, in
- PIC mode, &foo != NULL always evaluates to true if there is a direct
- call to foo(...) in the same function. To avoid this, we test the
- address of a function in libpthread that we don't use. */
-
-# pragma weak pthread_mutex_init
-# pragma weak pthread_mutex_lock
-# pragma weak pthread_mutex_unlock
-# pragma weak pthread_mutex_destroy
-# pragma weak pthread_rwlock_init
-# pragma weak pthread_rwlock_rdlock
-# pragma weak pthread_rwlock_wrlock
-# pragma weak pthread_rwlock_unlock
-# pragma weak pthread_rwlock_destroy
-# pragma weak pthread_once
-# pragma weak pthread_cond_init
-# pragma weak pthread_cond_wait
-# pragma weak pthread_cond_signal
-# pragma weak pthread_cond_broadcast
-# pragma weak pthread_cond_destroy
-# pragma weak pthread_mutexattr_init
-# pragma weak pthread_mutexattr_settype
-# pragma weak pthread_mutexattr_destroy
-# pragma weak pthread_rwlockattr_init
-# if __GNU_LIBRARY__ > 1
-# pragma weak pthread_rwlockattr_setkind_np
-# endif
-# pragma weak pthread_rwlockattr_destroy
-# ifndef pthread_self
-# pragma weak pthread_self
-# endif
-
-# if !PTHREAD_IN_USE_DETECTION_HARD
- /* Considering all platforms with USE_POSIX_THREADS_WEAK, only few symbols
- can be used to determine whether libpthread is in use. These are:
- pthread_mutexattr_gettype
- pthread_rwlockattr_destroy
- pthread_rwlockattr_init
- */
-# pragma weak pthread_mutexattr_gettype
-# define pthread_in_use() (pthread_mutexattr_gettype != NULL)
-# endif
-
-# else
-
-# if !PTHREAD_IN_USE_DETECTION_HARD
-# define pthread_in_use() 1
-# endif
-
-# endif
-
-/* -------------------------- gl_lock_t datatype -------------------------- */
-
-typedef pthread_mutex_t gl_lock_t;
-# define gl_lock_define(STORAGECLASS, NAME) \
- STORAGECLASS pthread_mutex_t NAME;
-# define gl_lock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS pthread_mutex_t NAME = gl_lock_initializer;
-# define gl_lock_initializer \
- PTHREAD_MUTEX_INITIALIZER
-# define glthread_lock_init(LOCK) \
- (pthread_in_use () ? pthread_mutex_init (LOCK, NULL) : 0)
-# define glthread_lock_lock(LOCK) \
- (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0)
-# define glthread_lock_unlock(LOCK) \
- (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0)
-# define glthread_lock_destroy(LOCK) \
- (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0)
-
-/* ------------------------- gl_rwlock_t datatype ------------------------- */
-
-# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1)))
-
-# ifdef PTHREAD_RWLOCK_INITIALIZER
-
-typedef pthread_rwlock_t gl_rwlock_t;
-# define gl_rwlock_define(STORAGECLASS, NAME) \
- STORAGECLASS pthread_rwlock_t NAME;
-# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer;
-# if HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
-# define gl_rwlock_initializer \
- PTHREAD_RWLOCK_INITIALIZER
-# define glthread_rwlock_init(LOCK) \
- (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0)
-# else /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */
-# define gl_rwlock_initializer \
- PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
-# define glthread_rwlock_init(LOCK) \
- (pthread_in_use () ? glthread_rwlock_init_for_glibc (LOCK) : 0)
-extern int glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock);
-# endif
-# define glthread_rwlock_rdlock(LOCK) \
- (pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0)
-# define glthread_rwlock_wrlock(LOCK) \
- (pthread_in_use () ? pthread_rwlock_wrlock (LOCK) : 0)
-# define glthread_rwlock_unlock(LOCK) \
- (pthread_in_use () ? pthread_rwlock_unlock (LOCK) : 0)
-# define glthread_rwlock_destroy(LOCK) \
- (pthread_in_use () ? pthread_rwlock_destroy (LOCK) : 0)
-
-# else
-
-typedef struct
- {
- int initialized;
- pthread_mutex_t guard; /* protects the initialization */
- pthread_rwlock_t rwlock; /* read-write lock */
- }
- gl_rwlock_t;
-# define gl_rwlock_define(STORAGECLASS, NAME) \
- STORAGECLASS gl_rwlock_t NAME;
-# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
-# define gl_rwlock_initializer \
- { 0, PTHREAD_MUTEX_INITIALIZER }
-# define glthread_rwlock_init(LOCK) \
- (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
-# define glthread_rwlock_rdlock(LOCK) \
- (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
-# define glthread_rwlock_wrlock(LOCK) \
- (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
-# define glthread_rwlock_unlock(LOCK) \
- (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
-# define glthread_rwlock_destroy(LOCK) \
- (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
-extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
-extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
-extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
-extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
-extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
-
-# endif
-
-# else
-
-typedef struct
- {
- pthread_mutex_t lock; /* protects the remaining fields */
- pthread_cond_t waiting_readers; /* waiting readers */
- pthread_cond_t waiting_writers; /* waiting writers */
- unsigned int waiting_writers_count; /* number of waiting writers */
- int runcount; /* number of readers running, or -1 when a writer runs */
- }
- gl_rwlock_t;
-# define gl_rwlock_define(STORAGECLASS, NAME) \
- STORAGECLASS gl_rwlock_t NAME;
-# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
-# define gl_rwlock_initializer \
- { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 }
-# define glthread_rwlock_init(LOCK) \
- (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
-# define glthread_rwlock_rdlock(LOCK) \
- (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
-# define glthread_rwlock_wrlock(LOCK) \
- (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
-# define glthread_rwlock_unlock(LOCK) \
- (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
-# define glthread_rwlock_destroy(LOCK) \
- (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
-extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
-extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
-extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
-extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
-extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
-
-# endif
-
-/* --------------------- gl_recursive_lock_t datatype --------------------- */
-
-# if HAVE_PTHREAD_MUTEX_RECURSIVE
-
-# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-
-typedef pthread_mutex_t gl_recursive_lock_t;
-# define gl_recursive_lock_define(STORAGECLASS, NAME) \
- STORAGECLASS pthread_mutex_t NAME;
-# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS pthread_mutex_t NAME = gl_recursive_lock_initializer;
-# ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER
-# define gl_recursive_lock_initializer \
- PTHREAD_RECURSIVE_MUTEX_INITIALIZER
-# else
-# define gl_recursive_lock_initializer \
- PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-# endif
-# define glthread_recursive_lock_init(LOCK) \
- (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
-# define glthread_recursive_lock_lock(LOCK) \
- (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0)
-# define glthread_recursive_lock_unlock(LOCK) \
- (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0)
-# define glthread_recursive_lock_destroy(LOCK) \
- (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0)
-extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
-
-# else
-
-typedef struct
- {
- pthread_mutex_t recmutex; /* recursive mutex */
- pthread_mutex_t guard; /* protects the initialization */
- int initialized;
- }
- gl_recursive_lock_t;
-# define gl_recursive_lock_define(STORAGECLASS, NAME) \
- STORAGECLASS gl_recursive_lock_t NAME;
-# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
-# define gl_recursive_lock_initializer \
- { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 }
-# define glthread_recursive_lock_init(LOCK) \
- (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
-# define glthread_recursive_lock_lock(LOCK) \
- (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
-# define glthread_recursive_lock_unlock(LOCK) \
- (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
-# define glthread_recursive_lock_destroy(LOCK) \
- (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
-extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
-extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
-extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
-extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
-
-# endif
-
-# else
-
-/* Old versions of POSIX threads on Solaris did not have recursive locks.
- We have to implement them ourselves. */
-
-typedef struct
- {
- pthread_mutex_t mutex;
- pthread_t owner;
- unsigned long depth;
- }
- gl_recursive_lock_t;
-# define gl_recursive_lock_define(STORAGECLASS, NAME) \
- STORAGECLASS gl_recursive_lock_t NAME;
-# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
-# define gl_recursive_lock_initializer \
- { PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 }
-# define glthread_recursive_lock_init(LOCK) \
- (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
-# define glthread_recursive_lock_lock(LOCK) \
- (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
-# define glthread_recursive_lock_unlock(LOCK) \
- (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
-# define glthread_recursive_lock_destroy(LOCK) \
- (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
-extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
-extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
-extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
-extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
-
-# endif
-
-/* -------------------------- gl_once_t datatype -------------------------- */
-
-typedef pthread_once_t gl_once_t;
-# define gl_once_define(STORAGECLASS, NAME) \
- STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT;
-# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
- (pthread_in_use () \
- ? pthread_once (ONCE_CONTROL, INITFUNCTION) \
- : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
-extern int glthread_once_singlethreaded (pthread_once_t *once_control);
-
-# ifdef __cplusplus
-}
-# endif
-
-#endif
-
-/* ========================================================================= */
-
-#if USE_PTH_THREADS
-
-/* Use the GNU Pth threads library. */
-
-# include <pth.h>
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-# if USE_PTH_THREADS_WEAK
-
-/* Use weak references to the GNU Pth threads library. */
-
-# pragma weak pth_mutex_init
-# pragma weak pth_mutex_acquire
-# pragma weak pth_mutex_release
-# pragma weak pth_rwlock_init
-# pragma weak pth_rwlock_acquire
-# pragma weak pth_rwlock_release
-# pragma weak pth_once
-
-# pragma weak pth_cancel
-# define pth_in_use() (pth_cancel != NULL)
-
-# else
-
-# define pth_in_use() 1
-
-# endif
-
-/* -------------------------- gl_lock_t datatype -------------------------- */
-
-typedef pth_mutex_t gl_lock_t;
-# define gl_lock_define(STORAGECLASS, NAME) \
- STORAGECLASS pth_mutex_t NAME;
-# define gl_lock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS pth_mutex_t NAME = gl_lock_initializer;
-# define gl_lock_initializer \
- PTH_MUTEX_INIT
-# define glthread_lock_init(LOCK) \
- (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
-# define glthread_lock_lock(LOCK) \
- (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
-# define glthread_lock_unlock(LOCK) \
- (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
-# define glthread_lock_destroy(LOCK) \
- ((void)(LOCK), 0)
-
-/* ------------------------- gl_rwlock_t datatype ------------------------- */
-
-/* Pth pth_rwlock_acquire always prefers readers. No autoconf test so far. */
-# if HAVE_PTH_RWLOCK_ACQUIRE_PREFER_WRITER
-
-typedef pth_rwlock_t gl_rwlock_t;
-# define gl_rwlock_define(STORAGECLASS, NAME) \
- STORAGECLASS pth_rwlock_t NAME;
-# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer;
-# define gl_rwlock_initializer \
- PTH_RWLOCK_INIT
-# define glthread_rwlock_init(LOCK) \
- (pth_in_use () && !pth_rwlock_init (LOCK) ? errno : 0)
-# define glthread_rwlock_rdlock(LOCK) \
- (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RD, 0, NULL) ? errno : 0)
-# define glthread_rwlock_wrlock(LOCK) \
- (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RW, 0, NULL) ? errno : 0)
-# define glthread_rwlock_unlock(LOCK) \
- (pth_in_use () && !pth_rwlock_release (LOCK) ? errno : 0)
-# define glthread_rwlock_destroy(LOCK) \
- ((void)(LOCK), 0)
-
-# else
-
-typedef struct
- {
- int initialized;
- pth_mutex_t lock; /* protects the remaining fields */
- pth_cond_t waiting_readers; /* waiting readers */
- pth_cond_t waiting_writers; /* waiting writers */
- unsigned int waiting_writers_count; /* number of waiting writers */
- int runcount; /* number of readers running, or -1 when a writer runs */
- }
- gl_rwlock_t;
-# define gl_rwlock_define(STORAGECLASS, NAME) \
- STORAGECLASS gl_rwlock_t NAME;
-# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
-# define gl_rwlock_initializer \
- { 0 }
-# define glthread_rwlock_init(LOCK) \
- (pth_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
-# define glthread_rwlock_rdlock(LOCK) \
- (pth_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
-# define glthread_rwlock_wrlock(LOCK) \
- (pth_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
-# define glthread_rwlock_unlock(LOCK) \
- (pth_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
-# define glthread_rwlock_destroy(LOCK) \
- (pth_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
-extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
-extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
-extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
-extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
-extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
-
-# endif
-
-/* --------------------- gl_recursive_lock_t datatype --------------------- */
-
-/* In Pth, mutexes are recursive by default. */
-typedef pth_mutex_t gl_recursive_lock_t;
-# define gl_recursive_lock_define(STORAGECLASS, NAME) \
- STORAGECLASS pth_mutex_t NAME;
-# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer;
-# define gl_recursive_lock_initializer \
- PTH_MUTEX_INIT
-# define glthread_recursive_lock_init(LOCK) \
- (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
-# define glthread_recursive_lock_lock(LOCK) \
- (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
-# define glthread_recursive_lock_unlock(LOCK) \
- (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
-# define glthread_recursive_lock_destroy(LOCK) \
- ((void)(LOCK), 0)
-
-/* -------------------------- gl_once_t datatype -------------------------- */
-
-typedef pth_once_t gl_once_t;
-# define gl_once_define(STORAGECLASS, NAME) \
- STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT;
-# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
- (pth_in_use () \
- ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
- : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
-extern int glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void));
-extern int glthread_once_singlethreaded (pth_once_t *once_control);
-
-# ifdef __cplusplus
-}
-# endif
-
-#endif
-
-/* ========================================================================= */
-
-#if USE_SOLARIS_THREADS
-
-/* Use the old Solaris threads library. */
-
-# include <thread.h>
-# error #include <synch.h>
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-# if USE_SOLARIS_THREADS_WEAK
-
-/* Use weak references to the old Solaris threads library. */
-
-# pragma weak mutex_init
-# pragma weak mutex_lock
-# pragma weak mutex_unlock
-# pragma weak mutex_destroy
-# pragma weak rwlock_init
-# pragma weak rw_rdlock
-# pragma weak rw_wrlock
-# pragma weak rw_unlock
-# pragma weak rwlock_destroy
-# pragma weak thr_self
-
-# pragma weak thr_suspend
-# define thread_in_use() (thr_suspend != NULL)
-
-# else
-
-# define thread_in_use() 1
-
-# endif
-
-/* -------------------------- gl_lock_t datatype -------------------------- */
-
-typedef mutex_t gl_lock_t;
-# define gl_lock_define(STORAGECLASS, NAME) \
- STORAGECLASS mutex_t NAME;
-# define gl_lock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS mutex_t NAME = gl_lock_initializer;
-# define gl_lock_initializer \
- DEFAULTMUTEX
-# define glthread_lock_init(LOCK) \
- (thread_in_use () ? mutex_init (LOCK, USYNC_THREAD, NULL) : 0)
-# define glthread_lock_lock(LOCK) \
- (thread_in_use () ? mutex_lock (LOCK) : 0)
-# define glthread_lock_unlock(LOCK) \
- (thread_in_use () ? mutex_unlock (LOCK) : 0)
-# define glthread_lock_destroy(LOCK) \
- (thread_in_use () ? mutex_destroy (LOCK) : 0)
-
-/* ------------------------- gl_rwlock_t datatype ------------------------- */
-
-typedef rwlock_t gl_rwlock_t;
-# define gl_rwlock_define(STORAGECLASS, NAME) \
- STORAGECLASS rwlock_t NAME;
-# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS rwlock_t NAME = gl_rwlock_initializer;
-# define gl_rwlock_initializer \
- DEFAULTRWLOCK
-# define glthread_rwlock_init(LOCK) \
- (thread_in_use () ? rwlock_init (LOCK, USYNC_THREAD, NULL) : 0)
-# define glthread_rwlock_rdlock(LOCK) \
- (thread_in_use () ? rw_rdlock (LOCK) : 0)
-# define glthread_rwlock_wrlock(LOCK) \
- (thread_in_use () ? rw_wrlock (LOCK) : 0)
-# define glthread_rwlock_unlock(LOCK) \
- (thread_in_use () ? rw_unlock (LOCK) : 0)
-# define glthread_rwlock_destroy(LOCK) \
- (thread_in_use () ? rwlock_destroy (LOCK) : 0)
-
-/* --------------------- gl_recursive_lock_t datatype --------------------- */
-
-/* Old Solaris threads did not have recursive locks.
- We have to implement them ourselves. */
-
-typedef struct
- {
- mutex_t mutex;
- thread_t owner;
- unsigned long depth;
- }
- gl_recursive_lock_t;
-# define gl_recursive_lock_define(STORAGECLASS, NAME) \
- STORAGECLASS gl_recursive_lock_t NAME;
-# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
-# define gl_recursive_lock_initializer \
- { DEFAULTMUTEX, (thread_t) 0, 0 }
-# define glthread_recursive_lock_init(LOCK) \
- (thread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
-# define glthread_recursive_lock_lock(LOCK) \
- (thread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
-# define glthread_recursive_lock_unlock(LOCK) \
- (thread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
-# define glthread_recursive_lock_destroy(LOCK) \
- (thread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
-extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
-extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
-extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
-extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
-
-/* -------------------------- gl_once_t datatype -------------------------- */
-
-typedef struct
- {
- volatile int inited;
- mutex_t mutex;
- }
- gl_once_t;
-# define gl_once_define(STORAGECLASS, NAME) \
- STORAGECLASS gl_once_t NAME = { 0, DEFAULTMUTEX };
-# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
- (thread_in_use () \
- ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
- : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
-extern int glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void));
-extern int glthread_once_singlethreaded (gl_once_t *once_control);
-
-# ifdef __cplusplus
-}
-# endif
-
-#endif
-
-/* ========================================================================= */
-
-#if USE_WINDOWS_THREADS
-
-# define WIN32_LEAN_AND_MEAN /* avoid including junk */
-# include <windows.h>
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-/* We can use CRITICAL_SECTION directly, rather than the native Windows Event,
- Mutex, Semaphore types, because
- - we need only to synchronize inside a single process (address space),
- not inter-process locking,
- - we don't need to support trylock operations. (TryEnterCriticalSection
- does not work on Windows 95/98/ME. Packages that need trylock usually
- define their own mutex type.) */
-
-/* There is no way to statically initialize a CRITICAL_SECTION. It needs
- to be done lazily, once only. For this we need spinlocks. */
-
-typedef struct { volatile int done; volatile long started; } gl_spinlock_t;
-
-/* -------------------------- gl_lock_t datatype -------------------------- */
-
-typedef struct
- {
- gl_spinlock_t guard; /* protects the initialization */
- CRITICAL_SECTION lock;
- }
- gl_lock_t;
-# define gl_lock_define(STORAGECLASS, NAME) \
- STORAGECLASS gl_lock_t NAME;
-# define gl_lock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS gl_lock_t NAME = gl_lock_initializer;
-# define gl_lock_initializer \
- { { 0, -1 } }
-# define glthread_lock_init(LOCK) \
- (glthread_lock_init_func (LOCK), 0)
-# define glthread_lock_lock(LOCK) \
- glthread_lock_lock_func (LOCK)
-# define glthread_lock_unlock(LOCK) \
- glthread_lock_unlock_func (LOCK)
-# define glthread_lock_destroy(LOCK) \
- glthread_lock_destroy_func (LOCK)
-extern void glthread_lock_init_func (gl_lock_t *lock);
-extern int glthread_lock_lock_func (gl_lock_t *lock);
-extern int glthread_lock_unlock_func (gl_lock_t *lock);
-extern int glthread_lock_destroy_func (gl_lock_t *lock);
-
-/* ------------------------- gl_rwlock_t datatype ------------------------- */
-
-/* It is impossible to implement read-write locks using plain locks, without
- introducing an extra thread dedicated to managing read-write locks.
- Therefore here we need to use the low-level Event type. */
-
-typedef struct
- {
- HANDLE *array; /* array of waiting threads, each represented by an event */
- unsigned int count; /* number of waiting threads */
- unsigned int alloc; /* length of allocated array */
- unsigned int offset; /* index of first waiting thread in array */
- }
- gl_carray_waitqueue_t;
-typedef struct
- {
- gl_spinlock_t guard; /* protects the initialization */
- CRITICAL_SECTION lock; /* protects the remaining fields */
- gl_carray_waitqueue_t waiting_readers; /* waiting readers */
- gl_carray_waitqueue_t waiting_writers; /* waiting writers */
- int runcount; /* number of readers running, or -1 when a writer runs */
- }
- gl_rwlock_t;
-# define gl_rwlock_define(STORAGECLASS, NAME) \
- STORAGECLASS gl_rwlock_t NAME;
-# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
-# define gl_rwlock_initializer \
- { { 0, -1 } }
-# define glthread_rwlock_init(LOCK) \
- (glthread_rwlock_init_func (LOCK), 0)
-# define glthread_rwlock_rdlock(LOCK) \
- glthread_rwlock_rdlock_func (LOCK)
-# define glthread_rwlock_wrlock(LOCK) \
- glthread_rwlock_wrlock_func (LOCK)
-# define glthread_rwlock_unlock(LOCK) \
- glthread_rwlock_unlock_func (LOCK)
-# define glthread_rwlock_destroy(LOCK) \
- glthread_rwlock_destroy_func (LOCK)
-extern void glthread_rwlock_init_func (gl_rwlock_t *lock);
-extern int glthread_rwlock_rdlock_func (gl_rwlock_t *lock);
-extern int glthread_rwlock_wrlock_func (gl_rwlock_t *lock);
-extern int glthread_rwlock_unlock_func (gl_rwlock_t *lock);
-extern int glthread_rwlock_destroy_func (gl_rwlock_t *lock);
-
-/* --------------------- gl_recursive_lock_t datatype --------------------- */
-
-/* The native Windows documentation says that CRITICAL_SECTION already
- implements a recursive lock. But we need not rely on it: It's easy to
- implement a recursive lock without this assumption. */
-
-typedef struct
- {
- gl_spinlock_t guard; /* protects the initialization */
- DWORD owner;
- unsigned long depth;
- CRITICAL_SECTION lock;
- }
- gl_recursive_lock_t;
-# define gl_recursive_lock_define(STORAGECLASS, NAME) \
- STORAGECLASS gl_recursive_lock_t NAME;
-# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
- STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
-# define gl_recursive_lock_initializer \
- { { 0, -1 }, 0, 0 }
-# define glthread_recursive_lock_init(LOCK) \
- (glthread_recursive_lock_init_func (LOCK), 0)
-# define glthread_recursive_lock_lock(LOCK) \
- glthread_recursive_lock_lock_func (LOCK)
-# define glthread_recursive_lock_unlock(LOCK) \
- glthread_recursive_lock_unlock_func (LOCK)
-# define glthread_recursive_lock_destroy(LOCK) \
- glthread_recursive_lock_destroy_func (LOCK)
-extern void glthread_recursive_lock_init_func (gl_recursive_lock_t *lock);
-extern int glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock);
-extern int glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock);
-extern int glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock);
-
-/* -------------------------- gl_once_t datatype -------------------------- */
-
-typedef struct
- {
- volatile int inited;
- volatile long started;
- CRITICAL_SECTION lock;
- }
- gl_once_t;
-# define gl_once_define(STORAGECLASS, NAME) \
- STORAGECLASS gl_once_t NAME = { -1, -1 };
-# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
- (glthread_once_func (ONCE_CONTROL, INITFUNCTION), 0)
-extern void glthread_once_func (gl_once_t *once_control, void (*initfunction) (void));
-
-# ifdef __cplusplus
-}
-# endif
-
-#endif
-
-/* ========================================================================= */
-
-#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WINDOWS_THREADS)
-
-/* Provide dummy implementation if threads are not supported. */
-
-/* -------------------------- gl_lock_t datatype -------------------------- */
-
-typedef int gl_lock_t;
-# define gl_lock_define(STORAGECLASS, NAME)
-# define gl_lock_define_initialized(STORAGECLASS, NAME)
-# define glthread_lock_init(NAME) 0
-# define glthread_lock_lock(NAME) 0
-# define glthread_lock_unlock(NAME) 0
-# define glthread_lock_destroy(NAME) 0
-
-/* ------------------------- gl_rwlock_t datatype ------------------------- */
-
-typedef int gl_rwlock_t;
-# define gl_rwlock_define(STORAGECLASS, NAME)
-# define gl_rwlock_define_initialized(STORAGECLASS, NAME)
-# define glthread_rwlock_init(NAME) 0
-# define glthread_rwlock_rdlock(NAME) 0
-# define glthread_rwlock_wrlock(NAME) 0
-# define glthread_rwlock_unlock(NAME) 0
-# define glthread_rwlock_destroy(NAME) 0
-
-/* --------------------- gl_recursive_lock_t datatype --------------------- */
-
-typedef int gl_recursive_lock_t;
-# define gl_recursive_lock_define(STORAGECLASS, NAME)
-# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME)
-# define glthread_recursive_lock_init(NAME) 0
-# define glthread_recursive_lock_lock(NAME) 0
-# define glthread_recursive_lock_unlock(NAME) 0
-# define glthread_recursive_lock_destroy(NAME) 0
-
-/* -------------------------- gl_once_t datatype -------------------------- */
-
-typedef int gl_once_t;
-# define gl_once_define(STORAGECLASS, NAME) \
- STORAGECLASS gl_once_t NAME = 0;
-# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
- (*(ONCE_CONTROL) == 0 ? (*(ONCE_CONTROL) = ~ 0, INITFUNCTION (), 0) : 0)
-
-#endif
-
-/* ========================================================================= */
-
-/* Macros with built-in error handling. */
-
-/* -------------------------- gl_lock_t datatype -------------------------- */
-
-#define gl_lock_init(NAME) \
- do \
- { \
- if (glthread_lock_init (&NAME)) \
- abort (); \
- } \
- while (0)
-#define gl_lock_lock(NAME) \
- do \
- { \
- if (glthread_lock_lock (&NAME)) \
- abort (); \
- } \
- while (0)
-#define gl_lock_unlock(NAME) \
- do \
- { \
- if (glthread_lock_unlock (&NAME)) \
- abort (); \
- } \
- while (0)
-#define gl_lock_destroy(NAME) \
- do \
- { \
- if (glthread_lock_destroy (&NAME)) \
- abort (); \
- } \
- while (0)
-
-/* ------------------------- gl_rwlock_t datatype ------------------------- */
-
-#define gl_rwlock_init(NAME) \
- do \
- { \
- if (glthread_rwlock_init (&NAME)) \
- abort (); \
- } \
- while (0)
-#define gl_rwlock_rdlock(NAME) \
- do \
- { \
- if (glthread_rwlock_rdlock (&NAME)) \
- abort (); \
- } \
- while (0)
-#define gl_rwlock_wrlock(NAME) \
- do \
- { \
- if (glthread_rwlock_wrlock (&NAME)) \
- abort (); \
- } \
- while (0)
-#define gl_rwlock_unlock(NAME) \
- do \
- { \
- if (glthread_rwlock_unlock (&NAME)) \
- abort (); \
- } \
- while (0)
-#define gl_rwlock_destroy(NAME) \
- do \
- { \
- if (glthread_rwlock_destroy (&NAME)) \
- abort (); \
- } \
- while (0)
-
-/* --------------------- gl_recursive_lock_t datatype --------------------- */
-
-#define gl_recursive_lock_init(NAME) \
- do \
- { \
- if (glthread_recursive_lock_init (&NAME)) \
- abort (); \
- } \
- while (0)
-#define gl_recursive_lock_lock(NAME) \
- do \
- { \
- if (glthread_recursive_lock_lock (&NAME)) \
- abort (); \
- } \
- while (0)
-#define gl_recursive_lock_unlock(NAME) \
- do \
- { \
- if (glthread_recursive_lock_unlock (&NAME)) \
- abort (); \
- } \
- while (0)
-#define gl_recursive_lock_destroy(NAME) \
- do \
- { \
- if (glthread_recursive_lock_destroy (&NAME)) \
- abort (); \
- } \
- while (0)
-
-/* -------------------------- gl_once_t datatype -------------------------- */
-
-#define gl_once(NAME, INITFUNCTION) \
- do \
- { \
- if (glthread_once (&NAME, INITFUNCTION)) \
- abort (); \
- } \
- while (0)
-
-/* ========================================================================= */
-
-#endif /* _LOCK_H */
diff --git a/contrib/tools/bison/lib/glthread/threadlib.c b/contrib/tools/bison/lib/glthread/threadlib.c
deleted file mode 100644
index e8b484a05c6..00000000000
--- a/contrib/tools/bison/lib/glthread/threadlib.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Multithreading primitives.
- Copyright (C) 2005-2018 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <[email protected]>, 2005. */
-
-#include <config.h>
-
-/* ========================================================================= */
-
-#if USE_POSIX_THREADS
-
-/* Use the POSIX threads library. */
-
-# include <pthread.h>
-# include <stdlib.h>
-
-# if PTHREAD_IN_USE_DETECTION_HARD
-
-/* The function to be executed by a dummy thread. */
-static void *
-dummy_thread_func (void *arg)
-{
- return arg;
-}
-
-int
-glthread_in_use (void)
-{
- static int tested;
- static int result; /* 1: linked with -lpthread, 0: only with libc */
-
- if (!tested)
- {
- pthread_t thread;
-
- if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0)
- /* Thread creation failed. */
- result = 0;
- else
- {
- /* Thread creation works. */
- void *retval;
- if (pthread_join (thread, &retval) != 0)
- abort ();
- result = 1;
- }
- tested = 1;
- }
- return result;
-}
-
-# endif
-
-#endif
-
-/* ========================================================================= */
-
-/* This declaration is solely to ensure that after preprocessing
- this file is never empty. */
-typedef int dummy;
diff --git a/contrib/tools/bison/lib/hard-locale.c b/contrib/tools/bison/lib/hard-locale.c
index 49bc6caff43..dcfcad62ee7 100644
--- a/contrib/tools/bison/lib/hard-locale.c
+++ b/contrib/tools/bison/lib/hard-locale.c
@@ -1,6 +1,6 @@
/* hard-locale.c -- Determine whether a locale is hard.
- Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2018 Free Software
+ Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2019 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/hard-locale.h b/contrib/tools/bison/lib/hard-locale.h
index 22eecc5ed80..8f1da96e2f2 100644
--- a/contrib/tools/bison/lib/hard-locale.h
+++ b/contrib/tools/bison/lib/hard-locale.h
@@ -1,6 +1,6 @@
/* Determine whether a locale is hard.
- Copyright (C) 1999, 2003-2004, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2003-2004, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/hash.c b/contrib/tools/bison/lib/hash.c
index 98a8ea3d3c0..9e1f8e8417e 100644
--- a/contrib/tools/bison/lib/hash.c
+++ b/contrib/tools/bison/lib/hash.c
@@ -1,6 +1,6 @@
/* hash - hashing table processing.
- Copyright (C) 1998-2004, 2006-2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 1998-2004, 2006-2007, 2009-2019 Free Software Foundation, Inc.
Written by Jim Meyering, 1992.
diff --git a/contrib/tools/bison/lib/hash.h b/contrib/tools/bison/lib/hash.h
index 562f5e67960..a1a483a3594 100644
--- a/contrib/tools/bison/lib/hash.h
+++ b/contrib/tools/bison/lib/hash.h
@@ -1,5 +1,5 @@
/* hash - hashing table processing.
- Copyright (C) 1998-1999, 2001, 2003, 2009-2018 Free Software Foundation,
+ Copyright (C) 1998-1999, 2001, 2003, 2009-2019 Free Software Foundation,
Inc.
Written by Jim Meyering <[email protected]>, 1998.
diff --git a/contrib/tools/bison/lib/intprops.h b/contrib/tools/bison/lib/intprops.h
deleted file mode 100644
index cdaf6586cb6..00000000000
--- a/contrib/tools/bison/lib/intprops.h
+++ /dev/null
@@ -1,455 +0,0 @@
-/* intprops.h -- properties of integer types
-
- Copyright (C) 2001-2018 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3 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 General Public License for more details.
-
- You should have received a copy of the GNU 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))
-
-/* The extra casts in the following macros work around compiler bugs,
- e.g., in Cray C 5.0.3.0. */
-
-/* True if the arithmetic type T is an integer type. bool counts as
- an integer. */
-#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))
-
-/* 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)
-
-
-/* Minimum and maximum values for integer types and expressions. */
-
-/* The width in bits of the integer type or expression T.
- Do not evaluate T.
- Padding bits are not supported; this is checked at compile-time below. */
-#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
-
-/* The maximum and minimum values for the integer type T. */
-#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
-#define TYPE_MAXIMUM(t) \
- ((t) (! TYPE_SIGNED (t) \
- ? (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) + 0) - 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__ \
- || (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. 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. */
-#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
-
-/* Bound on length of the string representing an integer type or expression T.
- Subtract 1 for the sign bit if T is signed, and then add 1 more for
- a minus sign if needed.
-
- Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is
- signed, this macro may overestimate the true bound by one byte when
- applied to unsigned types of size 2, 4, 16, ... bytes. */
-#define INT_STRLEN_BOUND(t) \
- (INT_BITS_STRLEN_BOUND (TYPE_WIDTH (t) - _GL_SIGNED_TYPE_OR_EXPR (t)) \
- + _GL_SIGNED_TYPE_OR_EXPR (t))
-
-/* Bound on buffer size needed to represent an integer type or expression T,
- including the terminating null. */
-#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
-
-
-/* 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 a bit harder to use than the
- INT_<op>_OVERFLOW macros described below.
-
- Example usage:
-
- long int i = ...;
- long int j = ...;
- if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX))
- printf ("multiply would overflow");
- else
- printf ("product is %ld", i * j);
-
- Restrictions on *_RANGE_OVERFLOW macros:
-
- These macros do not check for all possible numerical problems or
- undefined or unspecified behavior: they do not check for division
- by zero, for bad shift counts, or for shifting negative numbers.
-
- These macros may evaluate their arguments zero or multiple times,
- so the arguments should not have side effects. The arithmetic
- arguments (including the MIN and MAX arguments) must be of the same
- integer type after the usual arithmetic conversions, and the type
- must have minimum value MIN and maximum MAX. Unsigned types should
- use a zero MIN of the proper type.
-
- These macros are tuned for constant MIN and MAX. For commutative
- operations such as A + B, they are also tuned for constant B. */
-
-/* Return 1 if A + B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. */
-#define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \
- ((b) < 0 \
- ? (a) < (min) - (b) \
- : (max) - (b) < (a))
-
-/* Return 1 if A - B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. */
-#define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \
- ((b) < 0 \
- ? (max) + (b) < (a) \
- : (a) < (min) + (b))
-
-/* 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))
-
-/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Avoid && and || as they tickle
- bugs in Sun C 5.11 2010/08/13 and other compilers; see
- <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00401.html>. */
-#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \
- ((b) < 0 \
- ? ((a) < 0 \
- ? (a) < (max) / (b) \
- : (b) == -1 \
- ? 0 \
- : (min) / (b) < (a)) \
- : (b) == 0 \
- ? 0 \
- : ((a) < 0 \
- ? (a) < (min) / (b) \
- : (max) / (b) < (a)))
-
-/* Return 1 if A / B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Do not check for division by zero. */
-#define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \
- ((min) < 0 && (b) == -1 && (a) < - (max))
-
-/* Return 1 if A % B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Do not check for division by zero.
- Mathematically, % should never overflow, but on x86-like hosts
- INT_MIN % -1 traps, and the C standard permits this, so treat this
- as an overflow too. */
-#define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \
- INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max)
-
-/* Return 1 if A << B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Here, MIN and MAX are for A only, and B need
- not be of the same type as the other arguments. The C standard says that
- behavior is undefined for shifts unless 0 <= B < wordwidth, and that when
- A is negative then A << B has undefined behavior and A >> B has
- implementation-defined behavior, but do not check these other
- restrictions. */
-#define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \
- ((a) < 0 \
- ? (a) < (min) >> (b) \
- : (max) >> (b) < (a))
-
-/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */
-#if 5 <= __GNUC__ && !defined __ICC
-# define _GL_HAS_BUILTIN_OVERFLOW 1
-#else
-# define _GL_HAS_BUILTIN_OVERFLOW 0
-#endif
-
-/* True if __builtin_add_overflow_p (A, B, C) works. */
-#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
-
-/* 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
- that the result (e.g., A + B) has that type. */
-#if _GL_HAS_BUILTIN_OVERFLOW_P
-# define _GL_ADD_OVERFLOW(a, b, min, max) \
- __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
-# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
- __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0)
-# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
- __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0)
-#else
-# define _GL_ADD_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \
- : (a) < 0 ? (b) <= (a) + (b) \
- : (b) < 0 ? (a) <= (a) + (b) \
- : (a) + (b) < (b))
-# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \
- : (a) < 0 ? 1 \
- : (b) < 0 ? (a) - (b) <= (a) \
- : (a) < (b))
-# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
- (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \
- || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
-#endif
-#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
- : (a) < 0 ? (b) <= (a) + (b) - 1 \
- : (b) < 0 && (a) + (b) <= (a))
-#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
- : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \
- : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max))
-
-/* Return a nonzero value if A is a mathematical multiple of B, where
- A is unsigned, B is negative, and MAX is the maximum value of A's
- type. A's type must be the same as (A % B)'s type. Normally (A %
- -B == 0) suffices, but things get tricky if -B would overflow. */
-#define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \
- (((b) < -_GL_SIGNED_INT_MAXIMUM (b) \
- ? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \
- ? (a) \
- : (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \
- : (a) % - (b)) \
- == 0)
-
-/* Check for integer overflow, and report low order bits of answer.
-
- The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators
- might not yield numerically correct answers due to arithmetic overflow.
- The INT_<op>_WRAPV macros also store the low-order bits of the answer.
- These macros work correctly on all known practical hosts, and do not rely
- on undefined behavior due to signed arithmetic overflow.
-
- Example usage, assuming A and B are long int:
-
- if (INT_MULTIPLY_OVERFLOW (a, b))
- printf ("result would overflow\n");
- else
- printf ("result is %ld (no overflow)\n", a * b);
-
- Example usage with WRAPV flavor:
-
- long int result;
- bool overflow = INT_MULTIPLY_WRAPV (a, b, &result);
- printf ("result is %ld (%s)\n", result,
- overflow ? "after overflow" : "no overflow");
-
- Restrictions on these macros:
-
- These macros do not check for all possible numerical problems or
- undefined or unspecified behavior: they do not check for division
- by zero, for bad shift counts, or for shifting negative numbers.
-
- These macros may evaluate their arguments zero or multiple times, so the
- arguments should not have side effects.
-
- The WRAPV macros are not constant expressions. They support only
- +, binary -, and *. The result type must be signed.
-
- These macros are tuned for their last argument being a constant.
-
- Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B,
- A % B, and A << B would overflow, respectively. */
-
-#define INT_ADD_OVERFLOW(a, b) \
- _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_MULTIPLY_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
-#define INT_DIVIDE_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW)
-#define INT_REMAINDER_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW)
-#define INT_LEFT_SHIFT_OVERFLOW(a, b) \
- INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \
- _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
-
-/* Return 1 if the expression A <op> B would overflow,
- where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test,
- assuming MIN and MAX are the minimum and maximum for the result type.
- Arguments should be free of side effects. */
-#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \
- op_result_overflow (a, b, \
- _GL_INT_MINIMUM (_GL_INT_CONVERT (a, b)), \
- _GL_INT_MAXIMUM (_GL_INT_CONVERT (a, b)))
-
-/* 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. */
-#define INT_ADD_WRAPV(a, b, r) \
- _GL_INT_OP_WRAPV (a, b, r, +, __builtin_add_overflow, INT_ADD_OVERFLOW)
-#define INT_SUBTRACT_WRAPV(a, b, r) \
- _GL_INT_OP_WRAPV (a, b, r, -, __builtin_sub_overflow, INT_SUBTRACT_OVERFLOW)
-#define INT_MULTIPLY_WRAPV(a, b, r) \
- _GL_INT_OP_WRAPV (a, b, r, *, __builtin_mul_overflow, INT_MULTIPLY_OVERFLOW)
-
-/* 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 older compilers that
- lack __builtin_add_overflow. */
-#if __GNUC__
-# 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. BUILTIN is the builtin operation, and OVERFLOW the
- overflow predicate. Return 1 if the result overflows. See above
- for restrictions. */
-#if _GL_HAS_BUILTIN_OVERFLOW
-# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r)
-#elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
-# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
- (_Generic \
- (*(r), \
- signed char: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- signed char, SCHAR_MIN, SCHAR_MAX), \
- short int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- short int, SHRT_MIN, SHRT_MAX), \
- int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- int, INT_MIN, INT_MAX), \
- long int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
- long int, LONG_MIN, LONG_MAX), \
- long long int: \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
- long long int, LLONG_MIN, LLONG_MAX)))
-#else
-# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
- (sizeof *(r) == sizeof (signed char) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- signed char, SCHAR_MIN, SCHAR_MAX) \
- : sizeof *(r) == sizeof (short int) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- short int, SHRT_MIN, SHRT_MAX) \
- : sizeof *(r) == sizeof (int) \
- ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
- int, INT_MIN, INT_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_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 long int, \
- long long int, LLONG_MIN, LLONG_MAX))
-# else
-# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
- _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
- long int, LONG_MIN, LONG_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) \
- (sizeof ((a) op (b)) < sizeof (t) \
- ? _GL_INT_OP_CALC1 ((t) (a), (t) (b), r, op, overflow, ut, t, tmin, tmax) \
- : _GL_INT_OP_CALC1 (a, b, r, op, overflow, ut, t, tmin, tmax))
-#define _GL_INT_OP_CALC1(a, b, r, op, overflow, ut, t, tmin, tmax) \
- ((overflow (a, b) \
- || (EXPR_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \
- || (tmax) < ((a) op (b))) \
- ? (*(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)))
-
-#endif /* _GL_INTPROPS_H */
diff --git a/contrib/tools/bison/lib/isnand-nolibm.h b/contrib/tools/bison/lib/isnand-nolibm.h
index 7be45739557..174c61ebd23 100644
--- a/contrib/tools/bison/lib/isnand-nolibm.h
+++ b/contrib/tools/bison/lib/isnand-nolibm.h
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2007-2018 Free Software Foundation, Inc.
+ Copyright (C) 2007-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/isnanl-nolibm.h b/contrib/tools/bison/lib/isnanl-nolibm.h
index ddd12f0d24d..fdedf56b626 100644
--- a/contrib/tools/bison/lib/isnanl-nolibm.h
+++ b/contrib/tools/bison/lib/isnanl-nolibm.h
@@ -1,5 +1,5 @@
/* Test for NaN that does not need libm.
- Copyright (C) 2007-2018 Free Software Foundation, Inc.
+ Copyright (C) 2007-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/localcharset.c b/contrib/tools/bison/lib/localcharset.c
index bfa55317788..579972bc2f9 100644
--- a/contrib/tools/bison/lib/localcharset.c
+++ b/contrib/tools/bison/lib/localcharset.c
@@ -1,6 +1,6 @@
/* Determine a canonical name for the current locale's character encoding.
- Copyright (C) 2000-2006, 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2000-2006, 2008-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/localcharset.h b/contrib/tools/bison/lib/localcharset.h
index e4ba2960ba4..7d0d7711dbe 100644
--- a/contrib/tools/bison/lib/localcharset.h
+++ b/contrib/tools/bison/lib/localcharset.h
@@ -1,5 +1,5 @@
/* Determine a canonical name for the current locale's character encoding.
- Copyright (C) 2000-2003, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2000-2003, 2009-2019 Free Software Foundation, Inc.
This file is part of the GNU CHARSET Library.
This program is free software; you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/localtime-buffer.c b/contrib/tools/bison/lib/localtime-buffer.c
deleted file mode 100644
index df11f4321db..00000000000
--- a/contrib/tools/bison/lib/localtime-buffer.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Provide access to the last buffer returned by localtime() or gmtime().
-
- Copyright (C) 2001-2003, 2005-2007, 2009-2018 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <https://www.gnu.org/licenses/>. */
-
-/* written by Jim Meyering */
-
-#include <config.h>
-
-/* Specification. */
-#include "localtime-buffer.h"
-
-#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME
-
-static struct tm tm_zero_buffer;
-struct tm *localtime_buffer_addr = &tm_zero_buffer;
-
-/* This is a wrapper for localtime.
-
- On the first call, record the address of the static buffer that
- localtime uses for its result. */
-
-struct tm *
-rpl_localtime (time_t const *timep)
-{
- struct tm *tm = localtime (timep);
-
- if (localtime_buffer_addr == &tm_zero_buffer)
- localtime_buffer_addr = tm;
-
- return tm;
-}
-
-/* Same as above, since gmtime and localtime use the same buffer. */
-struct tm *
-rpl_gmtime (time_t const *timep)
-{
- struct tm *tm = gmtime (timep);
-
- if (localtime_buffer_addr == &tm_zero_buffer)
- localtime_buffer_addr = tm;
-
- return tm;
-}
-
-#endif
diff --git a/contrib/tools/bison/lib/localtime-buffer.h b/contrib/tools/bison/lib/localtime-buffer.h
deleted file mode 100644
index f381ff0e6de..00000000000
--- a/contrib/tools/bison/lib/localtime-buffer.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Provide access to the last buffer returned by localtime() or gmtime().
-
- Copyright (C) 2001-2003, 2005-2007, 2009-2018 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <https://www.gnu.org/licenses/>. */
-
-/* written by Jim Meyering */
-
-#include <time.h>
-
-#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME
-
-/* The address of the last buffer returned by localtime() or gmtime(). */
-extern struct tm *localtime_buffer_addr;
-
-#endif
diff --git a/contrib/tools/bison/lib/malloca.c b/contrib/tools/bison/lib/malloca.c
deleted file mode 100644
index c54e1e0f9b7..00000000000
--- a/contrib/tools/bison/lib/malloca.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Safe automatic memory allocation.
- Copyright (C) 2003, 2006-2007, 2009-2018 Free Software Foundation, Inc.
- Written by Bruno Haible <[email protected]>, 2003, 2018.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <https://www.gnu.org/licenses/>. */
-
-#define _GL_USE_STDLIB_ALLOC 1
-#include <config.h>
-
-/* Specification. */
-#include "malloca.h"
-
-#include "verify.h"
-
-/* The speed critical point in this file is freea() applied to an alloca()
- result: it must be fast, to match the speed of alloca(). The speed of
- mmalloca() and freea() in the other case are not critical, because they
- are only invoked for big memory sizes.
- Here we use a bit in the address as an indicator, an idea by Ondřej Bílka.
- malloca() can return three types of pointers:
- - Pointers ≡ 0 mod 2*sa_alignment_max come from stack allocation.
- - Pointers ≡ sa_alignment_max mod 2*sa_alignment_max come from heap
- allocation.
- - NULL comes from a failed heap allocation. */
-
-/* Type for holding very small pointer differences. */
-typedef unsigned char small_t;
-/* Verify that it is wide enough. */
-verify (2 * sa_alignment_max - 1 <= (small_t) -1);
-
-void *
-mmalloca (size_t n)
-{
-#if HAVE_ALLOCA
- /* Allocate one more word, used to determine the address to pass to freea(),
- and room for the alignment ≡ sa_alignment_max mod 2*sa_alignment_max. */
- size_t nplus = n + sizeof (small_t) + 2 * sa_alignment_max - 1;
-
- if (nplus >= n)
- {
- char *mem = (char *) malloc (nplus);
-
- if (mem != NULL)
- {
- char *p =
- (char *)((((uintptr_t)mem + sizeof (small_t) + sa_alignment_max - 1)
- & ~(uintptr_t)(2 * sa_alignment_max - 1))
- + sa_alignment_max);
- /* Here p >= mem + sizeof (small_t),
- and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1
- hence p + n <= mem + nplus.
- So, the memory range [p, p+n) lies in the allocated memory range
- [mem, mem + nplus). */
- ((small_t *) p)[-1] = p - mem;
- /* p ≡ sa_alignment_max mod 2*sa_alignment_max. */
- return p;
- }
- }
- /* Out of memory. */
- return NULL;
-#else
-# if !MALLOC_0_IS_NONNULL
- if (n == 0)
- n = 1;
-# endif
- return malloc (n);
-#endif
-}
-
-#if HAVE_ALLOCA
-void
-freea (void *p)
-{
- /* Check argument. */
- if ((uintptr_t) p & (sa_alignment_max - 1))
- {
- /* p was not the result of a malloca() call. Invalid argument. */
- abort ();
- }
- /* Determine whether p was a non-NULL pointer returned by mmalloca(). */
- if ((uintptr_t) p & sa_alignment_max)
- {
- void *mem = (char *) p - ((small_t *) p)[-1];
- free (mem);
- }
-}
-#endif
-
-/*
- * Hey Emacs!
- * Local Variables:
- * coding: utf-8
- * End:
- */
diff --git a/contrib/tools/bison/lib/malloca.h b/contrib/tools/bison/lib/malloca.h
deleted file mode 100644
index 1e47813ff48..00000000000
--- a/contrib/tools/bison/lib/malloca.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* Safe automatic memory allocation.
- Copyright (C) 2003-2007, 2009-2018 Free Software Foundation, Inc.
- Written by Bruno Haible <[email protected]>, 2003.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <https://www.gnu.org/licenses/>. */
-
-#ifndef _MALLOCA_H
-#define _MALLOCA_H
-
-#include <alloca.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#include "xalloc-oversized.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* safe_alloca(N) is equivalent to alloca(N) when it is safe to call
- alloca(N); otherwise it returns NULL. It either returns N bytes of
- memory allocated on the stack, that lasts until the function returns,
- or NULL.
- Use of safe_alloca should be avoided:
- - inside arguments of function calls - undefined behaviour,
- - in inline functions - the allocation may actually last until the
- calling function returns.
-*/
-#if HAVE_ALLOCA
-/* The OS usually guarantees only one guard page at the bottom of the stack,
- and a page size can be as small as 4096 bytes. So we cannot safely
- allocate anything larger than 4096 bytes. Also care for the possibility
- of a few compiler-allocated temporary stack slots.
- This must be a macro, not a function. */
-# define safe_alloca(N) ((N) < 4032 ? alloca (N) : NULL)
-#else
-# define safe_alloca(N) ((void) (N), NULL)
-#endif
-
-/* malloca(N) is a safe variant of alloca(N). It allocates N bytes of
- memory allocated on the stack, that must be freed using freea() before
- the function returns. Upon failure, it returns NULL. */
-#if HAVE_ALLOCA
-# define malloca(N) \
- ((N) < 4032 - (2 * sa_alignment_max - 1) \
- ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \
- + (2 * sa_alignment_max - 1)) \
- & ~(uintptr_t)(2 * sa_alignment_max - 1)) \
- : mmalloca (N))
-#else
-# define malloca(N) \
- mmalloca (N)
-#endif
-extern void * mmalloca (size_t n);
-
-/* Free a block of memory allocated through malloca(). */
-#if HAVE_ALLOCA
-extern void freea (void *p);
-#else
-# define freea free
-#endif
-
-/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S).
- It allocates an array of N objects, each with S bytes of memory,
- on the stack. S must be positive and N must be nonnegative.
- The array must be freed using freea() before the function returns. */
-#define nmalloca(n, s) (xalloc_oversized (n, s) ? NULL : malloca ((n) * (s)))
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-/* ------------------- Auxiliary, non-public definitions ------------------- */
-
-/* Determine the alignment of a type at compile time. */
-#if defined __GNUC__ || defined __IBM__ALIGNOF__
-# define sa_alignof __alignof__
-#elif defined __cplusplus
- template <class type> struct sa_alignof_helper { char __slot1; type __slot2; };
-# define sa_alignof(type) offsetof (sa_alignof_helper<type>, __slot2)
-#elif defined __hpux
- /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof
- values. */
-# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
-#elif defined _AIX
- /* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof
- values. */
-# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
-#else
-# define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
-#endif
-
-enum
-{
-/* The desired alignment of memory allocations is the maximum alignment
- among all elementary types. */
- sa_alignment_long = sa_alignof (long),
- sa_alignment_double = sa_alignof (double),
-#if HAVE_LONG_LONG_INT
- sa_alignment_longlong = sa_alignof (long long),
-#endif
- sa_alignment_longdouble = sa_alignof (long double),
- sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1)
-#if HAVE_LONG_LONG_INT
- | (sa_alignment_longlong - 1)
-#endif
- | (sa_alignment_longdouble - 1)
- ) + 1
-};
-
-#endif /* _MALLOCA_H */
diff --git a/contrib/tools/bison/lib/mbrtowc.c b/contrib/tools/bison/lib/mbrtowc.c
index 2f6df287a50..bbe3f7a3b91 100644
--- a/contrib/tools/bison/lib/mbrtowc.c
+++ b/contrib/tools/bison/lib/mbrtowc.c
@@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
- Copyright (C) 1999-2002, 2005-2018 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2005-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2008.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/mbswidth.c b/contrib/tools/bison/lib/mbswidth.c
index 7ef404794c0..408a15e3448 100644
--- a/contrib/tools/bison/lib/mbswidth.c
+++ b/contrib/tools/bison/lib/mbswidth.c
@@ -1,5 +1,5 @@
/* Determine the number of screen columns needed for a string.
- Copyright (C) 2000-2018 Free Software Foundation, Inc.
+ Copyright (C) 2000-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/mbswidth.h b/contrib/tools/bison/lib/mbswidth.h
index 0f22ca572d0..2b5c53c3728 100644
--- a/contrib/tools/bison/lib/mbswidth.h
+++ b/contrib/tools/bison/lib/mbswidth.h
@@ -1,5 +1,5 @@
/* Determine the number of screen columns needed for a string.
- Copyright (C) 2000-2004, 2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2000-2004, 2007, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/minmax.h b/contrib/tools/bison/lib/minmax.h
index 33a5305f429..d7f6bea0619 100644
--- a/contrib/tools/bison/lib/minmax.h
+++ b/contrib/tools/bison/lib/minmax.h
@@ -1,5 +1,5 @@
/* MIN, MAX macros.
- Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2018 Free Software
+ Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2019 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/msvc-inval.c b/contrib/tools/bison/lib/msvc-inval.c
index 0f19a09aee7..75b5a070ab5 100644
--- a/contrib/tools/bison/lib/msvc-inval.c
+++ b/contrib/tools/bison/lib/msvc-inval.c
@@ -1,5 +1,5 @@
/* Invalid parameter handler for MSVC runtime libraries.
- Copyright (C) 2011-2018 Free Software Foundation, Inc.
+ Copyright (C) 2011-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/msvc-inval.h b/contrib/tools/bison/lib/msvc-inval.h
index 8e7ff303a71..e31cf650919 100644
--- a/contrib/tools/bison/lib/msvc-inval.h
+++ b/contrib/tools/bison/lib/msvc-inval.h
@@ -1,5 +1,5 @@
/* Invalid parameter handler for MSVC runtime libraries.
- Copyright (C) 2011-2018 Free Software Foundation, Inc.
+ Copyright (C) 2011-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/msvc-nothrow.c b/contrib/tools/bison/lib/msvc-nothrow.c
index 785733e4395..49b709ca4aa 100644
--- a/contrib/tools/bison/lib/msvc-nothrow.c
+++ b/contrib/tools/bison/lib/msvc-nothrow.c
@@ -1,6 +1,6 @@
/* Wrappers that don't throw invalid parameter notifications
with MSVC runtime libraries.
- Copyright (C) 2011-2018 Free Software Foundation, Inc.
+ Copyright (C) 2011-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/msvc-nothrow.h b/contrib/tools/bison/lib/msvc-nothrow.h
index a9671c3b641..8d3ca7892e8 100644
--- a/contrib/tools/bison/lib/msvc-nothrow.h
+++ b/contrib/tools/bison/lib/msvc-nothrow.h
@@ -1,6 +1,6 @@
/* Wrappers that don't throw invalid parameter notifications
with MSVC runtime libraries.
- Copyright (C) 2011-2018 Free Software Foundation, Inc.
+ Copyright (C) 2011-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/obstack.c b/contrib/tools/bison/lib/obstack.c
index 16d17708826..411de474290 100644
--- a/contrib/tools/bison/lib/obstack.c
+++ b/contrib/tools/bison/lib/obstack.c
@@ -1,5 +1,5 @@
/* obstack.c - subroutines used implicitly by object stack macros
- Copyright (C) 1988-2018 Free Software Foundation, Inc.
+ Copyright (C) 1988-2019 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
diff --git a/contrib/tools/bison/lib/obstack.h b/contrib/tools/bison/lib/obstack.h
index 4355fc55c89..90ba66004b0 100644
--- a/contrib/tools/bison/lib/obstack.h
+++ b/contrib/tools/bison/lib/obstack.h
@@ -1,5 +1,5 @@
/* obstack.h - object stack macros
- Copyright (C) 1988-2018 Free Software Foundation, Inc.
+ Copyright (C) 1988-2019 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
@@ -111,7 +111,7 @@
#include <stddef.h> /* For size_t and ptrdiff_t. */
#include <string.h> /* For __GNU_LIBRARY__, and memcpy. */
-#if __STDC_VERSION__ < 199901L
+#if __STDC_VERSION__ < 199901L || defined __HP_cc
# define __FLEXIBLE_ARRAY_MEMBER 1
#else
# define __FLEXIBLE_ARRAY_MEMBER
diff --git a/contrib/tools/bison/lib/obstack_printf.c b/contrib/tools/bison/lib/obstack_printf.c
index 705b4c0e7da..0d59a8bcfff 100644
--- a/contrib/tools/bison/lib/obstack_printf.c
+++ b/contrib/tools/bison/lib/obstack_printf.c
@@ -1,5 +1,5 @@
/* Formatted output to obstacks.
- Copyright (C) 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2008-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/open.c b/contrib/tools/bison/lib/open.c
index 792e258ba0b..655260572d4 100644
--- a/contrib/tools/bison/lib/open.c
+++ b/contrib/tools/bison/lib/open.c
@@ -1,5 +1,5 @@
/* Open a descriptor to a file.
- Copyright (C) 2007-2018 Free Software Foundation, Inc.
+ Copyright (C) 2007-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/path-join.c b/contrib/tools/bison/lib/path-join.c
index 73560b445d6..727874222a7 100644
--- a/contrib/tools/bison/lib/path-join.c
+++ b/contrib/tools/bison/lib/path-join.c
@@ -1,5 +1,5 @@
/* Concatenate path components.
- Copyright (C) 2018 Free Software Foundation, Inc.
+ Copyright (C) 2018-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/contrib/tools/bison/lib/path-join.h b/contrib/tools/bison/lib/path-join.h
index baa472a97c8..0ac7055ff0a 100644
--- a/contrib/tools/bison/lib/path-join.h
+++ b/contrib/tools/bison/lib/path-join.h
@@ -1,5 +1,5 @@
/* Concatenate path components.
- Copyright (C) 2018 Free Software Foundation, Inc.
+ Copyright (C) 2018-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/contrib/tools/bison/lib/pipe-safer.c b/contrib/tools/bison/lib/pipe-safer.c
index 1669d90934c..62017397c60 100644
--- a/contrib/tools/bison/lib/pipe-safer.c
+++ b/contrib/tools/bison/lib/pipe-safer.c
@@ -1,5 +1,5 @@
/* Invoke pipe, but avoid some glitches.
- Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/pipe2-safer.c b/contrib/tools/bison/lib/pipe2-safer.c
index 71fef9ec8e5..390d96b51c3 100644
--- a/contrib/tools/bison/lib/pipe2-safer.c
+++ b/contrib/tools/bison/lib/pipe2-safer.c
@@ -1,5 +1,5 @@
/* Invoke pipe2, but avoid some glitches.
- Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/pipe2.c b/contrib/tools/bison/lib/pipe2.c
index c16d9351ec8..15a5dec9852 100644
--- a/contrib/tools/bison/lib/pipe2.c
+++ b/contrib/tools/bison/lib/pipe2.c
@@ -1,5 +1,5 @@
/* Create a pipe, with specific opening flags.
- Copyright (C) 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2009-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/printf-args.c b/contrib/tools/bison/lib/printf-args.c
index 1079e0a9a65..e45cfbede10 100644
--- a/contrib/tools/bison/lib/printf-args.c
+++ b/contrib/tools/bison/lib/printf-args.c
@@ -1,5 +1,5 @@
/* Decomposed printf argument list.
- Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2018 Free Software
+ Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2019 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/printf-args.h b/contrib/tools/bison/lib/printf-args.h
index 111e8a5605f..866cba04d8c 100644
--- a/contrib/tools/bison/lib/printf-args.h
+++ b/contrib/tools/bison/lib/printf-args.h
@@ -1,5 +1,5 @@
/* Decomposed printf argument list.
- Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2018 Free Software
+ Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2019 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/printf-frexp.c b/contrib/tools/bison/lib/printf-frexp.c
index c704090b9ee..77eafab5445 100644
--- a/contrib/tools/bison/lib/printf-frexp.c
+++ b/contrib/tools/bison/lib/printf-frexp.c
@@ -1,5 +1,5 @@
/* Split a double into fraction and mantissa, for hexadecimal printf.
- Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/printf-frexp.h b/contrib/tools/bison/lib/printf-frexp.h
index 814229f9c06..93107343adc 100644
--- a/contrib/tools/bison/lib/printf-frexp.h
+++ b/contrib/tools/bison/lib/printf-frexp.h
@@ -1,5 +1,5 @@
/* Split a double into fraction and mantissa, for hexadecimal printf.
- Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/printf-frexpl.c b/contrib/tools/bison/lib/printf-frexpl.c
index cc8db67e33e..693b88976d4 100644
--- a/contrib/tools/bison/lib/printf-frexpl.c
+++ b/contrib/tools/bison/lib/printf-frexpl.c
@@ -1,5 +1,5 @@
/* Split a 'long double' into fraction and mantissa, for hexadecimal printf.
- Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/printf-frexpl.h b/contrib/tools/bison/lib/printf-frexpl.h
index c48c70cd3a5..27607694427 100644
--- a/contrib/tools/bison/lib/printf-frexpl.h
+++ b/contrib/tools/bison/lib/printf-frexpl.h
@@ -1,5 +1,5 @@
/* Split a 'long double' into fraction and mantissa, for hexadecimal printf.
- Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/printf-parse.c b/contrib/tools/bison/lib/printf-parse.c
index e6251458fd9..8596fd5f305 100644
--- a/contrib/tools/bison/lib/printf-parse.c
+++ b/contrib/tools/bison/lib/printf-parse.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 1999-2000, 2002-2003, 2006-2018 Free Software Foundation, Inc.
+ Copyright (C) 1999-2000, 2002-2003, 2006-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/printf-parse.h b/contrib/tools/bison/lib/printf-parse.h
index 16d817ec025..746bb3fe0fa 100644
--- a/contrib/tools/bison/lib/printf-parse.h
+++ b/contrib/tools/bison/lib/printf-parse.h
@@ -1,5 +1,5 @@
/* Parse printf format string.
- Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2018 Free Software
+ Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2019 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/progname.c b/contrib/tools/bison/lib/progname.c
index 382f5031d5c..a42b7fa2f70 100644
--- a/contrib/tools/bison/lib/progname.c
+++ b/contrib/tools/bison/lib/progname.c
@@ -1,5 +1,5 @@
/* Program name management.
- Copyright (C) 2001-2003, 2005-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2001.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/progname.h b/contrib/tools/bison/lib/progname.h
index adc6b01d238..c726e97e905 100644
--- a/contrib/tools/bison/lib/progname.h
+++ b/contrib/tools/bison/lib/progname.h
@@ -1,5 +1,5 @@
/* Program name management.
- Copyright (C) 2001-2004, 2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004, 2006, 2009-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2001.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/quote.h b/contrib/tools/bison/lib/quote.h
index eedc283e086..5cef8ff1e09 100644
--- a/contrib/tools/bison/lib/quote.h
+++ b/contrib/tools/bison/lib/quote.h
@@ -1,6 +1,6 @@
/* quote.h - prototypes for quote.c
- Copyright (C) 1998-2001, 2003, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 1998-2001, 2003, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/quotearg.c b/contrib/tools/bison/lib/quotearg.c
index fe68dca313d..773d53f1154 100644
--- a/contrib/tools/bison/lib/quotearg.c
+++ b/contrib/tools/bison/lib/quotearg.c
@@ -1,6 +1,6 @@
/* quotearg.c - quote arguments for output
- Copyright (C) 1998-2002, 2004-2018 Free Software Foundation, Inc.
+ Copyright (C) 1998-2002, 2004-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/quotearg.h b/contrib/tools/bison/lib/quotearg.h
index 0584c56a2b0..0f07e0211e2 100644
--- a/contrib/tools/bison/lib/quotearg.h
+++ b/contrib/tools/bison/lib/quotearg.h
@@ -1,6 +1,6 @@
/* quotearg.h - quote arguments for output
- Copyright (C) 1998-2002, 2004, 2006, 2008-2018 Free Software Foundation,
+ Copyright (C) 1998-2002, 2004, 2006, 2008-2019 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/raise.c b/contrib/tools/bison/lib/raise.c
index 8a93bea7f77..e750b7a4c64 100644
--- a/contrib/tools/bison/lib/raise.c
+++ b/contrib/tools/bison/lib/raise.c
@@ -1,6 +1,6 @@
/* Provide a non-threads replacement for the POSIX raise function.
- Copyright (C) 2002-2003, 2005-2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/relocatable.h b/contrib/tools/bison/lib/relocatable.h
new file mode 100644
index 00000000000..896a7e59c02
--- /dev/null
+++ b/contrib/tools/bison/lib/relocatable.h
@@ -0,0 +1,101 @@
+/* Provide relocatable packages.
+ Copyright (C) 2003, 2005, 2008-2019 Free Software Foundation, Inc.
+ Written by Bruno Haible <[email protected]>, 2003.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _RELOCATABLE_H
+#define _RELOCATABLE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* This can be enabled through the configure --enable-relocatable option. */
+#if ENABLE_RELOCATABLE
+
+/* When building a DLL, we must export some functions. Note that because
+ this is a private .h file, we don't need to use __declspec(dllimport)
+ in any case. */
+#if HAVE_VISIBILITY && BUILDING_DLL
+# define RELOCATABLE_DLL_EXPORTED __attribute__((__visibility__("default")))
+#elif defined _MSC_VER && BUILDING_DLL
+# define RELOCATABLE_DLL_EXPORTED __declspec(dllexport)
+#else
+# define RELOCATABLE_DLL_EXPORTED
+#endif
+
+/* Sets the original and the current installation prefix of the package.
+ Relocation simply replaces a pathname starting with the original prefix
+ by the corresponding pathname with the current prefix instead. Both
+ prefixes should be directory names without trailing slash (i.e. use ""
+ instead of "/"). */
+extern RELOCATABLE_DLL_EXPORTED void
+ set_relocation_prefix (const char *orig_prefix,
+ const char *curr_prefix);
+
+/* Returns the pathname, relocated according to the current installation
+ directory.
+ The returned string is either PATHNAME unmodified or a freshly allocated
+ string that you can free with free() after casting it to 'char *'. */
+extern const char * relocate (const char *pathname);
+
+/* Returns the pathname, relocated according to the current installation
+ directory.
+ This function sets *ALLOCATEDP to the allocated memory, or to NULL if
+ no memory allocation occurs. So that, after you're done with the return
+ value, to reclaim allocated memory, you can do: free (*ALLOCATEDP). */
+extern const char * relocate2 (const char *pathname, char **allocatedp);
+
+/* Memory management: relocate() potentially allocates memory, because it has
+ to construct a fresh pathname. If this is a problem because your program
+ calls relocate() frequently or because you want to fix all potential memory
+ leaks anyway, you have three options:
+ 1) Use this idiom:
+ const char *pathname = ...;
+ const char *rel_pathname = relocate (pathname);
+ ...
+ if (rel_pathname != pathname)
+ free ((char *) rel_pathname);
+ 2) Use this idiom:
+ char *allocated;
+ const char *rel_pathname = relocate2 (..., &allocated);
+ ...
+ free (allocated);
+ 3) Think about caching the result. */
+
+/* Convenience function:
+ Computes the current installation prefix, based on the original
+ installation prefix, the original installation directory of a particular
+ file, and the current pathname of this file.
+ Returns it, freshly allocated. Returns NULL upon failure. */
+extern char * compute_curr_prefix (const char *orig_installprefix,
+ const char *orig_installdir,
+ const char *curr_pathname);
+
+#else
+
+/* By default, we use the hardwired pathnames. */
+#define relocate(pathname) (pathname)
+#define relocate2(pathname,allocatedp) (*(allocatedp) = NULL, (pathname))
+
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RELOCATABLE_H */
diff --git a/contrib/tools/bison/lib/sig-handler.h b/contrib/tools/bison/lib/sig-handler.h
index 9ea339453f3..b289473dbde 100644
--- a/contrib/tools/bison/lib/sig-handler.h
+++ b/contrib/tools/bison/lib/sig-handler.h
@@ -1,6 +1,6 @@
/* Convenience declarations when working with <signal.h>.
- Copyright (C) 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2008-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/sigaction.c b/contrib/tools/bison/lib/sigaction.c
index 7e4af5fe55d..abedfdcdc47 100644
--- a/contrib/tools/bison/lib/sigaction.c
+++ b/contrib/tools/bison/lib/sigaction.c
@@ -1,5 +1,5 @@
/* POSIX compatible signal blocking.
- Copyright (C) 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2008-2019 Free Software Foundation, Inc.
Written by Eric Blake <[email protected]>, 2008.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/sigprocmask.c b/contrib/tools/bison/lib/sigprocmask.c
index 7a49bcd1159..d6cd3f82e50 100644
--- a/contrib/tools/bison/lib/sigprocmask.c
+++ b/contrib/tools/bison/lib/sigprocmask.c
@@ -1,5 +1,5 @@
/* POSIX compatible signal blocking.
- Copyright (C) 2006-2018 Free Software Foundation, Inc.
+ Copyright (C) 2006-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2006.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/spawn-pipe.c b/contrib/tools/bison/lib/spawn-pipe.c
index 1324f9008c8..5fe50fc6403 100644
--- a/contrib/tools/bison/lib/spawn-pipe.c
+++ b/contrib/tools/bison/lib/spawn-pipe.c
@@ -1,5 +1,5 @@
/* Creation of subprocesses, communicating via pipes.
- Copyright (C) 2001-2004, 2006-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004, 2006-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2001.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/spawn-pipe.h b/contrib/tools/bison/lib/spawn-pipe.h
index 52576d00b8e..0d709686665 100644
--- a/contrib/tools/bison/lib/spawn-pipe.h
+++ b/contrib/tools/bison/lib/spawn-pipe.h
@@ -1,5 +1,5 @@
/* Creation of subprocesses, communicating via pipes.
- Copyright (C) 2001-2003, 2006, 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2006, 2008-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2001.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/stat-time.c b/contrib/tools/bison/lib/stat-time.c
deleted file mode 100644
index 81b83ddb4fe..00000000000
--- a/contrib/tools/bison/lib/stat-time.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <config.h>
-#define _GL_STAT_TIME_INLINE _GL_EXTERN_INLINE
-#include "stat-time.h"
diff --git a/contrib/tools/bison/lib/stat-time.h b/contrib/tools/bison/lib/stat-time.h
deleted file mode 100644
index 69ebe85df1d..00000000000
--- a/contrib/tools/bison/lib/stat-time.h
+++ /dev/null
@@ -1,252 +0,0 @@
-/* stat-related time functions.
-
- Copyright (C) 2005, 2007, 2009-2018 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Paul Eggert. */
-
-#ifndef STAT_TIME_H
-#define STAT_TIME_H 1
-
-#include "intprops.h"
-
-#include <errno.h>
-#include <stddef.h>
-#include <sys/stat.h>
-#include <time.h>
-
-#ifndef _GL_INLINE_HEADER_BEGIN
- #error "Please include config.h first."
-#endif
-_GL_INLINE_HEADER_BEGIN
-#ifndef _GL_STAT_TIME_INLINE
-# define _GL_STAT_TIME_INLINE _GL_INLINE
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* STAT_TIMESPEC (ST, ST_XTIM) is the ST_XTIM member for *ST of type
- struct timespec, if available. If not, then STAT_TIMESPEC_NS (ST,
- ST_XTIM) is the nanosecond component of the ST_XTIM member for *ST,
- if available. ST_XTIM can be st_atim, st_ctim, st_mtim, or st_birthtim
- for access, status change, data modification, or birth (creation)
- time respectively.
-
- These macros are private to stat-time.h. */
-#if _GL_WINDOWS_STAT_TIMESPEC || defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
-# if _GL_WINDOWS_STAT_TIMESPEC || defined TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC
-# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim)
-# else
-# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.tv_nsec)
-# endif
-#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
-# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim##espec)
-#elif defined HAVE_STRUCT_STAT_ST_ATIMENSEC
-# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim##ensec)
-#elif defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC
-# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.st__tim.tv_nsec)
-#endif
-
-/* Return the nanosecond component of *ST's access time. */
-_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
-get_stat_atime_ns (struct stat const *st)
-{
-# if defined STAT_TIMESPEC
- return STAT_TIMESPEC (st, st_atim).tv_nsec;
-# elif defined STAT_TIMESPEC_NS
- return STAT_TIMESPEC_NS (st, st_atim);
-# else
- return 0;
-# endif
-}
-
-/* Return the nanosecond component of *ST's status change time. */
-_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
-get_stat_ctime_ns (struct stat const *st)
-{
-# if defined STAT_TIMESPEC
- return STAT_TIMESPEC (st, st_ctim).tv_nsec;
-# elif defined STAT_TIMESPEC_NS
- return STAT_TIMESPEC_NS (st, st_ctim);
-# else
- return 0;
-# endif
-}
-
-/* Return the nanosecond component of *ST's data modification time. */
-_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
-get_stat_mtime_ns (struct stat const *st)
-{
-# if defined STAT_TIMESPEC
- return STAT_TIMESPEC (st, st_mtim).tv_nsec;
-# elif defined STAT_TIMESPEC_NS
- return STAT_TIMESPEC_NS (st, st_mtim);
-# else
- return 0;
-# endif
-}
-
-/* Return the nanosecond component of *ST's birth time. */
-_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
-get_stat_birthtime_ns (struct stat const *st _GL_UNUSED)
-{
-# if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC
- return STAT_TIMESPEC (st, st_birthtim).tv_nsec;
-# elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
- return STAT_TIMESPEC_NS (st, st_birthtim);
-# else
- return 0;
-# endif
-}
-
-/* Return *ST's access time. */
-_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
-get_stat_atime (struct stat const *st)
-{
-#ifdef STAT_TIMESPEC
- return STAT_TIMESPEC (st, st_atim);
-#else
- struct timespec t;
- t.tv_sec = st->st_atime;
- t.tv_nsec = get_stat_atime_ns (st);
- return t;
-#endif
-}
-
-/* Return *ST's status change time. */
-_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
-get_stat_ctime (struct stat const *st)
-{
-#ifdef STAT_TIMESPEC
- return STAT_TIMESPEC (st, st_ctim);
-#else
- struct timespec t;
- t.tv_sec = st->st_ctime;
- t.tv_nsec = get_stat_ctime_ns (st);
- return t;
-#endif
-}
-
-/* Return *ST's data modification time. */
-_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
-get_stat_mtime (struct stat const *st)
-{
-#ifdef STAT_TIMESPEC
- return STAT_TIMESPEC (st, st_mtim);
-#else
- struct timespec t;
- t.tv_sec = st->st_mtime;
- t.tv_nsec = get_stat_mtime_ns (st);
- return t;
-#endif
-}
-
-/* Return *ST's birth time, if available; otherwise return a value
- with tv_sec and tv_nsec both equal to -1. */
-_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
-get_stat_birthtime (struct stat const *st _GL_UNUSED)
-{
- struct timespec t;
-
-#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
- || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC)
- t = STAT_TIMESPEC (st, st_birthtim);
-#elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
- t.tv_sec = st->st_birthtime;
- t.tv_nsec = st->st_birthtimensec;
-#elif defined _WIN32 && ! defined __CYGWIN__
- /* Native Windows platforms (but not Cygwin) put the "file creation
- time" in st_ctime (!). See
- <https://msdn.microsoft.com/en-us/library/14h5k7ff(VS.80).aspx>. */
-# if _GL_WINDOWS_STAT_TIMESPEC
- t = st->st_ctim;
-# else
- t.tv_sec = st->st_ctime;
- t.tv_nsec = 0;
-# endif
-#else
- /* Birth time is not supported. */
- t.tv_sec = -1;
- t.tv_nsec = -1;
-#endif
-
-#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
- || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC \
- || defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC)
- /* FreeBSD and NetBSD sometimes signal the absence of knowledge by
- using zero. Attempt to work around this problem. Alas, this can
- report failure even for valid timestamps. Also, NetBSD
- sometimes returns junk in the birth time fields; work around this
- bug if it is detected. */
- if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000))
- {
- t.tv_sec = -1;
- t.tv_nsec = -1;
- }
-#endif
-
- return t;
-}
-
-/* If a stat-like function returned RESULT, normalize the timestamps
- in *ST, in case this platform suffers from the Solaris 11 bug where
- tv_nsec might be negative. Return the adjusted RESULT, setting
- errno to EOVERFLOW if normalization overflowed. This function
- is intended to be private to this .h file. */
-_GL_STAT_TIME_INLINE int
-stat_time_normalize (int result, struct stat *st _GL_UNUSED)
-{
-#if defined __sun && defined STAT_TIMESPEC
- if (result == 0)
- {
- long int timespec_hz = 1000000000;
- short int const ts_off[] = { offsetof (struct stat, st_atim),
- offsetof (struct stat, st_mtim),
- offsetof (struct stat, st_ctim) };
- int i;
- for (i = 0; i < sizeof ts_off / sizeof *ts_off; i++)
- {
- struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]);
- long int q = ts->tv_nsec / timespec_hz;
- long int r = ts->tv_nsec % timespec_hz;
- if (r < 0)
- {
- r += timespec_hz;
- q--;
- }
- ts->tv_nsec = r;
- /* Overflow is possible, as Solaris 11 stat can yield
- tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000.
- INT_ADD_WRAPV is OK, since time_t is signed on Solaris. */
- if (INT_ADD_WRAPV (q, ts->tv_sec, &ts->tv_sec))
- {
- errno = EOVERFLOW;
- return -1;
- }
- }
- }
-#endif
- return result;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-_GL_INLINE_HEADER_END
-
-#endif
diff --git a/contrib/tools/bison/lib/stdio-impl.h b/contrib/tools/bison/lib/stdio-impl.h
index 393ef0cf58d..4260468b612 100644
--- a/contrib/tools/bison/lib/stdio-impl.h
+++ b/contrib/tools/bison/lib/stdio-impl.h
@@ -1,5 +1,5 @@
/* Implementation details of FILE streams.
- Copyright (C) 2007-2008, 2010-2018 Free Software Foundation, Inc.
+ Copyright (C) 2007-2008, 2010-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -61,6 +61,11 @@
# define _r pub._r
# define _w pub._w
# elif defined __ANDROID__ /* Android */
+# ifdef __LP64__
+# define _gl_flags_file_t int
+# else
+# define _gl_flags_file_t short
+# endif
/* Up to this commit from 2015-10-12
<https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a>
the innards of FILE were public, and fp_ub could be defined like for OpenBSD,
@@ -70,8 +75,8 @@
# define fp_ ((struct { unsigned char *_p; \
int _r; \
int _w; \
- int _flags; \
- int _file; \
+ _gl_flags_file_t _flags; \
+ _gl_flags_file_t _file; \
struct { unsigned char *_base; size_t _size; } _bf; \
int _lbfsize; \
void *_cookie; \
diff --git a/contrib/tools/bison/lib/stdio-safer.h b/contrib/tools/bison/lib/stdio-safer.h
index 17d4dd282ac..790846c2e7e 100644
--- a/contrib/tools/bison/lib/stdio-safer.h
+++ b/contrib/tools/bison/lib/stdio-safer.h
@@ -1,6 +1,6 @@
/* Invoke stdio functions, but avoid some glitches.
- Copyright (C) 2001, 2003, 2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2006, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/stpcpy.c b/contrib/tools/bison/lib/stpcpy.c
index 61239e9f1d7..a1d32fdaf81 100644
--- a/contrib/tools/bison/lib/stpcpy.c
+++ b/contrib/tools/bison/lib/stpcpy.c
@@ -1,5 +1,5 @@
/* stpcpy.c -- copy a string and return pointer to end of new string
- Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2018 Free Software
+ Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2019 Free Software
Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
diff --git a/contrib/tools/bison/lib/streq.h b/contrib/tools/bison/lib/streq.h
index bde1b9562ff..326537b6d02 100644
--- a/contrib/tools/bison/lib/streq.h
+++ b/contrib/tools/bison/lib/streq.h
@@ -1,5 +1,5 @@
/* Optimized string comparison.
- Copyright (C) 2001-2002, 2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2007, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
diff --git a/contrib/tools/bison/lib/stripslash.c b/contrib/tools/bison/lib/stripslash.c
index 60c6781ca1e..dfc15b43cc9 100644
--- a/contrib/tools/bison/lib/stripslash.c
+++ b/contrib/tools/bison/lib/stripslash.c
@@ -1,6 +1,6 @@
/* stripslash.c -- remove redundant trailing slashes from a file name
- Copyright (C) 1990, 2001, 2003-2006, 2009-2018 Free Software Foundation,
+ Copyright (C) 1990, 2001, 2003-2006, 2009-2019 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/strndup.c b/contrib/tools/bison/lib/strndup.c
index b5c18dda66e..5b74828469a 100644
--- a/contrib/tools/bison/lib/strndup.c
+++ b/contrib/tools/bison/lib/strndup.c
@@ -1,6 +1,6 @@
/* A replacement function, for systems that lack strndup.
- Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2018 Free Software
+ Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2019 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
diff --git a/contrib/tools/bison/lib/strverscmp.c b/contrib/tools/bison/lib/strverscmp.c
index 4eac7915848..bf5ce5086f1 100644
--- a/contrib/tools/bison/lib/strverscmp.c
+++ b/contrib/tools/bison/lib/strverscmp.c
@@ -1,5 +1,5 @@
/* Compare strings while treating digits characters numerically.
- Copyright (C) 1997-2018 Free Software Foundation, Inc.
+ Copyright (C) 1997-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jean-François Bignolles <[email protected]>, 1997.
diff --git a/contrib/tools/bison/lib/timespec.h b/contrib/tools/bison/lib/timespec.h
index cc49668f42a..26f1bc1a4c7 100644
--- a/contrib/tools/bison/lib/timespec.h
+++ b/contrib/tools/bison/lib/timespec.h
@@ -1,6 +1,6 @@
/* timespec -- System time interface
- Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2018 Free Software
+ Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2019 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/timevar.c b/contrib/tools/bison/lib/timevar.c
index 46b8a689b45..0f6fb402e46 100644
--- a/contrib/tools/bison/lib/timevar.c
+++ b/contrib/tools/bison/lib/timevar.c
@@ -1,6 +1,6 @@
/* Timing variables for measuring compiler performance.
- Copyright (C) 2000, 2002, 2004, 2006, 2009-2015, 2018 Free Software
+ Copyright (C) 2000, 2002, 2004, 2006, 2009-2015, 2018-2019 Free Software
Foundation, Inc.
Contributed by Alex Samuel <[email protected]>
diff --git a/contrib/tools/bison/lib/timevar.def b/contrib/tools/bison/lib/timevar.def
index 00d0cd3391b..9de9b815a79 100644
--- a/contrib/tools/bison/lib/timevar.def
+++ b/contrib/tools/bison/lib/timevar.def
@@ -1,8 +1,8 @@
/* This file contains the definitions for timing variables used to -*- C -*-
measure run-time performance of the compiler.
- Copyright (C) 2002, 2007, 2009-2015, 2018 Free Software Foundation,
- Inc.
+ Copyright (C) 2002, 2007, 2009-2015, 2018-2019 Free Software
+ Foundation, Inc.
Contributed by Akim Demaille <[email protected]>.
diff --git a/contrib/tools/bison/lib/timevar.h b/contrib/tools/bison/lib/timevar.h
index cf9e0830d15..5d5a279cc5d 100644
--- a/contrib/tools/bison/lib/timevar.h
+++ b/contrib/tools/bison/lib/timevar.h
@@ -1,6 +1,6 @@
/* Timing variables for measuring application performance.
- Copyright (C) 2000, 2002, 2004, 2009-2015, 2018 Free Software
+ Copyright (C) 2000, 2002, 2004, 2009-2015, 2018-2019 Free Software
Foundation, Inc.
Contributed by Alex Samuel <[email protected]>
diff --git a/contrib/tools/bison/lib/unistd-safer.h b/contrib/tools/bison/lib/unistd-safer.h
index 5baf339a087..8eebffcae22 100644
--- a/contrib/tools/bison/lib/unistd-safer.h
+++ b/contrib/tools/bison/lib/unistd-safer.h
@@ -1,6 +1,6 @@
/* Invoke unistd-like functions, but avoid some glitches.
- Copyright (C) 2001, 2003, 2005, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2005, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/unitypes.h b/contrib/tools/bison/lib/unitypes.h
index e45ff8052a6..8ce466142b2 100644
--- a/contrib/tools/bison/lib/unitypes.h
+++ b/contrib/tools/bison/lib/unitypes.h
@@ -1,6 +1,6 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Elementary types and macros for the GNU UniString library.
- Copyright (C) 2002, 2005-2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
diff --git a/contrib/tools/bison/lib/uniwidth.h b/contrib/tools/bison/lib/uniwidth.h
index 65445fa519c..cb79a704815 100644
--- a/contrib/tools/bison/lib/uniwidth.h
+++ b/contrib/tools/bison/lib/uniwidth.h
@@ -1,6 +1,6 @@
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Display width functions.
- Copyright (C) 2001-2002, 2005, 2007, 2009-2018 Free Software Foundation,
+ Copyright (C) 2001-2002, 2005, 2007, 2009-2019 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify it
diff --git a/contrib/tools/bison/lib/uniwidth/cjk.h b/contrib/tools/bison/lib/uniwidth/cjk.h
index f7f822ca686..9870422ca6c 100644
--- a/contrib/tools/bison/lib/uniwidth/cjk.h
+++ b/contrib/tools/bison/lib/uniwidth/cjk.h
@@ -1,5 +1,5 @@
/* Test for CJK encoding.
- Copyright (C) 2001-2002, 2005-2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2005-2007, 2009-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/contrib/tools/bison/lib/uniwidth/width.c b/contrib/tools/bison/lib/uniwidth/width.c
index cd27d61b8dc..a7f59b18eba 100644
--- a/contrib/tools/bison/lib/uniwidth/width.c
+++ b/contrib/tools/bison/lib/uniwidth/width.c
@@ -1,5 +1,5 @@
/* Determine display width of Unicode character.
- Copyright (C) 2001-2002, 2006-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2006-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2002.
This program is free software: you can redistribute it and/or modify it
diff --git a/contrib/tools/bison/lib/unlocked-io.h b/contrib/tools/bison/lib/unlocked-io.h
index e3f0fcfed4a..ee1c06268fe 100644
--- a/contrib/tools/bison/lib/unlocked-io.h
+++ b/contrib/tools/bison/lib/unlocked-io.h
@@ -1,6 +1,6 @@
/* Prefer faster, non-thread-safe stdio functions if available.
- Copyright (C) 2001-2004, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/vasnprintf.c b/contrib/tools/bison/lib/vasnprintf.c
index 57571750a0b..f1f47f0d217 100644
--- a/contrib/tools/bison/lib/vasnprintf.c
+++ b/contrib/tools/bison/lib/vasnprintf.c
@@ -1,5 +1,5 @@
/* vsprintf with automatic memory allocation.
- Copyright (C) 1999, 2002-2018 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -4874,6 +4874,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
# if ! (((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \
&& !defined __UCLIBC__) \
|| (defined __APPLE__ && defined __MACH__) \
+ || defined __ANDROID__ \
|| (defined _WIN32 && ! defined __CYGWIN__))
fbp[1] = '%';
fbp[2] = 'n';
@@ -4895,6 +4896,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
On Mac OS X 10.13 or newer, the use of %n in format strings
in writable memory by default crashes the program, so we
should avoid it in this situation. */
+ /* On Android, we know that snprintf's return value conforms to
+ ISO C 99: the tests gl_SNPRINTF_RETVAL_C99 and
+ gl_SNPRINTF_TRUNCATION_C99 pass.
+ Therefore we can avoid using %n in this situation.
+ Starting on 2018-03-07, the use of %n in format strings
+ produces a fatal error (see
+ <https://android.googlesource.com/platform/bionic/+/41398d03b7e8e0dfb951660ae713e682e9fc0336>),
+ so we should avoid it. */
/* On native Windows systems (such as mingw), we can avoid using
%n because:
- Although the gl_SNPRINTF_TRUNCATION_C99 test fails,
diff --git a/contrib/tools/bison/lib/vasnprintf.h b/contrib/tools/bison/lib/vasnprintf.h
index 3eaaa7e5371..5b192b21e9b 100644
--- a/contrib/tools/bison/lib/vasnprintf.h
+++ b/contrib/tools/bison/lib/vasnprintf.h
@@ -1,5 +1,5 @@
/* vsprintf with automatic memory allocation.
- Copyright (C) 2002-2004, 2007-2018 Free Software Foundation, Inc.
+ Copyright (C) 2002-2004, 2007-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/verify.h b/contrib/tools/bison/lib/verify.h
index 3b57ddee0ac..6930645a350 100644
--- a/contrib/tools/bison/lib/verify.h
+++ b/contrib/tools/bison/lib/verify.h
@@ -1,6 +1,6 @@
/* Compile-time assert-like macros.
- Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
here generates easier-to-read diagnostics when verify (R) fails.
Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11.
- This will likely be supported by future GCC versions, in C++ mode.
+ This is supported by GCC 6.1.0 and later, in C++ mode.
Use this only with GCC. If we were willing to slow 'configure'
down we could also use it with other compilers, but since this
@@ -36,9 +36,7 @@
&& !defined __cplusplus)
# define _GL_HAVE__STATIC_ASSERT 1
#endif
-/* The condition (99 < __GNUC__) is temporary, until we know about the
- first G++ release that supports static_assert. */
-#if (99 < __GNUC__) && defined __cplusplus
+#if (6 <= __GNUC__) && defined __cplusplus
# define _GL_HAVE_STATIC_ASSERT 1
#endif
diff --git a/contrib/tools/bison/lib/w32spawn.h b/contrib/tools/bison/lib/w32spawn.h
index 3f675ebc44a..941ff1ab2d4 100644
--- a/contrib/tools/bison/lib/w32spawn.h
+++ b/contrib/tools/bison/lib/w32spawn.h
@@ -1,5 +1,5 @@
/* Auxiliary functions for the creation of subprocesses. Native Windows API.
- Copyright (C) 2001, 2003-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2003.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/wait-process.c b/contrib/tools/bison/lib/wait-process.c
index 9e59c08dd8c..84c0e86b1f5 100644
--- a/contrib/tools/bison/lib/wait-process.c
+++ b/contrib/tools/bison/lib/wait-process.c
@@ -1,5 +1,5 @@
/* Waiting for a subprocess to finish.
- Copyright (C) 2001-2003, 2005-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2001.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/wait-process.h b/contrib/tools/bison/lib/wait-process.h
index 0e73e710de8..08470fb850c 100644
--- a/contrib/tools/bison/lib/wait-process.h
+++ b/contrib/tools/bison/lib/wait-process.h
@@ -1,5 +1,5 @@
/* Waiting for a subprocess to finish.
- Copyright (C) 2001-2003, 2006, 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2006, 2008-2019 Free Software Foundation, Inc.
Written by Bruno Haible <[email protected]>, 2001.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/waitpid.c b/contrib/tools/bison/lib/waitpid.c
index b2e346a4756..a9dace628c4 100644
--- a/contrib/tools/bison/lib/waitpid.c
+++ b/contrib/tools/bison/lib/waitpid.c
@@ -1,5 +1,5 @@
/* Wait for process state change.
- Copyright (C) 2001-2003, 2005-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/wcwidth.c b/contrib/tools/bison/lib/wcwidth.c
index d33b6a9a555..1f081ccaa12 100644
--- a/contrib/tools/bison/lib/wcwidth.c
+++ b/contrib/tools/bison/lib/wcwidth.c
@@ -1,5 +1,5 @@
/* Determine the number of screen columns needed for a character.
- Copyright (C) 2006-2007, 2010-2018 Free Software Foundation, Inc.
+ Copyright (C) 2006-2007, 2010-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/xalloc-die.c b/contrib/tools/bison/lib/xalloc-die.c
index bfe610990e3..295f8d8e758 100644
--- a/contrib/tools/bison/lib/xalloc-die.c
+++ b/contrib/tools/bison/lib/xalloc-die.c
@@ -1,6 +1,6 @@
/* Report a memory allocation failure and exit.
- Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2018 Free Software
+ Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2019 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/contrib/tools/bison/lib/xalloc-oversized.h b/contrib/tools/bison/lib/xalloc-oversized.h
index 3426e10f4d2..e3068c83c48 100644
--- a/contrib/tools/bison/lib/xalloc-oversized.h
+++ b/contrib/tools/bison/lib/xalloc-oversized.h
@@ -1,6 +1,6 @@
/* xalloc-oversized.h -- memory allocation size checking
- Copyright (C) 1990-2000, 2003-2004, 2006-2018 Free Software Foundation, Inc.
+ Copyright (C) 1990-2000, 2003-2004, 2006-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/xalloc.h b/contrib/tools/bison/lib/xalloc.h
index c419a2de6c1..fc7e86bd89b 100644
--- a/contrib/tools/bison/lib/xalloc.h
+++ b/contrib/tools/bison/lib/xalloc.h
@@ -1,6 +1,6 @@
/* xalloc.h -- malloc with out-of-memory checking
- Copyright (C) 1990-2000, 2003-2004, 2006-2018 Free Software Foundation, Inc.
+ Copyright (C) 1990-2000, 2003-2004, 2006-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/xconcat-filename.c b/contrib/tools/bison/lib/xconcat-filename.c
index d44ca7d5eac..ad2d5f66b47 100644
--- a/contrib/tools/bison/lib/xconcat-filename.c
+++ b/contrib/tools/bison/lib/xconcat-filename.c
@@ -1,5 +1,5 @@
/* Construct a full filename from a directory and a relative filename.
- Copyright (C) 2001-2004, 2006-2018 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004, 2006-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/contrib/tools/bison/lib/xmalloc.c b/contrib/tools/bison/lib/xmalloc.c
index 9a30d67b9fa..cbe9a4f5671 100644
--- a/contrib/tools/bison/lib/xmalloc.c
+++ b/contrib/tools/bison/lib/xmalloc.c
@@ -1,6 +1,6 @@
/* xmalloc.c -- malloc with out of memory checking
- Copyright (C) 1990-2000, 2002-2006, 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 1990-2000, 2002-2006, 2008-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/xmemdup0.c b/contrib/tools/bison/lib/xmemdup0.c
index 1b53d11757c..4f491be1b8d 100644
--- a/contrib/tools/bison/lib/xmemdup0.c
+++ b/contrib/tools/bison/lib/xmemdup0.c
@@ -1,6 +1,6 @@
/* xmemdup0.c -- copy a block of arbitrary bytes, plus a trailing NUL
- Copyright (C) 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2008-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/xmemdup0.h b/contrib/tools/bison/lib/xmemdup0.h
index d1820288d62..768f0b274b6 100644
--- a/contrib/tools/bison/lib/xmemdup0.h
+++ b/contrib/tools/bison/lib/xmemdup0.h
@@ -1,6 +1,6 @@
/* xmemdup0.h -- copy a block of arbitrary bytes, plus a trailing NUL
- Copyright (C) 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2008-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -25,13 +25,6 @@
extern "C" {
# endif
-/* This function is always triggered when memory is exhausted.
- It must be defined by the application, either explicitly
- or by using gnulib's xalloc-die module. This is the
- function to call when one wants the program to die because of a
- memory allocation failure. */
-extern _Noreturn void xalloc_die (void);
-
char *xmemdup0 (void const *p, size_t s);
# ifdef __cplusplus
diff --git a/contrib/tools/bison/lib/xreadlink.c b/contrib/tools/bison/lib/xreadlink.c
new file mode 100644
index 00000000000..59cfde91b94
--- /dev/null
+++ b/contrib/tools/bison/lib/xreadlink.c
@@ -0,0 +1,44 @@
+/* xreadlink.c -- readlink wrapper to return the link name in malloc'd storage
+
+ Copyright (C) 2001, 2003-2007, 2009-2019 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Jim Meyering <[email protected]>
+ and Bruno Haible <[email protected]>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "xreadlink.h"
+
+#include <errno.h>
+
+#include "areadlink.h"
+#include "xalloc.h"
+
+/* Call readlink to get the symbolic link value of FILENAME.
+ Return a pointer to that NUL-terminated string in malloc'd storage.
+ If readlink fails, return NULL and set errno.
+ If realloc fails, or if the link value is longer than SIZE_MAX :-),
+ give a diagnostic and exit. */
+
+char *
+xreadlink (char const *filename)
+{
+ char *result = areadlink (filename);
+ if (result == NULL && errno == ENOMEM)
+ xalloc_die ();
+ return result;
+}
diff --git a/contrib/tools/bison/lib/xreadlink.h b/contrib/tools/bison/lib/xreadlink.h
new file mode 100644
index 00000000000..583205be54f
--- /dev/null
+++ b/contrib/tools/bison/lib/xreadlink.h
@@ -0,0 +1,25 @@
+/* Reading symbolic links without size limitation.
+
+ Copyright (C) 2001, 2003-2004, 2007, 2009-2019 Free Software Foundation,
+ Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Jim Meyering <[email protected]> */
+
+extern char *xreadlink (char const *filename);
+
+#if GNULIB_XREADLINKAT
+extern char *xreadlinkat (int fd, char const *filename);
+#endif
diff --git a/contrib/tools/bison/lib/xsize.h b/contrib/tools/bison/lib/xsize.h
index 8aeb3b7a68f..ecfd478dcd5 100644
--- a/contrib/tools/bison/lib/xsize.h
+++ b/contrib/tools/bison/lib/xsize.h
@@ -1,6 +1,6 @@
/* xsize.h -- Checked size_t computations.
- Copyright (C) 2003, 2008-2018 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2008-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/xstrndup.c b/contrib/tools/bison/lib/xstrndup.c
index 3b1700a6278..a9738291130 100644
--- a/contrib/tools/bison/lib/xstrndup.c
+++ b/contrib/tools/bison/lib/xstrndup.c
@@ -1,6 +1,6 @@
/* Duplicate a bounded initial segment of a string, with out-of-memory
checking.
- Copyright (C) 2003, 2006-2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2006-2007, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/xstrndup.h b/contrib/tools/bison/lib/xstrndup.h
index 54b0967f15d..360ccfdbb1f 100644
--- a/contrib/tools/bison/lib/xstrndup.h
+++ b/contrib/tools/bison/lib/xstrndup.h
@@ -1,6 +1,6 @@
/* Duplicate a bounded initial segment of a string, with out-of-memory
checking.
- Copyright (C) 2003, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/xtime.h b/contrib/tools/bison/lib/xtime.h
index aabcee9e689..9edd12392db 100644
--- a/contrib/tools/bison/lib/xtime.h
+++ b/contrib/tools/bison/lib/xtime.h
@@ -1,6 +1,6 @@
/* xtime -- extended-resolution integer timestamps
- Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/contrib/tools/bison/lib/ya.make b/contrib/tools/bison/lib/ya.make
index adda78c9fde..4d6afb692a2 100644
--- a/contrib/tools/bison/lib/ya.make
+++ b/contrib/tools/bison/lib/ya.make
@@ -15,8 +15,13 @@ NO_COMPILER_WARNINGS()
NO_RUNTIME()
+CFLAGS(
+ -DEXEEXT=\"\"
+)
+
SRCS(
- abitset.c
+ allocator.c
+ areadlink.c
argmatch.c
asnprintf.c
basename-lgpl.c
@@ -24,12 +29,16 @@ SRCS(
binary-io.c
bitrotate.c
bitset.c
- bitset_stats.c
- bitsetv-print.c
+ bitset/array.c
+ bitset/list.c
+ bitset/stats.c
+ bitset/table.c
+ bitset/vector.c
bitsetv.c
c-ctype.c
c-strcasecmp.c
c-strncasecmp.c
+ careadlinkat.c
cloexec.c
close-stream.c
closeout.c
@@ -38,10 +47,8 @@ SRCS(
dirname.c
dup-safer-flag.c
dup-safer.c
- ebitset.c
exitfail.c
fatal-signal.c
- fd-hook.c
fd-safer-flag.c
fd-safer.c
fopen-safer.c
@@ -49,14 +56,12 @@ SRCS(
get-errno.c
gethrxtime.c
getprogname.c
- glthread/lock.c
- glthread/threadlib.c
+ gl_array_list.c
+ gl_list.c
+ gl_xlist.c
hard-locale.c
hash.c
- lbitset.c
localcharset.c
- localtime-buffer.c
- malloca.c
math.c
mbrtowc.c
mbswidth.c
@@ -72,20 +77,19 @@ SRCS(
quotearg.c
sig-handler.c
spawn-pipe.c
- stat-time.c
stripslash.c
timespec.c
timevar.c
unistd.c
uniwidth/width.c
vasnprintf.c
- vbitset.c
wait-process.c
wctype-h.c
xalloc-die.c
xconcat-filename.c
xmalloc.c
xmemdup0.c
+ xreadlink.c
xsize.c
xstrndup.c
xtime.c
@@ -108,6 +112,7 @@ ELSEIF (OS_WINDOWS)
dup2.c
error.c
fcntl.c
+ fd-hook.c
fpending.c
getdtablesize.c
getopt.c