Flatten GNU Make directory structure

This commit is contained in:
Justine Tunney 2022-04-06 00:22:54 -07:00
parent 04d39d47f1
commit 58d74ede4c
113 changed files with 241 additions and 7671 deletions

View file

@ -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 <stolcke@speech.sri.com>
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 <malloc.h> 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 <malloc.h> */
#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 <http://www.gnu.org/licenses/>.

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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 */

View file

@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
#include "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.

View file

@ -17,10 +17,10 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include "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

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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 ' '

View file

@ -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

View file

@ -15,15 +15,15 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
/* 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

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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 */

View file

@ -17,11 +17,11 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include "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

View file

@ -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 '/'

View file

@ -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

View file

@ -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

View file

@ -15,13 +15,13 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
/* 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. */

View file

@ -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. */

View file

@ -17,10 +17,10 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include "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. */

View file

@ -15,17 +15,17 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
/* 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

View file

@ -18,7 +18,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
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;

View file

@ -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 */

View file

@ -15,15 +15,15 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
/* 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
{

View file

@ -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.

View file

@ -31,7 +31,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#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 <http://www.gnu.org/licenses/>. */
/* 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 <http://www.gnu.org/licenses/>. */
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,

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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__

View file

@ -15,9 +15,9 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* 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)

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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;
}

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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)))

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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);

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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";

View file

@ -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 <http://www.gnu.org/licenses/>. */
#include "third_party/make/src/output.h"
#include "third_party/make/output.h"
/* Structure describing a running or dead child process. */

View file

@ -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 <https://www.gnu.org/licenses/>. */
#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

View file

@ -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 <https://www.gnu.org/licenses/>. */
/* Specification. */
int
access (const char *file, int mode)
{
if ((mode & X_OK) != 0)
mode = (mode & ~X_OK) | R_OK;
return _access (file, mode);
}

View file

@ -1,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 <jot@cray.com> 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 */

View file

@ -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 <https://www.gnu.org/licenses/>. */
/* _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

View file

@ -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 <https://www.gnu.org/licenses/>. */
#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<type>(::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<type>(::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<type>((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 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
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 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
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 */

View file

@ -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 <https://www.gnu.org/licenses/>. */
/* 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;
}

View file

@ -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: <wchar.h> must be included before <wctype.h>. */
#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__. */

View file

@ -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 <bruno@clisp.org>, 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 <https://www.gnu.org/licenses/>. */
/* 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

View file

@ -1,105 +0,0 @@
/* clang-format off */
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* A GNU-like <limits.h>.
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 <https://www.gnu.org/licenses/>. */
#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 */

View file

@ -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 <https://www.gnu.org/licenses/>. */
#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

View file

@ -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 <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 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 <errno.h> */
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 <errno.h> */
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;
}
}

View file

@ -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 <https://www.gnu.org/licenses/>. */
#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 */

View file

@ -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 <https://www.gnu.org/licenses/>. */
/* 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;
}

File diff suppressed because it is too large Load diff

View file

@ -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 <https://www.gnu.org/licenses/>. */
/* 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 <sys/cdefs.h>, included by <stddef.h> 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 <int w>
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

View file

@ -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 <https://www.gnu.org/licenses/>. */
/* _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 <stdio.h>:
#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

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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 <http://www.gnu.org/licenses/>. */
#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

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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 *

View file

@ -15,19 +15,19 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
/* 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

View file

@ -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)

View file

@ -59,7 +59,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* We use <config.h> 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 <http://www.gnu.org/licenses/>. */
#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)

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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. */

View file

@ -15,9 +15,9 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
/* 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. */

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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

View file

@ -15,17 +15,17 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
/* 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. */

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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;

View file

@ -15,13 +15,13 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
/* 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);

View file

@ -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 <http://www.gnu.org/licenses/>. */
#include "third_party/make/src/makeint.h"
#include "third_party/make/makeint.h"
/* If the system provides strsignal, we don't need it. */

View file

@ -1,48 +0,0 @@
/* clang-format off */
/* Convenience header for conditional use of GNU <libintl.h>.
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 <http://www.gnu.org/licenses/>. */
#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 */

View file

@ -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) \
";

View file

@ -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 <http://www.gnu.org/licenses/>.
(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)

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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;
}

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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$";
}

View file

@ -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 <http://www.gnu.org/licenses/>. */
#ifndef _DIRENT_H
#define _DIRENT_H
#ifdef __MINGW32__
#include_next <dirent.h>
#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

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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 */

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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

View file

@ -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 <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#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

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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;
}

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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

File diff suppressed because it is too large Load diff

View file

@ -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 <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <windows.h>
#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;
}

View file

@ -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 <http://www.gnu.org/licenses/>. */
#include <io.h>
#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);
}

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