diff --git a/third_party/make/README.customs b/third_party/make/README.customs deleted file mode 100644 index a62e003bd..000000000 --- a/third_party/make/README.customs +++ /dev/null @@ -1,112 +0,0 @@ - -*-indented-text-*- - -GNU make can utilize the Customs library, distributed with Pmake, to -provide builds distributed across multiple hosts. - -In order to utilize this capability, you must first download and build -the Customs library. It is contained in the Pmake distribution, which -can be obtained at: - - ftp://ftp.icsi.berkeley.edu/pub/ai/stolcke/software/ - -This integration was tested (superficially) with Pmake 2.1.33. - - -BUILDING CUSTOMS ----------------- - -First, build pmake and Customs. You need to build pmake first, because -Customs require pmake to build. Unfortunately, this is not trivial; -please see the pmake and Customs documentation for details. The best -place to look for instructions is in the pmake-2.1.33/INSTALL file. - -Note that the 2.1.33 Pmake distribution comes with a set of patches to -GNU make, distributed in the pmake-2.1.33/etc/gnumake/ directory. These -patches are based on GNU make 3.75 (there are patches for earlier -versions of GNU make, also). The parts of this patchfile which relate -directly to Customs support have already been incorporated into this -version of GNU make, so you should _NOT_ apply the patch file. - -However, there are a few non-Customs specific (as far as I could tell) -changes here which are not incorporated (for example, the modification -to try expanding -lfoo to libfoo.so). If you rely on these changes -you'll need to re-apply them by hand. - -Install the Customs library and header files according to the -documentation. You should also install the man pages (contrary to -comments in the documentation, they weren't installed automatically for -me; I had to cd to the 'pmake-2.1.33/doc' directory and run 'pmake -install' there directly). - - -BUILDING GNU MAKE ------------------ - -Once you've installed Customs, you can build GNU make to use it. When -configuring GNU make, merely use the '--with-customs=DIR' option. -Provide the directory containing the 'lib' and 'include/customs' -subdirectories as DIR. For example, if you installed the customs -library in /usr/local/lib and the headers in /usr/local/include/customs, -then you'd pass '--with-customs=/usr/local' as an option to configure. - -Run make (or use build.sh) normally to build GNU make as described in -the INSTALL file. - -See the documentation for Customs for information on starting and -configuring Customs. - - -INVOKING CUSTOMS-IZED GNU MAKE ------------------------------ - -One thing you should be aware of is that the default build environment -for Customs requires root permissions. Practically, this means that GNU -make must be installed setuid root to use Customs. - -If you don't want to do this, you can build Customs such that root -permissions are not necessary. Andreas Stolcke -writes: - - > pmake, gnumake or any other customs client program is not required to - > be suid root if customs was compiled WITHOUT the USE_RESERVED_PORTS - > option in customs/config.h. Make sure the "customs" service in - > /etc/services is defined accordingly (port 8231 instead of 1001). - - > Not using USE_RESERVED_PORTS means that a user with programming - > skills could impersonate another user by writing a fake customs - > client that pretends to be someone other than himself. See the - > discussion in etc/SECURITY. - - -PROBLEMS --------- - -SunOS 4.1.x: - The customs/sprite.h header file #includes the header - files; this conflicts with GNU make's configuration so you'll get a - compile error if you use GCC (or any other ANSI-capable C compiler). - - I commented out the #include in sprite.h:107: - - #if defined(sun) || defined(ultrix) || defined(hpux) || defined(sgi) - /* #include */ - #else - - YMMV. - - -------------------------------------------------------------------------------- -Copyright (C) 1998-2020 Free Software Foundation, Inc. -This file is part of GNU Make. - -GNU Make 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. - -GNU Make 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 . diff --git a/third_party/make/lib/alloca.h b/third_party/make/alloca.h similarity index 100% rename from third_party/make/lib/alloca.h rename to third_party/make/alloca.h diff --git a/third_party/make/src/ar.c b/third_party/make/ar.c similarity index 98% rename from third_party/make/src/ar.c rename to third_party/make/ar.c index 26c50c3e8..12a7f89f9 100644 --- a/third_party/make/src/ar.c +++ b/third_party/make/ar.c @@ -14,11 +14,11 @@ 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 . */ -#include "third_party/make/src/makeint.h" +#include "third_party/make/makeint.h" /**/ #include "libc/alg/alg.h" -#include "third_party/make/src/dep.h" -#include "third_party/make/src/filedef.h" +#include "third_party/make/dep.h" +#include "third_party/make/filedef.h" #include "third_party/musl/fnmatch.h" /* clang-format off */ diff --git a/third_party/make/src/arscan.c b/third_party/make/arscan.c similarity index 99% rename from third_party/make/src/arscan.c rename to third_party/make/arscan.c index aba8130de..ce942ec6c 100644 --- a/third_party/make/src/arscan.c +++ b/third_party/make/arscan.c @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "libc/sysv/consts/o.h" -#include "third_party/make/src/makeint.h" +#include "third_party/make/makeint.h" /* clang-format off */ #ifdef TEST @@ -99,7 +99,7 @@ struct ar_hdr # define AR_HDR_SIZE (sizeof (struct ar_hdr)) #endif -#include "third_party/make/src/output.h" +#include "third_party/make/output.h" /* Takes three arguments ARCHIVE, FUNCTION and ARG. diff --git a/third_party/make/lib/basename-lgpl.c b/third_party/make/basename-lgpl.c similarity index 96% rename from third_party/make/lib/basename-lgpl.c rename to third_party/make/basename-lgpl.c index 8f3ba73df..4161cc4da 100644 --- a/third_party/make/lib/basename-lgpl.c +++ b/third_party/make/basename-lgpl.c @@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "third_party/make/src/config.h" +#include "third_party/make/config.h" /**/ #include "libc/str/str.h" -#include "third_party/make/lib/dirname.h" +#include "third_party/make/dirname.h" /* clang-format off */ /* Return the address of the last file name component of NAME. If diff --git a/third_party/make/src/commands.c b/third_party/make/commands.c similarity index 98% rename from third_party/make/src/commands.c rename to third_party/make/commands.c index d37cc03da..2f66a4de6 100644 --- a/third_party/make/src/commands.c +++ b/third_party/make/commands.c @@ -14,14 +14,14 @@ 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 . */ -#include "third_party/make/src/makeint.h" +#include "third_party/make/makeint.h" /**/ -#include "third_party/make/src/dep.h" -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/job.h" -#include "third_party/make/src/variable.h" +#include "third_party/make/dep.h" +#include "third_party/make/filedef.h" +#include "third_party/make/job.h" +#include "third_party/make/variable.h" /**/ -#include "third_party/make/src/commands.h" +#include "third_party/make/commands.h" /* clang-format off */ #define FILE_LIST_SEPARATOR ' ' diff --git a/third_party/make/src/commands.h b/third_party/make/commands.h similarity index 100% rename from third_party/make/src/commands.h rename to third_party/make/commands.h diff --git a/third_party/make/lib/concat-filename.c b/third_party/make/concat-filename.c similarity index 94% rename from third_party/make/lib/concat-filename.c rename to third_party/make/concat-filename.c index eabdfdcbd..457c8ff87 100644 --- a/third_party/make/lib/concat-filename.c +++ b/third_party/make/concat-filename.c @@ -18,9 +18,9 @@ #include "libc/mem/mem.h" #include "libc/str/str.h" -#include "third_party/make/lib/concat-filename.h" -#include "third_party/make/lib/filename.h" -#include "third_party/make/src/config.h" +#include "third_party/make/concat-filename.h" +#include "third_party/make/filename.h" +#include "third_party/make/config.h" /* clang-format off */ /* Concatenate a directory filename, a relative filename and an optional diff --git a/third_party/make/lib/concat-filename.h b/third_party/make/concat-filename.h similarity index 100% rename from third_party/make/lib/concat-filename.h rename to third_party/make/concat-filename.h diff --git a/third_party/make/src/config.h b/third_party/make/config.h similarity index 100% rename from third_party/make/src/config.h rename to third_party/make/config.h diff --git a/third_party/make/src/debug.h b/third_party/make/debug.h similarity index 100% rename from third_party/make/src/debug.h rename to third_party/make/debug.h diff --git a/third_party/make/src/default.c b/third_party/make/default.c similarity index 97% rename from third_party/make/src/default.c rename to third_party/make/default.c index 7dfd35b3d..b71edf8f5 100644 --- a/third_party/make/src/default.c +++ b/third_party/make/default.c @@ -15,15 +15,15 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* clang-format off */ -#include "third_party/make/src/makeint.h" +#include "third_party/make/makeint.h" /**/ -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/variable.h" -#include "third_party/make/src/rule.h" -#include "third_party/make/src/dep.h" -#include "third_party/make/src/job.h" +#include "third_party/make/filedef.h" +#include "third_party/make/variable.h" +#include "third_party/make/rule.h" +#include "third_party/make/dep.h" +#include "third_party/make/job.h" #include "libc/assert.h" -#include "third_party/make/src/commands.h" +#include "third_party/make/commands.h" /* This is the default list of suffixes for suffix rules. '.s' must come last, so that a '.o' file will be made from diff --git a/third_party/make/src/dep.h b/third_party/make/dep.h similarity index 100% rename from third_party/make/src/dep.h rename to third_party/make/dep.h diff --git a/third_party/make/src/dir.c b/third_party/make/dir.c similarity index 99% rename from third_party/make/src/dir.c rename to third_party/make/dir.c index a83e2bf48..fdfdd6686 100644 --- a/third_party/make/src/dir.c +++ b/third_party/make/dir.c @@ -14,11 +14,11 @@ 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 . */ -#include "third_party/make/src/makeint.h" +#include "third_party/make/makeint.h" /**/ -#include "third_party/make/src/dep.h" -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/hash.h" +#include "third_party/make/dep.h" +#include "third_party/make/filedef.h" +#include "third_party/make/hash.h" #include "third_party/musl/glob.h" /* clang-format off */ diff --git a/third_party/make/lib/dirname-lgpl.c b/third_party/make/dirname-lgpl.c similarity index 97% rename from third_party/make/lib/dirname-lgpl.c rename to third_party/make/dirname-lgpl.c index 365d9ffcb..1d69e3c9a 100644 --- a/third_party/make/lib/dirname-lgpl.c +++ b/third_party/make/dirname-lgpl.c @@ -17,11 +17,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "third_party/make/src/config.h" +#include "third_party/make/config.h" /**/ #include "libc/mem/mem.h" #include "libc/str/str.h" -#include "third_party/make/lib/dirname.h" +#include "third_party/make/dirname.h" /* clang-format off */ /* Return the length of the prefix of FILE that will be used by diff --git a/third_party/make/lib/dirname.h b/third_party/make/dirname.h similarity index 97% rename from third_party/make/lib/dirname.h rename to third_party/make/dirname.h index e39363744..52ee3a92c 100644 --- a/third_party/make/lib/dirname.h +++ b/third_party/make/dirname.h @@ -20,7 +20,7 @@ #ifndef DIRNAME_H_ # define DIRNAME_H_ 1 -# include "third_party/make/lib/dosname.h" +# include "third_party/make/dosname.h" # ifndef DIRECTORY_SEPARATOR # define DIRECTORY_SEPARATOR '/' diff --git a/third_party/make/lib/dosname.h b/third_party/make/dosname.h similarity index 100% rename from third_party/make/lib/dosname.h rename to third_party/make/dosname.h diff --git a/third_party/make/lib/dup2.c b/third_party/make/dup2.c similarity index 99% rename from third_party/make/lib/dup2.c rename to third_party/make/dup2.c index 61272f4db..c734e82fd 100644 --- a/third_party/make/lib/dup2.c +++ b/third_party/make/dup2.c @@ -19,7 +19,7 @@ #include "libc/calls/calls.h" #include "libc/errno.h" -#include "third_party/make/src/config.h" +#include "third_party/make/config.h" /* clang-format off */ #if HAVE_DUP2 diff --git a/third_party/make/lib/error.c b/third_party/make/error.c similarity index 97% rename from third_party/make/lib/error.c rename to third_party/make/error.c index a545f2fd9..07bb08918 100644 --- a/third_party/make/lib/error.c +++ b/third_party/make/error.c @@ -20,15 +20,15 @@ #include "libc/sysv/consts/f.h" #include "libc/calls/calls.h" -#include "third_party/make/src/config.h" -#include "third_party/make/lib/error.h" +#include "third_party/make/config.h" +#include "third_party/make/error.h" #include "libc/stdio/stdio.h" #include "libc/fmt/fmt.h" #include "libc/fmt/fmt.h" -#include "third_party/make/lib/stdio.h" +#include "third_party/make/stdio.h" #if !_LIBC && ENABLE_NLS -# include "third_party/make/lib/gettext.h" +# include "third_party/make/gettext.h" # define _(msgid) gettext (msgid) #endif diff --git a/third_party/make/lib/error.h b/third_party/make/error.h similarity index 100% rename from third_party/make/lib/error.h rename to third_party/make/error.h diff --git a/third_party/make/lib/exitfail.c b/third_party/make/exitfail.c similarity index 100% rename from third_party/make/lib/exitfail.c rename to third_party/make/exitfail.c diff --git a/third_party/make/lib/exitfail.h b/third_party/make/exitfail.h similarity index 100% rename from third_party/make/lib/exitfail.h rename to third_party/make/exitfail.h diff --git a/third_party/make/src/expand.c b/third_party/make/expand.c similarity index 98% rename from third_party/make/src/expand.c rename to third_party/make/expand.c index 20f5c3db4..bb09d877c 100644 --- a/third_party/make/src/expand.c +++ b/third_party/make/expand.c @@ -15,13 +15,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* clang-format off */ -#include "third_party/make/src/makeint.h" +#include "third_party/make/makeint.h" /**/ -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/job.h" -#include "third_party/make/src/commands.h" -#include "third_party/make/src/variable.h" -#include "third_party/make/src/rule.h" +#include "third_party/make/filedef.h" +#include "third_party/make/job.h" +#include "third_party/make/commands.h" +#include "third_party/make/variable.h" +#include "third_party/make/rule.h" /* Initially, any errors reported when expanding strings will be reported against the file where the error appears. */ diff --git a/third_party/make/lib/fcntl.c b/third_party/make/fcntl.c similarity index 99% rename from third_party/make/lib/fcntl.c rename to third_party/make/fcntl.c index 81e64ccbe..50a08c37d 100644 --- a/third_party/make/lib/fcntl.c +++ b/third_party/make/fcntl.c @@ -21,10 +21,10 @@ #include "libc/calls/calls.h" #include "libc/errno.h" #include "libc/sysv/consts/f.h" -#include "third_party/make/src/config.h" +#include "third_party/make/config.h" /* Specification. */ -#include "third_party/make/lib/fcntl.h" +#include "third_party/make/fcntl.h" #if defined _WIN32 && !defined __CYGWIN__ /* Get declarations of the native Windows API functions. */ diff --git a/third_party/make/lib/fcntl.h b/third_party/make/fcntl.h similarity index 100% rename from third_party/make/lib/fcntl.h rename to third_party/make/fcntl.h diff --git a/third_party/make/lib/fd-hook.c b/third_party/make/fd-hook.c similarity index 97% rename from third_party/make/lib/fd-hook.c rename to third_party/make/fd-hook.c index 4413111a0..1add5ecea 100644 --- a/third_party/make/lib/fd-hook.c +++ b/third_party/make/fd-hook.c @@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "third_party/make/src/config.h" +#include "third_party/make/config.h" /* Specification. */ -#include "third_party/make/lib/fd-hook.h" +#include "third_party/make/fd-hook.h" /* Currently, this entire code is only needed for the handling of sockets on native Windows platforms. */ diff --git a/third_party/make/lib/fd-hook.h b/third_party/make/fd-hook.h similarity index 100% rename from third_party/make/lib/fd-hook.h rename to third_party/make/fd-hook.h diff --git a/third_party/make/src/file.c b/third_party/make/file.c similarity index 99% rename from third_party/make/src/file.c rename to third_party/make/file.c index 4e21aa450..f8c33aaad 100644 --- a/third_party/make/src/file.c +++ b/third_party/make/file.c @@ -15,17 +15,17 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* clang-format off */ -#include "third_party/make/src/makeint.h" +#include "third_party/make/makeint.h" /**/ -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/dep.h" -#include "third_party/make/src/job.h" -#include "third_party/make/src/commands.h" -#include "third_party/make/src/variable.h" -#include "third_party/make/src/debug.h" +#include "third_party/make/filedef.h" +#include "third_party/make/dep.h" +#include "third_party/make/job.h" +#include "third_party/make/commands.h" +#include "third_party/make/variable.h" +#include "third_party/make/debug.h" #include "libc/assert.h" #include "libc/assert.h" -#include "third_party/make/src/hash.h" +#include "third_party/make/hash.h" /* Remember whether snap_deps has been invoked: we need this to be sure we diff --git a/third_party/make/src/filedef.h b/third_party/make/filedef.h similarity index 99% rename from third_party/make/src/filedef.h rename to third_party/make/filedef.h index f8472b96e..2034fbb88 100644 --- a/third_party/make/src/filedef.h +++ b/third_party/make/filedef.h @@ -18,7 +18,7 @@ this program. If not, see . */ that the makefile says how to make. All of these are chained together through 'next'. */ -#include "third_party/make/src/hash.h" +#include "third_party/make/hash.h" /* clang-format off */ struct commands; diff --git a/third_party/make/lib/filename.h b/third_party/make/filename.h similarity index 100% rename from third_party/make/lib/filename.h rename to third_party/make/filename.h diff --git a/third_party/make/lib/findprog-in.c b/third_party/make/findprog-in.c similarity index 97% rename from third_party/make/lib/findprog-in.c rename to third_party/make/findprog-in.c index 99695b690..76890d77a 100644 --- a/third_party/make/lib/findprog-in.c +++ b/third_party/make/findprog-in.c @@ -18,16 +18,16 @@ #include "libc/errno.h" -#include "third_party/make/src/config.h" +#include "third_party/make/config.h" /* Specification. */ -#include "third_party/make/lib/findprog.h" +#include "third_party/make/findprog.h" #include "libc/sysv/consts/ok.h" -#include "third_party/make/lib/filename.h" -#include "third_party/make/lib/concat-filename.h" -#include "third_party/make/lib/xalloc.h" +#include "third_party/make/filename.h" +#include "third_party/make/concat-filename.h" +#include "third_party/make/xalloc.h" #if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__ /* Native Windows, OS/2, DOS */ diff --git a/third_party/make/lib/findprog.h b/third_party/make/findprog.h similarity index 100% rename from third_party/make/lib/findprog.h rename to third_party/make/findprog.h diff --git a/third_party/make/src/function.c b/third_party/make/function.c similarity index 99% rename from third_party/make/src/function.c rename to third_party/make/function.c index d8ae61056..b631a4354 100644 --- a/third_party/make/src/function.c +++ b/third_party/make/function.c @@ -15,15 +15,15 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* clang-format off */ -#include "third_party/make/src/makeint.h" +#include "third_party/make/makeint.h" /**/ -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/variable.h" -#include "third_party/make/src/dep.h" -#include "third_party/make/src/job.h" -#include "third_party/make/src/os.h" -#include "third_party/make/src/commands.h" -#include "third_party/make/src/debug.h" +#include "third_party/make/filedef.h" +#include "third_party/make/variable.h" +#include "third_party/make/dep.h" +#include "third_party/make/job.h" +#include "third_party/make/os.h" +#include "third_party/make/commands.h" +#include "third_party/make/debug.h" struct function_table_entry { diff --git a/third_party/make/lib/getloadavg.c b/third_party/make/getloadavg.c similarity index 98% rename from third_party/make/lib/getloadavg.c rename to third_party/make/getloadavg.c index de564b952..24b53edb4 100644 --- a/third_party/make/lib/getloadavg.c +++ b/third_party/make/getloadavg.c @@ -84,8 +84,8 @@ #include "libc/dce.h" #include "libc/sysv/errfuns.h" #include "libc/stdio/stdio.h" -#include "third_party/make/src/config.h" -#include "third_party/make/lib/intprops.h" +#include "third_party/make/config.h" +#include "third_party/make/intprops.h" /* Put the 1 minute, 5 minute and 15 minute load averages into the first NELEM elements of LOADAVG. diff --git a/third_party/make/src/getopt.c b/third_party/make/getopt.c similarity index 99% rename from third_party/make/src/getopt.c rename to third_party/make/getopt.c index cae667d71..9a502e9a5 100644 --- a/third_party/make/src/getopt.c +++ b/third_party/make/getopt.c @@ -31,7 +31,7 @@ this program. If not, see . */ #endif #ifdef HAVE_CONFIG_H -# include "third_party/make/src/config.h" +# include "third_party/make/config.h" #endif #pragma GCC diagnostic ignored "-Wredundant-decls" @@ -62,7 +62,7 @@ this program. If not, see . */ /* This is for other GNU distributions with internationalized messages. When compiling libc, the _ macro is predefined. */ -#include "third_party/make/src/gettext.h" +#include "third_party/make/gettext.h" #define _(msgid) gettext (msgid) @@ -80,7 +80,7 @@ this program. If not, see . */ GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ -#include "third_party/make/src/getopt.h" +#include "third_party/make/getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, diff --git a/third_party/make/src/getopt.h b/third_party/make/getopt.h similarity index 100% rename from third_party/make/src/getopt.h rename to third_party/make/getopt.h diff --git a/third_party/make/src/getopt1.c b/third_party/make/getopt1.c similarity index 98% rename from third_party/make/src/getopt1.c rename to third_party/make/getopt1.c index c5ca54c93..43a55faaf 100644 --- a/third_party/make/src/getopt1.c +++ b/third_party/make/getopt1.c @@ -16,11 +16,11 @@ 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 . */ -#include "third_party/make/src/getopt.h" +#include "third_party/make/getopt.h" /* clang-format off */ #ifdef HAVE_CONFIG_H -#include "third_party/make/src/config.h" +#include "third_party/make/config.h" #endif #if !defined __STDC__ || !__STDC__ diff --git a/third_party/make/lib/getprogname.c b/third_party/make/getprogname.c similarity index 87% rename from third_party/make/lib/getprogname.c rename to third_party/make/getprogname.c index 5a033b21f..cd183fa6f 100644 --- a/third_party/make/lib/getprogname.c +++ b/third_party/make/getprogname.c @@ -15,9 +15,9 @@ along with this program. If not, see . */ /* clang-format off */ -#include "third_party/make/src/config.h" -#include "third_party/make/lib/getprogname.h" -#include "third_party/make/lib/dirname.h" +#include "third_party/make/config.h" +#include "third_party/make/getprogname.h" +#include "third_party/make/dirname.h" char const * getprogname (void) diff --git a/third_party/make/lib/getprogname.h b/third_party/make/getprogname.h similarity index 100% rename from third_party/make/lib/getprogname.h rename to third_party/make/getprogname.h diff --git a/third_party/make/lib/gettext.h b/third_party/make/gettext.h similarity index 100% rename from third_party/make/lib/gettext.h rename to third_party/make/gettext.h diff --git a/third_party/make/src/gnumake.h b/third_party/make/gnumake.h similarity index 100% rename from third_party/make/src/gnumake.h rename to third_party/make/gnumake.h diff --git a/third_party/make/src/w32/include/w32err.h b/third_party/make/guile.c similarity index 67% rename from third_party/make/src/w32/include/w32err.h rename to third_party/make/guile.c index f3ca50c22..2f9d3a2c7 100644 --- a/third_party/make/src/w32/include/w32err.h +++ b/third_party/make/guile.c @@ -1,5 +1,6 @@ -/* Definitions for Windows error handling. -Copyright (C) 1996-2020 Free Software Foundation, Inc. +/* clang-format off */ +/* GNU Guile interface for GNU Make. +Copyright (C) 2011-2020 Free Software Foundation, Inc. This file is part of GNU Make. GNU Make is free software; you can redistribute it and/or modify it under the @@ -14,13 +15,10 @@ 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 . */ -#ifndef _W32ERR_H_ -#define _W32ERR_H_ +#include "third_party/make/makeint.h" -#ifndef EXTERN_DECL -#define EXTERN_DECL(entry, args) entry args -#endif - -EXTERN_DECL(const char * map_windows32_error_to_string, (DWORD error)); - -#endif /* !_W32ERR_H */ +int +guile_gmake_setup (const floc *flocp UNUSED) +{ + return 1; +} diff --git a/third_party/make/src/hash.c b/third_party/make/hash.c similarity index 99% rename from third_party/make/src/hash.c rename to third_party/make/hash.c index 7f2fe98c1..6ac3aa6e4 100644 --- a/third_party/make/src/hash.c +++ b/third_party/make/hash.c @@ -14,10 +14,10 @@ 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 . */ -#include "third_party/make/src/makeint.h" +#include "third_party/make/makeint.h" /**/ #include "libc/assert.h" -#include "third_party/make/src/hash.h" +#include "third_party/make/hash.h" /* clang-format off */ #define CALLOC(t, n) ((t *) xcalloc (sizeof (t) * (n))) diff --git a/third_party/make/src/hash.h b/third_party/make/hash.h similarity index 100% rename from third_party/make/src/hash.h rename to third_party/make/hash.h diff --git a/third_party/make/src/implicit.c b/third_party/make/implicit.c similarity index 98% rename from third_party/make/src/implicit.c rename to third_party/make/implicit.c index 499c469d5..7e46e9022 100644 --- a/third_party/make/src/implicit.c +++ b/third_party/make/implicit.c @@ -15,14 +15,14 @@ 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 . */ -#include "third_party/make/src/makeint.h" -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/rule.h" -#include "third_party/make/src/dep.h" -#include "third_party/make/src/debug.h" -#include "third_party/make/src/variable.h" -#include "third_party/make/src/job.h" /* struct child, used inside commands.h */ -#include "third_party/make/src/commands.h" /* set_file_variables */ +#include "third_party/make/makeint.h" +#include "third_party/make/filedef.h" +#include "third_party/make/rule.h" +#include "third_party/make/dep.h" +#include "third_party/make/debug.h" +#include "third_party/make/variable.h" +#include "third_party/make/job.h" /* struct child, used inside commands.h */ +#include "third_party/make/commands.h" /* set_file_variables */ static int pattern_search (struct file *file, int archive, unsigned int depth, unsigned int recursions); diff --git a/third_party/make/lib/intprops.h b/third_party/make/intprops.h similarity index 100% rename from third_party/make/lib/intprops.h rename to third_party/make/intprops.h diff --git a/third_party/make/src/job.c b/third_party/make/job.c similarity index 99% rename from third_party/make/src/job.c rename to third_party/make/job.c index 01d28f901..0a8aaa0d5 100644 --- a/third_party/make/src/job.c +++ b/third_party/make/job.c @@ -15,15 +15,15 @@ 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 . */ -#include "third_party/make/src/makeint.h" +#include "third_party/make/makeint.h" /**/ -#include "third_party/make/src/debug.h" -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/job.h" +#include "third_party/make/debug.h" +#include "third_party/make/filedef.h" +#include "third_party/make/job.h" /**/ -#include "third_party/make/src/commands.h" -#include "third_party/make/src/os.h" -#include "third_party/make/src/variable.h" +#include "third_party/make/commands.h" +#include "third_party/make/os.h" +#include "third_party/make/variable.h" #ifdef WINDOWS32 const char *default_shell = "sh.exe"; diff --git a/third_party/make/src/job.h b/third_party/make/job.h similarity index 98% rename from third_party/make/src/job.h rename to third_party/make/job.h index 315dd5217..f34888702 100644 --- a/third_party/make/src/job.h +++ b/third_party/make/job.h @@ -15,7 +15,7 @@ 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 . */ -#include "third_party/make/src/output.h" +#include "third_party/make/output.h" /* Structure describing a running or dead child process. */ diff --git a/third_party/make/lib/_Noreturn.h b/third_party/make/lib/_Noreturn.h deleted file mode 100644 index b2d361e8a..000000000 --- a/third_party/make/lib/_Noreturn.h +++ /dev/null @@ -1,41 +0,0 @@ -/* clang-format off */ -/* A C macro for declaring that a function does not return. - Copyright (C) 2011-2020 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 . */ - -#ifndef _Noreturn -# if (defined __cplusplus \ - && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ - || (defined _MSC_VER && 1900 <= _MSC_VER)) \ - && 0) - /* [[noreturn]] is not practically usable, because with it the syntax - extern _Noreturn void func (...); - would not be valid; such a declaration would only be valid with 'extern' - and '_Noreturn' swapped, or without the 'extern' keyword. However, some - AIX system header files and several gnulib header files use precisely - this syntax with 'extern'. */ -# define _Noreturn [[noreturn]] -# elif ((!defined __cplusplus || defined __clang__) \ - && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ - || 4 < __GNUC__ + (7 <= __GNUC_MINOR__))) - /* _Noreturn works as-is. */ -# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C -# define _Noreturn __attribute__ ((__noreturn__)) -# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn -# endif -#endif diff --git a/third_party/make/lib/access.c b/third_party/make/lib/access.c deleted file mode 100644 index 66698fae2..000000000 --- a/third_party/make/lib/access.c +++ /dev/null @@ -1,28 +0,0 @@ -/* clang-format off */ -/* Test the access rights of a file. - Copyright (C) 2019-2020 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 . */ - - -/* Specification. */ - - -int -access (const char *file, int mode) -{ - if ((mode & X_OK) != 0) - mode = (mode & ~X_OK) | R_OK; - return _access (file, mode); -} diff --git a/third_party/make/lib/alloca.c b/third_party/make/lib/alloca.c deleted file mode 100644 index f3d954424..000000000 --- a/third_party/make/lib/alloca.c +++ /dev/null @@ -1,474 +0,0 @@ -/* clang-format off */ -/* alloca.c -- allocate automatically reclaimed memory - (Mostly) portable public-domain implementation -- D A Gwyn - - This implementation of the PWB library alloca function, - which is used to allocate space off the run-time stack so - that it is automatically reclaimed upon procedure exit, - was inspired by discussions with J. Q. Johnson of Cornell. - J.Otto Tennant contributed the Cray support. - - There are some preprocessor constants that can - be defined when compiling for your specific system, for - improved efficiency; however, the defaults should be okay. - - The general concept of this implementation is to keep - track of all alloca-allocated blocks, and reclaim any - that are found to be deeper in the stack than the current - invocation. This heuristic does not reclaim storage as - soon as it becomes invalid, but it will do so eventually. - - As a special case, alloca(0) reclaims storage without - allocating any. It is a good idea to use alloca(0) in - your main control loop, etc. to force garbage collection. */ - - - - -#ifdef emacs -# include "lisp.h" -# include "blockinput.h" -# ifdef EMACS_FREE -# undef free -# define free EMACS_FREE -# endif -#else -# define memory_full() abort () -#endif - -/* If compiling with GCC 2, this file's not needed. */ -#if !defined (__GNUC__) || __GNUC__ < 2 - -/* If someone has defined alloca as a macro, - there must be some other way alloca is supposed to work. */ -# ifndef alloca - -# ifdef emacs -# ifdef static -/* actually, only want this if static is defined as "" - -- this is for usg, in which emacs must undefine static - in order to make unexec workable - */ -# ifndef STACK_DIRECTION -you -lose --- must know STACK_DIRECTION at compile-time -/* Using #error here is not wise since this file should work for - old and obscure compilers. */ -# endif /* STACK_DIRECTION undefined */ -# endif /* static */ -# endif /* emacs */ - -/* If your stack is a linked list of frames, you have to - provide an "address metric" ADDRESS_FUNCTION macro. */ - -# if defined (CRAY) && defined (CRAY_STACKSEG_END) -long i00afunc (); -# define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) -# else -# define ADDRESS_FUNCTION(arg) &(arg) -# endif - -/* Define STACK_DIRECTION if you know the direction of stack - growth for your system; otherwise it will be automatically - deduced at run-time. - - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ - -# ifndef STACK_DIRECTION -# define STACK_DIRECTION 0 /* Direction unknown. */ -# endif - -# if STACK_DIRECTION != 0 - -# define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ - -# else /* STACK_DIRECTION == 0; need run-time code. */ - -static int stack_dir; /* 1 or -1 once known. */ -# define STACK_DIR stack_dir - -static int -find_stack_direction (int *addr, int depth) -{ - int dir, dummy = 0; - if (! addr) - addr = &dummy; - *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; - dir = depth ? find_stack_direction (addr, depth - 1) : 0; - return dir + dummy; -} - -# endif /* STACK_DIRECTION == 0 */ - -/* An "alloca header" is used to: - (a) chain together all alloca'ed blocks; - (b) keep track of stack depth. - - It is very important that sizeof(header) agree with malloc - alignment chunk size. The following default should work okay. */ - -# ifndef ALIGN_SIZE -# define ALIGN_SIZE sizeof(double) -# endif - -typedef union hdr -{ - char align[ALIGN_SIZE]; /* To force sizeof(header). */ - struct - { - union hdr *next; /* For chaining headers. */ - char *deep; /* For stack depth measure. */ - } h; -} header; - -static header *last_alloca_header = NULL; /* -> last alloca header. */ - -/* Return a pointer to at least SIZE bytes of storage, - which will be automatically reclaimed upon exit from - the procedure that called alloca. Originally, this space - was supposed to be taken from the current stack frame of the - caller, but that method cannot be made to work for some - implementations of C, for example under Gould's UTX/32. */ - -void * -alloca (size_t size) -{ - auto char probe; /* Probes stack depth: */ - register char *depth = ADDRESS_FUNCTION (probe); - -# if STACK_DIRECTION == 0 - if (STACK_DIR == 0) /* Unknown growth direction. */ - STACK_DIR = find_stack_direction (NULL, (size & 1) + 20); -# endif - - /* Reclaim garbage, defined as all alloca'd storage that - was allocated from deeper in the stack than currently. */ - - { - register header *hp; /* Traverses linked list. */ - -# ifdef emacs - BLOCK_INPUT; -# endif - - for (hp = last_alloca_header; hp != NULL;) - if ((STACK_DIR > 0 && hp->h.deep > depth) - || (STACK_DIR < 0 && hp->h.deep < depth)) - { - register header *np = hp->h.next; - - free (hp); /* Collect garbage. */ - - hp = np; /* -> next header. */ - } - else - break; /* Rest are not deeper. */ - - last_alloca_header = hp; /* -> last valid storage. */ - -# ifdef emacs - UNBLOCK_INPUT; -# endif - } - - if (size == 0) - return NULL; /* No allocation required. */ - - /* Allocate combined header + user data storage. */ - - { - /* Address of header. */ - register header *new; - - size_t combined_size = sizeof (header) + size; - if (combined_size < sizeof (header)) - memory_full (); - - new = malloc (combined_size); - - if (! new) - memory_full (); - - new->h.next = last_alloca_header; - new->h.deep = depth; - - last_alloca_header = new; - - /* User storage begins just after header. */ - - return (void *) (new + 1); - } -} - -# if defined (CRAY) && defined (CRAY_STACKSEG_END) - -# ifdef DEBUG_I00AFUNC -# endif - -# ifndef CRAY_STACK -# define CRAY_STACK -# ifndef CRAY2 -/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ -struct stack_control_header - { - long shgrow:32; /* Number of times stack has grown. */ - long shaseg:32; /* Size of increments to stack. */ - long shhwm:32; /* High water mark of stack. */ - long shsize:32; /* Current size of stack (all segments). */ - }; - -/* The stack segment linkage control information occurs at - the high-address end of a stack segment. (The stack - grows from low addresses to high addresses.) The initial - part of the stack segment linkage control information is - 0200 (octal) words. This provides for register storage - for the routine which overflows the stack. */ - -struct stack_segment_linkage - { - long ss[0200]; /* 0200 overflow words. */ - long sssize:32; /* Number of words in this segment. */ - long ssbase:32; /* Offset to stack base. */ - long:32; - long sspseg:32; /* Offset to linkage control of previous - segment of stack. */ - long:32; - long sstcpt:32; /* Pointer to task common address block. */ - long sscsnm; /* Private control structure number for - microtasking. */ - long ssusr1; /* Reserved for user. */ - long ssusr2; /* Reserved for user. */ - long sstpid; /* Process ID for pid based multi-tasking. */ - long ssgvup; /* Pointer to multitasking thread giveup. */ - long sscray[7]; /* Reserved for Cray Research. */ - long ssa0; - long ssa1; - long ssa2; - long ssa3; - long ssa4; - long ssa5; - long ssa6; - long ssa7; - long sss0; - long sss1; - long sss2; - long sss3; - long sss4; - long sss5; - long sss6; - long sss7; - }; - -# else /* CRAY2 */ -/* The following structure defines the vector of words - returned by the STKSTAT library routine. */ -struct stk_stat - { - long now; /* Current total stack size. */ - long maxc; /* Amount of contiguous space which would - be required to satisfy the maximum - stack demand to date. */ - long high_water; /* Stack high-water mark. */ - long overflows; /* Number of stack overflow ($STKOFEN) calls. */ - long hits; /* Number of internal buffer hits. */ - long extends; /* Number of block extensions. */ - long stko_mallocs; /* Block allocations by $STKOFEN. */ - long underflows; /* Number of stack underflow calls ($STKRETN). */ - long stko_free; /* Number of deallocations by $STKRETN. */ - long stkm_free; /* Number of deallocations by $STKMRET. */ - long segments; /* Current number of stack segments. */ - long maxs; /* Maximum number of stack segments so far. */ - long pad_size; /* Stack pad size. */ - long current_address; /* Current stack segment address. */ - long current_size; /* Current stack segment size. This - number is actually corrupted by STKSTAT to - include the fifteen word trailer area. */ - long initial_address; /* Address of initial segment. */ - long initial_size; /* Size of initial segment. */ - }; - -/* The following structure describes the data structure which trails - any stack segment. I think that the description in 'asdef' is - out of date. I only describe the parts that I am sure about. */ - -struct stk_trailer - { - long this_address; /* Address of this block. */ - long this_size; /* Size of this block (does not include - this trailer). */ - long unknown2; - long unknown3; - long link; /* Address of trailer block of previous - segment. */ - long unknown5; - long unknown6; - long unknown7; - long unknown8; - long unknown9; - long unknown10; - long unknown11; - long unknown12; - long unknown13; - long unknown14; - }; - -# endif /* CRAY2 */ -# endif /* not CRAY_STACK */ - -# ifdef CRAY2 -/* Determine a "stack measure" for an arbitrary ADDRESS. - I doubt that "lint" will like this much. */ - -static long -i00afunc (long *address) -{ - struct stk_stat status; - struct stk_trailer *trailer; - long *block, size; - long result = 0; - - /* We want to iterate through all of the segments. The first - step is to get the stack status structure. We could do this - more quickly and more directly, perhaps, by referencing the - $LM00 common block, but I know that this works. */ - - STKSTAT (&status); - - /* Set up the iteration. */ - - trailer = (struct stk_trailer *) (status.current_address - + status.current_size - - 15); - - /* There must be at least one stack segment. Therefore it is - a fatal error if "trailer" is null. */ - - if (trailer == NULL) - abort (); - - /* Discard segments that do not contain our argument address. */ - - while (trailer != NULL) - { - block = (long *) trailer->this_address; - size = trailer->this_size; - if (block == NULL || size == 0) - abort (); - trailer = (struct stk_trailer *) trailer->link; - if ((block <= address) && (address < (block + size))) - break; - } - - /* Set the result to the offset in this segment and add the sizes - of all predecessor segments. */ - - result = address - block; - - if (trailer == NULL) - { - return result; - } - - do - { - if (trailer->this_size <= 0) - abort (); - result += trailer->this_size; - trailer = (struct stk_trailer *) trailer->link; - } - while (trailer != NULL); - - /* We are done. Note that if you present a bogus address (one - not in any segment), you will get a different number back, formed - from subtracting the address of the first block. This is probably - not what you want. */ - - return (result); -} - -# else /* not CRAY2 */ -/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. - Determine the number of the cell within the stack, - given the address of the cell. The purpose of this - routine is to linearize, in some sense, stack addresses - for alloca. */ - -static long -i00afunc (long address) -{ - long stkl = 0; - - long size, pseg, this_segment, stack; - long result = 0; - - struct stack_segment_linkage *ssptr; - - /* Register B67 contains the address of the end of the - current stack segment. If you (as a subprogram) store - your registers on the stack and find that you are past - the contents of B67, you have overflowed the segment. - - B67 also points to the stack segment linkage control - area, which is what we are really interested in. */ - - stkl = CRAY_STACKSEG_END (); - ssptr = (struct stack_segment_linkage *) stkl; - - /* If one subtracts 'size' from the end of the segment, - one has the address of the first word of the segment. - - If this is not the first segment, 'pseg' will be - nonzero. */ - - pseg = ssptr->sspseg; - size = ssptr->sssize; - - this_segment = stkl - size; - - /* It is possible that calling this routine itself caused - a stack overflow. Discard stack segments which do not - contain the target address. */ - - while (!(this_segment <= address && address <= stkl)) - { -# ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); -# endif - if (pseg == 0) - break; - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - this_segment = stkl - size; - } - - result = address - this_segment; - - /* If you subtract pseg from the current end of the stack, - you get the address of the previous stack segment's end. - This seems a little convoluted to me, but I'll bet you save - a cycle somewhere. */ - - while (pseg != 0) - { -# ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o\n", pseg, size); -# endif - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - result += size; - } - return (result); -} - -# endif /* not CRAY2 */ -# endif /* CRAY */ - -# endif /* no alloca */ -#endif /* not GCC 2 */ diff --git a/third_party/make/lib/arg-nonnull.h b/third_party/make/lib/arg-nonnull.h deleted file mode 100644 index 04e26b105..000000000 --- a/third_party/make/lib/arg-nonnull.h +++ /dev/null @@ -1,27 +0,0 @@ -/* clang-format off */ -/* A C macro for declaring that specific arguments must not be NULL. - Copyright (C) 2009-2020 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 . */ - -/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools - that the values passed as arguments n, ..., m must be non-NULL pointers. - n = 1 stands for the first argument, n = 2 for the second argument etc. */ -#ifndef _GL_ARG_NONNULL -# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 -# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) -# else -# define _GL_ARG_NONNULL(params) -# endif -#endif diff --git a/third_party/make/lib/c++defs.h b/third_party/make/lib/c++defs.h deleted file mode 100644 index 943d3e948..000000000 --- a/third_party/make/lib/c++defs.h +++ /dev/null @@ -1,317 +0,0 @@ -/* clang-format off */ -/* C++ compatible function declaration macros. - Copyright (C) 2010-2020 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 . */ - -#ifndef _GL_CXXDEFS_H -#define _GL_CXXDEFS_H - -/* Begin/end the GNULIB_NAMESPACE namespace. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { -# define _GL_END_NAMESPACE } -#else -# define _GL_BEGIN_NAMESPACE -# define _GL_END_NAMESPACE -#endif - -/* The three most frequent use cases of these macros are: - - * For providing a substitute for a function that is missing on some - platforms, but is declared and works fine on the platforms on which - it exists: - - #if @GNULIB_FOO@ - # if !@HAVE_FOO@ - _GL_FUNCDECL_SYS (foo, ...); - # endif - _GL_CXXALIAS_SYS (foo, ...); - _GL_CXXALIASWARN (foo); - #elif defined GNULIB_POSIXCHECK - ... - #endif - - * For providing a replacement for a function that exists on all platforms, - but is broken/insufficient and needs to be replaced on some platforms: - - #if @GNULIB_FOO@ - # if @REPLACE_FOO@ - # if !(defined __cplusplus && defined GNULIB_NAMESPACE) - # undef foo - # define foo rpl_foo - # endif - _GL_FUNCDECL_RPL (foo, ...); - _GL_CXXALIAS_RPL (foo, ...); - # else - _GL_CXXALIAS_SYS (foo, ...); - # endif - _GL_CXXALIASWARN (foo); - #elif defined GNULIB_POSIXCHECK - ... - #endif - - * For providing a replacement for a function that exists on some platforms - but is broken/insufficient and needs to be replaced on some of them and - is additionally either missing or undeclared on some other platforms: - - #if @GNULIB_FOO@ - # if @REPLACE_FOO@ - # if !(defined __cplusplus && defined GNULIB_NAMESPACE) - # undef foo - # define foo rpl_foo - # endif - _GL_FUNCDECL_RPL (foo, ...); - _GL_CXXALIAS_RPL (foo, ...); - # else - # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ - _GL_FUNCDECL_SYS (foo, ...); - # endif - _GL_CXXALIAS_SYS (foo, ...); - # endif - _GL_CXXALIASWARN (foo); - #elif defined GNULIB_POSIXCHECK - ... - #endif -*/ - -/* _GL_EXTERN_C declaration; - performs the declaration with C linkage. */ -#if defined __cplusplus -# define _GL_EXTERN_C extern "C" -#else -# define _GL_EXTERN_C extern -#endif - -/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); - declares a replacement function, named rpl_func, with the given prototype, - consisting of return type, parameters, and attributes. - Example: - _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) - _GL_ARG_NONNULL ((1))); - */ -#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ - _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) -#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ - _GL_EXTERN_C rettype rpl_func parameters_and_attributes - -/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); - declares the system function, named func, with the given prototype, - consisting of return type, parameters, and attributes. - Example: - _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) - _GL_ARG_NONNULL ((1))); - */ -#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ - _GL_EXTERN_C rettype func parameters_and_attributes - -/* _GL_CXXALIAS_RPL (func, rettype, parameters); - declares a C++ alias called GNULIB_NAMESPACE::func - that redirects to rpl_func, if GNULIB_NAMESPACE is defined. - Example: - _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); - - Wrapping rpl_func in an object with an inline conversion operator - avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is - actually used in the program. */ -#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ - _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - static const struct _gl_ ## func ## _wrapper \ - { \ - typedef rettype (*type) parameters; \ - \ - inline operator type () const \ - { \ - return ::rpl_func; \ - } \ - } func = {}; \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); - is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); - except that the C function rpl_func may have a slightly different - declaration. A cast is used to silence the "invalid conversion" error - that would otherwise occur. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - static const struct _gl_ ## func ## _wrapper \ - { \ - typedef rettype (*type) parameters; \ - \ - inline operator type () const \ - { \ - return reinterpret_cast(::rpl_func); \ - } \ - } func = {}; \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_SYS (func, rettype, parameters); - declares a C++ alias called GNULIB_NAMESPACE::func - that redirects to the system provided function func, if GNULIB_NAMESPACE - is defined. - Example: - _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); - - Wrapping func in an object with an inline conversion operator - avoids a reference to func unless GNULIB_NAMESPACE::func is - actually used in the program. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - static const struct _gl_ ## func ## _wrapper \ - { \ - typedef rettype (*type) parameters; \ - \ - inline operator type () const \ - { \ - return ::func; \ - } \ - } func = {}; \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); - is like _GL_CXXALIAS_SYS (func, rettype, parameters); - except that the C function func may have a slightly different declaration. - A cast is used to silence the "invalid conversion" error that would - otherwise occur. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - static const struct _gl_ ## func ## _wrapper \ - { \ - typedef rettype (*type) parameters; \ - \ - inline operator type () const \ - { \ - return reinterpret_cast(::func); \ - } \ - } func = {}; \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); - is like _GL_CXXALIAS_SYS (func, rettype, parameters); - except that the C function is picked among a set of overloaded functions, - namely the one with rettype2 and parameters2. Two consecutive casts - are used to silence the "cannot find a match" and "invalid conversion" - errors that would otherwise occur. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE - /* The outer cast must be a reinterpret_cast. - The inner cast: When the function is defined as a set of overloaded - functions, it works as a static_cast<>, choosing the designated variant. - When the function is defined as a single variant, it works as a - reinterpret_cast<>. The parenthesized cast syntax works both ways. */ -# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ - namespace GNULIB_NAMESPACE \ - { \ - static const struct _gl_ ## func ## _wrapper \ - { \ - typedef rettype (*type) parameters; \ - \ - inline operator type () const \ - { \ - return reinterpret_cast((rettype2 (*) parameters2)(::func)); \ - } \ - } func = {}; \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIASWARN (func); - causes a warning to be emitted when ::func is used but not when - GNULIB_NAMESPACE::func is used. func must be defined without overloaded - variants. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIASWARN(func) \ - _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) -# define _GL_CXXALIASWARN_1(func,namespace) \ - _GL_CXXALIASWARN_2 (func, namespace) -/* To work around GCC bug , - we enable the warning only when not optimizing. */ -# if !__OPTIMIZE__ -# define _GL_CXXALIASWARN_2(func,namespace) \ - _GL_WARN_ON_USE (func, \ - "The symbol ::" #func " refers to the system function. " \ - "Use " #namespace "::" #func " instead.") -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -# define _GL_CXXALIASWARN_2(func,namespace) \ - extern __typeof__ (func) func -# else -# define _GL_CXXALIASWARN_2(func,namespace) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -# endif -#else -# define _GL_CXXALIASWARN(func) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); - causes a warning to be emitted when the given overloaded variant of ::func - is used but not when GNULIB_NAMESPACE::func is used. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ - _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ - GNULIB_NAMESPACE) -# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ - _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) -/* To work around GCC bug , - we enable the warning only when not optimizing. */ -# if !__OPTIMIZE__ -# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ - _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ - "The symbol ::" #func " refers to the system function. " \ - "Use " #namespace "::" #func " instead.") -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ - extern __typeof__ (func) func -# else -# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -# endif -#else -# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -#endif /* _GL_CXXDEFS_H */ diff --git a/third_party/make/lib/close.c b/third_party/make/lib/close.c deleted file mode 100644 index bea9d4214..000000000 --- a/third_party/make/lib/close.c +++ /dev/null @@ -1,69 +0,0 @@ -/* clang-format off */ -/* close replacement. - Copyright (C) 2008-2020 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 . */ - - -/* Specification. */ - - -#include "fd-hook.h" -#if HAVE_MSVC_INVALID_PARAMETER_HANDLER -# include "msvc-inval.h" -#endif - -#undef close - -#if HAVE_MSVC_INVALID_PARAMETER_HANDLER -static int -close_nothrow (int fd) -{ - int result; - - TRY_MSVC_INVAL - { - result = close (fd); - } - CATCH_MSVC_INVAL - { - result = -1; - errno = EBADF; - } - DONE_MSVC_INVAL; - - return result; -} -#else -# define close_nothrow close -#endif - -/* Override close() to call into other gnulib modules. */ - -int -rpl_close (int fd) -{ -#if WINDOWS_SOCKETS - int retval = execute_all_close_hooks (close_nothrow, fd); -#else - int retval = close_nothrow (fd); -#endif - -#if REPLACE_FCHDIR - if (retval >= 0) - _gl_unregister_fd (fd); -#endif - - return retval; -} diff --git a/third_party/make/lib/fnmatch.c b/third_party/make/lib/fnmatch.c deleted file mode 100644 index 077f8b48d..000000000 --- a/third_party/make/lib/fnmatch.c +++ /dev/null @@ -1,481 +0,0 @@ -/* clang-format off */ -/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999 Free Software -Foundation, Inc. -This file is part of the GNU C Library. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -This library 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 -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public License -along with this library; see the file COPYING.LIB. If not, write to the Free -Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -USA. */ - -#if HAVE_CONFIG_H -#endif - -/* Enable GNU extensions in fnmatch.h. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif - - -#if HAVE_STRING_H || defined _LIBC -#else -#endif - -#if defined STDC_HEADERS || defined _LIBC -#endif - -/* For platform which support the ISO C amendement 1 functionality we - support user defined character classes. */ -#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H) -/* Solaris 2.5 has a bug: must be included before . */ -#endif - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#if defined _LIBC || !defined __GNU_LIBRARY__ - - -# if defined STDC_HEADERS || !defined isascii -# define ISASCII(c) 1 -# else -# define ISASCII(c) isascii(c) -# endif - -# ifdef isblank -# define ISBLANK(c) (ISASCII (c) && isblank (c)) -# else -# define ISBLANK(c) ((c) == ' ' || (c) == '\t') -# endif -# ifdef isgraph -# define ISGRAPH(c) (ISASCII (c) && isgraph (c)) -# else -# define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c)) -# endif - -# define ISPRINT(c) (ISASCII (c) && isprint (c)) -# define ISDIGIT(c) (ISASCII (c) && isdigit (c)) -# define ISALNUM(c) (ISASCII (c) && isalnum (c)) -# define ISALPHA(c) (ISASCII (c) && isalpha (c)) -# define ISCNTRL(c) (ISASCII (c) && iscntrl (c)) -# define ISLOWER(c) (ISASCII (c) && islower (c)) -# define ISPUNCT(c) (ISASCII (c) && ispunct (c)) -# define ISSPACE(c) (ISASCII (c) && isspace (c)) -# define ISUPPER(c) (ISASCII (c) && isupper (c)) -# define ISXDIGIT(c) (ISASCII (c) && isxdigit (c)) - -# define STREQ(s1, s2) ((strcmp (s1, s2) == 0)) - -# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H) -/* The GNU C library provides support for user-defined character classes - and the functions from ISO C amendement 1. */ -# ifdef CHARCLASS_NAME_MAX -# define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX -# else -/* This shouldn't happen but some implementation might still have this - problem. Use a reasonable default value. */ -# define CHAR_CLASS_MAX_LENGTH 256 -# endif - -# ifdef _LIBC -# define IS_CHAR_CLASS(string) __wctype (string) -# else -# define IS_CHAR_CLASS(string) wctype (string) -# endif -# else -# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */ - -# define IS_CHAR_CLASS(string) \ - (STREQ (string, "alpha") || STREQ (string, "upper") \ - || STREQ (string, "lower") || STREQ (string, "digit") \ - || STREQ (string, "alnum") || STREQ (string, "xdigit") \ - || STREQ (string, "space") || STREQ (string, "print") \ - || STREQ (string, "punct") || STREQ (string, "graph") \ - || STREQ (string, "cntrl") || STREQ (string, "blank")) -# endif - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -# if !defined _LIBC && !defined getenv -extern char *getenv (); -# endif - -# ifndef errno -extern int errno; -# endif - -/* This function doesn't exist on most systems. */ - -# if !defined HAVE___STRCHRNUL && !defined _LIBC -static char * -__strchrnul (s, c) - const char *s; - int c; -{ - char *result = strchr (s, c); - if (result == NULL) - result = strchr (s, '\0'); - return result; -} -# endif - -# ifndef internal_function -/* Inside GNU libc we mark some function in a special way. In other - environments simply ignore the marking. */ -# define internal_function -# endif - -/* Match STRING against the filename pattern PATTERN, returning zero if - it matches, nonzero if not. */ -static int internal_fnmatch __P ((const char *pattern, const char *string, - int no_leading_period, int flags)) - internal_function; -static int -internal_function -internal_fnmatch (pattern, string, no_leading_period, flags) - const char *pattern; - const char *string; - int no_leading_period; - int flags; -{ - register const char *p = pattern, *n = string; - register unsigned char c; - -/* Note that this evaluates C many times. */ -# ifdef _LIBC -# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c)) -# else -# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c)) -# endif - - while ((c = *p++) != '\0') - { - c = FOLD (c); - - switch (c) - { - case '?': - if (*n == '\0') - return FNM_NOMATCH; - else if (*n == '/' && (flags & FNM_FILE_NAME)) - return FNM_NOMATCH; - else if (*n == '.' && no_leading_period - && (n == string - || (n[-1] == '/' && (flags & FNM_FILE_NAME)))) - return FNM_NOMATCH; - break; - - case '\\': - if (!(flags & FNM_NOESCAPE)) - { - c = *p++; - if (c == '\0') - /* Trailing \ loses. */ - return FNM_NOMATCH; - c = FOLD (c); - } - if (FOLD ((unsigned char) *n) != c) - return FNM_NOMATCH; - break; - - case '*': - if (*n == '.' && no_leading_period - && (n == string - || (n[-1] == '/' && (flags & FNM_FILE_NAME)))) - return FNM_NOMATCH; - - for (c = *p++; c == '?' || c == '*'; c = *p++) - { - if (*n == '/' && (flags & FNM_FILE_NAME)) - /* A slash does not match a wildcard under FNM_FILE_NAME. */ - return FNM_NOMATCH; - else if (c == '?') - { - /* A ? needs to match one character. */ - if (*n == '\0') - /* There isn't another character; no match. */ - return FNM_NOMATCH; - else - /* One character of the string is consumed in matching - this ? wildcard, so *??? won't match if there are - less than three characters. */ - ++n; - } - } - - if (c == '\0') - /* The wildcard(s) is/are the last element of the pattern. - If the name is a file name and contains another slash - this does mean it cannot match. */ - return ((flags & FNM_FILE_NAME) && strchr (n, '/') != NULL - ? FNM_NOMATCH : 0); - else - { - const char *endp; - - endp = __strchrnul (n, (flags & FNM_FILE_NAME) ? '/' : '\0'); - - if (c == '[') - { - int flags2 = ((flags & FNM_FILE_NAME) - ? flags : (flags & ~FNM_PERIOD)); - - for (--p; n < endp; ++n) - if (internal_fnmatch (p, n, - (no_leading_period - && (n == string - || (n[-1] == '/' - && (flags - & FNM_FILE_NAME)))), - flags2) - == 0) - return 0; - } - else if (c == '/' && (flags & FNM_FILE_NAME)) - { - while (*n != '\0' && *n != '/') - ++n; - if (*n == '/' - && (internal_fnmatch (p, n + 1, flags & FNM_PERIOD, - flags) == 0)) - return 0; - } - else - { - int flags2 = ((flags & FNM_FILE_NAME) - ? flags : (flags & ~FNM_PERIOD)); - - if (c == '\\' && !(flags & FNM_NOESCAPE)) - c = *p; - c = FOLD (c); - for (--p; n < endp; ++n) - if (FOLD ((unsigned char) *n) == c - && (internal_fnmatch (p, n, - (no_leading_period - && (n == string - || (n[-1] == '/' - && (flags - & FNM_FILE_NAME)))), - flags2) == 0)) - return 0; - } - } - - /* If we come here no match is possible with the wildcard. */ - return FNM_NOMATCH; - - case '[': - { - /* Nonzero if the sense of the character class is inverted. */ - static int posixly_correct; - register int not; - char cold; - - if (posixly_correct == 0) - posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; - - if (*n == '\0') - return FNM_NOMATCH; - - if (*n == '.' && no_leading_period && (n == string - || (n[-1] == '/' - && (flags - & FNM_FILE_NAME)))) - return FNM_NOMATCH; - - if (*n == '/' && (flags & FNM_FILE_NAME)) - /* `/' cannot be matched. */ - return FNM_NOMATCH; - - not = (*p == '!' || (posixly_correct < 0 && *p == '^')); - if (not) - ++p; - - c = *p++; - for (;;) - { - unsigned char fn = FOLD ((unsigned char) *n); - - if (!(flags & FNM_NOESCAPE) && c == '\\') - { - if (*p == '\0') - return FNM_NOMATCH; - c = FOLD ((unsigned char) *p); - ++p; - - if (c == fn) - goto matched; - } - else if (c == '[' && *p == ':') - { - /* Leave room for the null. */ - char str[CHAR_CLASS_MAX_LENGTH + 1]; - size_t c1 = 0; -# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H) - wctype_t wt; -# endif - const char *startp = p; - - for (;;) - { - if (c1 == CHAR_CLASS_MAX_LENGTH) - /* The name is too long and therefore the pattern - is ill-formed. */ - return FNM_NOMATCH; - - c = *++p; - if (c == ':' && p[1] == ']') - { - p += 2; - break; - } - if (c < 'a' || c >= 'z') - { - /* This cannot possibly be a character class name. - Match it as a normal range. */ - p = startp; - c = '['; - goto normal_bracket; - } - str[c1++] = c; - } - str[c1] = '\0'; - -# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H) - wt = IS_CHAR_CLASS (str); - if (wt == 0) - /* Invalid character class name. */ - return FNM_NOMATCH; - - if (__iswctype (__btowc ((unsigned char) *n), wt)) - goto matched; -# else - if ((STREQ (str, "alnum") && ISALNUM ((unsigned char) *n)) - || (STREQ (str, "alpha") && ISALPHA ((unsigned char) *n)) - || (STREQ (str, "blank") && ISBLANK ((unsigned char) *n)) - || (STREQ (str, "cntrl") && ISCNTRL ((unsigned char) *n)) - || (STREQ (str, "digit") && ISDIGIT ((unsigned char) *n)) - || (STREQ (str, "graph") && ISGRAPH ((unsigned char) *n)) - || (STREQ (str, "lower") && ISLOWER ((unsigned char) *n)) - || (STREQ (str, "print") && ISPRINT ((unsigned char) *n)) - || (STREQ (str, "punct") && ISPUNCT ((unsigned char) *n)) - || (STREQ (str, "space") && ISSPACE ((unsigned char) *n)) - || (STREQ (str, "upper") && ISUPPER ((unsigned char) *n)) - || (STREQ (str, "xdigit") && ISXDIGIT ((unsigned char) *n))) - goto matched; -# endif - } - else if (c == '\0') - /* [ (unterminated) loses. */ - return FNM_NOMATCH; - else - { - normal_bracket: - if (FOLD (c) == fn) - goto matched; - - cold = c; - c = *p++; - - if (c == '-' && *p != ']') - { - /* It is a range. */ - unsigned char cend = *p++; - if (!(flags & FNM_NOESCAPE) && cend == '\\') - cend = *p++; - if (cend == '\0') - return FNM_NOMATCH; - - if (cold <= fn && fn <= FOLD (cend)) - goto matched; - - c = *p++; - } - } - - if (c == ']') - break; - } - - if (!not) - return FNM_NOMATCH; - break; - - matched: - /* Skip the rest of the [...] that already matched. */ - while (c != ']') - { - if (c == '\0') - /* [... (unterminated) loses. */ - return FNM_NOMATCH; - - c = *p++; - if (!(flags & FNM_NOESCAPE) && c == '\\') - { - if (*p == '\0') - return FNM_NOMATCH; - /* XXX 1003.2d11 is unclear if this is right. */ - ++p; - } - else if (c == '[' && *p == ':') - { - do - if (*++p == '\0') - return FNM_NOMATCH; - while (*p != ':' || p[1] == ']'); - p += 2; - c = *p; - } - } - if (not) - return FNM_NOMATCH; - } - break; - - default: - if (c != FOLD ((unsigned char) *n)) - return FNM_NOMATCH; - } - - ++n; - } - - if (*n == '\0') - return 0; - - if ((flags & FNM_LEADING_DIR) && *n == '/') - /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */ - return 0; - - return FNM_NOMATCH; - -# undef FOLD -} - - -int -fnmatch (pattern, string, flags) - const char *pattern; - const char *string; - int flags; -{ - return internal_fnmatch (pattern, string, flags & FNM_PERIOD, flags); -} - -#endif /* _LIBC or not __GNU_LIBRARY__. */ diff --git a/third_party/make/lib/getdtablesize.c b/third_party/make/lib/getdtablesize.c deleted file mode 100644 index f22edec11..000000000 --- a/third_party/make/lib/getdtablesize.c +++ /dev/null @@ -1,120 +0,0 @@ -/* clang-format off */ -/* getdtablesize() function: Return maximum possible file descriptor value + 1. - Copyright (C) 2008-2020 Free Software Foundation, Inc. - Written by Bruno Haible , 2008. - - 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 . */ - - -/* Specification. */ - -#if defined _WIN32 && ! defined __CYGWIN__ - - -# if HAVE_MSVC_INVALID_PARAMETER_HANDLER -# include "msvc-inval.h" -# endif - -# if HAVE_MSVC_INVALID_PARAMETER_HANDLER -static int -_setmaxstdio_nothrow (int newmax) -{ - int result; - - TRY_MSVC_INVAL - { - result = _setmaxstdio (newmax); - } - CATCH_MSVC_INVAL - { - result = -1; - } - DONE_MSVC_INVAL; - - return result; -} -# else -# define _setmaxstdio_nothrow _setmaxstdio -# endif - -/* Cache for the previous getdtablesize () result. Safe to cache because - Windows also lacks setrlimit. */ -static int dtablesize; - -int -getdtablesize (void) -{ - if (dtablesize == 0) - { - /* We are looking for the number N such that the valid file descriptors - are 0..N-1. It can be obtained through a loop as follows: - { - int fd; - for (fd = 3; fd < 65536; fd++) - if (dup2 (0, fd) == -1) - break; - return fd; - } - On Windows XP, the result is 2048. - The drawback of this loop is that it allocates memory for a libc - internal array that is never freed. - - The number N can also be obtained as the upper bound for - _getmaxstdio (). _getmaxstdio () returns the maximum number of open - FILE objects. The sanity check in _setmaxstdio reveals the maximum - number of file descriptors. This too allocates memory, but it is - freed when we call _setmaxstdio with the original value. */ - int orig_max_stdio = _getmaxstdio (); - unsigned int bound; - for (bound = 0x10000; _setmaxstdio_nothrow (bound) < 0; bound = bound / 2) - ; - _setmaxstdio_nothrow (orig_max_stdio); - dtablesize = bound; - } - return dtablesize; -} - -#else - - -# ifndef RLIM_SAVED_CUR -# define RLIM_SAVED_CUR RLIM_INFINITY -# endif -# ifndef RLIM_SAVED_MAX -# define RLIM_SAVED_MAX RLIM_INFINITY -# endif - -# ifdef __CYGWIN__ - /* Cygwin 1.7.25 auto-increases the RLIMIT_NOFILE soft limit until it - hits the compile-time constant hard limit of 3200. We might as - well just report the hard limit. */ -# define rlim_cur rlim_max -# endif - -int -getdtablesize (void) -{ - struct rlimit lim; - - if (getrlimit (RLIMIT_NOFILE, &lim) == 0 - && 0 <= lim.rlim_cur && lim.rlim_cur <= INT_MAX - && lim.rlim_cur != RLIM_INFINITY - && lim.rlim_cur != RLIM_SAVED_CUR - && lim.rlim_cur != RLIM_SAVED_MAX) - return lim.rlim_cur; - - return INT_MAX; -} - -#endif diff --git a/third_party/make/lib/limits.h b/third_party/make/lib/limits.h deleted file mode 100644 index 0fa186be8..000000000 --- a/third_party/make/lib/limits.h +++ /dev/null @@ -1,105 +0,0 @@ -/* clang-format off */ -/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -/* A GNU-like . - - Copyright 2016-2020 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 . */ - -#ifndef _GL_LIMITS_H - -#if __GNUC__ >= 3 -#pragma GCC system_header -#endif - - -/* The include_next requires a split double-inclusion guard. */ - -#ifndef _GL_LIMITS_H -#define _GL_LIMITS_H - -#ifndef LLONG_MIN -# if defined LONG_LONG_MIN /* HP-UX 11.31 */ -# define LLONG_MIN LONG_LONG_MIN -# elif defined LONGLONG_MIN /* IRIX 6.5 */ -# define LLONG_MIN LONGLONG_MIN -# elif defined __GNUC__ -# define LLONG_MIN (- __LONG_LONG_MAX__ - 1LL) -# endif -#endif -#ifndef LLONG_MAX -# if defined LONG_LONG_MAX /* HP-UX 11.31 */ -# define LLONG_MAX LONG_LONG_MAX -# elif defined LONGLONG_MAX /* IRIX 6.5 */ -# define LLONG_MAX LONGLONG_MAX -# elif defined __GNUC__ -# define LLONG_MAX __LONG_LONG_MAX__ -# endif -#endif -#ifndef ULLONG_MAX -# if defined ULONG_LONG_MAX /* HP-UX 11.31 */ -# define ULLONG_MAX ULONG_LONG_MAX -# elif defined ULONGLONG_MAX /* IRIX 6.5 */ -# define ULLONG_MAX ULONGLONG_MAX -# elif defined __GNUC__ -# define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL) -# endif -#endif - -/* The number of usable bits in an unsigned or signed integer type - with minimum value MIN and maximum value MAX, as an int expression - suitable in #if. Cover all known practical hosts. This - implementation exploits the fact that MAX is 1 less than a power of - 2, and merely counts the number of 1 bits in MAX; "COBn" means - "count the number of 1 bits in the low-order n bits"). */ -#define _GL_INTEGER_WIDTH(min, max) (((min) < 0) + _GL_COB128 (max)) -#define _GL_COB128(n) (_GL_COB64 ((n) >> 31 >> 31 >> 2) + _GL_COB64 (n)) -#define _GL_COB64(n) (_GL_COB32 ((n) >> 31 >> 1) + _GL_COB32 (n)) -#define _GL_COB32(n) (_GL_COB16 ((n) >> 16) + _GL_COB16 (n)) -#define _GL_COB16(n) (_GL_COB8 ((n) >> 8) + _GL_COB8 (n)) -#define _GL_COB8(n) (_GL_COB4 ((n) >> 4) + _GL_COB4 (n)) -#define _GL_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + !!((n) & 1)) - -#ifndef WORD_BIT -/* Assume 'int' is 32 bits wide. */ -# define WORD_BIT 32 -#endif -#ifndef LONG_BIT -/* Assume 'long' is 32 or 64 bits wide. */ -# if LONG_MAX == INT_MAX -# define LONG_BIT 32 -# else -# define LONG_BIT 64 -# endif -#endif - -/* Macros specified by ISO/IEC TS 18661-1:2014. */ - -#if (! defined ULLONG_WIDTH \ - && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__)) -# define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX) -# define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX) -# define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX) -# define SHRT_WIDTH _GL_INTEGER_WIDTH (SHRT_MIN, SHRT_MAX) -# define USHRT_WIDTH _GL_INTEGER_WIDTH (0, USHRT_MAX) -# define INT_WIDTH _GL_INTEGER_WIDTH (INT_MIN, INT_MAX) -# define UINT_WIDTH _GL_INTEGER_WIDTH (0, UINT_MAX) -# define LONG_WIDTH _GL_INTEGER_WIDTH (LONG_MIN, LONG_MAX) -# define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX) -# define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX) -# define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX) -#endif /* !ULLONG_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */ - -#endif /* _GL_LIMITS_H */ -#endif /* _GL_LIMITS_H */ diff --git a/third_party/make/lib/stpcpy.c b/third_party/make/lib/stpcpy.c deleted file mode 100644 index 38778f4a6..000000000 --- a/third_party/make/lib/stpcpy.c +++ /dev/null @@ -1,48 +0,0 @@ -/* clang-format off */ -/* stpcpy.c -- copy a string and return pointer to end of new string - Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2020 Free Software - Foundation, Inc. - - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@prep.ai.mit.edu. - - 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 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 . */ - - - -#undef __stpcpy -#ifdef _LIBC -# undef stpcpy -#endif - -#ifndef weak_alias -# define __stpcpy stpcpy -#endif - -/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ -char * -__stpcpy (char *dest, const char *src) -{ - register char *d = dest; - register const char *s = src; - - do - *d++ = *s; - while (*s++ != '\0'); - - return d - 1; -} -#ifdef weak_alias -weak_alias (__stpcpy, stpcpy) -#endif diff --git a/third_party/make/lib/strerror-override.c b/third_party/make/lib/strerror-override.c deleted file mode 100644 index 70511972e..000000000 --- a/third_party/make/lib/strerror-override.c +++ /dev/null @@ -1,300 +0,0 @@ -/* clang-format off */ -/* strerror-override.c --- POSIX compatible system error routine - - Copyright (C) 2010-2020 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 . */ - -/* Written by Bruno Haible , 2010. */ - - -#include "strerror-override.h" - - -#if GNULIB_defined_EWINSOCK /* native Windows platforms */ -# if HAVE_WINSOCK2_H -# endif -#endif - -/* If ERRNUM maps to an errno value defined by gnulib, return a string - describing the error. Otherwise return NULL. */ -const char * -strerror_override (int errnum) -{ - /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */ - switch (errnum) - { -#if REPLACE_STRERROR_0 - case 0: - return "Success"; -#endif - -#if GNULIB_defined_ESOCK /* native Windows platforms with older */ - case EINPROGRESS: - return "Operation now in progress"; - case EALREADY: - return "Operation already in progress"; - case ENOTSOCK: - return "Socket operation on non-socket"; - case EDESTADDRREQ: - return "Destination address required"; - case EMSGSIZE: - return "Message too long"; - case EPROTOTYPE: - return "Protocol wrong type for socket"; - case ENOPROTOOPT: - return "Protocol not available"; - case EPROTONOSUPPORT: - return "Protocol not supported"; - case EOPNOTSUPP: - return "Operation not supported"; - case EAFNOSUPPORT: - return "Address family not supported by protocol"; - case EADDRINUSE: - return "Address already in use"; - case EADDRNOTAVAIL: - return "Cannot assign requested address"; - case ENETDOWN: - return "Network is down"; - case ENETUNREACH: - return "Network is unreachable"; - case ECONNRESET: - return "Connection reset by peer"; - case ENOBUFS: - return "No buffer space available"; - case EISCONN: - return "Transport endpoint is already connected"; - case ENOTCONN: - return "Transport endpoint is not connected"; - case ETIMEDOUT: - return "Connection timed out"; - case ECONNREFUSED: - return "Connection refused"; - case ELOOP: - return "Too many levels of symbolic links"; - case EHOSTUNREACH: - return "No route to host"; - case EWOULDBLOCK: - return "Operation would block"; -#endif -#if GNULIB_defined_ESTREAMS /* native Windows platforms with older */ - case ETXTBSY: - return "Text file busy"; - case ENODATA: - return "No data available"; - case ENOSR: - return "Out of streams resources"; - case ENOSTR: - return "Device not a stream"; - case ETIME: - return "Timer expired"; - case EOTHER: - return "Other error"; -#endif -#if GNULIB_defined_EWINSOCK /* native Windows platforms */ - case ESOCKTNOSUPPORT: - return "Socket type not supported"; - case EPFNOSUPPORT: - return "Protocol family not supported"; - case ESHUTDOWN: - return "Cannot send after transport endpoint shutdown"; - case ETOOMANYREFS: - return "Too many references: cannot splice"; - case EHOSTDOWN: - return "Host is down"; - case EPROCLIM: - return "Too many processes"; - case EUSERS: - return "Too many users"; - case EDQUOT: - return "Disk quota exceeded"; - case ESTALE: - return "Stale NFS file handle"; - case EREMOTE: - return "Object is remote"; -# if HAVE_WINSOCK2_H - /* WSA_INVALID_HANDLE maps to EBADF */ - /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */ - /* WSA_INVALID_PARAMETER maps to EINVAL */ - case WSA_OPERATION_ABORTED: - return "Overlapped operation aborted"; - case WSA_IO_INCOMPLETE: - return "Overlapped I/O event object not in signaled state"; - case WSA_IO_PENDING: - return "Overlapped operations will complete later"; - /* WSAEINTR maps to EINTR */ - /* WSAEBADF maps to EBADF */ - /* WSAEACCES maps to EACCES */ - /* WSAEFAULT maps to EFAULT */ - /* WSAEINVAL maps to EINVAL */ - /* WSAEMFILE maps to EMFILE */ - /* WSAEWOULDBLOCK maps to EWOULDBLOCK */ - /* WSAEINPROGRESS maps to EINPROGRESS */ - /* WSAEALREADY maps to EALREADY */ - /* WSAENOTSOCK maps to ENOTSOCK */ - /* WSAEDESTADDRREQ maps to EDESTADDRREQ */ - /* WSAEMSGSIZE maps to EMSGSIZE */ - /* WSAEPROTOTYPE maps to EPROTOTYPE */ - /* WSAENOPROTOOPT maps to ENOPROTOOPT */ - /* WSAEPROTONOSUPPORT maps to EPROTONOSUPPORT */ - /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */ - /* WSAEOPNOTSUPP maps to EOPNOTSUPP */ - /* WSAEPFNOSUPPORT is EPFNOSUPPORT */ - /* WSAEAFNOSUPPORT maps to EAFNOSUPPORT */ - /* WSAEADDRINUSE maps to EADDRINUSE */ - /* WSAEADDRNOTAVAIL maps to EADDRNOTAVAIL */ - /* WSAENETDOWN maps to ENETDOWN */ - /* WSAENETUNREACH maps to ENETUNREACH */ - /* WSAENETRESET maps to ENETRESET */ - /* WSAECONNABORTED maps to ECONNABORTED */ - /* WSAECONNRESET maps to ECONNRESET */ - /* WSAENOBUFS maps to ENOBUFS */ - /* WSAEISCONN maps to EISCONN */ - /* WSAENOTCONN maps to ENOTCONN */ - /* WSAESHUTDOWN is ESHUTDOWN */ - /* WSAETOOMANYREFS is ETOOMANYREFS */ - /* WSAETIMEDOUT maps to ETIMEDOUT */ - /* WSAECONNREFUSED maps to ECONNREFUSED */ - /* WSAELOOP maps to ELOOP */ - /* WSAENAMETOOLONG maps to ENAMETOOLONG */ - /* WSAEHOSTDOWN is EHOSTDOWN */ - /* WSAEHOSTUNREACH maps to EHOSTUNREACH */ - /* WSAENOTEMPTY maps to ENOTEMPTY */ - /* WSAEPROCLIM is EPROCLIM */ - /* WSAEUSERS is EUSERS */ - /* WSAEDQUOT is EDQUOT */ - /* WSAESTALE is ESTALE */ - /* WSAEREMOTE is EREMOTE */ - case WSASYSNOTREADY: - return "Network subsystem is unavailable"; - case WSAVERNOTSUPPORTED: - return "Winsock.dll version out of range"; - case WSANOTINITIALISED: - return "Successful WSAStartup not yet performed"; - case WSAEDISCON: - return "Graceful shutdown in progress"; - case WSAENOMORE: case WSA_E_NO_MORE: - return "No more results"; - case WSAECANCELLED: case WSA_E_CANCELLED: - return "Call was canceled"; - case WSAEINVALIDPROCTABLE: - return "Procedure call table is invalid"; - case WSAEINVALIDPROVIDER: - return "Service provider is invalid"; - case WSAEPROVIDERFAILEDINIT: - return "Service provider failed to initialize"; - case WSASYSCALLFAILURE: - return "System call failure"; - case WSASERVICE_NOT_FOUND: - return "Service not found"; - case WSATYPE_NOT_FOUND: - return "Class type not found"; - case WSAEREFUSED: - return "Database query was refused"; - case WSAHOST_NOT_FOUND: - return "Host not found"; - case WSATRY_AGAIN: - return "Nonauthoritative host not found"; - case WSANO_RECOVERY: - return "Nonrecoverable error"; - case WSANO_DATA: - return "Valid name, no data record of requested type"; - /* WSA_QOS_* omitted */ -# endif -#endif - -#if GNULIB_defined_ENOMSG - case ENOMSG: - return "No message of desired type"; -#endif - -#if GNULIB_defined_EIDRM - case EIDRM: - return "Identifier removed"; -#endif - -#if GNULIB_defined_ENOLINK - case ENOLINK: - return "Link has been severed"; -#endif - -#if GNULIB_defined_EPROTO - case EPROTO: - return "Protocol error"; -#endif - -#if GNULIB_defined_EMULTIHOP - case EMULTIHOP: - return "Multihop attempted"; -#endif - -#if GNULIB_defined_EBADMSG - case EBADMSG: - return "Bad message"; -#endif - -#if GNULIB_defined_EOVERFLOW - case EOVERFLOW: - return "Value too large for defined data type"; -#endif - -#if GNULIB_defined_ENOTSUP - case ENOTSUP: - return "Not supported"; -#endif - -#if GNULIB_defined_ENETRESET - case ENETRESET: - return "Network dropped connection on reset"; -#endif - -#if GNULIB_defined_ECONNABORTED - case ECONNABORTED: - return "Software caused connection abort"; -#endif - -#if GNULIB_defined_ESTALE - case ESTALE: - return "Stale NFS file handle"; -#endif - -#if GNULIB_defined_EDQUOT - case EDQUOT: - return "Disk quota exceeded"; -#endif - -#if GNULIB_defined_ECANCELED - case ECANCELED: - return "Operation canceled"; -#endif - -#if GNULIB_defined_EOWNERDEAD - case EOWNERDEAD: - return "Owner died"; -#endif - -#if GNULIB_defined_ENOTRECOVERABLE - case ENOTRECOVERABLE: - return "State not recoverable"; -#endif - -#if GNULIB_defined_EILSEQ - case EILSEQ: - return "Invalid or incomplete multibyte or wide character"; -#endif - - default: - return NULL; - } -} diff --git a/third_party/make/lib/strerror-override.h b/third_party/make/lib/strerror-override.h deleted file mode 100644 index cab18a821..000000000 --- a/third_party/make/lib/strerror-override.h +++ /dev/null @@ -1,55 +0,0 @@ -/* clang-format off */ -/* strerror-override.h --- POSIX compatible system error routine - - Copyright (C) 2010-2020 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 . */ - -#ifndef _GL_STRERROR_OVERRIDE_H -# define _GL_STRERROR_OVERRIDE_H - - -/* Reasonable buffer size that should never trigger ERANGE; if this - proves too small, we intentionally abort(), to remind us to fix - this value. */ -# define STACKBUF_LEN 256 - -/* If ERRNUM maps to an errno value defined by gnulib, return a string - describing the error. Otherwise return NULL. */ -# if REPLACE_STRERROR_0 \ - || GNULIB_defined_ESOCK \ - || GNULIB_defined_ESTREAMS \ - || GNULIB_defined_EWINSOCK \ - || GNULIB_defined_ENOMSG \ - || GNULIB_defined_EIDRM \ - || GNULIB_defined_ENOLINK \ - || GNULIB_defined_EPROTO \ - || GNULIB_defined_EMULTIHOP \ - || GNULIB_defined_EBADMSG \ - || GNULIB_defined_EOVERFLOW \ - || GNULIB_defined_ENOTSUP \ - || GNULIB_defined_ENETRESET \ - || GNULIB_defined_ECONNABORTED \ - || GNULIB_defined_ESTALE \ - || GNULIB_defined_EDQUOT \ - || GNULIB_defined_ECANCELED \ - || GNULIB_defined_EOWNERDEAD \ - || GNULIB_defined_ENOTRECOVERABLE \ - || GNULIB_defined_EILSEQ -extern const char *strerror_override (int errnum) _GL_ATTRIBUTE_CONST; -# else -# define strerror_override(ignored) NULL -# endif - -#endif /* _GL_STRERROR_OVERRIDE_H */ diff --git a/third_party/make/lib/strerror.c b/third_party/make/lib/strerror.c deleted file mode 100644 index b28be2cf4..000000000 --- a/third_party/make/lib/strerror.c +++ /dev/null @@ -1,66 +0,0 @@ -/* clang-format off */ -/* strerror.c --- POSIX compatible system error routine - - Copyright (C) 2007-2020 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 . */ - - -/* Specification. */ - - -#include "intprops.h" -#include "strerror-override.h" -#include "verify.h" - -/* Use the system functions, not the gnulib overrides in this file. */ -#undef sprintf - -char * -strerror (int n) -#undef strerror -{ - static char buf[STACKBUF_LEN]; - size_t len; - - /* Cast away const, due to the historical signature of strerror; - callers should not be modifying the string. */ - const char *msg = strerror_override (n); - if (msg) - return (char *) msg; - - msg = strerror (n); - - /* Our strerror_r implementation might use the system's strerror - buffer, so all other clients of strerror have to see the error - copied into a buffer that we manage. This is not thread-safe, - even if the system strerror is, but portable programs shouldn't - be using strerror if they care about thread-safety. */ - if (!msg || !*msg) - { - static char const fmt[] = "Unknown error %d"; - verify (sizeof buf >= sizeof (fmt) + INT_STRLEN_BOUND (n)); - sprintf (buf, fmt, n); - errno = EINVAL; - return buf; - } - - /* Fix STACKBUF_LEN if this ever aborts. */ - len = strlen (msg); - if (sizeof buf <= len) - abort (); - - memcpy (buf, msg, len + 1); - return buf; -} diff --git a/third_party/make/lib/string.h b/third_party/make/lib/string.h deleted file mode 100644 index 2a6e164be..000000000 --- a/third_party/make/lib/string.h +++ /dev/null @@ -1,1536 +0,0 @@ -/* clang-format off */ -/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -/* A GNU-like . - - Copyright (C) 1995-1996, 2001-2020 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 . */ - -#if __GNUC__ >= 3 -#pragma GCC system_header -#endif - - -#if defined _GL_ALREADY_INCLUDING_STRING_H -/* Special invocation convention: - - On OS X/NetBSD we have a sequence of nested includes - -> -> "string.h" - In this situation system _chk variants due to -D_FORTIFY_SOURCE - might be used after any replacements defined here. */ - - -#else -/* Normal invocation convention. */ - -#ifndef _GL_STRING_H - -#define _GL_ALREADY_INCLUDING_STRING_H - -/* The include_next requires a split double-inclusion guard. */ - -#undef _GL_ALREADY_INCLUDING_STRING_H - -#ifndef _GL_STRING_H -#define _GL_STRING_H - -/* NetBSD 5.0 mis-defines NULL. */ - -/* MirBSD defines mbslen as a macro. */ -#if 0 && defined __MirBSD__ -#endif - -/* The __attribute__ feature is available in gcc versions 2.5 and later. - The attribute __pure__ was added in gcc 2.96. */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) -# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) -#else -# define _GL_ATTRIBUTE_PURE /* empty */ -#endif - -/* NetBSD 5.0 declares strsignal in , not in . */ -/* But in any case avoid namespace pollution on glibc systems. */ -#if (0 || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ - && ! defined __GLIBC__ -#endif - -/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ -/* C++ compatible function declaration macros. - Copyright (C) 2010-2020 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 . */ - -#ifndef _GL_CXXDEFS_H -#define _GL_CXXDEFS_H - -/* Begin/end the GNULIB_NAMESPACE namespace. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { -# define _GL_END_NAMESPACE } -#else -# define _GL_BEGIN_NAMESPACE -# define _GL_END_NAMESPACE -#endif - -/* The three most frequent use cases of these macros are: - - * For providing a substitute for a function that is missing on some - platforms, but is declared and works fine on the platforms on which - it exists: - - #if @GNULIB_FOO@ - # if !@HAVE_FOO@ - _GL_FUNCDECL_SYS (foo, ...); - # endif - _GL_CXXALIAS_SYS (foo, ...); - _GL_CXXALIASWARN (foo); - #elif defined GNULIB_POSIXCHECK - ... - #endif - - * For providing a replacement for a function that exists on all platforms, - but is broken/insufficient and needs to be replaced on some platforms: - - #if @GNULIB_FOO@ - # if @REPLACE_FOO@ - # if !(defined __cplusplus && defined GNULIB_NAMESPACE) - # undef foo - # define foo rpl_foo - # endif - _GL_FUNCDECL_RPL (foo, ...); - _GL_CXXALIAS_RPL (foo, ...); - # else - _GL_CXXALIAS_SYS (foo, ...); - # endif - _GL_CXXALIASWARN (foo); - #elif defined GNULIB_POSIXCHECK - ... - #endif - - * For providing a replacement for a function that exists on some platforms - but is broken/insufficient and needs to be replaced on some of them and - is additionally either missing or undeclared on some other platforms: - - #if @GNULIB_FOO@ - # if @REPLACE_FOO@ - # if !(defined __cplusplus && defined GNULIB_NAMESPACE) - # undef foo - # define foo rpl_foo - # endif - _GL_FUNCDECL_RPL (foo, ...); - _GL_CXXALIAS_RPL (foo, ...); - # else - # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ - _GL_FUNCDECL_SYS (foo, ...); - # endif - _GL_CXXALIAS_SYS (foo, ...); - # endif - _GL_CXXALIASWARN (foo); - #elif defined GNULIB_POSIXCHECK - ... - #endif -*/ - -/* _GL_EXTERN_C declaration; - performs the declaration with C linkage. */ -#if defined __cplusplus -# define _GL_EXTERN_C extern "C" -#else -# define _GL_EXTERN_C extern -#endif - -/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); - declares a replacement function, named rpl_func, with the given prototype, - consisting of return type, parameters, and attributes. - Example: - _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) - _GL_ARG_NONNULL ((1))); - */ -#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ - _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) -#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ - _GL_EXTERN_C rettype rpl_func parameters_and_attributes - -/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); - declares the system function, named func, with the given prototype, - consisting of return type, parameters, and attributes. - Example: - _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) - _GL_ARG_NONNULL ((1))); - */ -#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ - _GL_EXTERN_C rettype func parameters_and_attributes - -/* _GL_CXXALIAS_RPL (func, rettype, parameters); - declares a C++ alias called GNULIB_NAMESPACE::func - that redirects to rpl_func, if GNULIB_NAMESPACE is defined. - Example: - _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); - - Wrapping rpl_func in an object with an inline conversion operator - avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is - actually used in the program. */ -#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ - _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - static const struct _gl_ ## func ## _wrapper \ - { \ - typedef rettype (*type) parameters; \ - \ - inline operator type () const \ - { \ - return ::rpl_func; \ - } \ - } func = {}; \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); - is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); - except that the C function rpl_func may have a slightly different - declaration. A cast is used to silence the "invalid conversion" error - that would otherwise occur. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - static const struct _gl_ ## func ## _wrapper \ - { \ - typedef rettype (*type) parameters; \ - \ - inline operator type () const \ - { \ - return reinterpret_cast(::rpl_func); \ - } \ - } func = {}; \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_SYS (func, rettype, parameters); - declares a C++ alias called GNULIB_NAMESPACE::func - that redirects to the system provided function func, if GNULIB_NAMESPACE - is defined. - Example: - _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); - - Wrapping func in an object with an inline conversion operator - avoids a reference to func unless GNULIB_NAMESPACE::func is - actually used in the program. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - static const struct _gl_ ## func ## _wrapper \ - { \ - typedef rettype (*type) parameters; \ - \ - inline operator type () const \ - { \ - return ::func; \ - } \ - } func = {}; \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); - is like _GL_CXXALIAS_SYS (func, rettype, parameters); - except that the C function func may have a slightly different declaration. - A cast is used to silence the "invalid conversion" error that would - otherwise occur. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ - namespace GNULIB_NAMESPACE \ - { \ - static const struct _gl_ ## func ## _wrapper \ - { \ - typedef rettype (*type) parameters; \ - \ - inline operator type () const \ - { \ - return reinterpret_cast(::func); \ - } \ - } func = {}; \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); - is like _GL_CXXALIAS_SYS (func, rettype, parameters); - except that the C function is picked among a set of overloaded functions, - namely the one with rettype2 and parameters2. Two consecutive casts - are used to silence the "cannot find a match" and "invalid conversion" - errors that would otherwise occur. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE - /* The outer cast must be a reinterpret_cast. - The inner cast: When the function is defined as a set of overloaded - functions, it works as a static_cast<>, choosing the designated variant. - When the function is defined as a single variant, it works as a - reinterpret_cast<>. The parenthesized cast syntax works both ways. */ -# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ - namespace GNULIB_NAMESPACE \ - { \ - static const struct _gl_ ## func ## _wrapper \ - { \ - typedef rettype (*type) parameters; \ - \ - inline operator type () const \ - { \ - return reinterpret_cast((rettype2 (*) parameters2)(::func)); \ - } \ - } func = {}; \ - } \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#else -# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIASWARN (func); - causes a warning to be emitted when ::func is used but not when - GNULIB_NAMESPACE::func is used. func must be defined without overloaded - variants. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIASWARN(func) \ - _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) -# define _GL_CXXALIASWARN_1(func,namespace) \ - _GL_CXXALIASWARN_2 (func, namespace) -/* To work around GCC bug , - we enable the warning only when not optimizing. */ -# if !__OPTIMIZE__ -# define _GL_CXXALIASWARN_2(func,namespace) \ - _GL_WARN_ON_USE (func, \ - "The symbol ::" #func " refers to the system function. " \ - "Use " #namespace "::" #func " instead.") -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -# define _GL_CXXALIASWARN_2(func,namespace) \ - extern __typeof__ (func) func -# else -# define _GL_CXXALIASWARN_2(func,namespace) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -# endif -#else -# define _GL_CXXALIASWARN(func) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); - causes a warning to be emitted when the given overloaded variant of ::func - is used but not when GNULIB_NAMESPACE::func is used. */ -#if defined __cplusplus && defined GNULIB_NAMESPACE -# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ - _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ - GNULIB_NAMESPACE) -# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ - _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) -/* To work around GCC bug , - we enable the warning only when not optimizing. */ -# if !__OPTIMIZE__ -# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ - _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ - "The symbol ::" #func " refers to the system function. " \ - "Use " #namespace "::" #func " instead.") -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ - extern __typeof__ (func) func -# else -# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -# endif -#else -# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ - _GL_EXTERN_C int _gl_cxxalias_dummy -#endif - -#endif /* _GL_CXXDEFS_H */ - -/* The definition of _GL_ARG_NONNULL is copied here. */ -/* A C macro for declaring that specific arguments must not be NULL. - Copyright (C) 2009-2020 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 . */ - -/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools - that the values passed as arguments n, ..., m must be non-NULL pointers. - n = 1 stands for the first argument, n = 2 for the second argument etc. */ -#ifndef _GL_ARG_NONNULL -# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 -# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) -# else -# define _GL_ARG_NONNULL(params) -# endif -#endif - -/* The definition of _GL_WARN_ON_USE is copied here. */ -/* A C macro for emitting warnings if a function is used. - Copyright (C) 2010-2020 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 . */ - -/* _GL_WARN_ON_USE (function, "literal string") issues a declaration - for FUNCTION which will then trigger a compiler warning containing - the text of "literal string" anywhere that function is called, if - supported by the compiler. If the compiler does not support this - feature, the macro expands to an unused extern declaration. - - _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the - attribute used in _GL_WARN_ON_USE. If the compiler does not support - this feature, it expands to empty. - - These macros are useful for marking a function as a potential - portability trap, with the intent that "literal string" include - instructions on the replacement function that should be used - instead. - _GL_WARN_ON_USE is for functions with 'extern' linkage. - _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' - linkage. - - However, one of the reasons that a function is a portability trap is - if it has the wrong signature. Declaring FUNCTION with a different - signature in C is a compilation error, so this macro must use the - same type as any existing declaration so that programs that avoid - the problematic FUNCTION do not fail to compile merely because they - included a header that poisoned the function. But this implies that - _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already - have a declaration. Use of this macro implies that there must not - be any other macro hiding the declaration of FUNCTION; but - undefining FUNCTION first is part of the poisoning process anyway - (although for symbols that are provided only via a macro, the result - is a compilation error rather than a warning containing - "literal string"). Also note that in C++, it is only safe to use if - FUNCTION has no overloads. - - For an example, it is possible to poison 'getline' by: - [getline]) in configure.ac, which potentially defines - HAVE_RAW_DECL_GETLINE - - adding this code to a header that wraps the system : - #undef getline - #if HAVE_RAW_DECL_GETLINE - _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" - "not universally present; use the gnulib module getline"); - #endif - - It is not possible to directly poison global variables. But it is - possible to write a wrapper accessor function, and poison that - (less common usage, like &environ, will cause a compilation error - rather than issue the nice warning, but the end result of informing - the developer about their portability problem is still achieved): - #if HAVE_RAW_DECL_ENVIRON - static char *** - rpl_environ (void) { return &environ; } - _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); - # undef environ - # define environ (*rpl_environ ()) - #endif - or better (avoiding contradictory use of 'static' and 'extern'): - #if HAVE_RAW_DECL_ENVIRON - static char *** - _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") - rpl_environ (void) { return &environ; } - # undef environ - # define environ (*rpl_environ ()) - #endif - */ -#ifndef _GL_WARN_ON_USE - -# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) -/* A compiler attribute is available in gcc versions 4.3.0 and later. */ -# define _GL_WARN_ON_USE(function, message) \ -extern __typeof__ (function) function __attribute__ ((__warning__ (message))) -# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ - __attribute__ ((__warning__ (message))) -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -/* Verify the existence of the function. */ -# define _GL_WARN_ON_USE(function, message) \ -extern __typeof__ (function) function -# define _GL_WARN_ON_USE_ATTRIBUTE(message) -# else /* Unsupported. */ -# define _GL_WARN_ON_USE(function, message) \ -_GL_WARN_EXTERN_C int _gl_warn_on_use -# define _GL_WARN_ON_USE_ATTRIBUTE(message) -# endif -#endif - -/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") - is like _GL_WARN_ON_USE (function, "string"), except that the function is - declared with the given prototype, consisting of return type, parameters, - and attributes. - This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does - not work in this case. */ -#ifndef _GL_WARN_ON_USE_CXX -# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) -# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -extern rettype function parameters_and_attributes \ - __attribute__ ((__warning__ (msg))) -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -/* Verify the existence of the function. */ -# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -extern rettype function parameters_and_attributes -# else /* Unsupported. */ -# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -_GL_WARN_EXTERN_C int _gl_warn_on_use -# endif -#endif - -/* _GL_WARN_EXTERN_C declaration; - performs the declaration with C linkage. */ -#ifndef _GL_WARN_EXTERN_C -# if defined __cplusplus -# define _GL_WARN_EXTERN_C extern "C" -# else -# define _GL_WARN_EXTERN_C extern -# endif -#endif - - -/* Clear a block of memory. The compiler will not delete a call to - this function, even if the block is dead after the call. */ -#if 0 -# if ! 1 -_GL_FUNCDECL_SYS (explicit_bzero, void, - (void *__dest, size_t __n) _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n)); -_GL_CXXALIASWARN (explicit_bzero); -#elif defined GNULIB_POSIXCHECK -# undef explicit_bzero -# if HAVE_RAW_DECL_EXPLICIT_BZERO -_GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - " - "use gnulib module explicit_bzero for portability"); -# endif -#endif - -/* Find the index of the least-significant set bit. */ -#if 0 -# if !1 -_GL_FUNCDECL_SYS (ffsl, int, (long int i)); -# endif -_GL_CXXALIAS_SYS (ffsl, int, (long int i)); -_GL_CXXALIASWARN (ffsl); -#elif defined GNULIB_POSIXCHECK -# undef ffsl -# if HAVE_RAW_DECL_FFSL -_GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module"); -# endif -#endif - - -/* Find the index of the least-significant set bit. */ -#if 0 -# if !1 -_GL_FUNCDECL_SYS (ffsll, int, (long long int i)); -# endif -_GL_CXXALIAS_SYS (ffsll, int, (long long int i)); -_GL_CXXALIASWARN (ffsll); -#elif defined GNULIB_POSIXCHECK -# undef ffsll -# if HAVE_RAW_DECL_FFSLL -_GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module"); -# endif -#endif - - -/* Return the first instance of C within N bytes of S, or NULL. */ -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define memchr rpl_memchr -# endif -_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); -# else -# if ! 1 -_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C" { const void * std::memchr (const void *, int, size_t); } - extern "C++" { void * std::memchr (void *, int, size_t); } */ -_GL_CXXALIAS_SYS_CAST2 (memchr, - void *, (void const *__s, int __c, size_t __n), - void const *, (void const *__s, int __c, size_t __n)); -# endif -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); -_GL_CXXALIASWARN1 (memchr, void const *, - (void const *__s, int __c, size_t __n)); -# elif __GLIBC__ >= 2 -_GL_CXXALIASWARN (memchr); -# endif -#elif defined GNULIB_POSIXCHECK -# undef memchr -/* Assume memchr is always declared. */ -_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " - "use gnulib module memchr for portability" ); -#endif - -/* Return the first occurrence of NEEDLE in HAYSTACK. */ -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define memmem rpl_memmem -# endif -_GL_FUNCDECL_RPL (memmem, void *, - (void const *__haystack, size_t __haystack_len, - void const *__needle, size_t __needle_len) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 3))); -_GL_CXXALIAS_RPL (memmem, void *, - (void const *__haystack, size_t __haystack_len, - void const *__needle, size_t __needle_len)); -# else -# if ! 1 -_GL_FUNCDECL_SYS (memmem, void *, - (void const *__haystack, size_t __haystack_len, - void const *__needle, size_t __needle_len) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 3))); -# endif -_GL_CXXALIAS_SYS (memmem, void *, - (void const *__haystack, size_t __haystack_len, - void const *__needle, size_t __needle_len)); -# endif -_GL_CXXALIASWARN (memmem); -#elif defined GNULIB_POSIXCHECK -# undef memmem -# if HAVE_RAW_DECL_MEMMEM -_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - " - "use gnulib module memmem-simple for portability, " - "and module memmem for speed" ); -# endif -#endif - -/* Copy N bytes of SRC to DEST, return pointer to bytes after the - last written byte. */ -#if 0 -# if ! 1 -_GL_FUNCDECL_SYS (mempcpy, void *, - (void *restrict __dest, void const *restrict __src, - size_t __n) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (mempcpy, void *, - (void *restrict __dest, void const *restrict __src, - size_t __n)); -_GL_CXXALIASWARN (mempcpy); -#elif defined GNULIB_POSIXCHECK -# undef mempcpy -# if HAVE_RAW_DECL_MEMPCPY -_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " - "use gnulib module mempcpy for portability"); -# endif -#endif - -/* Search backwards through a block for a byte (specified as an int). */ -#if 0 -# if ! 1 -_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C++" { const void * std::memrchr (const void *, int, size_t); } - extern "C++" { void * std::memrchr (void *, int, size_t); } */ -_GL_CXXALIAS_SYS_CAST2 (memrchr, - void *, (void const *, int, size_t), - void const *, (void const *, int, size_t)); -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); -_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); -# else -_GL_CXXALIASWARN (memrchr); -# endif -#elif defined GNULIB_POSIXCHECK -# undef memrchr -# if HAVE_RAW_DECL_MEMRCHR -_GL_WARN_ON_USE (memrchr, "memrchr is unportable - " - "use gnulib module memrchr for portability"); -# endif -#endif - -/* Find the first occurrence of C in S. More efficient than - memchr(S,C,N), at the expense of undefined behavior if C does not - occur within N bytes. */ -#if 0 -# if ! 1 -_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C++" { const void * std::rawmemchr (const void *, int); } - extern "C++" { void * std::rawmemchr (void *, int); } */ -_GL_CXXALIAS_SYS_CAST2 (rawmemchr, - void *, (void const *__s, int __c_in), - void const *, (void const *__s, int __c_in)); -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); -_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); -# else -_GL_CXXALIASWARN (rawmemchr); -# endif -#elif defined GNULIB_POSIXCHECK -# undef rawmemchr -# if HAVE_RAW_DECL_RAWMEMCHR -_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " - "use gnulib module rawmemchr for portability"); -# endif -#endif - -/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ -#if 1 -# if ! 1 -_GL_FUNCDECL_SYS (stpcpy, char *, - (char *restrict __dst, char const *restrict __src) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (stpcpy, char *, - (char *restrict __dst, char const *restrict __src)); -_GL_CXXALIASWARN (stpcpy); -#elif defined GNULIB_POSIXCHECK -# undef stpcpy -# if HAVE_RAW_DECL_STPCPY -_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " - "use gnulib module stpcpy for portability"); -# endif -#endif - -/* Copy no more than N bytes of SRC to DST, returning a pointer past the - last non-NUL byte written into DST. */ -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef stpncpy -# define stpncpy rpl_stpncpy -# endif -_GL_FUNCDECL_RPL (stpncpy, char *, - (char *restrict __dst, char const *restrict __src, - size_t __n) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (stpncpy, char *, - (char *restrict __dst, char const *restrict __src, - size_t __n)); -# else -# if ! 1 -_GL_FUNCDECL_SYS (stpncpy, char *, - (char *restrict __dst, char const *restrict __src, - size_t __n) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (stpncpy, char *, - (char *restrict __dst, char const *restrict __src, - size_t __n)); -# endif -_GL_CXXALIASWARN (stpncpy); -#elif defined GNULIB_POSIXCHECK -# undef stpncpy -# if HAVE_RAW_DECL_STPNCPY -_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - " - "use gnulib module stpncpy for portability"); -# endif -#endif - -#if defined GNULIB_POSIXCHECK -/* strchr() does not work with multibyte strings if the locale encoding is - GB18030 and the character to be searched is a digit. */ -# undef strchr -/* Assume strchr is always declared. */ -_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " - "in some multibyte locales - " - "use mbschr if you care about internationalization"); -#endif - -/* Find the first occurrence of C in S or the final NUL byte. */ -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define strchrnul rpl_strchrnul -# endif -_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (strchrnul, char *, - (const char *str, int ch)); -# else -# if ! 1 -_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C++" { const char * std::strchrnul (const char *, int); } - extern "C++" { char * std::strchrnul (char *, int); } */ -_GL_CXXALIAS_SYS_CAST2 (strchrnul, - char *, (char const *__s, int __c_in), - char const *, (char const *__s, int __c_in)); -# endif -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); -_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); -# else -_GL_CXXALIASWARN (strchrnul); -# endif -#elif defined GNULIB_POSIXCHECK -# undef strchrnul -# if HAVE_RAW_DECL_STRCHRNUL -_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " - "use gnulib module strchrnul for portability"); -# endif -#endif - -/* Duplicate S, returning an identical malloc'd string. */ -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef strdup -# define strdup rpl_strdup -# endif -_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); -# else -# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup - /* strdup exists as a function and as a macro. Get rid of the macro. */ -# undef strdup -# endif -# if !(1 || defined strdup) -_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); -# endif -_GL_CXXALIASWARN (strdup); -#elif defined GNULIB_POSIXCHECK -# undef strdup -# if HAVE_RAW_DECL_STRDUP -_GL_WARN_ON_USE (strdup, "strdup is unportable - " - "use gnulib module strdup for portability"); -# endif -#endif - -/* Append no more than N characters from SRC onto DEST. */ -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef strncat -# define strncat rpl_strncat -# endif -_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n) - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n)); -# else -_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n)); -# endif -# if __GLIBC__ >= 2 -_GL_CXXALIASWARN (strncat); -# endif -#elif defined GNULIB_POSIXCHECK -# undef strncat -# if HAVE_RAW_DECL_STRNCAT -_GL_WARN_ON_USE (strncat, "strncat is unportable - " - "use gnulib module strncat for portability"); -# endif -#endif - -/* Return a newly allocated copy of at most N bytes of STRING. */ -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef strndup -# define strndup rpl_strndup -# endif -_GL_FUNCDECL_RPL (strndup, char *, (char const *__s, size_t __n) - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n)); -# else -# if ! 1 -_GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n) - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n)); -# endif -_GL_CXXALIASWARN (strndup); -#elif defined GNULIB_POSIXCHECK -# undef strndup -# if HAVE_RAW_DECL_STRNDUP -_GL_WARN_ON_USE (strndup, "strndup is unportable - " - "use gnulib module strndup for portability"); -# endif -#endif - -/* Find the length (number of bytes) of STRING, but scan at most - MAXLEN bytes. If no '\0' terminator is found in that many bytes, - return MAXLEN. */ -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef strnlen -# define strnlen rpl_strnlen -# endif -_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)); -# else -# if ! 1 -_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -# endif -_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)); -# endif -_GL_CXXALIASWARN (strnlen); -#elif defined GNULIB_POSIXCHECK -# undef strnlen -# if HAVE_RAW_DECL_STRNLEN -_GL_WARN_ON_USE (strnlen, "strnlen is unportable - " - "use gnulib module strnlen for portability"); -# endif -#endif - -#if defined GNULIB_POSIXCHECK -/* strcspn() assumes the second argument is a list of single-byte characters. - Even in this simple case, it does not work with multibyte strings if the - locale encoding is GB18030 and one of the characters to be searched is a - digit. */ -# undef strcspn -/* Assume strcspn is always declared. */ -_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " - "in multibyte locales - " - "use mbscspn if you care about internationalization"); -#endif - -/* Find the first occurrence in S of any character in ACCEPT. */ -#if 0 -# if ! 1 -_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2))); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C" { const char * strpbrk (const char *, const char *); } - extern "C++" { char * strpbrk (char *, const char *); } */ -_GL_CXXALIAS_SYS_CAST2 (strpbrk, - char *, (char const *__s, char const *__accept), - const char *, (char const *__s, char const *__accept)); -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); -_GL_CXXALIASWARN1 (strpbrk, char const *, - (char const *__s, char const *__accept)); -# elif __GLIBC__ >= 2 -_GL_CXXALIASWARN (strpbrk); -# endif -# if defined GNULIB_POSIXCHECK -/* strpbrk() assumes the second argument is a list of single-byte characters. - Even in this simple case, it does not work with multibyte strings if the - locale encoding is GB18030 and one of the characters to be searched is a - digit. */ -# undef strpbrk -_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings " - "in multibyte locales - " - "use mbspbrk if you care about internationalization"); -# endif -#elif defined GNULIB_POSIXCHECK -# undef strpbrk -# if HAVE_RAW_DECL_STRPBRK -_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - " - "use gnulib module strpbrk for portability"); -# endif -#endif - -#if defined GNULIB_POSIXCHECK -/* strspn() assumes the second argument is a list of single-byte characters. - Even in this simple case, it cannot work with multibyte strings. */ -# undef strspn -/* Assume strspn is always declared. */ -_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings " - "in multibyte locales - " - "use mbsspn if you care about internationalization"); -#endif - -#if defined GNULIB_POSIXCHECK -/* strrchr() does not work with multibyte strings if the locale encoding is - GB18030 and the character to be searched is a digit. */ -# undef strrchr -/* Assume strrchr is always declared. */ -_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings " - "in some multibyte locales - " - "use mbsrchr if you care about internationalization"); -#endif - -/* Search the next delimiter (char listed in DELIM) starting at *STRINGP. - If one is found, overwrite it with a NUL, and advance *STRINGP - to point to the next char after it. Otherwise, set *STRINGP to NULL. - If *STRINGP was already NULL, nothing happens. - Return the old value of *STRINGP. - - This is a variant of strtok() that is multithread-safe and supports - empty fields. - - Caveat: It modifies the original string. - Caveat: These functions cannot be used on constant strings. - Caveat: The identity of the delimiting character is lost. - Caveat: It doesn't work with multibyte strings unless all of the delimiter - characters are ASCII characters < 0x30. - - See also strtok_r(). */ -#if 0 -# if ! 1 -_GL_FUNCDECL_SYS (strsep, char *, - (char **restrict __stringp, char const *restrict __delim) - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (strsep, char *, - (char **restrict __stringp, char const *restrict __delim)); -_GL_CXXALIASWARN (strsep); -# if defined GNULIB_POSIXCHECK -# undef strsep -_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings " - "in multibyte locales - " - "use mbssep if you care about internationalization"); -# endif -#elif defined GNULIB_POSIXCHECK -# undef strsep -# if HAVE_RAW_DECL_STRSEP -_GL_WARN_ON_USE (strsep, "strsep is unportable - " - "use gnulib module strsep for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define strstr rpl_strstr -# endif -_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); -# else - /* On some systems, this function is defined as an overloaded function: - extern "C++" { const char * strstr (const char *, const char *); } - extern "C++" { char * strstr (char *, const char *); } */ -_GL_CXXALIAS_SYS_CAST2 (strstr, - char *, (const char *haystack, const char *needle), - const char *, (const char *haystack, const char *needle)); -# endif -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); -_GL_CXXALIASWARN1 (strstr, const char *, - (const char *haystack, const char *needle)); -# elif __GLIBC__ >= 2 -_GL_CXXALIASWARN (strstr); -# endif -#elif defined GNULIB_POSIXCHECK -/* strstr() does not work with multibyte strings if the locale encoding is - different from UTF-8: - POSIX says that it operates on "strings", and "string" in POSIX is defined - as a sequence of bytes, not of characters. */ -# undef strstr -/* Assume strstr is always declared. */ -_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " - "work correctly on character strings in most " - "multibyte locales - " - "use mbsstr if you care about internationalization, " - "or use strstr if you care about speed"); -#endif - -/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive - comparison. */ -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define strcasestr rpl_strcasestr -# endif -_GL_FUNCDECL_RPL (strcasestr, char *, - (const char *haystack, const char *needle) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (strcasestr, char *, - (const char *haystack, const char *needle)); -# else -# if ! 1 -_GL_FUNCDECL_SYS (strcasestr, char *, - (const char *haystack, const char *needle) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2))); -# endif - /* On some systems, this function is defined as an overloaded function: - extern "C++" { const char * strcasestr (const char *, const char *); } - extern "C++" { char * strcasestr (char *, const char *); } */ -_GL_CXXALIAS_SYS_CAST2 (strcasestr, - char *, (const char *haystack, const char *needle), - const char *, (const char *haystack, const char *needle)); -# endif -# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); -_GL_CXXALIASWARN1 (strcasestr, const char *, - (const char *haystack, const char *needle)); -# else -_GL_CXXALIASWARN (strcasestr); -# endif -#elif defined GNULIB_POSIXCHECK -/* strcasestr() does not work with multibyte strings: - It is a glibc extension, and glibc implements it only for unibyte - locales. */ -# undef strcasestr -# if HAVE_RAW_DECL_STRCASESTR -_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character " - "strings in multibyte locales - " - "use mbscasestr if you care about " - "internationalization, or use c-strcasestr if you want " - "a locale independent function"); -# endif -#endif - -/* Parse S into tokens separated by characters in DELIM. - If S is NULL, the saved pointer in SAVE_PTR is used as - the next starting point. For example: - char s[] = "-abc-=-def"; - char *sp; - x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" - x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL - x = strtok_r(NULL, "=", &sp); // x = NULL - // s = "abc\0-def\0" - - This is a variant of strtok() that is multithread-safe. - - For the POSIX documentation for this function, see: - https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html - - Caveat: It modifies the original string. - Caveat: These functions cannot be used on constant strings. - Caveat: The identity of the delimiting character is lost. - Caveat: It doesn't work with multibyte strings unless all of the delimiter - characters are ASCII characters < 0x30. - - See also strsep(). */ -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef strtok_r -# define strtok_r rpl_strtok_r -# endif -_GL_FUNCDECL_RPL (strtok_r, char *, - (char *restrict s, char const *restrict delim, - char **restrict save_ptr) - _GL_ARG_NONNULL ((2, 3))); -_GL_CXXALIAS_RPL (strtok_r, char *, - (char *restrict s, char const *restrict delim, - char **restrict save_ptr)); -# else -# if 0 || defined GNULIB_POSIXCHECK -# undef strtok_r -# endif -# if ! 1 -_GL_FUNCDECL_SYS (strtok_r, char *, - (char *restrict s, char const *restrict delim, - char **restrict save_ptr) - _GL_ARG_NONNULL ((2, 3))); -# endif -_GL_CXXALIAS_SYS (strtok_r, char *, - (char *restrict s, char const *restrict delim, - char **restrict save_ptr)); -# endif -_GL_CXXALIASWARN (strtok_r); -# if defined GNULIB_POSIXCHECK -_GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character " - "strings in multibyte locales - " - "use mbstok_r if you care about internationalization"); -# endif -#elif defined GNULIB_POSIXCHECK -# undef strtok_r -# if HAVE_RAW_DECL_STRTOK_R -_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " - "use gnulib module strtok_r for portability"); -# endif -#endif - - -/* The following functions are not specified by POSIX. They are gnulib - extensions. */ - -#if 0 -/* Return the number of multibyte characters in the character string STRING. - This considers multibyte characters, unlike strlen, which counts bytes. */ -# ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */ -# undef mbslen -# endif -# if 0 /* AIX, OSF/1, MirBSD define mbslen already in libc. */ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define mbslen rpl_mbslen -# endif -_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); -# else -_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); -# endif -_GL_CXXALIASWARN (mbslen); -#endif - -#if 0 -/* Return the number of multibyte characters in the character string starting - at STRING and ending at STRING + LEN. */ -_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1)); -#endif - -#if 0 -/* Locate the first single-byte character C in the character string STRING, - and return a pointer to it. Return NULL if C is not found in STRING. - Unlike strchr(), this function works correctly in multibyte locales with - encodings such as GB18030. */ -# if defined __hpux -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define mbschr rpl_mbschr /* avoid collision with HP-UX function */ -# endif -_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); -# else -_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); -# endif -_GL_CXXALIASWARN (mbschr); -#endif - -#if 0 -/* Locate the last single-byte character C in the character string STRING, - and return a pointer to it. Return NULL if C is not found in STRING. - Unlike strrchr(), this function works correctly in multibyte locales with - encodings such as GB18030. */ -# if defined __hpux || defined __INTERIX -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define mbsrchr rpl_mbsrchr /* avoid collision with system function */ -# endif -_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); -# else -_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); -# endif -_GL_CXXALIASWARN (mbsrchr); -#endif - -#if 0 -/* Find the first occurrence of the character string NEEDLE in the character - string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. - Unlike strstr(), this function works correctly in multibyte locales with - encodings different from UTF-8. */ -_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if 0 -/* Compare the character strings S1 and S2, ignoring case, returning less than, - equal to or greater than zero if S1 is lexicographically less than, equal to - or greater than S2. - Note: This function may, in multibyte locales, return 0 for strings of - different lengths! - Unlike strcasecmp(), this function works correctly in multibyte locales. */ -_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if 0 -/* Compare the initial segment of the character string S1 consisting of at most - N characters with the initial segment of the character string S2 consisting - of at most N characters, ignoring case, returning less than, equal to or - greater than zero if the initial segment of S1 is lexicographically less - than, equal to or greater than the initial segment of S2. - Note: This function may, in multibyte locales, return 0 for initial segments - of different lengths! - Unlike strncasecmp(), this function works correctly in multibyte locales. - But beware that N is not a byte count but a character count! */ -_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if 0 -/* Compare the initial segment of the character string STRING consisting of - at most mbslen (PREFIX) characters with the character string PREFIX, - ignoring case. If the two match, return a pointer to the first byte - after this prefix in STRING. Otherwise, return NULL. - Note: This function may, in multibyte locales, return non-NULL if STRING - is of smaller length than PREFIX! - Unlike strncasecmp(), this function works correctly in multibyte - locales. */ -_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if 0 -/* Find the first occurrence of the character string NEEDLE in the character - string HAYSTACK, using case-insensitive comparison. - Note: This function may, in multibyte locales, return success even if - strlen (haystack) < strlen (needle) ! - Unlike strcasestr(), this function works correctly in multibyte locales. */ -_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if 0 -/* Find the first occurrence in the character string STRING of any character - in the character string ACCEPT. Return the number of bytes from the - beginning of the string to this occurrence, or to the end of the string - if none exists. - Unlike strcspn(), this function works correctly in multibyte locales. */ -_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if 0 -/* Find the first occurrence in the character string STRING of any character - in the character string ACCEPT. Return the pointer to it, or NULL if none - exists. - Unlike strpbrk(), this function works correctly in multibyte locales. */ -# if defined __hpux -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ -# endif -_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); -# else -_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2))); -_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); -# endif -_GL_CXXALIASWARN (mbspbrk); -#endif - -#if 0 -/* Find the first occurrence in the character string STRING of any character - not in the character string REJECT. Return the number of bytes from the - beginning of the string to this occurrence, or to the end of the string - if none exists. - Unlike strspn(), this function works correctly in multibyte locales. */ -_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if 0 -/* Search the next delimiter (multibyte character listed in the character - string DELIM) starting at the character string *STRINGP. - If one is found, overwrite it with a NUL, and advance *STRINGP to point - to the next multibyte character after it. Otherwise, set *STRINGP to NULL. - If *STRINGP was already NULL, nothing happens. - Return the old value of *STRINGP. - - This is a variant of mbstok_r() that supports empty fields. - - Caveat: It modifies the original string. - Caveat: These functions cannot be used on constant strings. - Caveat: The identity of the delimiting character is lost. - - See also mbstok_r(). */ -_GL_EXTERN_C char * mbssep (char **stringp, const char *delim) - _GL_ARG_NONNULL ((1, 2)); -#endif - -#if 0 -/* Parse the character string STRING into tokens separated by characters in - the character string DELIM. - If STRING is NULL, the saved pointer in SAVE_PTR is used as - the next starting point. For example: - char s[] = "-abc-=-def"; - char *sp; - x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" - x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL - x = mbstok_r(NULL, "=", &sp); // x = NULL - // s = "abc\0-def\0" - - Caveat: It modifies the original string. - Caveat: These functions cannot be used on constant strings. - Caveat: The identity of the delimiting character is lost. - - See also mbssep(). */ -_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr) - _GL_ARG_NONNULL ((2, 3)); -#endif - -/* Map any int, typically from errno, into an error message. */ -#if 1 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef strerror -# define strerror rpl_strerror -# endif -_GL_FUNCDECL_RPL (strerror, char *, (int)); -_GL_CXXALIAS_RPL (strerror, char *, (int)); -# else -_GL_CXXALIAS_SYS (strerror, char *, (int)); -# endif -# if __GLIBC__ >= 2 -_GL_CXXALIASWARN (strerror); -# endif -#elif defined GNULIB_POSIXCHECK -# undef strerror -/* Assume strerror is always declared. */ -_GL_WARN_ON_USE (strerror, "strerror is unportable - " - "use gnulib module strerror to guarantee non-NULL result"); -#endif - -/* Map any int, typically from errno, into an error message. Multithread-safe. - Uses the POSIX declaration, not the glibc declaration. */ -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef strerror_r -# define strerror_r rpl_strerror_r -# endif -_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen) - _GL_ARG_NONNULL ((2))); -_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)); -# else -# if !1 -_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen) - _GL_ARG_NONNULL ((2))); -# endif -_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)); -# endif -# if 1 -_GL_CXXALIASWARN (strerror_r); -# endif -#elif defined GNULIB_POSIXCHECK -# undef strerror_r -# if HAVE_RAW_DECL_STRERROR_R -_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - " - "use gnulib module strerror_r-posix for portability"); -# endif -#endif - -#if 0 -# if 0 -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# define strsignal rpl_strsignal -# endif -_GL_FUNCDECL_RPL (strsignal, char *, (int __sig)); -_GL_CXXALIAS_RPL (strsignal, char *, (int __sig)); -# else -# if ! 1 -_GL_FUNCDECL_SYS (strsignal, char *, (int __sig)); -# endif -/* Need to cast, because on Cygwin 1.5.x systems, the return type is - 'const char *'. */ -_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig)); -# endif -_GL_CXXALIASWARN (strsignal); -#elif defined GNULIB_POSIXCHECK -# undef strsignal -# if HAVE_RAW_DECL_STRSIGNAL -_GL_WARN_ON_USE (strsignal, "strsignal is unportable - " - "use gnulib module strsignal for portability"); -# endif -#endif - -#if 0 -# if !1 -_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) - _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1, 2))); -# endif -_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); -_GL_CXXALIASWARN (strverscmp); -#elif defined GNULIB_POSIXCHECK -# undef strverscmp -# if HAVE_RAW_DECL_STRVERSCMP -_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - " - "use gnulib module strverscmp for portability"); -# endif -#endif - - -#endif /* _GL_STRING_H */ -#endif /* _GL_STRING_H */ -#endif diff --git a/third_party/make/lib/verify.h b/third_party/make/lib/verify.h deleted file mode 100644 index df996c3ce..000000000 --- a/third_party/make/lib/verify.h +++ /dev/null @@ -1,301 +0,0 @@ -/* clang-format off */ -/* Compile-time assert-like macros. - - Copyright (C) 2005-2006, 2009-2020 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 . */ - -/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ - -#ifndef _GL_VERIFY_H -#define _GL_VERIFY_H - - -/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert (R, DIAGNOSTIC) - works as per C11. This is supported by GCC 4.6.0 and later, in C - mode. - - Define _GL_HAVE__STATIC_ASSERT1 to 1 if _Static_assert (R) works as - per C2X, and define _GL_HAVE_STATIC_ASSERT1 if static_assert (R) - works as per C++17. This is supported by GCC 9.1 and later. - - Support compilers claiming conformance to the relevant standard, - and also support GCC when not pedantic. If we were willing to slow - 'configure' down we could also use it with other compilers, but - since this affects only the quality of diagnostics, why bother? */ -#ifndef __cplusplus -# if (201112L <= __STDC_VERSION__ \ - || (!defined __STRICT_ANSI__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__))) -# define _GL_HAVE__STATIC_ASSERT 1 -# endif -# if (202000L <= __STDC_VERSION__ \ - || (!defined __STRICT_ANSI__ && 9 <= __GNUC__)) -# define _GL_HAVE__STATIC_ASSERT1 1 -# endif -#else -# if 201703L <= __cplusplus || 9 <= __GNUC__ -# define _GL_HAVE_STATIC_ASSERT1 1 -# endif -#endif - -/* FreeBSD 9.1 , included by and lots of other - system headers, defines a conflicting _Static_assert that is no - better than ours; override it. */ -#ifndef _GL_HAVE__STATIC_ASSERT -# undef _Static_assert -#endif - -/* Each of these macros verifies that its argument R is nonzero. To - be portable, R should be an integer constant expression. Unlike - assert (R), there is no run-time overhead. - - If _Static_assert works, verify (R) uses it directly. Similarly, - _GL_VERIFY_TRUE works by packaging a _Static_assert inside a struct - that is an operand of sizeof. - - The code below uses several ideas for C++ compilers, and for C - compilers that do not support _Static_assert: - - * The first step is ((R) ? 1 : -1). Given an expression R, of - integral or boolean or floating-point type, this yields an - expression of integral type, whose value is later verified to be - constant and nonnegative. - - * Next this expression W is wrapped in a type - struct _gl_verify_type { - unsigned int _gl_verify_error_if_negative: W; - }. - If W is negative, this yields a compile-time error. No compiler can - deal with a bit-field of negative size. - - One might think that an array size check would have the same - effect, that is, that the type struct { unsigned int dummy[W]; } - would work as well. However, inside a function, some compilers - (such as C++ compilers and GNU C) allow local parameters and - variables inside array size expressions. With these compilers, - an array size check would not properly diagnose this misuse of - the verify macro: - - void function (int n) { verify (n < 0); } - - * For the verify macro, the struct _gl_verify_type will need to - somehow be embedded into a declaration. To be portable, this - declaration must declare an object, a constant, a function, or a - typedef name. If the declared entity uses the type directly, - such as in - - struct dummy {...}; - typedef struct {...} dummy; - extern struct {...} *dummy; - extern void dummy (struct {...} *); - extern struct {...} *dummy (void); - - two uses of the verify macro would yield colliding declarations - if the entity names are not disambiguated. A workaround is to - attach the current line number to the entity name: - - #define _GL_CONCAT0(x, y) x##y - #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) - extern struct {...} * _GL_CONCAT (dummy, __LINE__); - - But this has the problem that two invocations of verify from - within the same macro would collide, since the __LINE__ value - would be the same for both invocations. (The GCC __COUNTER__ - macro solves this problem, but is not portable.) - - A solution is to use the sizeof operator. It yields a number, - getting rid of the identity of the type. Declarations like - - extern int dummy [sizeof (struct {...})]; - extern void dummy (int [sizeof (struct {...})]); - extern int (*dummy (void)) [sizeof (struct {...})]; - - can be repeated. - - * Should the implementation use a named struct or an unnamed struct? - Which of the following alternatives can be used? - - extern int dummy [sizeof (struct {...})]; - extern int dummy [sizeof (struct _gl_verify_type {...})]; - extern void dummy (int [sizeof (struct {...})]); - extern void dummy (int [sizeof (struct _gl_verify_type {...})]); - extern int (*dummy (void)) [sizeof (struct {...})]; - extern int (*dummy (void)) [sizeof (struct _gl_verify_type {...})]; - - In the second and sixth case, the struct type is exported to the - outer scope; two such declarations therefore collide. GCC warns - about the first, third, and fourth cases. So the only remaining - possibility is the fifth case: - - extern int (*dummy (void)) [sizeof (struct {...})]; - - * GCC warns about duplicate declarations of the dummy function if - -Wredundant-decls is used. GCC 4.3 and later have a builtin - __COUNTER__ macro that can let us generate unique identifiers for - each dummy function, to suppress this warning. - - * This implementation exploits the fact that older versions of GCC, - which do not support _Static_assert, also do not warn about the - last declaration mentioned above. - - * GCC warns if -Wnested-externs is enabled and 'verify' is used - within a function body; but inside a function, you can always - arrange to use verify_expr instead. - - * In C++, any struct definition inside sizeof is invalid. - Use a template type to work around the problem. */ - -/* Concatenate two preprocessor tokens. */ -#define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) -#define _GL_CONCAT0(x, y) x##y - -/* _GL_COUNTER is an integer, preferably one that changes each time we - use it. Use __COUNTER__ if it works, falling back on __LINE__ - otherwise. __LINE__ isn't perfect, but it's better than a - constant. */ -#if defined __COUNTER__ && __COUNTER__ != __COUNTER__ -# define _GL_COUNTER __COUNTER__ -#else -# define _GL_COUNTER __LINE__ -#endif - -/* Generate a symbol with the given prefix, making it unique if - possible. */ -#define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER) - -/* Verify requirement R at compile-time, as an integer constant expression - that returns 1. If R is false, fail at compile-time, preferably - with a diagnostic that includes the string-literal DIAGNOSTIC. */ - -#define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \ - (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC))) - -#ifdef __cplusplus -# if !GNULIB_defined_struct__gl_verify_type -template - struct _gl_verify_type { - unsigned int _gl_verify_error_if_negative: w; - }; -# define GNULIB_defined_struct__gl_verify_type 1 -# endif -# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ - _gl_verify_type<(R) ? 1 : -1> -#elif defined _GL_HAVE__STATIC_ASSERT -# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ - struct { \ - _Static_assert (R, DIAGNOSTIC); \ - int _gl_dummy; \ - } -#else -# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ - struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; } -#endif - -/* Verify requirement R at compile-time, as a declaration without a - trailing ';'. If R is false, fail at compile-time. - - This macro requires three or more arguments but uses at most the first - two, so that the _Static_assert macro optionally defined below supports - both the C11 two-argument syntax and the C2X one-argument syntax. - - Unfortunately, unlike C11, this implementation must appear as an - ordinary declaration, and cannot appear inside struct { ... }. */ - -#if defined _GL_HAVE__STATIC_ASSERT -# define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC) -#else -# define _GL_VERIFY(R, DIAGNOSTIC, ...) \ - extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ - [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] -#endif - -/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ -#ifdef _GL_STATIC_ASSERT_H -# if !defined _GL_HAVE__STATIC_ASSERT1 && !defined _Static_assert -# define _Static_assert(...) \ - _GL_VERIFY (__VA_ARGS__, "static assertion failed", -) -# endif -# if !defined _GL_HAVE_STATIC_ASSERT1 && !defined static_assert -# define static_assert _Static_assert /* C11 requires this #define. */ -# endif -#endif - -/* @assert.h omit start@ */ - -#if 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__)) -# define _GL_HAS_BUILTIN_TRAP 1 -#elif defined __has_builtin -# define _GL_HAS_BUILTIN_TRAP __has_builtin (__builtin_trap) -#else -# define _GL_HAS_BUILTIN_TRAP 0 -#endif - -#if 4 < __GNUC__ + (5 <= __GNUC_MINOR__) -# define _GL_HAS_BUILTIN_UNREACHABLE 1 -#elif defined __has_builtin -# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) -#else -# define _GL_HAS_BUILTIN_UNREACHABLE 0 -#endif - -/* Each of these macros verifies that its argument R is nonzero. To - be portable, R should be an integer constant expression. Unlike - assert (R), there is no run-time overhead. - - There are two macros, since no single macro can be used in all - contexts in C. verify_expr (R, E) is for scalar contexts, including - integer constant expression contexts. verify (R) is for declaration - contexts, e.g., the top level. */ - -/* Verify requirement R at compile-time. Return the value of the - expression E. */ - -#define verify_expr(R, E) \ - (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E)) - -/* Verify requirement R at compile-time, as a declaration without a - trailing ';'. verify (R) acts like static_assert (R) except that - it is portable to C11/C++14 and earlier, it can issue better - diagnostics, and its name is shorter and may be more convenient. */ - -#ifdef __PGI -/* PGI barfs if R is long. */ -# define verify(R) _GL_VERIFY (R, "verify (...)", -) -#else -# define verify(R) _GL_VERIFY (R, "verify (" #R ")", -) -#endif - -/* Assume that R always holds. Behavior is undefined if R is false, - fails to evaluate, or has side effects. Although assuming R can - help a compiler generate better code or diagnostics, performance - can suffer if R uses hard-to-optimize features such as function - calls not inlined by the compiler. */ - -#if _GL_HAS_BUILTIN_UNREACHABLE -# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ()) -#elif 1200 <= _MSC_VER -# define assume(R) __assume (R) -#elif (defined GCC_LINT || defined lint) && _GL_HAS_BUILTIN_TRAP - /* Doing it this way helps various packages when configured with - --enable-gcc-warnings, which compiles with -Dlint. It's nicer - when 'assume' silences warnings even with older GCCs. */ -# define assume(R) ((R) ? (void) 0 : __builtin_trap ()) -#else - /* Some tools grok NOTREACHED, e.g., Oracle Studio 12.6. */ -# define assume(R) ((R) ? (void) 0 : /*NOTREACHED*/ (void) 0) -#endif - -/* @assert.h omit end@ */ - -#endif diff --git a/third_party/make/lib/warn-on-use.h b/third_party/make/lib/warn-on-use.h deleted file mode 100644 index da7273e91..000000000 --- a/third_party/make/lib/warn-on-use.h +++ /dev/null @@ -1,131 +0,0 @@ -/* clang-format off */ -/* A C macro for emitting warnings if a function is used. - Copyright (C) 2010-2020 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 . */ - -/* _GL_WARN_ON_USE (function, "literal string") issues a declaration - for FUNCTION which will then trigger a compiler warning containing - the text of "literal string" anywhere that function is called, if - supported by the compiler. If the compiler does not support this - feature, the macro expands to an unused extern declaration. - - _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the - attribute used in _GL_WARN_ON_USE. If the compiler does not support - this feature, it expands to empty. - - These macros are useful for marking a function as a potential - portability trap, with the intent that "literal string" include - instructions on the replacement function that should be used - instead. - _GL_WARN_ON_USE is for functions with 'extern' linkage. - _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' - linkage. - - However, one of the reasons that a function is a portability trap is - if it has the wrong signature. Declaring FUNCTION with a different - signature in C is a compilation error, so this macro must use the - same type as any existing declaration so that programs that avoid - the problematic FUNCTION do not fail to compile merely because they - included a header that poisoned the function. But this implies that - _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already - have a declaration. Use of this macro implies that there must not - be any other macro hiding the declaration of FUNCTION; but - undefining FUNCTION first is part of the poisoning process anyway - (although for symbols that are provided only via a macro, the result - is a compilation error rather than a warning containing - "literal string"). Also note that in C++, it is only safe to use if - FUNCTION has no overloads. - - For an example, it is possible to poison 'getline' by: - [getline]) in configure.ac, which potentially defines - HAVE_RAW_DECL_GETLINE - - adding this code to a header that wraps the system : - #undef getline - #if HAVE_RAW_DECL_GETLINE - _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" - "not universally present; use the gnulib module getline"); - #endif - - It is not possible to directly poison global variables. But it is - possible to write a wrapper accessor function, and poison that - (less common usage, like &environ, will cause a compilation error - rather than issue the nice warning, but the end result of informing - the developer about their portability problem is still achieved): - #if HAVE_RAW_DECL_ENVIRON - static char *** - rpl_environ (void) { return &environ; } - _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); - # undef environ - # define environ (*rpl_environ ()) - #endif - or better (avoiding contradictory use of 'static' and 'extern'): - #if HAVE_RAW_DECL_ENVIRON - static char *** - _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") - rpl_environ (void) { return &environ; } - # undef environ - # define environ (*rpl_environ ()) - #endif - */ -#ifndef _GL_WARN_ON_USE - -# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) -/* A compiler attribute is available in gcc versions 4.3.0 and later. */ -# define _GL_WARN_ON_USE(function, message) \ -extern __typeof__ (function) function __attribute__ ((__warning__ (message))) -# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ - __attribute__ ((__warning__ (message))) -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -/* Verify the existence of the function. */ -# define _GL_WARN_ON_USE(function, message) \ -extern __typeof__ (function) function -# define _GL_WARN_ON_USE_ATTRIBUTE(message) -# else /* Unsupported. */ -# define _GL_WARN_ON_USE(function, message) \ -_GL_WARN_EXTERN_C int _gl_warn_on_use -# define _GL_WARN_ON_USE_ATTRIBUTE(message) -# endif -#endif - -/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") - is like _GL_WARN_ON_USE (function, "string"), except that the function is - declared with the given prototype, consisting of return type, parameters, - and attributes. - This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does - not work in this case. */ -#ifndef _GL_WARN_ON_USE_CXX -# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) -# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -extern rettype function parameters_and_attributes \ - __attribute__ ((__warning__ (msg))) -# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -/* Verify the existence of the function. */ -# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -extern rettype function parameters_and_attributes -# else /* Unsupported. */ -# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -_GL_WARN_EXTERN_C int _gl_warn_on_use -# endif -#endif - -/* _GL_WARN_EXTERN_C declaration; - performs the declaration with C linkage. */ -#ifndef _GL_WARN_EXTERN_C -# if defined __cplusplus -# define _GL_WARN_EXTERN_C extern "C" -# else -# define _GL_WARN_EXTERN_C extern -# endif -#endif diff --git a/third_party/make/src/load.c b/third_party/make/load.c similarity index 97% rename from third_party/make/src/load.c rename to third_party/make/load.c index e25e1b20a..69ea3b457 100644 --- a/third_party/make/src/load.c +++ b/third_party/make/load.c @@ -15,7 +15,7 @@ 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 . */ -#include "third_party/make/src/makeint.h" +#include "third_party/make/makeint.h" #if MAKE_LOAD @@ -23,9 +23,9 @@ this program. If not, see . */ #define SYMBOL_EXTENSION "_gmk_setup" -#include "third_party/make/src/debug.h" -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/variable.h" +#include "third_party/make/debug.h" +#include "third_party/make/filedef.h" +#include "third_party/make/variable.h" /* Tru64 V4.0 does not have this flag */ #ifndef RTLD_GLOBAL diff --git a/third_party/make/src/loadapi.c b/third_party/make/loadapi.c similarity index 92% rename from third_party/make/src/loadapi.c rename to third_party/make/loadapi.c index 2ca026cf0..035ef3682 100644 --- a/third_party/make/src/loadapi.c +++ b/third_party/make/loadapi.c @@ -15,11 +15,11 @@ 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 . */ -#include "third_party/make/src/makeint.h" +#include "third_party/make/makeint.h" -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/variable.h" -#include "third_party/make/src/dep.h" +#include "third_party/make/filedef.h" +#include "third_party/make/variable.h" +#include "third_party/make/dep.h" /* Allocate a buffer in our context, so we can free it. */ char * diff --git a/third_party/make/src/main.c b/third_party/make/main.c similarity index 99% rename from third_party/make/src/main.c rename to third_party/make/main.c index 727db0dae..917d98be9 100644 --- a/third_party/make/src/main.c +++ b/third_party/make/main.c @@ -15,19 +15,19 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* clang-format off */ -#include "third_party/make/src/makeint.h" -#include "third_party/make/src/os.h" -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/dep.h" -#include "third_party/make/src/variable.h" -#include "third_party/make/src/job.h" -#include "third_party/make/src/commands.h" -#include "third_party/make/src/rule.h" -#include "third_party/make/src/debug.h" +#include "third_party/make/makeint.h" +#include "third_party/make/os.h" +#include "third_party/make/filedef.h" +#include "third_party/make/dep.h" +#include "third_party/make/variable.h" +#include "third_party/make/job.h" +#include "third_party/make/commands.h" +#include "third_party/make/rule.h" +#include "third_party/make/debug.h" #include "libc/runtime/stack.h" #include "libc/limits.h" #include "libc/sysv/consts/sig.h" -#include "third_party/make/src/getopt.h" +#include "third_party/make/getopt.h" STATIC_STACK_SIZE(0x200000); // 2mb stack diff --git a/third_party/make/make.mk b/third_party/make/make.mk index 527b04e55..ec8bdf7ed 100644 --- a/third_party/make/make.mk +++ b/third_party/make/make.mk @@ -18,53 +18,53 @@ THIRD_PARTY_MAKE_CHECKS = \ # libgnu.a recipe THIRD_PARTY_MAKE_SRCS_LIB = \ - third_party/make/lib/basename-lgpl.c \ - third_party/make/lib/concat-filename.c \ - third_party/make/lib/dirname-lgpl.c \ - third_party/make/lib/dup2.c \ - third_party/make/lib/error.c \ - third_party/make/lib/exitfail.c \ - third_party/make/lib/fcntl.c \ - third_party/make/lib/fd-hook.c \ - third_party/make/lib/findprog-in.c \ - third_party/make/lib/getloadavg.c \ - third_party/make/lib/getprogname.c \ - third_party/make/lib/stripslash.c \ - third_party/make/lib/unistd.c \ - third_party/make/lib/xalloc-die.c \ - third_party/make/lib/xconcat-filename.c \ - third_party/make/lib/xmalloc.c + third_party/make/basename-lgpl.c \ + third_party/make/concat-filename.c \ + third_party/make/dirname-lgpl.c \ + third_party/make/dup2.c \ + third_party/make/error.c \ + third_party/make/exitfail.c \ + third_party/make/fcntl.c \ + third_party/make/fd-hook.c \ + third_party/make/findprog-in.c \ + third_party/make/getloadavg.c \ + third_party/make/getprogname.c \ + third_party/make/stripslash.c \ + third_party/make/unistd.c \ + third_party/make/xalloc-die.c \ + third_party/make/xconcat-filename.c \ + third_party/make/xmalloc.c THIRD_PARTY_MAKE_SRCS_BASE = \ - third_party/make/src/ar.c \ - third_party/make/src/arscan.c \ - third_party/make/src/commands.c \ - third_party/make/src/default.c \ - third_party/make/src/dir.c \ - third_party/make/src/expand.c \ - third_party/make/src/file.c \ - third_party/make/src/function.c \ - third_party/make/src/getopt.c \ - third_party/make/src/getopt1.c \ - third_party/make/src/guile.c \ - third_party/make/src/hash.c \ - third_party/make/src/implicit.c \ - third_party/make/src/job.c \ - third_party/make/src/load.c \ - third_party/make/src/loadapi.c \ - third_party/make/src/main.c \ - third_party/make/src/misc.c \ - third_party/make/src/output.c \ - third_party/make/src/posixos.c \ - third_party/make/src/read.c \ - third_party/make/src/remake.c \ - third_party/make/src/remote-stub.c \ - third_party/make/src/rule.c \ - third_party/make/src/signame.c \ - third_party/make/src/strcache.c \ - third_party/make/src/variable.c \ - third_party/make/src/version.c \ - third_party/make/src/vpath.c + third_party/make/ar.c \ + third_party/make/arscan.c \ + third_party/make/commands.c \ + third_party/make/default.c \ + third_party/make/dir.c \ + third_party/make/expand.c \ + third_party/make/file.c \ + third_party/make/function.c \ + third_party/make/getopt.c \ + third_party/make/getopt1.c \ + third_party/make/guile.c \ + third_party/make/hash.c \ + third_party/make/implicit.c \ + third_party/make/job.c \ + third_party/make/load.c \ + third_party/make/loadapi.c \ + third_party/make/main.c \ + third_party/make/misc.c \ + third_party/make/output.c \ + third_party/make/posixos.c \ + third_party/make/read.c \ + third_party/make/remake.c \ + third_party/make/remote-stub.c \ + third_party/make/rule.c \ + third_party/make/signame.c \ + third_party/make/strcache.c \ + third_party/make/variable.c \ + third_party/make/version.c \ + third_party/make/vpath.c THIRD_PARTY_MAKE_SRCS = \ $(THIRD_PARTY_MAKE_SRCS_BASE) \ @@ -109,7 +109,7 @@ o/$(MODE)/third_party/make/make.com.dbg: \ $(THIRD_PARTY_MAKE_DEPS) \ $(THIRD_PARTY_MAKE_A) \ $(THIRD_PARTY_MAKE_A).pkg \ - o/$(MODE)/third_party/make/src/main.o \ + o/$(MODE)/third_party/make/main.o \ $(CRT) \ $(APE_NO_MODIFY_SELF) @$(APELINK) diff --git a/third_party/make/src/makeint.h b/third_party/make/makeint.h similarity index 99% rename from third_party/make/src/makeint.h rename to third_party/make/makeint.h index 43f2e157c..b126cb342 100644 --- a/third_party/make/src/makeint.h +++ b/third_party/make/makeint.h @@ -59,7 +59,7 @@ this program. If not, see . */ /* We use instead of "config.h" so that a compilation using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h (which it would do because makeint.h was found in $srcdir). */ -#include "third_party/make/src/config.h" +#include "third_party/make/config.h" #pragma GCC diagnostic ignored "-Wredundant-decls" #undef HAVE_CONFIG_H #define HAVE_CONFIG_H 1 @@ -82,7 +82,7 @@ this program. If not, see . */ #ifdef WINDOWS32 # define GMK_BUILDING_MAKE #endif -#include "third_party/make/src/gnumake.h" +#include "third_party/make/gnumake.h" /* If we're compiling for the dmalloc debugger, turn off string inlining. */ #if defined(HAVE_DMALLOC_H) && defined(__GNUC__) @@ -241,7 +241,7 @@ extern mode_t umask (mode_t); /* Handle gettext and locales. */ -#include "third_party/make/src/gettext.h" +#include "third_party/make/gettext.h" #define _(msgid) gettext (msgid) #define N_(msgid) gettext_noop (msgid) diff --git a/third_party/make/src/misc.c b/third_party/make/misc.c similarity index 98% rename from third_party/make/src/misc.c rename to third_party/make/misc.c index 615f89947..05dfdacf0 100644 --- a/third_party/make/src/misc.c +++ b/third_party/make/misc.c @@ -15,10 +15,10 @@ 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 . */ -#include "third_party/make/src/makeint.h" -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/dep.h" -#include "third_party/make/src/debug.h" +#include "third_party/make/makeint.h" +#include "third_party/make/filedef.h" +#include "third_party/make/dep.h" +#include "third_party/make/debug.h" #include "libc/calls/calls.h" /* GNU make no longer supports pre-ANSI89 environments. */ diff --git a/third_party/make/src/os.h b/third_party/make/os.h similarity index 100% rename from third_party/make/src/os.h rename to third_party/make/os.h diff --git a/third_party/make/src/output.c b/third_party/make/output.c similarity index 99% rename from third_party/make/src/output.c rename to third_party/make/output.c index 117a1ec95..8d576a11b 100644 --- a/third_party/make/src/output.c +++ b/third_party/make/output.c @@ -15,9 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* clang-format off */ -#include "third_party/make/src/makeint.h" -#include "third_party/make/src/os.h" -#include "third_party/make/src/output.h" +#include "third_party/make/makeint.h" +#include "third_party/make/os.h" +#include "third_party/make/output.h" #include "libc/calls/struct/flock.h" /* GNU make no longer supports pre-ANSI89 environments. */ diff --git a/third_party/make/src/output.h b/third_party/make/output.h similarity index 100% rename from third_party/make/src/output.h rename to third_party/make/output.h diff --git a/third_party/make/src/posixos.c b/third_party/make/posixos.c similarity index 98% rename from third_party/make/src/posixos.c rename to third_party/make/posixos.c index f9da4ee35..084b3182a 100644 --- a/third_party/make/src/posixos.c +++ b/third_party/make/posixos.c @@ -14,12 +14,12 @@ 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 . */ -#include "third_party/make/src/makeint.h" +#include "third_party/make/makeint.h" /**/ #include "libc/sysv/consts/sa.h" -#include "third_party/make/src/debug.h" -#include "third_party/make/src/job.h" -#include "third_party/make/src/os.h" +#include "third_party/make/debug.h" +#include "third_party/make/job.h" +#include "third_party/make/os.h" /* clang-format off */ #ifdef MAKE_JOBSERVER diff --git a/third_party/make/src/read.c b/third_party/make/read.c similarity index 99% rename from third_party/make/src/read.c rename to third_party/make/read.c index 0a8f55210..ff81d8c61 100644 --- a/third_party/make/src/read.c +++ b/third_party/make/read.c @@ -15,17 +15,17 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* clang-format off */ -#include "third_party/make/src/makeint.h" -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/dep.h" -#include "third_party/make/src/job.h" -#include "third_party/make/src/os.h" -#include "third_party/make/src/commands.h" -#include "third_party/make/src/variable.h" -#include "third_party/make/src/rule.h" -#include "third_party/make/src/debug.h" +#include "third_party/make/makeint.h" +#include "third_party/make/filedef.h" +#include "third_party/make/dep.h" +#include "third_party/make/job.h" +#include "third_party/make/os.h" +#include "third_party/make/commands.h" +#include "third_party/make/variable.h" +#include "third_party/make/rule.h" +#include "third_party/make/debug.h" #include "third_party/musl/passwd.h" -#include "third_party/make/src/hash.h" +#include "third_party/make/hash.h" # define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */ diff --git a/third_party/make/src/remake.c b/third_party/make/remake.c similarity index 99% rename from third_party/make/src/remake.c rename to third_party/make/remake.c index 26c225645..816952af4 100644 --- a/third_party/make/src/remake.c +++ b/third_party/make/remake.c @@ -15,13 +15,13 @@ 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 . */ -#include "third_party/make/src/makeint.h" -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/job.h" -#include "third_party/make/src/commands.h" -#include "third_party/make/src/dep.h" -#include "third_party/make/src/variable.h" -#include "third_party/make/src/debug.h" +#include "third_party/make/makeint.h" +#include "third_party/make/filedef.h" +#include "third_party/make/job.h" +#include "third_party/make/commands.h" +#include "third_party/make/dep.h" +#include "third_party/make/variable.h" +#include "third_party/make/debug.h" /* The test for circular dependencies is based on the 'updating' bit in 'struct file'. However, double colon targets have separate 'struct diff --git a/third_party/make/src/remote-stub.c b/third_party/make/remote-stub.c similarity index 94% rename from third_party/make/src/remote-stub.c rename to third_party/make/remote-stub.c index 412568599..16c8d340d 100644 --- a/third_party/make/src/remote-stub.c +++ b/third_party/make/remote-stub.c @@ -15,10 +15,10 @@ 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 . */ -#include "third_party/make/src/makeint.h" -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/job.h" -#include "third_party/make/src/commands.h" +#include "third_party/make/makeint.h" +#include "third_party/make/filedef.h" +#include "third_party/make/job.h" +#include "third_party/make/commands.h" char *remote_description = 0; diff --git a/third_party/make/src/rule.c b/third_party/make/rule.c similarity index 98% rename from third_party/make/src/rule.c rename to third_party/make/rule.c index f5e5695d6..03c833fc8 100644 --- a/third_party/make/src/rule.c +++ b/third_party/make/rule.c @@ -15,13 +15,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* clang-format off */ -#include "third_party/make/src/makeint.h" -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/dep.h" -#include "third_party/make/src/job.h" -#include "third_party/make/src/commands.h" -#include "third_party/make/src/variable.h" -#include "third_party/make/src/rule.h" +#include "third_party/make/makeint.h" +#include "third_party/make/filedef.h" +#include "third_party/make/dep.h" +#include "third_party/make/job.h" +#include "third_party/make/commands.h" +#include "third_party/make/variable.h" +#include "third_party/make/rule.h" static void freerule (struct rule *rule, struct rule *lastrule); diff --git a/third_party/make/src/rule.h b/third_party/make/rule.h similarity index 100% rename from third_party/make/src/rule.h rename to third_party/make/rule.h diff --git a/third_party/make/src/signame.c b/third_party/make/signame.c similarity index 99% rename from third_party/make/src/signame.c rename to third_party/make/signame.c index 805eefa38..d390ab0cd 100644 --- a/third_party/make/src/signame.c +++ b/third_party/make/signame.c @@ -15,7 +15,7 @@ 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 . */ -#include "third_party/make/src/makeint.h" +#include "third_party/make/makeint.h" /* If the system provides strsignal, we don't need it. */ diff --git a/third_party/make/src/gettext.h b/third_party/make/src/gettext.h deleted file mode 100644 index 086e28a5b..000000000 --- a/third_party/make/src/gettext.h +++ /dev/null @@ -1,48 +0,0 @@ -/* clang-format off */ -/* Convenience header for conditional use of GNU . -Copyright (C) 1995-2020 Free Software Foundation, Inc. -This file is part of GNU Make. - -GNU Make 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. - -GNU Make 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 . */ - -#ifndef _LIBGETTEXT_H -#define _LIBGETTEXT_H 1 - -/* Disabled NLS. - The casts to 'const char *' serve the purpose of producing warnings - for invalid uses of the value returned from these functions. - On pre-ANSI systems without 'const', the config.h file is supposed to - contain "#define const". */ -# define gettext(Msgid) ((const char *) (Msgid)) -# define dgettext(Domainname, Msgid) ((const char *) (Msgid)) -# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid)) -# define ngettext(Msgid1, Msgid2, N) \ - ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) -# define dngettext(Domainname, Msgid1, Msgid2, N) \ - ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) -# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ - ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) -# define textdomain(Domainname) ((const char *) (Domainname)) -# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) -# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset)) - -/* A pseudo function call that serves as a marker for the automated - extraction of messages, but does not call gettext(). The run-time - translation is done at a different place in the code. - The argument, String, should be a literal string. Concatenated strings - and other string expressions won't work. - The macro's expansion is not parenthesized, so that it is suitable as - initializer for static 'char[]' or 'const char[]' variables. */ -#define gettext_noop(String) String - -#endif /* _LIBGETTEXT_H */ diff --git a/third_party/make/src/gmk-default.h b/third_party/make/src/gmk-default.h deleted file mode 100644 index d4731d9cd..000000000 --- a/third_party/make/src/gmk-default.h +++ /dev/null @@ -1,29 +0,0 @@ -/* clang-format off */ -static const char *const GUILE_module_defn = " \ -(define (to-string-maybe x) \ - (cond \ - ((or (not x) \ - (unspecified? x) \ - (variable? x) \ - (null? x) \ - (and (string? x) (string-null? x))) \ - #f) \ - ((eq? x #t) \"#t\") \ - ((or (symbol? x) (number? x)) \ - (object->string x)) \ - ((char? x) \ - (string x)) \ - ((and (string? x) (string-every char-set:printing x)) \ - x) \ - (else (error \"Unknown object:\" x)))) \ -(define (obj-to-str x) \ - (let ((acc '())) \ - (define (walk x) \ - (cond ((pair? x) (walk (car x)) (walk (cdr x))) \ - ((to-string-maybe x) => (lambda (s) (set! acc (cons s acc)))))) \ - (walk x) \ - (string-join (reverse! acc)))) \ -(define (gmk-var v) \ - (gmk-expand (format #f \"$(~a)\" (obj-to-str v)))) \ -(export gmk-expand gmk-eval gmk-var) \ -"; diff --git a/third_party/make/src/gmk-default.scm b/third_party/make/src/gmk-default.scm deleted file mode 100644 index ffcea6bd8..000000000 --- a/third_party/make/src/gmk-default.scm +++ /dev/null @@ -1,53 +0,0 @@ -;; Contents of the (gnu make) Guile module -;; Copyright (C) 2011-2020 Free Software Foundation, Inc. -;; This file is part of GNU Make. -;; -;; GNU Make 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. -;; -;; GNU Make 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 . - -(define (to-string-maybe x) - (cond - ;; In GNU make, "false" is the empty string - ((or (not x) - (unspecified? x) - (variable? x) - (null? x) - (and (string? x) (string-null? x))) - #f) - ;; We want something not false... not sure about this - ((eq? x #t) "#t") - ;; Basics - ((or (symbol? x) (number? x)) - (object->string x)) - ((char? x) - (string x)) - ;; Printable string (no special characters) - ((and (string? x) (string-every char-set:printing x)) - x) - ;; No idea: fail - (else (error "Unknown object:" x)))) - -(define (obj-to-str x) - (let ((acc '())) - (define (walk x) - (cond ((pair? x) (walk (car x)) (walk (cdr x))) - ((to-string-maybe x) => (lambda (s) (set! acc (cons s acc)))))) - (walk x) - (string-join (reverse! acc)))) - -;; Return the value of the GNU make variable V -(define (gmk-var v) - (gmk-expand (format #f "$(~a)" (obj-to-str v)))) - -;; Export the public interfaces -(export gmk-expand gmk-eval gmk-var) diff --git a/third_party/make/src/guile.c b/third_party/make/src/guile.c deleted file mode 100644 index a0cb2f4a1..000000000 --- a/third_party/make/src/guile.c +++ /dev/null @@ -1,158 +0,0 @@ -/* clang-format off */ -/* GNU Guile interface for GNU Make. -Copyright (C) 2011-2020 Free Software Foundation, Inc. -This file is part of GNU Make. - -GNU Make 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. - -GNU Make 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 . */ - -#include "third_party/make/src/makeint.h" - -#ifdef HAVE_GUILE - -#include "third_party/make/src/gnumake.h" - -#include "third_party/make/src/debug.h" -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/dep.h" -#include "third_party/make/src/variable.h" - -/* Pre-2.0 versions of Guile don't have a typedef for gsubr function types. */ -#if SCM_MAJOR_VERSION < 2 -# define GSUBR_TYPE SCM (*) () -/* Guile 1.x doesn't really support i18n. */ -# define EVAL_STRING(_s) scm_c_eval_string (_s) -#else -# define GSUBR_TYPE scm_t_subr -# define EVAL_STRING(_s) scm_eval_string (scm_from_utf8_string (_s)) -#endif - -static SCM make_mod = SCM_EOL; -static SCM obj_to_str = SCM_EOL; - -/* Convert an SCM object into a string. */ -static char * -cvt_scm_to_str (SCM obj) -{ - return scm_to_locale_string (scm_call_1 (obj_to_str, obj)); -} - -/* Perform the GNU make expansion function. */ -static SCM -guile_expand_wrapper (SCM obj) -{ - char *str = cvt_scm_to_str (obj); - SCM ret; - char *res; - - DB (DB_BASIC, (_("guile: Expanding '%s'\n"), str)); - res = gmk_expand (str); - ret = scm_from_locale_string (res); - - free (str); - free (res); - - return ret; -} - -/* Perform the GNU make eval function. */ -static SCM -guile_eval_wrapper (SCM obj) -{ - char *str = cvt_scm_to_str (obj); - - DB (DB_BASIC, (_("guile: Evaluating '%s'\n"), str)); - gmk_eval (str, 0); - - return SCM_BOOL_F; -} - -/* Invoked by scm_c_define_module(), in the context of the GNU make module. */ -static void -guile_define_module (void *data UNUSED) -{ -/* Ingest the predefined Guile module for GNU make. */ -#include "third_party/make/src/gmk-default.h" - - /* Register a subr for GNU make's eval capability. */ - scm_c_define_gsubr ("gmk-expand", 1, 0, 0, (GSUBR_TYPE) guile_expand_wrapper); - - /* Register a subr for GNU make's eval capability. */ - scm_c_define_gsubr ("gmk-eval", 1, 0, 0, (GSUBR_TYPE) guile_eval_wrapper); - - /* Define the rest of the module. */ - scm_c_eval_string (GUILE_module_defn); -} - -/* Initialize the GNU make Guile module. */ -static void * -guile_init (void *arg UNUSED) -{ - /* Define the module. */ - make_mod = scm_c_define_module ("gnu make", guile_define_module, NULL); - - /* Get a reference to the object-to-string translator, for later. */ - obj_to_str = scm_variable_ref (scm_c_module_lookup (make_mod, "obj-to-str")); - - /* Import the GNU make module exports into the generic space. */ - scm_c_eval_string ("(use-modules (gnu make))"); - - return NULL; -} - -static void * -internal_guile_eval (void *arg) -{ - return cvt_scm_to_str (EVAL_STRING (arg)); -} - -/* This is the function registered with make */ -static char * -func_guile (const char *funcname UNUSED, unsigned int argc UNUSED, char **argv) -{ - static int init = 0; - - if (! init) - { - /* Initialize the Guile interpreter. */ - scm_with_guile (guile_init, NULL); - init = 1; - } - - if (argv[0] && argv[0][0] != '\0') - return scm_with_guile (internal_guile_eval, argv[0]); - - return NULL; -} - -/* ----- Public interface ----- */ - -/* We could send the flocp to define_new_function(), but since guile is - "kind of" built-in, that didn't seem so useful. */ -int -guile_gmake_setup (const floc *flocp UNUSED) -{ - /* Create a make function "guile". */ - gmk_add_function ("guile", func_guile, 0, 1, GMK_FUNC_DEFAULT); - - return 1; -} - -#else - -int -guile_gmake_setup (const floc *flocp UNUSED) -{ - return 1; -} - -#endif diff --git a/third_party/make/src/w32/compat/dirent.c b/third_party/make/src/w32/compat/dirent.c deleted file mode 100644 index 84193aa5d..000000000 --- a/third_party/make/src/w32/compat/dirent.c +++ /dev/null @@ -1,173 +0,0 @@ -/* Directory entry code for Window platforms. -Copyright (C) 1996-2020 Free Software Foundation, Inc. -This file is part of GNU Make. - -GNU Make 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. - -GNU Make 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 . */ - -#include "dirent.h" - -DIR* opendir(const char* pDirName) { - struct stat sb; - DIR* pDir; - char* pEndDirName; - size_t nBufferLen; - - /* sanity checks */ - if (!pDirName) { - errno = EINVAL; - return NULL; - } - if (stat(pDirName, &sb) != 0) { - errno = ENOENT; - return NULL; - } - if ((sb.st_mode & S_IFMT) != S_IFDIR) { - errno = ENOTDIR; - return NULL; - } - - /* allocate a DIR structure to return */ - pDir = (DIR*)malloc(sizeof(DIR)); - - if (!pDir) return NULL; - - /* input directory name length */ - nBufferLen = strlen(pDirName); - - /* copy input directory name to DIR buffer */ - strcpy(pDir->dir_pDirectoryName, pDirName); - - /* point to end of the copied directory name */ - pEndDirName = &pDir->dir_pDirectoryName[nBufferLen - 1]; - - /* if directory name did not end in '/' or '\', add '/' */ - if ((*pEndDirName != '/') && (*pEndDirName != '\\')) { - pEndDirName++; - *pEndDirName = '/'; - } - - /* now append the wildcard character to the buffer */ - pEndDirName++; - *pEndDirName = '*'; - pEndDirName++; - *pEndDirName = '\0'; - - /* other values defaulted */ - pDir->dir_nNumFiles = 0; - pDir->dir_hDirHandle = INVALID_HANDLE_VALUE; - pDir->dir_ulCookie = __DIRENT_COOKIE; - - return pDir; -} - -void closedir(DIR* pDir) { - /* got a valid pointer? */ - if (!pDir) { - errno = EINVAL; - return; - } - - /* sanity check that this is a DIR pointer */ - if (pDir->dir_ulCookie != __DIRENT_COOKIE) { - errno = EINVAL; - return; - } - - /* close the WINDOWS32 directory handle */ - if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE) - FindClose(pDir->dir_hDirHandle); - - free(pDir); - - return; -} - -struct dirent* readdir(DIR* pDir) { - WIN32_FIND_DATA wfdFindData; - - if (!pDir) { - errno = EINVAL; - return NULL; - } - - /* sanity check that this is a DIR pointer */ - if (pDir->dir_ulCookie != __DIRENT_COOKIE) { - errno = EINVAL; - return NULL; - } - - if (pDir->dir_nNumFiles == 0) { - pDir->dir_hDirHandle = - FindFirstFile(pDir->dir_pDirectoryName, &wfdFindData); - if (pDir->dir_hDirHandle == INVALID_HANDLE_VALUE) return NULL; - } else if (!FindNextFile(pDir->dir_hDirHandle, &wfdFindData)) - return NULL; - - /* bump count for next call to readdir() */ - pDir->dir_nNumFiles++; - - /* fill in struct dirent values */ - pDir->dir_sdReturn.d_ino = (ino_t)-1; - strcpy(pDir->dir_sdReturn.d_name, wfdFindData.cFileName); - - if (wfdFindData.dwFileAttributes & FILE_ATTRIBUTE_DEVICE) - pDir->dir_sdReturn.d_type = DT_CHR; - else if (wfdFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - pDir->dir_sdReturn.d_type = DT_DIR; - else - pDir->dir_sdReturn.d_type = DT_REG; - - return &pDir->dir_sdReturn; -} - -void rewinddir(DIR* pDir) { - if (!pDir) { - errno = EINVAL; - return; - } - - /* sanity check that this is a DIR pointer */ - if (pDir->dir_ulCookie != __DIRENT_COOKIE) { - errno = EINVAL; - return; - } - - /* close the WINDOWS32 directory handle */ - if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE) - if (!FindClose(pDir->dir_hDirHandle)) errno = EBADF; - - /* reset members which control readdir() */ - pDir->dir_hDirHandle = INVALID_HANDLE_VALUE; - pDir->dir_nNumFiles = 0; - - return; -} - -void seekdir(DIR* pDir, long nPosition) { - if (!pDir) return; - - /* sanity check that this is a DIR pointer */ - if (pDir->dir_ulCookie != __DIRENT_COOKIE) return; - - /* go back to beginning of directory */ - rewinddir(pDir); - - /* loop until we have found position we care about */ - for (--nPosition; nPosition && readdir(pDir); nPosition--) - ; - - /* flag invalid nPosition value */ - if (nPosition) errno = EINVAL; - - return; -} diff --git a/third_party/make/src/w32/compat/posixfcn.c b/third_party/make/src/w32/compat/posixfcn.c deleted file mode 100644 index a5992cbb3..000000000 --- a/third_party/make/src/w32/compat/posixfcn.c +++ /dev/null @@ -1,405 +0,0 @@ -/* Replacements for Posix functions and Posix functionality for MS-Windows. - -Copyright (C) 2013-2020 Free Software Foundation, Inc. -This file is part of GNU Make. - -GNU Make 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. - -GNU Make 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 . */ - -#include "dlfcn.h" -#include "job.h" -#include "makeint.h" - -#ifndef NO_OUTPUT_SYNC -/* Support for OUTPUT_SYNC and related functionality. */ - -/* Emulation of fcntl that supports only F_GETFD and F_SETLKW. */ -int fcntl(intptr_t fd, int cmd, ...) { - va_list ap; - - va_start(ap, cmd); - - switch (cmd) { - case F_GETFD: - va_end(ap); - /* Could have used GetHandleInformation, but that isn't - supported on Windows 9X. */ - if (_get_osfhandle(fd) == -1) return -1; - return 0; - case F_SETLKW: { - void *buf = va_arg(ap, void *); - struct flock *fl = (struct flock *)buf; - HANDLE hmutex = (HANDLE)fd; - static struct flock last_fl; - short last_type = last_fl.l_type; - - va_end(ap); - - if (hmutex == INVALID_HANDLE_VALUE || !hmutex) return -1; - - last_fl = *fl; - - switch (fl->l_type) { - - case F_WRLCK: { - DWORD result; - - if (last_type == F_WRLCK) { - /* Don't call WaitForSingleObject if we already - own the mutex, because doing so will require - us to call ReleaseMutex an equal number of - times, before the mutex is actually - released. */ - return 0; - } - - result = WaitForSingleObject(hmutex, INFINITE); - switch (result) { - case WAIT_OBJECT_0: - /* We don't care if the mutex owner crashed or - exited. */ - case WAIT_ABANDONED: - return 0; - case WAIT_FAILED: - case WAIT_TIMEOUT: /* cannot happen, really */ - { - DWORD err = GetLastError(); - - /* Invalidate the last command. */ - memset(&last_fl, 0, sizeof(last_fl)); - - switch (err) { - case ERROR_INVALID_HANDLE: - case ERROR_INVALID_FUNCTION: - errno = EINVAL; - return -1; - default: - errno = EDEADLOCK; - return -1; - } - } - } - } - case F_UNLCK: { - /* FIXME: Perhaps we should call ReleaseMutex - repatedly until it errors out, to make sure the - mutext is released even if we somehow managed to - to take ownership multiple times? */ - BOOL status = ReleaseMutex(hmutex); - - if (status) - return 0; - else { - DWORD err = GetLastError(); - - if (err == ERROR_NOT_OWNER) - errno = EPERM; - else { - memset(&last_fl, 0, sizeof(last_fl)); - errno = EINVAL; - } - return -1; - } - } - default: - errno = ENOSYS; - return -1; - } - } - default: - errno = ENOSYS; - va_end(ap); - return -1; - } -} - -static intptr_t mutex_handle = -1; - -/* Record in a static variable the mutex handle we were requested to - use. That nameless mutex was created by the top-level Make, and - its handle was passed to us via inheritance. The value of that - handle is passed via the command-line arguments, so that we know - which handle to use. */ -void record_sync_mutex(const char *str) { - char *endp; - intptr_t hmutex = strtol(str, &endp, 16); - - if (*endp == '\0') - mutex_handle = hmutex; - else { - mutex_handle = -1; - errno = EINVAL; - } -} - -/* Create a new mutex or reuse one created by our parent. */ -intptr_t create_mutex(void) { - SECURITY_ATTRIBUTES secattr; - intptr_t hmutex = -1; - - /* If we have a mutex handle passed from the parent Make, just use - that. */ - if (mutex_handle > 0) return mutex_handle; - - /* We are the top-level Make, and we want the handle to be inherited - by our child processes. */ - secattr.nLength = sizeof(secattr); - secattr.lpSecurityDescriptor = NULL; /* use default security descriptor */ - secattr.bInheritHandle = TRUE; - - hmutex = (intptr_t)CreateMutex(&secattr, FALSE, NULL); - if (!hmutex) { - DWORD err = GetLastError(); - - fprintf(stderr, "CreateMutex: error %lu\n", err); - errno = ENOLCK; - hmutex = -1; - } - - mutex_handle = hmutex; - return hmutex; -} - -/* Return non-zero if F1 and F2 are 2 streams representing the same - file or pipe or device. */ -int same_stream(FILE *f1, FILE *f2) { - HANDLE fh1 = (HANDLE)_get_osfhandle(fileno(f1)); - HANDLE fh2 = (HANDLE)_get_osfhandle(fileno(f2)); - - /* Invalid file descriptors get treated as different streams. */ - if (fh1 && fh1 != INVALID_HANDLE_VALUE && fh2 && - fh2 != INVALID_HANDLE_VALUE) { - if (fh1 == fh2) - return 1; - else { - DWORD ftyp1 = GetFileType(fh1), ftyp2 = GetFileType(fh2); - - if (ftyp1 != ftyp2 || ftyp1 == FILE_TYPE_UNKNOWN || - ftyp2 == FILE_TYPE_UNKNOWN) - return 0; - else if (ftyp1 == FILE_TYPE_CHAR) { - /* For character devices, check if they both refer to a - console. This loses if both handles refer to the - null device (FIXME!), but in that case we don't care - in the context of Make. */ - DWORD conmode1, conmode2; - - /* Each process on Windows can have at most 1 console, - so if both handles are for the console device, they - are the same. We also compare the console mode to - distinguish between stdin and stdout/stderr. */ - if (GetConsoleMode(fh1, &conmode1) && GetConsoleMode(fh2, &conmode2) && - conmode1 == conmode2) - return 1; - } else { - /* For disk files and pipes, compare their unique - attributes. */ - BY_HANDLE_FILE_INFORMATION bhfi1, bhfi2; - - /* Pipes get zero in the volume serial number, but do - appear to have meaningful information in file index - attributes. We test file attributes as well, for a - good measure. */ - if (GetFileInformationByHandle(fh1, &bhfi1) && - GetFileInformationByHandle(fh2, &bhfi2)) - return (bhfi1.dwVolumeSerialNumber == bhfi2.dwVolumeSerialNumber && - bhfi1.nFileIndexLow == bhfi2.nFileIndexLow && - bhfi1.nFileIndexHigh == bhfi2.nFileIndexHigh && - bhfi1.dwFileAttributes == bhfi2.dwFileAttributes); - } - } - } - return 0; -} - -/* A replacement for tmpfile, since the MSVCRT implementation creates - the file in the root directory of the current drive, which might - not be writable by our user. Most of the code borrowed from - create_batch_file, see job.c. */ -FILE *tmpfile(void) { - char temp_path[MAXPATHLEN]; - unsigned path_size = GetTempPath(sizeof temp_path, temp_path); - int path_is_dot = 0; - /* The following variable is static so we won't try to reuse a name - that was generated a little while ago, because that file might - not be on disk yet, since we use FILE_ATTRIBUTE_TEMPORARY below, - which tells the OS it doesn't need to flush the cache to disk. - If the file is not yet on disk, we might think the name is - available, while it really isn't. This happens in parallel - builds, where Make doesn't wait for one job to finish before it - launches the next one. */ - static unsigned uniq = 0; - static int second_loop = 0; - const char base[] = "gmake_tmpf"; - const unsigned sizemax = sizeof base - 1 + 4 + 10 + 10; - unsigned pid = GetCurrentProcessId(); - - if (path_size == 0) { - path_size = GetCurrentDirectory(sizeof temp_path, temp_path); - path_is_dot = 1; - } - - ++uniq; - if (uniq >= 0x10000 && !second_loop) { - /* If we already had 64K batch files in this - process, make a second loop through the numbers, - looking for free slots, i.e. files that were - deleted in the meantime. */ - second_loop = 1; - uniq = 1; - } - while (path_size > 0 && path_size + sizemax < sizeof temp_path && - !(uniq >= 0x10000 && second_loop)) { - HANDLE h; - - sprintf(temp_path + path_size, "%s%s%u-%x.tmp", - temp_path[path_size - 1] == '\\' ? "" : "\\", base, pid, uniq); - h = CreateFile(temp_path, /* file name */ - GENERIC_READ | GENERIC_WRITE | DELETE, /* desired access */ - FILE_SHARE_READ | FILE_SHARE_WRITE, /* share mode */ - NULL, /* default security attributes */ - CREATE_NEW, /* creation disposition */ - FILE_ATTRIBUTE_NORMAL | /* flags and attributes */ - FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, - NULL); /* no template file */ - - if (h == INVALID_HANDLE_VALUE) { - const DWORD er = GetLastError(); - - if (er == ERROR_FILE_EXISTS || er == ERROR_ALREADY_EXISTS) { - ++uniq; - if (uniq == 0x10000 && !second_loop) { - second_loop = 1; - uniq = 1; - } - } - - /* The temporary path is not guaranteed to exist, or might - not be writable by user. Use the current directory as - fallback. */ - else if (path_is_dot == 0) { - path_size = GetCurrentDirectory(sizeof temp_path, temp_path); - path_is_dot = 1; - } - - else { - errno = EACCES; - break; - } - } else { - int fd = _open_osfhandle((intptr_t)h, 0); - - return _fdopen(fd, "w+b"); - } - } - - if (uniq >= 0x10000) errno = EEXIST; - return NULL; -} - -#endif /* !NO_OUTPUT_SYNC */ - -#if MAKE_LOAD - -/* Support for dynamic loading of objects. */ - -static DWORD last_err; - -void *dlopen(const char *file, int mode) { - char dllfn[MAX_PATH], *p; - HANDLE dllhandle; - - if ((mode & ~(RTLD_LAZY | RTLD_NOW | RTLD_GLOBAL)) != 0) { - errno = EINVAL; - last_err = ERROR_INVALID_PARAMETER; - return NULL; - } - - if (!file) - dllhandle = GetModuleHandle(NULL); - else { - /* MSDN says to be sure to use backslashes in the DLL file name. */ - strcpy(dllfn, file); - for (p = dllfn; *p; p++) - if (*p == '/') *p = '\\'; - - dllhandle = LoadLibrary(dllfn); - } - if (!dllhandle) last_err = GetLastError(); - - return dllhandle; -} - -char *dlerror(void) { - static char errbuf[1024]; - DWORD ret; - - if (!last_err) return NULL; - - ret = - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, last_err, 0, errbuf, sizeof(errbuf), NULL); - while (ret > 0 && (errbuf[ret - 1] == '\n' || errbuf[ret - 1] == '\r')) --ret; - - errbuf[ret] = '\0'; - if (!ret) sprintf(errbuf, "Error code %lu", last_err); - - last_err = 0; - return errbuf; -} - -void *dlsym(void *handle, const char *name) { - FARPROC addr = NULL; - - if (!handle || handle == INVALID_HANDLE_VALUE) { - last_err = ERROR_INVALID_PARAMETER; - return NULL; - } - - addr = GetProcAddress(handle, name); - if (!addr) last_err = GetLastError(); - - return (void *)addr; -} - -int dlclose(void *handle) { - if (!handle || handle == INVALID_HANDLE_VALUE) return -1; - if (!FreeLibrary(handle)) return -1; - - return 0; -} - -#endif /* MAKE_LOAD */ - -/* MS runtime's isatty returns non-zero for any character device, - including the null device, which is not what we want. */ -int isatty(int fd) { - HANDLE fh = (HANDLE)_get_osfhandle(fd); - DWORD con_mode; - - if (fh == INVALID_HANDLE_VALUE) { - errno = EBADF; - return 0; - } - if (GetConsoleMode(fh, &con_mode)) return 1; - - errno = ENOTTY; - return 0; -} - -char *ttyname(int fd) { - /* This "knows" that Make only asks about stdout and stderr. A more - sophisticated implementation should test whether FD is open for - input or output. We can do that by looking at the mode returned - by GetConsoleMode. */ - return "CONOUT$"; -} diff --git a/third_party/make/src/w32/include/dirent.h b/third_party/make/src/w32/include/dirent.h deleted file mode 100644 index 393584d27..000000000 --- a/third_party/make/src/w32/include/dirent.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Windows version of dirent.h -Copyright (C) 1996-2020 Free Software Foundation, Inc. -This file is part of GNU Make. - -GNU Make 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. - -GNU Make 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 . */ - -#ifndef _DIRENT_H -#define _DIRENT_H - -#ifdef __MINGW32__ -#include_next -#else - -#ifndef NAME_MAX -#define NAME_MAX 255 -#endif - -#define __DIRENT_COOKIE 0xfefeabab - -/* File types for `d_type'. - Windows only supports DT_CHR, DT_DIR, and DT_REG. */ -enum { - DT_UNKNOWN = 0, -#define DT_UNKNOWN DT_UNKNOWN - DT_FIFO = 1, -#define DT_FIFO DT_FIFO - DT_CHR = 2, -#define DT_CHR DT_CHR - DT_DIR = 4, -#define DT_DIR DT_DIR - DT_BLK = 6, -#define DT_BLK DT_BLK - DT_REG = 8, -#define DT_REG DT_REG - DT_LNK = 10, -#define DT_LNK DT_LNK - DT_SOCK = 12, -#define DT_SOCK DT_SOCK - DT_WHT = 14 -#define DT_WHT DT_WHT -}; - -struct dirent { - ino_t d_ino; /* unused - no equivalent on WINDOWS32. */ - unsigned char d_type; - char d_name[NAME_MAX + 1]; /* must come last due to dir.c assumptions. */ -}; - -typedef struct dir_struct { - ULONG dir_ulCookie; - HANDLE dir_hDirHandle; - DWORD dir_nNumFiles; - char dir_pDirectoryName[NAME_MAX + 1]; - struct dirent dir_sdReturn; -} DIR; - -DIR *opendir(const char *); -struct dirent *readdir(DIR *); -void rewinddir(DIR *); -void closedir(DIR *); -void seekdir(DIR *, long); - -#endif /* !__MINGW32__ */ -#endif diff --git a/third_party/make/src/w32/include/dlfcn.h b/third_party/make/src/w32/include/dlfcn.h deleted file mode 100644 index 00d1d7d9b..000000000 --- a/third_party/make/src/w32/include/dlfcn.h +++ /dev/null @@ -1,29 +0,0 @@ -/* dlfcn.h replacement for MS-Windows build. -Copyright (C) 2013-2020 Free Software Foundation, Inc. -This file is part of GNU Make. - -GNU Make 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. - -GNU Make 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 . */ - -#ifndef DLFCN_H -#define DLFCN_H - -#define RTLD_LAZY 1 -#define RTLD_NOW 2 -#define RTLD_GLOBAL 4 - -extern void *dlopen (const char *, int); -extern void *dlsym (void *, const char *); -extern char *dlerror (void); -extern int dlclose (void *); - -#endif /* DLFCN_H */ diff --git a/third_party/make/src/w32/include/pathstuff.h b/third_party/make/src/w32/include/pathstuff.h deleted file mode 100644 index 63f432517..000000000 --- a/third_party/make/src/w32/include/pathstuff.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Definitions for Windows path manipulation. -Copyright (C) 1996-2020 Free Software Foundation, Inc. -This file is part of GNU Make. - -GNU Make 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. - -GNU Make 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 . */ - -#ifndef _PATHSTUFF_H -#define _PATHSTUFF_H - -char *convert_Path_to_windows32(char *Path, char to_delim); -char *convert_vpath_to_windows32(char *Path, char to_delim); -char *w32ify(const char *file, int resolve); -char *getcwd_fs(char *buf, int len); - -#endif diff --git a/third_party/make/src/w32/include/sub_proc.h b/third_party/make/src/w32/include/sub_proc.h deleted file mode 100644 index 8ab93532d..000000000 --- a/third_party/make/src/w32/include/sub_proc.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Definitions for Windows process invocation. -Copyright (C) 1996-2020 Free Software Foundation, Inc. -This file is part of GNU Make. - -GNU Make 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. - -GNU Make 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 . */ - -#ifndef SUB_PROC_H -#define SUB_PROC_H - -/* - * Component Name: - * - * $Date$ - * - * $Source$ - * - * $Id$ - */ - -#define EXTERN_DECL(entry, args) extern entry args -#define VOID_DECL void - -EXTERN_DECL(HANDLE process_init, (VOID_DECL)); -EXTERN_DECL(HANDLE process_init_fd, (HANDLE stdinh, HANDLE stdouth, - HANDLE stderrh)); -EXTERN_DECL(long process_begin, (HANDLE proc, char **argv, char **envp, - char *exec_path, char *as_user)); -EXTERN_DECL(long process_pipe_io, (HANDLE proc, char *stdin_data, - int stdin_data_len)); -EXTERN_DECL(long process_file_io, (HANDLE proc)); -EXTERN_DECL(void process_cleanup, (HANDLE proc)); -EXTERN_DECL(HANDLE process_wait_for_any, (int block, DWORD* pdwWaitStatus)); -EXTERN_DECL(void process_register, (HANDLE proc)); -EXTERN_DECL(HANDLE process_easy, (char** argv, char** env, - int outfd, int errfd)); -EXTERN_DECL(BOOL process_kill, (HANDLE proc, int signal)); -EXTERN_DECL(BOOL process_table_full, (VOID_DECL)); -EXTERN_DECL(int process_table_usable_size, (VOID_DECL)); -EXTERN_DECL(int process_table_actual_size, (VOID_DECL)); -EXTERN_DECL(DWORD process_set_handles, (HANDLE *handles)); -EXTERN_DECL(DWORD process_wait_for_multiple_objects, (DWORD, const HANDLE*, BOOL, DWORD)); - -/* support routines */ -EXTERN_DECL(long process_errno, (HANDLE proc)); -EXTERN_DECL(long process_last_err, (HANDLE proc)); -EXTERN_DECL(long process_exit_code, (HANDLE proc)); -EXTERN_DECL(long process_signal, (HANDLE proc)); -EXTERN_DECL(char * process_outbuf, (HANDLE proc)); -EXTERN_DECL(char * process_errbuf, (HANDLE proc)); -EXTERN_DECL(int process_outcnt, (HANDLE proc)); -EXTERN_DECL(int process_errcnt, (HANDLE proc)); -EXTERN_DECL(void process_pipes, (HANDLE proc, int pipes[3])); - -#endif diff --git a/third_party/make/src/w32/pathstuff.c b/third_party/make/src/w32/pathstuff.c deleted file mode 100644 index 073200fcf..000000000 --- a/third_party/make/src/w32/pathstuff.c +++ /dev/null @@ -1,244 +0,0 @@ -/* Path conversion for Windows pathnames. -Copyright (C) 1996-2020 Free Software Foundation, Inc. -This file is part of GNU Make. - -GNU Make 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. - -GNU Make 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 . */ - -#include - -#include "pathstuff.h" - -/* - * Convert delimiter separated vpath to Canonical format. - */ -char *convert_vpath_to_windows32(char *Path, char to_delim) { - char *etok; /* token separator for old Path */ - - /* - * Convert all spaces to delimiters. Note that pathnames which - * contain blanks get trounced here. Use 8.3 format as a workaround. - */ - for (etok = Path; etok && *etok; etok++) - if (ISBLANK((unsigned char)*etok)) *etok = to_delim; - - return (convert_Path_to_windows32(Path, to_delim)); -} - -/* - * Convert delimiter separated path to Canonical format. - */ -char *convert_Path_to_windows32(char *Path, char to_delim) { - char *etok; /* token separator for old Path */ - char *p; /* points to element of old Path */ - - /* is this a multi-element Path ? */ - /* FIXME: Perhaps use ":;\"" in strpbrk to convert all quotes to - delimiters as well, as a way to handle quoted directories in - PATH? */ - for (p = Path, etok = strpbrk(p, ":;"); etok; etok = strpbrk(p, ":;")) - if ((etok - p) == 1) { - if (*(etok - 1) == ';' || *(etok - 1) == ':') { - etok[-1] = to_delim; - etok[0] = to_delim; - p = ++etok; - continue; /* ignore empty bucket */ - } else if (!isalpha((unsigned char)*p)) { - /* found one to count, handle things like '.' */ - *etok = to_delim; - p = ++etok; - } else if ((*etok == ':') && ((etok = strpbrk(etok + 1, ":;")) != NULL)) { - /* found one to count, handle drive letter */ - *etok = to_delim; - p = ++etok; - } else - /* all finished, force abort */ - p += strlen(p); - } else if (*p == '"') { /* a quoted directory */ - for (p++; *p && *p != '"'; p++) /* skip quoted part */ - ; - etok = strpbrk(p, ":;"); /* find next delimiter */ - if (etok) { - *etok = to_delim; - p = ++etok; - } else - p += strlen(p); - } else { - /* found another one, no drive letter */ - *etok = to_delim; - p = ++etok; - } - - return Path; -} - -/* - * Convert to forward slashes. Resolve to full pathname optionally - */ -char *w32ify(const char *filename, int resolve) { - static char w32_path[FILENAME_MAX]; - char *p; - - if (resolve) - _fullpath(w32_path, filename, sizeof(w32_path)); - else - strncpy(w32_path, filename, sizeof(w32_path)); - - for (p = w32_path; p && *p; p++) - if (*p == '\\') *p = '/'; - - return w32_path; -} - -char *getcwd_fs(char *buf, int len) { - char *p = getcwd(buf, len); - - if (p) { - char *q = w32ify(buf, 0); - strncpy(buf, q, len); - } - - return p; -} - -#ifdef unused -/* - * Convert delimiter separated pathnames (e.g. PATH) or single file pathname - * (e.g. c:/foo, c:\bar) to NutC format. If we are handed a string that - * _NutPathToNutc() fails to convert, just return the path we were handed - * and assume the caller will know what to do with it (It was probably - * a mistake to try and convert it anyway due to some of the bizarre things - * that might look like pathnames in makefiles). - */ -char *convert_path_to_nutc(char *path) { - int count; /* count of path elements */ - char *nutc_path; /* new NutC path */ - int nutc_path_len; /* length of buffer to allocate for new path */ - char *pathp; /* pointer to nutc_path used to build it */ - char *etok; /* token separator for old path */ - char *p; /* points to element of old path */ - char sep; /* what flavor of separator used in old path */ - char *rval; - - /* is this a multi-element path ? */ - for (p = path, etok = strpbrk(p, ":;"), count = 0; etok; - etok = strpbrk(p, ":;")) - if ((etok - p) == 1) { - if (*(etok - 1) == ';' || *(etok - 1) == ':') { - p = ++etok; - continue; /* ignore empty bucket */ - } else if (etok = strpbrk(etok + 1, ":;")) - /* found one to count, handle drive letter */ - p = ++etok, count++; - else - /* all finished, force abort */ - p += strlen(p); - } else - /* found another one, no drive letter */ - p = ++etok, count++; - - if (count) { - count++; /* x1;x2;x3 <- need to count x3 */ - - /* - * Hazard a guess on how big the buffer needs to be. - * We have to convert things like c:/foo to /c=/foo. - */ - nutc_path_len = strlen(path) + (count * 2) + 1; - nutc_path = xmalloc(nutc_path_len); - pathp = nutc_path; - *pathp = '\0'; - - /* - * Loop through PATH and convert one elemnt of the path at at - * a time. Single file pathnames will fail this and fall - * to the logic below loop. - */ - for (p = path, etok = strpbrk(p, ":;"); etok; etok = strpbrk(p, ":;")) { - - /* don't trip up on device specifiers or empty path slots */ - if ((etok - p) == 1) - if (*(etok - 1) == ';' || *(etok - 1) == ':') { - p = ++etok; - continue; - } else if ((etok = strpbrk(etok + 1, ":;")) == NULL) - break; /* thing found was a WINDOWS32 pathname */ - - /* save separator */ - sep = *etok; - - /* terminate the current path element -- temporarily */ - *etok = '\0'; - -#ifdef __NUTC__ - /* convert to NutC format */ - if (_NutPathToNutc(p, pathp, 0) == FALSE) { - free(nutc_path); - rval = savestring(path, strlen(path)); - return rval; - } -#else - *pathp++ = '/'; - *pathp++ = p[0]; - *pathp++ = '='; - *pathp++ = '/'; - strcpy(pathp, &p[2]); -#endif - - pathp += strlen(pathp); - *pathp++ = ':'; /* use Unix style path separtor for new path */ - *pathp = '\0'; /* make sure we are null terminaed */ - - /* restore path separator */ - *etok = sep; - - /* point p to first char of next path element */ - p = ++etok; - } - } else { - nutc_path_len = strlen(path) + 3; - nutc_path = xmalloc(nutc_path_len); - pathp = nutc_path; - *pathp = '\0'; - p = path; - } - - /* - * OK, here we handle the last element in PATH (e.g. c of a;b;c) - * or the path was a single filename and will be converted - * here. Note, testing p here assures that we don't trip up - * on paths like a;b; which have trailing delimiter followed by - * nothing. - */ - if (*p != '\0') { -#ifdef __NUTC__ - if (_NutPathToNutc(p, pathp, 0) == FALSE) { - free(nutc_path); - rval = savestring(path, strlen(path)); - return rval; - } -#else - *pathp++ = '/'; - *pathp++ = p[0]; - *pathp++ = '='; - *pathp++ = '/'; - strcpy(pathp, &p[2]); -#endif - } else - *(pathp - 1) = '\0'; /* we're already done, don't leave trailing : */ - - rval = savestring(nutc_path, strlen(nutc_path)); - free(nutc_path); - return rval; -} - -#endif diff --git a/third_party/make/src/w32/subproc/misc.c b/third_party/make/src/w32/subproc/misc.c deleted file mode 100644 index 9f253a3dc..000000000 --- a/third_party/make/src/w32/subproc/misc.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Process handling for Windows -Copyright (C) 1996-2020 Free Software Foundation, Inc. -This file is part of GNU Make. - -GNU Make 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. - -GNU Make 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 . */ - -#include "proc.h" - -/* - * Description: Convert a NULL string terminated UNIX environment block to - * an environment block suitable for a windows32 system call - * - * Returns: TRUE= success, FALSE=fail - * - * Notes/Dependencies: the environment block is sorted in case-insensitive - * order, is double-null terminated, and is a char *, not a char ** - */ -int _cdecl compare(const void *a1, const void *a2) { - return _stricoll(*((char **)a1), *((char **)a2)); -} -bool_t arr2envblk(char **arr, char **envblk_out, size_t *envsize_needed) { - char **tmp; - size_t size_needed; - int arrcnt; - char *ptr; - - arrcnt = 0; - while (arr[arrcnt]) { - arrcnt++; - } - - tmp = (char **)calloc(arrcnt + 1, sizeof(char *)); - if (!tmp) { - return FALSE; - } - - arrcnt = 0; - size_needed = *envsize_needed = 0; - while (arr[arrcnt]) { - tmp[arrcnt] = arr[arrcnt]; - size_needed += strlen(arr[arrcnt]) + 1; - arrcnt++; - } - size_needed++; - *envsize_needed = size_needed; - - qsort((void *)tmp, (size_t)arrcnt, sizeof(char *), compare); - - ptr = *envblk_out = calloc(size_needed, 1); - if (!ptr) { - free(tmp); - return FALSE; - } - - arrcnt = 0; - while (tmp[arrcnt]) { - strcpy(ptr, tmp[arrcnt]); - ptr += strlen(tmp[arrcnt]) + 1; - arrcnt++; - } - - free(tmp); - return TRUE; -} diff --git a/third_party/make/src/w32/subproc/proc.h b/third_party/make/src/w32/subproc/proc.h deleted file mode 100644 index d9f640630..000000000 --- a/third_party/make/src/w32/subproc/proc.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Definitions for Windows -Copyright (C) 1996-2020 Free Software Foundation, Inc. -This file is part of GNU Make. - -GNU Make 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. - -GNU Make 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 . */ - -#ifndef _PROC_H -#define _PROC_H - -typedef int bool_t; - -#define E_SCALL 101 -#define E_IO 102 -#define E_NO_MEM 103 -#define E_FORK 104 - -extern bool_t arr2envblk(char **arr, char **envblk_out, size_t *envsize_needed); - -#endif diff --git a/third_party/make/src/w32/subproc/sub_proc.c b/third_party/make/src/w32/subproc/sub_proc.c deleted file mode 100644 index c79b7ddcc..000000000 --- a/third_party/make/src/w32/subproc/sub_proc.c +++ /dev/null @@ -1,1550 +0,0 @@ -/* clang-format off */ -/* Process handling for Windows. -Copyright (C) 1996-2020 Free Software Foundation, Inc. -This file is part of GNU Make. - -GNU Make 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. - -GNU Make 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 . */ - -#include "makeint.h" -#include "filedef.h" -#include "variable.h" -#include "sub_proc.h" -#include "proc.h" -#include "w32err.h" -#include "debug.h" -#include "os.h" - -#define GMAKE_MAXIMUM_WAIT_OBJECTS (MAXIMUM_WAIT_OBJECTS * MAXIMUM_WAIT_OBJECTS) - -/* We need to move these special-case return codes out-of-band */ -#define GMAKE_WAIT_TIMEOUT 0xFFFF0102L -#define GMAKE_WAIT_ABANDONED_0 0x00080000L - -static char *make_command_line(char *shell_name, char *exec_path, char **argv); - -typedef struct sub_process_t { - intptr_t sv_stdin[2]; - intptr_t sv_stdout[2]; - intptr_t sv_stderr[2]; - int using_pipes; - char *inp; - DWORD incnt; - char * volatile outp; - volatile DWORD outcnt; - char * volatile errp; - volatile DWORD errcnt; - pid_t pid; - int exit_code; - int signal; - long last_err; - long lerrno; -} sub_process; - -/* keep track of children so we can implement a waitpid-like routine */ -static sub_process *proc_array[GMAKE_MAXIMUM_WAIT_OBJECTS]; -static unsigned int proc_index = 0; -static unsigned int fake_exits_pending = 0; - -/* - * Address the scalability limit intrisic to WaitForMultipleOjects by - * calling WaitForMultipleObjects on 64 element chunks of the input - * array with 0 timeout. Exit with an appropriately conditioned result - * or repeat again every 10 ms if no handle has signaled and the - * requested timeout was not zero. - */ -DWORD process_wait_for_multiple_objects( - DWORD nCount, - const HANDLE *lpHandles, - BOOL bWaitAll, - DWORD dwMilliseconds -) -{ - assert(nCount <= GMAKE_MAXIMUM_WAIT_OBJECTS); - - if (nCount <= MAXIMUM_WAIT_OBJECTS) { - DWORD retVal = WaitForMultipleObjects(nCount, lpHandles, bWaitAll, dwMilliseconds); - return (retVal == WAIT_TIMEOUT) ? GMAKE_WAIT_TIMEOUT : retVal; - } else { - for (;;) { - DWORD objectCount = nCount; - int blockCount = 0; - DWORD retVal; - - assert(bWaitAll == FALSE); /* This logic only works for this use case */ - assert(dwMilliseconds == 0 || dwMilliseconds == INFINITE); /* No support for timeouts */ - - for (; objectCount > 0; blockCount++) { - DWORD n = objectCount <= MAXIMUM_WAIT_OBJECTS ? objectCount : MAXIMUM_WAIT_OBJECTS; - objectCount -= n; - retVal = WaitForMultipleObjects(n, &lpHandles[blockCount * MAXIMUM_WAIT_OBJECTS], - FALSE, 0); - switch (retVal) { - case WAIT_TIMEOUT: - retVal = GMAKE_WAIT_TIMEOUT; - continue; - break; - case WAIT_FAILED: - fprintf(stderr,"WaitForMultipleOjbects failed waiting with error %lu\n", GetLastError()); - break; - default: - if (retVal >= WAIT_ABANDONED_0) { - assert(retVal < WAIT_ABANDONED_0 + MAXIMUM_WAIT_OBJECTS); - retVal += blockCount * MAXIMUM_WAIT_OBJECTS - WAIT_ABANDONED_0 + GMAKE_WAIT_ABANDONED_0; - } else { - assert(retVal < WAIT_OBJECT_0 + MAXIMUM_WAIT_OBJECTS); - retVal += blockCount * MAXIMUM_WAIT_OBJECTS; - } - break; - } - - return retVal; - - } - - if (dwMilliseconds == 0) return retVal; - - Sleep(10); /* Sleep for 10 ms */ - } - } -} - -/* - * Fill a HANDLE list with handles to wait for. - */ -DWORD -process_set_handles(HANDLE *handles) -{ - DWORD count = 0; - unsigned int i; - - /* Build array of handles to wait for */ - for (i = 0; i < proc_index; i++) { - /* Don't wait on child processes that have already finished */ - if (fake_exits_pending && proc_array[i]->exit_code) - continue; - - handles[count++] = (HANDLE) proc_array[i]->pid; - } - - return count; -} - -/* - * When a process has been waited for, adjust the wait state - * array so that we don't wait for it again - */ -static void -process_adjust_wait_state(sub_process* pproc) -{ - unsigned int i; - - if (!proc_index) - return; - - for (i = 0; i < proc_index; i++) - if (proc_array[i]->pid == pproc->pid) - break; - - if (i < proc_index) { - proc_index--; - if (i != proc_index) - memmove(&proc_array[i], &proc_array[i+1], - (proc_index-i) * sizeof(sub_process*)); - proc_array[proc_index] = NULL; - } -} - -/* - * Waits for any of the registered child processes to finish. - */ -static sub_process * -process_wait_for_any_private(int block, DWORD* pdwWaitStatus) -{ - HANDLE handles[GMAKE_MAXIMUM_WAIT_OBJECTS]; - DWORD retval, which; - unsigned int i; - - if (!proc_index) - return NULL; - - /* build array of handles to wait for */ - for (i = 0; i < proc_index; i++) { - handles[i] = (HANDLE) proc_array[i]->pid; - - if (fake_exits_pending && proc_array[i]->exit_code) - break; - } - - /* wait for someone to exit */ - if (!fake_exits_pending) { - retval = process_wait_for_multiple_objects(proc_index, handles, FALSE, (block ? INFINITE : 0)); - which = retval - WAIT_OBJECT_0; - } else { - fake_exits_pending--; - retval = !WAIT_FAILED; - which = i; - } - - /* If the pointer is not NULL, set the wait status result variable. */ - if (pdwWaitStatus) - *pdwWaitStatus = (retval == GMAKE_WAIT_TIMEOUT) ? WAIT_TIMEOUT : retval; - - /* return pointer to process */ - if ((retval == GMAKE_WAIT_TIMEOUT) || (retval == WAIT_FAILED)) { - return NULL; - } - else { - sub_process* pproc = proc_array[which]; - process_adjust_wait_state(pproc); - return pproc; - } -} - -/* - * Terminate a process. - */ -BOOL -process_kill(HANDLE proc, int signal) -{ - sub_process* pproc = (sub_process*) proc; - pproc->signal = signal; - return (TerminateProcess((HANDLE) pproc->pid, signal)); -} - -/* - * Returns true when we have no more available slots in our process table. - */ -BOOL -process_table_full() -{ - extern int shell_function_pid; - - /* Reserve slots for jobserver_semaphore if we have one and the shell function if not active */ - return(proc_index >= GMAKE_MAXIMUM_WAIT_OBJECTS - jobserver_enabled() - (shell_function_pid == 0)); -} - -/* - * Returns the maximum number of job slots we can support when using the jobserver. - */ -int -process_table_usable_size() -{ - /* Reserve slots for jobserver_semaphore and shell function */ - return(GMAKE_MAXIMUM_WAIT_OBJECTS - 2); -} - -/* - * Returns the actual size of the process table. - */ -int -process_table_actual_size() -{ - return(GMAKE_MAXIMUM_WAIT_OBJECTS); -} - -/* - * Use this function to register processes you wish to wait for by - * calling process_file_io(NULL) or process_wait_any(). This must be done - * because it is possible for callers of this library to reuse the same - * handle for multiple processes launches :-( - */ -void -process_register(HANDLE proc) -{ - assert(proc_index < GMAKE_MAXIMUM_WAIT_OBJECTS); - proc_array[proc_index++] = (sub_process *) proc; -} - -/* - * Public function which works kind of like waitpid(). Wait for any - * of the children to die and return results. To call this function, - * you must do 1 of things: - * - * x = process_easy(...); - * - * or - * - * x = process_init_fd(); - * process_register(x); - * - * or - * - * x = process_init(); - * process_register(x); - * - * You must NOT then call process_pipe_io() because this function is - * not capable of handling automatic notification of any child - * death. - */ - -HANDLE -process_wait_for_any(int block, DWORD* pdwWaitStatus) -{ - sub_process* pproc = process_wait_for_any_private(block, pdwWaitStatus); - - if (!pproc) - return NULL; - else { - /* - * Ouch! can't tell caller if this fails directly. Caller - * will have to use process_last_err() - */ - (void) process_file_io(pproc); - return ((HANDLE) pproc); - } -} - -long -process_signal(HANDLE proc) -{ - if (proc == INVALID_HANDLE_VALUE) return 0; - return (((sub_process *)proc)->signal); -} - -long -process_last_err(HANDLE proc) -{ - if (proc == INVALID_HANDLE_VALUE) return ERROR_INVALID_HANDLE; - return (((sub_process *)proc)->last_err); -} - -long -process_exit_code(HANDLE proc) -{ - if (proc == INVALID_HANDLE_VALUE) return EXIT_FAILURE; - return (((sub_process *)proc)->exit_code); -} - -/* -2006-02: -All the following functions are currently unused. -All of them would crash gmake if called with argument INVALID_HANDLE_VALUE. -Hence whoever wants to use one of this functions must invent and implement -a reasonable error handling for this function. - -char * -process_outbuf(HANDLE proc) -{ - return (((sub_process *)proc)->outp); -} - -char * -process_errbuf(HANDLE proc) -{ - return (((sub_process *)proc)->errp); -} - -int -process_outcnt(HANDLE proc) -{ - return (((sub_process *)proc)->outcnt); -} - -int -process_errcnt(HANDLE proc) -{ - return (((sub_process *)proc)->errcnt); -} - -void -process_pipes(HANDLE proc, int pipes[3]) -{ - pipes[0] = ((sub_process *)proc)->sv_stdin[0]; - pipes[1] = ((sub_process *)proc)->sv_stdout[0]; - pipes[2] = ((sub_process *)proc)->sv_stderr[0]; - return; -} -*/ - - HANDLE -process_init() -{ - sub_process *pproc; - /* - * open file descriptors for attaching stdin/stdout/sterr - */ - HANDLE stdin_pipes[2]; - HANDLE stdout_pipes[2]; - HANDLE stderr_pipes[2]; - SECURITY_ATTRIBUTES inherit; - BYTE sd[SECURITY_DESCRIPTOR_MIN_LENGTH]; - - pproc = malloc(sizeof(*pproc)); - memset(pproc, 0, sizeof(*pproc)); - - /* We can't use NULL for lpSecurityDescriptor because that - uses the default security descriptor of the calling process. - Instead we use a security descriptor with no DACL. This - allows nonrestricted access to the associated objects. */ - - if (!InitializeSecurityDescriptor((PSECURITY_DESCRIPTOR)(&sd), - SECURITY_DESCRIPTOR_REVISION)) { - pproc->last_err = GetLastError(); - pproc->lerrno = E_SCALL; - return((HANDLE)pproc); - } - - inherit.nLength = sizeof(inherit); - inherit.lpSecurityDescriptor = (PSECURITY_DESCRIPTOR)(&sd); - inherit.bInheritHandle = TRUE; - - /* By convention, parent gets pipe[0], and child gets pipe[1]. - This means the READ side of stdin pipe goes into pipe[1] and the - WRITE side of the stdout and stderr pipes go into pipe[1]. */ - if (CreatePipe( &stdin_pipes[1], &stdin_pipes[0], &inherit, 0) == FALSE || - CreatePipe( &stdout_pipes[0], &stdout_pipes[1], &inherit, 0) == FALSE || - CreatePipe( &stderr_pipes[0], &stderr_pipes[1], &inherit, 0) == FALSE) { - - pproc->last_err = GetLastError(); - pproc->lerrno = E_SCALL; - return((HANDLE)pproc); - } - - /* Mark the parent sides of the pipes as non-inheritable. */ - if (SetHandleInformation(stdin_pipes[0], - HANDLE_FLAG_INHERIT, 0) == FALSE || - SetHandleInformation(stdout_pipes[0], - HANDLE_FLAG_INHERIT, 0) == FALSE || - SetHandleInformation(stderr_pipes[0], - HANDLE_FLAG_INHERIT, 0) == FALSE) { - - pproc->last_err = GetLastError(); - pproc->lerrno = E_SCALL; - return((HANDLE)pproc); - } - pproc->sv_stdin[0] = (intptr_t) stdin_pipes[0]; - pproc->sv_stdin[1] = (intptr_t) stdin_pipes[1]; - pproc->sv_stdout[0] = (intptr_t) stdout_pipes[0]; - pproc->sv_stdout[1] = (intptr_t) stdout_pipes[1]; - pproc->sv_stderr[0] = (intptr_t) stderr_pipes[0]; - pproc->sv_stderr[1] = (intptr_t) stderr_pipes[1]; - - pproc->using_pipes = 1; - - pproc->lerrno = 0; - - return((HANDLE)pproc); -} - - - HANDLE -process_init_fd(HANDLE stdinh, HANDLE stdouth, HANDLE stderrh) -{ - sub_process *pproc; - - pproc = malloc(sizeof(*pproc)); - if (pproc) { - memset(pproc, 0, sizeof(*pproc)); - - /* - * Just pass the provided file handles to the 'child - * side' of the pipe, bypassing pipes altogether. - */ - pproc->sv_stdin[1] = (intptr_t) stdinh; - pproc->sv_stdout[1] = (intptr_t) stdouth; - pproc->sv_stderr[1] = (intptr_t) stderrh; - - pproc->last_err = pproc->lerrno = 0; - } - - return((HANDLE)pproc); -} - - -static HANDLE -find_file(const char *exec_path, const char *path_var, - char *full_fname, DWORD full_len) -{ - HANDLE exec_handle; - char *fname; - char *ext; - DWORD req_len; - int i; - static const char *extensions[] = - /* Should .com come before no-extension case? */ - { ".exe", ".cmd", ".bat", "", ".com", NULL }; - - fname = xmalloc(strlen(exec_path) + 5); - strcpy(fname, exec_path); - ext = fname + strlen(fname); - - for (i = 0; extensions[i]; i++) { - strcpy(ext, extensions[i]); - if (((req_len = SearchPath (path_var, fname, NULL, full_len, - full_fname, NULL)) > 0 - /* For compatibility with previous code, which - used OpenFile, and with Windows operation in - general, also look in various default - locations, such as Windows directory and - Windows System directory. Warning: this also - searches PATH in the Make's environment, which - might not be what the Makefile wants, but it - seems to be OK as a fallback, after the - previous SearchPath failed to find on child's - PATH. */ - || (req_len = SearchPath (NULL, fname, NULL, full_len, - full_fname, NULL)) > 0) - && req_len <= full_len - && (exec_handle = - CreateFile(full_fname, - GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL)) != INVALID_HANDLE_VALUE) { - free(fname); - return(exec_handle); - } - } - - free(fname); - return INVALID_HANDLE_VALUE; -} - -/* - * Return non-zero of FNAME specifies a batch file and its name - * includes embedded whitespace. - */ - -static int -batch_file_with_spaces(const char *fname) -{ - size_t fnlen = strlen(fname); - - return (fnlen > 4 - && (_strnicmp(fname + fnlen - 4, ".bat", 4) == 0 - || _strnicmp(fname + fnlen - 4, ".cmd", 4) == 0) - /* The set of characters in the 2nd arg to strpbrk - should be the same one used by make_command_line - below to decide whether an argv[] element needs - quoting. */ - && strpbrk(fname, " \t") != NULL); -} - - -/* - * Description: Create the child process to be helped - * - * Returns: success <=> 0 - * - * Notes/Dependencies: - */ -long -process_begin( - HANDLE proc, - char **argv, - char **envp, - char *exec_path, - char *as_user) -{ - sub_process *pproc = (sub_process *)proc; - char *shell_name = 0; - int file_not_found=0; - HANDLE exec_handle; - char exec_fname[MAX_PATH]; - const char *path_var = NULL; - char **ep; - char buf[MAX_PATH]; - DWORD bytes_returned; - DWORD flags; - char *command_line; - STARTUPINFO startInfo; - PROCESS_INFORMATION procInfo; - char *envblk=NULL; - size_t envsize_needed = 0; - int pass_null_exec_path = 0; - - /* - * Shell script detection... if the exec_path starts with #! then - * we want to exec shell-script-name exec-path, not just exec-path - * NT doesn't recognize #!/bin/sh or #!/etc/Tivoli/bin/perl. We do not - * hard-code the path to the shell or perl or whatever: Instead, we - * assume it's in the path somewhere (generally, the NT tools - * bin directory) - */ - - /* Use the Makefile's value of PATH to look for the program to - execute, because it could be different from Make's PATH - (e.g., if the target sets its own value. */ - if (envp) - for (ep = envp; *ep; ep++) { - if (strncmp (*ep, "PATH=", 5) == 0 - || strncmp (*ep, "Path=", 5) == 0) { - path_var = *ep + 5; - break; - } - } - exec_handle = find_file(exec_path, path_var, - exec_fname, sizeof(exec_fname)); - - /* - * If we couldn't open the file, just assume that Windows will be - * somehow able to find and execute it. If the first character - * of the command is '/', assume they set SHELL to a Unixy shell - * that have some magic mounts known only to it, and run the whole - * command via $SHELL -c "COMMAND" instead. - */ - if (exec_handle == INVALID_HANDLE_VALUE) { - if (exec_path[0] == '/') { - char *new_argv0; - char **argvi = argv; - size_t arglen = 0; - - strcpy(buf, variable_expand ("$(SHELL)")); - shell_name = &buf[0]; - strcpy(exec_fname, "-c"); - /* Construct a single command string in argv[0]. */ - while (*argvi) { - arglen += strlen(*argvi) + 1; - argvi++; - } - new_argv0 = xmalloc(arglen + 1); - new_argv0[0] = '\0'; - for (argvi = argv; *argvi; argvi++) { - strcat(new_argv0, *argvi); - strcat(new_argv0, " "); - } - /* Remove the extra blank at the end. */ - new_argv0[arglen-1] = '\0'; - free(argv[0]); - argv[0] = new_argv0; - argv[1] = NULL; - } - else - file_not_found++; - } - else { - /* Attempt to read the first line of the file */ - if (ReadFile( exec_handle, - buf, sizeof(buf) - 1, /* leave room for trailing NULL */ - &bytes_returned, 0) == FALSE || bytes_returned < 2) { - - pproc->last_err = GetLastError(); - pproc->lerrno = E_IO; - CloseHandle(exec_handle); - return(-1); - } - if (buf[0] == '#' && buf[1] == '!') { - /* - * This is a shell script... Change the command line from - * exec_path args to shell_name exec_path args - */ - char *p; - - /* Make sure buf is NULL terminated */ - buf[bytes_returned] = 0; - /* - * Depending on the file system type, etc. the first line - * of the shell script may end with newline or newline-carriage-return - * Whatever it ends with, cut it off. - */ - p= strchr(buf, '\n'); - if (p) - *p = 0; - p = strchr(buf, '\r'); - if (p) - *p = 0; - - /* - * Find base name of shell - */ - shell_name = strrchr( buf, '/'); - if (shell_name) { - shell_name++; - } else { - shell_name = &buf[2];/* skipping "#!" */ - } - - } - CloseHandle(exec_handle); - } - - flags = 0; - - if (file_not_found) - command_line = make_command_line( shell_name, exec_path, argv); - else { - /* If exec_fname includes whitespace, CreateProcess - behaves erratically and unreliably, and often fails - if argv[0] also includes whitespace (and thus will - be quoted by make_command_line below). So in that - case, we don't pass exec_fname as the 1st arg to - CreateProcess, but instead replace argv[0] with - exec_fname (to keep its leading directories and - extension as found by find_file), and pass NULL to - CreateProcess as its 1st arg. This works around - the bugs in CreateProcess, which are probably - caused by its passing the command to cmd.exe with - some incorrect quoting. */ - if (!shell_name - && batch_file_with_spaces(exec_fname) - && _stricmp(exec_path, argv[0]) == 0) { - char *new_argv, *p; - char **argvi; - size_t arglen; - int i; - pass_null_exec_path = 1; - /* Rewrite argv[] replacing argv[0] with exec_fname. */ - for (argvi = argv + 1, arglen = strlen(exec_fname) + 1; - *argvi; - argvi++) { - arglen += strlen(*argvi) + 1; - } - new_argv = xmalloc(arglen); - p = strcpy(new_argv, exec_fname) + strlen(exec_fname) + 1; - for (argvi = argv + 1, i = 1; *argvi; argvi++, i++) { - strcpy(p, *argvi); - argv[i] = p; - p += strlen(*argvi) + 1; - } - argv[i] = NULL; - free (argv[0]); - argv[0] = new_argv; - } - command_line = make_command_line( shell_name, exec_fname, argv); - } - - if ( command_line == NULL ) { - pproc->last_err = 0; - pproc->lerrno = E_NO_MEM; - return(-1); - } - - if (envp) { - if (arr2envblk(envp, &envblk, &envsize_needed) == FALSE) { - pproc->lerrno = E_NO_MEM; - free( command_line ); - if ((pproc->last_err == ERROR_INVALID_PARAMETER - || pproc->last_err == ERROR_MORE_DATA) - && envsize_needed > 32*1024) { - fprintf (stderr, "CreateProcess failed, probably because environment is too large (%Iu bytes).\n", - envsize_needed); - } - pproc->last_err = 0; - return(-1); - } - } - - if (shell_name || file_not_found || pass_null_exec_path) { - exec_path = 0; /* Search for the program in %Path% */ - } else { - exec_path = exec_fname; - } - - /* - * Set up inherited stdin, stdout, stderr for child - */ - memset(&startInfo, '\0', sizeof(startInfo)); - GetStartupInfo(&startInfo); - startInfo.dwFlags = STARTF_USESTDHANDLES; - startInfo.lpReserved = 0; - startInfo.cbReserved2 = 0; - startInfo.lpReserved2 = 0; - startInfo.hStdInput = (HANDLE)pproc->sv_stdin[1]; - startInfo.hStdOutput = (HANDLE)pproc->sv_stdout[1]; - startInfo.hStdError = (HANDLE)pproc->sv_stderr[1]; - - if (as_user) { - free(envblk); - return -1; - } else { - DB (DB_JOBS, ("CreateProcess(%s,%s,...)\n", - exec_path ? exec_path : "NULL", - command_line ? command_line : "NULL")); - if (CreateProcess( - exec_path, - command_line, - NULL, - 0, /* default security attributes for thread */ - TRUE, /* inherit handles (e.g. helper pipes, oserv socket) */ - flags, - envblk, - 0, /* default starting directory */ - &startInfo, - &procInfo) == FALSE) { - - pproc->last_err = GetLastError(); - pproc->lerrno = E_FORK; - fprintf(stderr, "process_begin: CreateProcess(%s, %s, ...) failed.\n", - exec_path ? exec_path : "NULL", command_line); - free(envblk); - free( command_line ); - return(-1); - } - } - - pproc->pid = (pid_t)procInfo.hProcess; - /* Close the thread handle -- we'll just watch the process */ - CloseHandle(procInfo.hThread); - - /* Close the halves of the pipes we don't need */ - if ((HANDLE)pproc->sv_stdin[1] != INVALID_HANDLE_VALUE) - CloseHandle((HANDLE)pproc->sv_stdin[1]); - if ((HANDLE)pproc->sv_stdout[1] != INVALID_HANDLE_VALUE) - CloseHandle((HANDLE)pproc->sv_stdout[1]); - if ((HANDLE)pproc->sv_stderr[1] != INVALID_HANDLE_VALUE) - CloseHandle((HANDLE)pproc->sv_stderr[1]); - pproc->sv_stdin[1] = 0; - pproc->sv_stdout[1] = 0; - pproc->sv_stderr[1] = 0; - - free( command_line ); - free(envblk); - pproc->lerrno=0; - return 0; -} - - - -#if 0 /* unused */ -static DWORD -proc_stdin_thread(sub_process *pproc) -{ - DWORD in_done; - for (;;) { - if (WriteFile( (HANDLE) pproc->sv_stdin[0], pproc->inp, pproc->incnt, - &in_done, NULL) == FALSE) - _endthreadex(0); - /* This if should never be true for anonymous pipes, but gives - us a chance to change I/O mechanisms later. */ - if (in_done < pproc->incnt) { - pproc->incnt -= in_done; - pproc->inp += in_done; - } else { - _endthreadex(0); - } - } - return 0; /* for compiler warnings only.. not reached. */ -} - -static DWORD -proc_stdout_thread(sub_process *pproc) -{ - DWORD bufsize = 1024; - char c; - DWORD nread; - pproc->outp = malloc(bufsize); - if (pproc->outp == NULL) - _endthreadex(0); - pproc->outcnt = 0; - - for (;;) { - if (ReadFile( (HANDLE)pproc->sv_stdout[0], &c, 1, &nread, NULL) - == FALSE) { -/* map_windows32_error_to_string(GetLastError());*/ - _endthreadex(0); - } - if (nread == 0) - _endthreadex(0); - if (pproc->outcnt + nread > bufsize) { - bufsize += nread + 512; - pproc->outp = realloc(pproc->outp, bufsize); - if (pproc->outp == NULL) { - pproc->outcnt = 0; - _endthreadex(0); - } - } - pproc->outp[pproc->outcnt++] = c; - } - return 0; -} - -static DWORD -proc_stderr_thread(sub_process *pproc) -{ - DWORD bufsize = 1024; - char c; - DWORD nread; - pproc->errp = malloc(bufsize); - if (pproc->errp == NULL) - _endthreadex(0); - pproc->errcnt = 0; - - for (;;) { - if (ReadFile( (HANDLE)pproc->sv_stderr[0], &c, 1, &nread, NULL) == FALSE) { - map_windows32_error_to_string(GetLastError()); - _endthreadex(0); - } - if (nread == 0) - _endthreadex(0); - if (pproc->errcnt + nread > bufsize) { - bufsize += nread + 512; - pproc->errp = realloc(pproc->errp, bufsize); - if (pproc->errp == NULL) { - pproc->errcnt = 0; - _endthreadex(0); - } - } - pproc->errp[pproc->errcnt++] = c; - } - return 0; -} - - -/* - * Purpose: collects output from child process and returns results - * - * Description: - * - * Returns: - * - * Notes/Dependencies: - */ - long -process_pipe_io( - HANDLE proc, - char *stdin_data, - int stdin_data_len) -{ - sub_process *pproc = (sub_process *)proc; - bool_t stdin_eof = FALSE, stdout_eof = FALSE, stderr_eof = FALSE; - HANDLE childhand = (HANDLE) pproc->pid; - HANDLE tStdin = NULL, tStdout = NULL, tStderr = NULL; - unsigned int dwStdin, dwStdout, dwStderr; - HANDLE wait_list[4]; - DWORD wait_count; - DWORD wait_return; - HANDLE ready_hand; - bool_t child_dead = FALSE; - BOOL GetExitCodeResult; - - /* - * Create stdin thread, if needed - */ - pproc->inp = stdin_data; - pproc->incnt = stdin_data_len; - if (!pproc->inp) { - stdin_eof = TRUE; - CloseHandle((HANDLE)pproc->sv_stdin[0]); - pproc->sv_stdin[0] = 0; - } else { - tStdin = (HANDLE) _beginthreadex( 0, 1024, - (unsigned (__stdcall *) (void *))proc_stdin_thread, - pproc, 0, &dwStdin); - if (tStdin == 0) { - pproc->last_err = GetLastError(); - pproc->lerrno = E_SCALL; - goto done; - } - } - - /* - * Assume child will produce stdout and stderr - */ - tStdout = (HANDLE) _beginthreadex( 0, 1024, - (unsigned (__stdcall *) (void *))proc_stdout_thread, pproc, 0, - &dwStdout); - tStderr = (HANDLE) _beginthreadex( 0, 1024, - (unsigned (__stdcall *) (void *))proc_stderr_thread, pproc, 0, - &dwStderr); - - if (tStdout == 0 || tStderr == 0) { - - pproc->last_err = GetLastError(); - pproc->lerrno = E_SCALL; - goto done; - } - - - /* - * Wait for all I/O to finish and for the child process to exit - */ - - while (!stdin_eof || !stdout_eof || !stderr_eof || !child_dead) { - wait_count = 0; - if (!stdin_eof) { - wait_list[wait_count++] = tStdin; - } - if (!stdout_eof) { - wait_list[wait_count++] = tStdout; - } - if (!stderr_eof) { - wait_list[wait_count++] = tStderr; - } - if (!child_dead) { - wait_list[wait_count++] = childhand; - } - - wait_return = WaitForMultipleObjects(wait_count, wait_list, - FALSE, /* don't wait for all: one ready will do */ - child_dead? 1000 :INFINITE); /* after the child dies, subthreads have - one second to collect all remaining output */ - - if (wait_return == WAIT_FAILED) { -/* map_windows32_error_to_string(GetLastError());*/ - pproc->last_err = GetLastError(); - pproc->lerrno = E_SCALL; - goto done; - } - - ready_hand = wait_list[wait_return - WAIT_OBJECT_0]; - - if (ready_hand == tStdin) { - CloseHandle((HANDLE)pproc->sv_stdin[0]); - pproc->sv_stdin[0] = 0; - CloseHandle(tStdin); - tStdin = 0; - stdin_eof = TRUE; - - } else if (ready_hand == tStdout) { - - CloseHandle((HANDLE)pproc->sv_stdout[0]); - pproc->sv_stdout[0] = 0; - CloseHandle(tStdout); - tStdout = 0; - stdout_eof = TRUE; - - } else if (ready_hand == tStderr) { - - CloseHandle((HANDLE)pproc->sv_stderr[0]); - pproc->sv_stderr[0] = 0; - CloseHandle(tStderr); - tStderr = 0; - stderr_eof = TRUE; - - } else if (ready_hand == childhand) { - - DWORD ierr; - GetExitCodeResult = GetExitCodeProcess(childhand, &ierr); - if (ierr == CONTROL_C_EXIT) { - pproc->signal = SIGINT; - } else { - pproc->exit_code = ierr; - } - if (GetExitCodeResult == FALSE) { - pproc->last_err = GetLastError(); - pproc->lerrno = E_SCALL; - goto done; - } - child_dead = TRUE; - - } else { - - /* ?? Got back a handle we didn't query ?? */ - pproc->last_err = 0; - pproc->lerrno = E_FAIL; - goto done; - } - } - - done: - if (tStdin != 0) - CloseHandle(tStdin); - if (tStdout != 0) - CloseHandle(tStdout); - if (tStderr != 0) - CloseHandle(tStderr); - - if (pproc->lerrno) - return(-1); - else - return(0); - -} -#endif /* unused */ - -/* - * Purpose: collects output from child process and returns results - * - * Description: - * - * Returns: - * - * Notes/Dependencies: - */ - long -process_file_io( - HANDLE proc) -{ - sub_process *pproc; - HANDLE childhand; - DWORD wait_return; - BOOL GetExitCodeResult; - DWORD ierr; - - if (proc == NULL) - pproc = process_wait_for_any_private(1, 0); - else - pproc = (sub_process *)proc; - - /* some sort of internal error */ - if (!pproc) - return -1; - - childhand = (HANDLE) pproc->pid; - - /* - * This function is poorly named, and could also be used just to wait - * for child death if you're doing your own pipe I/O. If that is - * the case, close the pipe handles here. - */ - if (pproc->sv_stdin[0]) { - CloseHandle((HANDLE)pproc->sv_stdin[0]); - pproc->sv_stdin[0] = 0; - } - if (pproc->sv_stdout[0]) { - CloseHandle((HANDLE)pproc->sv_stdout[0]); - pproc->sv_stdout[0] = 0; - } - if (pproc->sv_stderr[0]) { - CloseHandle((HANDLE)pproc->sv_stderr[0]); - pproc->sv_stderr[0] = 0; - } - - /* - * Wait for the child process to exit - */ - - wait_return = WaitForSingleObject(childhand, INFINITE); - - if (wait_return != WAIT_OBJECT_0) { -/* map_windows32_error_to_string(GetLastError());*/ - pproc->last_err = GetLastError(); - pproc->lerrno = E_SCALL; - goto done2; - } - - GetExitCodeResult = GetExitCodeProcess(childhand, &ierr); - if (ierr == CONTROL_C_EXIT) { - pproc->signal = SIGINT; - } else { - pproc->exit_code = ierr; - } - if (GetExitCodeResult == FALSE) { - pproc->last_err = GetLastError(); - pproc->lerrno = E_SCALL; - } - -done2: - if (pproc->lerrno) - return(-1); - else - return(0); - -} - -/* - * Description: Clean up any leftover handles, etc. It is up to the - * caller to manage and free the input, output, and stderr buffers. - */ - void -process_cleanup( - HANDLE proc) -{ - sub_process *pproc = (sub_process *)proc; - int i; - - if (pproc->using_pipes) { - for (i= 0; i <= 1; i++) { - if ((HANDLE)pproc->sv_stdin[i] - && (HANDLE)pproc->sv_stdin[i] != INVALID_HANDLE_VALUE) - CloseHandle((HANDLE)pproc->sv_stdin[i]); - if ((HANDLE)pproc->sv_stdout[i] - && (HANDLE)pproc->sv_stdout[i] != INVALID_HANDLE_VALUE) - CloseHandle((HANDLE)pproc->sv_stdout[i]); - if ((HANDLE)pproc->sv_stderr[i] - && (HANDLE)pproc->sv_stderr[i] != INVALID_HANDLE_VALUE) - CloseHandle((HANDLE)pproc->sv_stderr[i]); - } - } - if ((HANDLE)pproc->pid) - CloseHandle((HANDLE)pproc->pid); - - free(pproc); -} - - -/* - * Description: - * Create a command line buffer to pass to CreateProcess - * - * Returns: the buffer or NULL for failure - * Shell case: sh_name a:/full/path/to/script argv[1] argv[2] ... - * Otherwise: argv[0] argv[1] argv[2] ... - * - * Notes/Dependencies: - * CreateProcess does not take an argv, so this command creates a - * command line for the executable. - */ - -static char * -make_command_line( char *shell_name, char *full_exec_path, char **argv) -{ - int argc = 0; - char** argvi; - int* enclose_in_quotes = NULL; - int* enclose_in_quotes_i; - size_t bytes_required = 0; - char* command_line; - char* command_line_i; - int have_sh = 0; /* HAVE_CYGWIN_SHELL */ - int cygwin_mode = 0; /* HAVE_CYGWIN_SHELL */ - -#ifdef HAVE_CYGWIN_SHELL - cygwin_mode = 1; -#endif - - if (shell_name && full_exec_path) { - have_sh = cygwin_mode && strstr(full_exec_path, "sh.exe"); - bytes_required - = strlen(shell_name) + 1 + strlen(full_exec_path); - /* - * Skip argv[0] if any, when shell_name is given. - * The special case of "-c" in full_exec_path means - * argv[0] is not the shell name, but the command string - * to pass to the shell. - */ - if (*argv && strcmp(full_exec_path, "-c")) argv++; - /* - * Add one for the intervening space. - */ - if (*argv) bytes_required++; - } - - argvi = argv; - while (*(argvi++)) argc++; - - if (argc) { - enclose_in_quotes = (int*) calloc(1, argc * sizeof(int)); - - if (!enclose_in_quotes) { - return NULL; - } - } - - /* We have to make one pass through each argv[i] to see if we need - * to enclose it in ", so we might as well figure out how much - * memory we'll need on the same pass. - */ - - argvi = argv; - enclose_in_quotes_i = enclose_in_quotes; - while(*argvi) { - char* p = *argvi; - unsigned int backslash_count = 0; - - /* - * We have to enclose empty arguments in ". - */ - if (!(*p)) *enclose_in_quotes_i = 1; - - while(*p) { - switch (*p) { - case '\"': - /* - * We have to insert a backslash for each " - * and each \ that precedes the ". - */ - bytes_required += (backslash_count + 1); - backslash_count = 0; - break; - -#if !defined(HAVE_MKS_SHELL) && !defined(HAVE_CYGWIN_SHELL) - case '\\': - backslash_count++; - break; -#endif - /* - * At one time we set *enclose_in_quotes_i for '*' or '?' to suppress - * wildcard expansion in programs linked with MSVC's SETARGV.OBJ so - * that argv in always equals argv out. This was removed. Say you have - * such a program named glob.exe. You enter - * glob '*' - * at the sh command prompt. Obviously the intent is to make glob do the - * wildcarding instead of sh. If we set *enclose_in_quotes_i for '*' or '?', - * then the command line that glob would see would be - * glob "*" - * and the _setargv in SETARGV.OBJ would _not_ expand the *. - */ - case ' ': - case '\t': - *enclose_in_quotes_i = 1; - /* fall through */ - - default: - backslash_count = 0; - break; - } - - /* - * Add one for each character in argv[i]. - */ - bytes_required++; - - p++; - } - - if (*enclose_in_quotes_i) { - /* - * Add one for each enclosing ", - * and one for each \ that precedes the - * closing ". - */ - bytes_required += (backslash_count + 2); - } - - /* - * Add one for the intervening space. - */ - if (*(++argvi)) bytes_required++; - enclose_in_quotes_i++; - } - - /* - * Add one for the terminating NULL. - */ - bytes_required++; - - command_line = (char*) malloc(bytes_required); - - if (!command_line) { - free(enclose_in_quotes); - return NULL; - } - - command_line_i = command_line; - - if (shell_name && full_exec_path) { - while(*shell_name) { - *(command_line_i++) = *(shell_name++); - } - - *(command_line_i++) = ' '; - - while(*full_exec_path) { - *(command_line_i++) = *(full_exec_path++); - } - - if (*argv) { - *(command_line_i++) = ' '; - } - } - - argvi = argv; - enclose_in_quotes_i = enclose_in_quotes; - - while(*argvi) { - char* p = *argvi; - unsigned int backslash_count = 0; - - if (*enclose_in_quotes_i) { - *(command_line_i++) = '\"'; - } - - while(*p) { - if (*p == '\"') { - if (cygwin_mode && have_sh) { /* HAVE_CYGWIN_SHELL */ - /* instead of a \", cygwin likes "" */ - *(command_line_i++) = '\"'; - } else { - - /* - * We have to insert a backslash for the " - * and each \ that precedes the ". - */ - backslash_count++; - - while(backslash_count) { - *(command_line_i++) = '\\'; - backslash_count--; - }; - } -#if !defined(HAVE_MKS_SHELL) && !defined(HAVE_CYGWIN_SHELL) - } else if (*p == '\\') { - backslash_count++; - } else { - backslash_count = 0; -#endif - } - - /* - * Copy the character. - */ - *(command_line_i++) = *(p++); - } - - if (*enclose_in_quotes_i) { -#if !defined(HAVE_MKS_SHELL) && !defined(HAVE_CYGWIN_SHELL) - /* - * Add one \ for each \ that precedes the - * closing ". - */ - while(backslash_count--) { - *(command_line_i++) = '\\'; - }; -#endif - *(command_line_i++) = '\"'; - } - - /* - * Append an intervening space. - */ - if (*(++argvi)) { - *(command_line_i++) = ' '; - } - - enclose_in_quotes_i++; - } - - /* - * Append the terminating NULL. - */ - *command_line_i = '\0'; - - free(enclose_in_quotes); - return command_line; -} - -/* - * Description: Given an argv and optional envp, launch the process - * using the default stdin, stdout, and stderr handles. - * Also, register process so that process_wait_for_any_private() - * can be used via process_file_io(NULL) or - * process_wait_for_any(). - * - * Returns: - * - * Notes/Dependencies: - */ -HANDLE -process_easy( - char **argv, - char **envp, - int outfd, - int errfd) -{ - HANDLE hIn = INVALID_HANDLE_VALUE; - HANDLE hOut = INVALID_HANDLE_VALUE; - HANDLE hErr = INVALID_HANDLE_VALUE; - HANDLE hProcess, tmpIn, tmpOut, tmpErr; - DWORD e; - - if (process_table_full()) { - DB (DB_JOBS, ("process_easy: All process slots used up\n")); - return INVALID_HANDLE_VALUE; - } - /* Standard handles returned by GetStdHandle can be NULL or - INVALID_HANDLE_VALUE if the parent process closed them. If that - happens, we open the null device and pass its handle to - CreateProcess as the corresponding handle to inherit. */ - tmpIn = GetStdHandle(STD_INPUT_HANDLE); - if (DuplicateHandle(GetCurrentProcess(), - tmpIn, - GetCurrentProcess(), - &hIn, - 0, - TRUE, - DUPLICATE_SAME_ACCESS) == FALSE) { - if ((e = GetLastError()) == ERROR_INVALID_HANDLE) { - tmpIn = CreateFile("NUL", GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (tmpIn != INVALID_HANDLE_VALUE - && DuplicateHandle(GetCurrentProcess(), - tmpIn, - GetCurrentProcess(), - &hIn, - 0, - TRUE, - DUPLICATE_SAME_ACCESS) == FALSE) - CloseHandle(tmpIn); - } - if (hIn == INVALID_HANDLE_VALUE) { - fprintf(stderr, "process_easy: DuplicateHandle(In) failed (e=%ld)\n", e); - return INVALID_HANDLE_VALUE; - } - } - if (outfd >= 0) - tmpOut = (HANDLE)_get_osfhandle (outfd); - else - tmpOut = GetStdHandle (STD_OUTPUT_HANDLE); - if (DuplicateHandle(GetCurrentProcess(), - tmpOut, - GetCurrentProcess(), - &hOut, - 0, - TRUE, - DUPLICATE_SAME_ACCESS) == FALSE) { - if ((e = GetLastError()) == ERROR_INVALID_HANDLE) { - tmpOut = CreateFile("NUL", GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (tmpOut != INVALID_HANDLE_VALUE - && DuplicateHandle(GetCurrentProcess(), - tmpOut, - GetCurrentProcess(), - &hOut, - 0, - TRUE, - DUPLICATE_SAME_ACCESS) == FALSE) - CloseHandle(tmpOut); - } - if (hOut == INVALID_HANDLE_VALUE) { - fprintf(stderr, "process_easy: DuplicateHandle(Out) failed (e=%ld)\n", e); - return INVALID_HANDLE_VALUE; - } - } - if (errfd >= 0) - tmpErr = (HANDLE)_get_osfhandle (errfd); - else - tmpErr = GetStdHandle(STD_ERROR_HANDLE); - if (DuplicateHandle(GetCurrentProcess(), - tmpErr, - GetCurrentProcess(), - &hErr, - 0, - TRUE, - DUPLICATE_SAME_ACCESS) == FALSE) { - if ((e = GetLastError()) == ERROR_INVALID_HANDLE) { - tmpErr = CreateFile("NUL", GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (tmpErr != INVALID_HANDLE_VALUE - && DuplicateHandle(GetCurrentProcess(), - tmpErr, - GetCurrentProcess(), - &hErr, - 0, - TRUE, - DUPLICATE_SAME_ACCESS) == FALSE) - CloseHandle(tmpErr); - } - if (hErr == INVALID_HANDLE_VALUE) { - fprintf(stderr, "process_easy: DuplicateHandle(Err) failed (e=%ld)\n", e); - return INVALID_HANDLE_VALUE; - } - } - - hProcess = process_init_fd(hIn, hOut, hErr); - - if (process_begin(hProcess, argv, envp, argv[0], NULL)) { - fake_exits_pending++; - /* process_begin() failed: make a note of that. */ - if (!((sub_process*) hProcess)->last_err) - ((sub_process*) hProcess)->last_err = -1; - ((sub_process*) hProcess)->exit_code = process_last_err(hProcess); - - /* close up unused handles */ - if (hIn != INVALID_HANDLE_VALUE) - CloseHandle(hIn); - if (hOut != INVALID_HANDLE_VALUE) - CloseHandle(hOut); - if (hErr != INVALID_HANDLE_VALUE) - CloseHandle(hErr); - } - - process_register(hProcess); - - return hProcess; -} diff --git a/third_party/make/src/w32/subproc/w32err.c b/third_party/make/src/w32/subproc/w32err.c deleted file mode 100644 index 5ae30435e..000000000 --- a/third_party/make/src/w32/subproc/w32err.c +++ /dev/null @@ -1,85 +0,0 @@ -/* Error handling for Windows -Copyright (C) 1996-2020 Free Software Foundation, Inc. -This file is part of GNU Make. - -GNU Make 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. - -GNU Make 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 . */ - -#include -#include -#include "makeint.h" -#include "w32err.h" - -/* - * Description: the windows32 version of perror() - * - * Returns: a pointer to a static error - * - * Notes/Dependencies: I got this from - * comp.os.ms-windows.programmer.win32 - */ -const char * -map_windows32_error_to_string (DWORD ercode) { -/* - * We used to have an MSVC-specific '__declspec (thread)' qualifier - * here, with the following comment: - * - * __declspec (thread) necessary if you will use multiple threads on MSVC - * - * However, Make was never multithreaded on Windows (except when - * Ctrl-C is hit, in which case the main thread is stopped - * immediately, so it doesn't matter in this context). The functions - * on sub_proc.c that started and stopped additional threads were - * never used, and are now #ifdef'ed away. Until we need more than - * one thread, we have no problems with the following buffer being - * static. (If and when we do need it to be in thread-local storage, - * the corresponding GCC qualifier is '__thread'.) - */ - static char szMessageBuffer[128]; - /* Fill message buffer with a default message in - * case FormatMessage fails - */ - wsprintf (szMessageBuffer, "Error %ld\n", ercode); - - /* - * Special code for winsock error handling. - */ - if (ercode > WSABASEERR) { -#if 0 - HMODULE hModule = GetModuleHandle("wsock32"); - if (hModule != NULL) { - FormatMessage(FORMAT_MESSAGE_FROM_HMODULE, - hModule, - ercode, - LANG_NEUTRAL, - szMessageBuffer, - sizeof(szMessageBuffer), - NULL); - FreeLibrary(hModule); - } -#else - O (fatal, NILF, szMessageBuffer); -#endif - } else { - /* - * Default system message handling - */ - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - ercode, - LANG_NEUTRAL, - szMessageBuffer, - sizeof(szMessageBuffer), - NULL); - } - return szMessageBuffer; -} diff --git a/third_party/make/src/w32/w32os.c b/third_party/make/src/w32/w32os.c deleted file mode 100644 index 6124d22ba..000000000 --- a/third_party/make/src/w32/w32os.c +++ /dev/null @@ -1,177 +0,0 @@ -/* Windows32-based operating system interface for GNU Make. -Copyright (C) 2016-2020 Free Software Foundation, Inc. -This file is part of GNU Make. - -GNU Make 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. - -GNU Make 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 . */ - -#include - -#include "makeint.h" -#include "os.h" -#include "pathstuff.h" -#include "sub_proc.h" -#include "w32err.h" - -/* This section provides OS-specific functions to support the jobserver. */ - -static char jobserver_semaphore_name[MAX_PATH + 1]; -static HANDLE jobserver_semaphore = NULL; - -unsigned int jobserver_setup(int slots) { - /* sub_proc.c is limited in the number of objects it can wait for. */ - - if (slots > process_table_usable_size()) { - slots = process_table_usable_size(); - DB(DB_JOBS, (_("Jobserver slots limited to %d\n"), slots)); - } - - sprintf(jobserver_semaphore_name, "gmake_semaphore_%d", _getpid()); - - jobserver_semaphore = - CreateSemaphore(NULL, /* Use default security descriptor */ - slots, /* Initial count */ - slots, /* Maximum count */ - jobserver_semaphore_name); /* Semaphore name */ - - if (jobserver_semaphore == NULL) { - DWORD err = GetLastError(); - const char *estr = map_windows32_error_to_string(err); - ONS(fatal, NILF, _("creating jobserver semaphore: (Error %ld: %s)"), err, - estr); - } - - return 1; -} - -unsigned int jobserver_parse_auth(const char *auth) { - jobserver_semaphore = - OpenSemaphore(SEMAPHORE_ALL_ACCESS, /* Semaphore access setting */ - FALSE, /* Child processes DON'T inherit */ - auth); /* Semaphore name */ - - if (jobserver_semaphore == NULL) { - DWORD err = GetLastError(); - const char *estr = map_windows32_error_to_string(err); - fatal(NILF, strlen(auth) + INTSTR_LENGTH + strlen(estr), - _("internal error: unable to open jobserver semaphore '%s': (Error " - "%ld: %s)"), - auth, err, estr); - } - DB(DB_JOBS, (_("Jobserver client (semaphore %s)\n"), auth)); - - return 1; -} - -char *jobserver_get_auth() { - return xstrdup(jobserver_semaphore_name); -} - -unsigned int jobserver_enabled() { - return jobserver_semaphore != NULL; -} - -/* Close jobserver semaphore */ -void jobserver_clear() { - if (jobserver_semaphore != NULL) { - CloseHandle(jobserver_semaphore); - jobserver_semaphore = NULL; - } -} - -void jobserver_release(int is_fatal) { - if (!ReleaseSemaphore(jobserver_semaphore, /* handle to semaphore */ - 1, /* increase count by one */ - NULL)) /* not interested in previous count */ - { - if (is_fatal) { - DWORD err = GetLastError(); - const char *estr = map_windows32_error_to_string(err); - ONS(fatal, NILF, _("release jobserver semaphore: (Error %ld: %s)"), err, - estr); - } - perror_with_name("release_jobserver_semaphore", ""); - } -} - -unsigned int jobserver_acquire_all() { - unsigned int tokens = 0; - while (1) { - DWORD dwEvent = - WaitForSingleObject(jobserver_semaphore, /* Handle to semaphore */ - 0); /* DON'T wait on semaphore */ - - if (dwEvent != WAIT_OBJECT_0) return tokens; - - ++tokens; - } -} - -void jobserver_signal() { -} - -void jobserver_pre_child(int recursive) { -} - -void jobserver_post_child(int recursive) { -} - -void jobserver_pre_acquire() { -} - -/* Returns 1 if we got a token, or 0 if a child has completed. - The Windows implementation doesn't support load detection. */ -unsigned int jobserver_acquire(int timeout) { - HANDLE *handles; - DWORD dwHandleCount; - DWORD dwEvent; - - handles = xmalloc(process_table_actual_size() * sizeof(HANDLE)); - - /* Add jobserver semaphore to first slot. */ - handles[0] = jobserver_semaphore; - - /* Build array of handles to wait for. */ - dwHandleCount = 1 + process_set_handles(&handles[1]); - - dwEvent = process_wait_for_multiple_objects( - dwHandleCount, /* number of objects in array */ - handles, /* array of objects */ - FALSE, /* wait for any object */ - INFINITE); /* wait until object is signalled */ - - free(handles); - - if (dwEvent == WAIT_FAILED) { - DWORD err = GetLastError(); - const char *estr = map_windows32_error_to_string(err); - ONS(fatal, NILF, _("semaphore or child process wait: (Error %ld: %s)"), err, - estr); - } - - /* WAIT_OBJECT_0 indicates that the semaphore was signalled. */ - return dwEvent == WAIT_OBJECT_0; -} - -void fd_inherit(int fd) { - HANDLE fh = (HANDLE)_get_osfhandle(fd); - - if (fh && fh != INVALID_HANDLE_VALUE) - SetHandleInformation(fh, HANDLE_FLAG_INHERIT, 1); -} - -void fd_noinherit(int fd) { - HANDLE fh = (HANDLE)_get_osfhandle(fd); - - if (fh && fh != INVALID_HANDLE_VALUE) - SetHandleInformation(fh, HANDLE_FLAG_INHERIT, 0); -} diff --git a/third_party/make/lib/stddef.h b/third_party/make/stddef.h similarity index 100% rename from third_party/make/lib/stddef.h rename to third_party/make/stddef.h diff --git a/third_party/make/lib/stdint.h b/third_party/make/stdint.h similarity index 100% rename from third_party/make/lib/stdint.h rename to third_party/make/stdint.h diff --git a/third_party/make/lib/stdio.h b/third_party/make/stdio.h similarity index 100% rename from third_party/make/lib/stdio.h rename to third_party/make/stdio.h diff --git a/third_party/make/lib/stdlib.h b/third_party/make/stdlib.h similarity index 100% rename from third_party/make/lib/stdlib.h rename to third_party/make/stdlib.h diff --git a/third_party/make/src/strcache.c b/third_party/make/strcache.c similarity index 99% rename from third_party/make/src/strcache.c rename to third_party/make/strcache.c index 73aac38bc..4c515c8bb 100644 --- a/third_party/make/src/strcache.c +++ b/third_party/make/strcache.c @@ -15,8 +15,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* clang-format off */ -#include "third_party/make/src/makeint.h" -#include "third_party/make/src/hash.h" +#include "third_party/make/makeint.h" +#include "third_party/make/hash.h" /* A string cached here will never be freed, so we don't need to worry about reference counting. We just store the string, and then remember it in a diff --git a/third_party/make/lib/stripslash.c b/third_party/make/stripslash.c similarity index 94% rename from third_party/make/lib/stripslash.c rename to third_party/make/stripslash.c index 0b342deae..1b27fb032 100644 --- a/third_party/make/lib/stripslash.c +++ b/third_party/make/stripslash.c @@ -17,9 +17,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "third_party/make/src/config.h" +#include "third_party/make/config.h" -#include "third_party/make/lib/dirname.h" +#include "third_party/make/dirname.h" /* Remove trailing slashes from FILE. Return true if a trailing slash was removed. This is useful when using file name completion from a diff --git a/third_party/make/lib/unistd.c b/third_party/make/unistd.c similarity index 51% rename from third_party/make/lib/unistd.c rename to third_party/make/unistd.c index 2b1411ff0..b52b1b50b 100644 --- a/third_party/make/lib/unistd.c +++ b/third_party/make/unistd.c @@ -1,5 +1,5 @@ /* clang-format off */ -#include "third_party/make/src/config.h" +#include "third_party/make/config.h" #define _GL_UNISTD_INLINE _GL_EXTERN_INLINE -#include "third_party/make/lib/unistd.h" +#include "third_party/make/unistd.h" typedef int dummy; diff --git a/third_party/make/lib/unistd.h b/third_party/make/unistd.h similarity index 100% rename from third_party/make/lib/unistd.h rename to third_party/make/unistd.h diff --git a/third_party/make/src/variable.c b/third_party/make/variable.c similarity index 99% rename from third_party/make/src/variable.c rename to third_party/make/variable.c index 8a64795aa..e0e38ce3a 100644 --- a/third_party/make/src/variable.c +++ b/third_party/make/variable.c @@ -15,19 +15,19 @@ 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 . */ -#include "third_party/make/src/makeint.h" +#include "third_party/make/makeint.h" -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/dep.h" -#include "third_party/make/src/job.h" -#include "third_party/make/src/commands.h" -#include "third_party/make/src/variable.h" -#include "third_party/make/src/rule.h" +#include "third_party/make/filedef.h" +#include "third_party/make/dep.h" +#include "third_party/make/job.h" +#include "third_party/make/commands.h" +#include "third_party/make/variable.h" +#include "third_party/make/rule.h" #ifdef WINDOWS32 // #include "pathstuff.h" #endif -#include "third_party/make/src/hash.h" +#include "third_party/make/hash.h" /* Incremented every time we add or remove a global variable. */ static unsigned long variable_changenum; diff --git a/third_party/make/src/variable.h b/third_party/make/variable.h similarity index 99% rename from third_party/make/src/variable.h rename to third_party/make/variable.h index a0344bf62..9099cca49 100644 --- a/third_party/make/src/variable.h +++ b/third_party/make/variable.h @@ -15,7 +15,7 @@ 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 . */ -#include "third_party/make/src/hash.h" +#include "third_party/make/hash.h" /* Codes in a variable definition saying where the definition came from. Increasing numeric values signify less-overridable definitions. */ diff --git a/third_party/make/src/version.c b/third_party/make/version.c similarity index 96% rename from third_party/make/src/version.c rename to third_party/make/version.c index e38b48bce..cfe376d35 100644 --- a/third_party/make/src/version.c +++ b/third_party/make/version.c @@ -18,7 +18,7 @@ this program. If not, see . */ /* We use instead of "config.h" so that a compilation using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h (which it would do because makeint.h was found in $srcdir). */ -#include "third_party/make/src/config.h" +#include "third_party/make/config.h" #ifndef MAKE_HOST # define MAKE_HOST "unknown" diff --git a/third_party/make/src/vpath.c b/third_party/make/vpath.c similarity index 99% rename from third_party/make/src/vpath.c rename to third_party/make/vpath.c index 8ae8b4651..545e10ae5 100644 --- a/third_party/make/src/vpath.c +++ b/third_party/make/vpath.c @@ -15,9 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* clang-format off */ -#include "third_party/make/src/makeint.h" -#include "third_party/make/src/filedef.h" -#include "third_party/make/src/variable.h" +#include "third_party/make/makeint.h" +#include "third_party/make/filedef.h" +#include "third_party/make/variable.h" /* Structure used to represent a selective VPATH searchpath. */ diff --git a/third_party/make/lib/xalloc-die.c b/third_party/make/xalloc-die.c similarity index 85% rename from third_party/make/lib/xalloc-die.c rename to third_party/make/xalloc-die.c index b4003a596..621cbc8ff 100644 --- a/third_party/make/lib/xalloc-die.c +++ b/third_party/make/xalloc-die.c @@ -17,15 +17,15 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "third_party/make/src/config.h" +#include "third_party/make/config.h" -#include "third_party/make/lib/xalloc.h" +#include "third_party/make/xalloc.h" -#include "third_party/make/lib/error.h" -#include "third_party/make/lib/exitfail.h" +#include "third_party/make/error.h" +#include "third_party/make/exitfail.h" -#include "third_party/make/lib/gettext.h" +#include "third_party/make/gettext.h" #define _(msgid) gettext (msgid) void diff --git a/third_party/make/lib/xalloc-oversized.h b/third_party/make/xalloc-oversized.h similarity index 100% rename from third_party/make/lib/xalloc-oversized.h rename to third_party/make/xalloc-oversized.h diff --git a/third_party/make/lib/xalloc.h b/third_party/make/xalloc.h similarity index 99% rename from third_party/make/lib/xalloc.h rename to third_party/make/xalloc.h index 42323d7da..70c57bea9 100644 --- a/third_party/make/lib/xalloc.h +++ b/third_party/make/xalloc.h @@ -21,7 +21,7 @@ #include "libc/limits.h" -#include "third_party/make/lib/xalloc-oversized.h" +#include "third_party/make/xalloc-oversized.h" #ifndef _GL_INLINE_HEADER_BEGIN #error "Please include config.h first." diff --git a/third_party/make/lib/xconcat-filename.c b/third_party/make/xconcat-filename.c similarity index 91% rename from third_party/make/lib/xconcat-filename.c rename to third_party/make/xconcat-filename.c index f6fc9441a..3c111095c 100644 --- a/third_party/make/lib/xconcat-filename.c +++ b/third_party/make/xconcat-filename.c @@ -17,12 +17,12 @@ /* Written by Bruno Haible . */ -#include "third_party/make/src/config.h" +#include "third_party/make/config.h" /* Specification. */ -#include "third_party/make/lib/concat-filename.h" +#include "third_party/make/concat-filename.h" -#include "third_party/make/lib/xalloc.h" +#include "third_party/make/xalloc.h" /* Concatenate a directory filename, a relative filename and an optional suffix. The directory may end with the directory separator. The second diff --git a/third_party/make/lib/xmalloc.c b/third_party/make/xmalloc.c similarity index 97% rename from third_party/make/lib/xmalloc.c rename to third_party/make/xmalloc.c index de00b9a0b..80f52f226 100644 --- a/third_party/make/lib/xmalloc.c +++ b/third_party/make/xmalloc.c @@ -16,11 +16,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "third_party/make/src/config.h" +#include "third_party/make/config.h" #define XALLOC_INLINE _GL_EXTERN_INLINE -#include "third_party/make/lib/xalloc.h" +#include "third_party/make/xalloc.h" /* 1 if calloc is known to be compatible with GNU calloc. This