Commit f95e46b9 by Zack Weinberg Committed by Zack Weinberg

Makefile.in (STMP_FIXINC): New toggle.

	* Makefile.in (STMP_FIXINC): New toggle.
	(LIBGCC2_DEPS): Delete all references.
	(stmp-headers): Delete target.  All references either deleted
	or changed to stmp-int-headers.
	(all.cross): Don't depend on stmp-headers or STMP_FIXPROTO.
	(LIBCPP_OBJS): Take out cppalloc.o.
	(cppalloc.o): Delete target.
	(stmp-int-hdrs): Depend on $(STMP_FIXINC).
	(gen-protos, fix-header): Link with libiberty.a.
	* build-make: Don't change FIXINCLUDES.  Override STMP_FIXINC
	to empty.
	* cp/Make-lang.in: Delete refs to LIBGCC2_DEPS.

	* configure.in: Remove refs to strerror.
	* acconfig.h: Take out NEED_DECLARATION_STRERROR.
	* system.h: Take out strerror stanza.

	* cpperror.c (my_strerror): Delete function.
	(cpp_error_from_errno, cpp_notice_from_errno): Use xstrerror.
	* cppmain.c (main): Call xmalloc_set_program_name first thing.
	* cppalloc.c: Delete file.
	* gen-protos.c: Don't provide xrealloc.

	* fixinc/fixincl.c, fixinc/fixlib.c, fixinc/procopen.c: Use
	xstrerror throughout.

From-SVN: r32200
parent 42a2c30e
2000-02-26 Zack Weinberg <zack@wolery.cumb.org>
* Makefile.in (STMP_FIXINC): New toggle.
(LIBGCC2_DEPS): Delete all references.
(stmp-headers): Delete target. All references either deleted
or changed to stmp-int-headers.
(all.cross): Don't depend on stmp-headers or STMP_FIXPROTO.
(LIBCPP_OBJS): Take out cppalloc.o.
(cppalloc.o): Delete target.
(stmp-int-hdrs): Depend on $(STMP_FIXINC).
(gen-protos, fix-header): Link with libiberty.a.
* build-make: Don't change FIXINCLUDES. Override STMP_FIXINC
to empty.
* configure.in: Remove refs to strerror.
* acconfig.h: Take out NEED_DECLARATION_STRERROR.
* system.h: Take out strerror stanza.
* cpperror.c (my_strerror): Delete function.
(cpp_error_from_errno, cpp_notice_from_errno): Use xstrerror.
* cppmain.c (main): Call xmalloc_set_program_name first thing.
* cppalloc.c: Delete file.
* gen-protos.c: Don't provide xrealloc.
* fixinc/fixincl.c, fixinc/fixlib.c, fixinc/procopen.c: Use
xstrerror throughout.
2000-02-26 Bruce Korb <bkorb@gnu.org>
fixinc/inclhack.def(undefine_null): the bypass pattern needs to
......
......@@ -219,8 +219,9 @@ SYSTEM_HEADER_DIR = /usr/include
# Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
CROSS_SYSTEM_HEADER_DIR = $(tooldir)/sys-include
# Control whether to run fixproto.
# Control whether to run fixproto and fixincludes.
STMP_FIXPROTO = stmp-fixproto
STMP_FIXINC = stmp-fixinc
# Test to see whether <limits.h> exists in the system header files.
LIMITS_H_TEST = [ -f $(SYSTEM_HEADER_DIR)/limits.h ]
......@@ -359,10 +360,6 @@ LIBGCC2_INCLUDES =
# Additional target-dependent options for compiling libgcc2.a.
TARGET_LIBGCC2_CFLAGS =
# Things which must be built before building libgcc2.a.
# Some targets override this to stmp-int-hdrs
LIBGCC2_DEPS =
# libgcc1-test target (must also be overridable for a target)
LIBGCC1_TEST = libgcc1-test
......@@ -836,7 +833,7 @@ all.internal: start.encap rest.encap doc
# This is what to compile if making a cross-compiler.
# Note that we can compile enquire using the cross-compiler just built,
# although we can't run it on this machine.
all.cross: native gcc-cross xcpp$(exeext) specs stmp-headers $(STMP_FIXPROTO) \
all.cross: native gcc-cross xcpp$(exeext) specs \
$(LIBGCC) $(LIBGCC1_TEST) $(EXTRA_PARTS) lang.all.cross doc
# This is what to compile if making gcc with a cross-compiler.
all.build: native xgcc$(exeext) xcpp$(exeext) $(EXTRA_PARTS) lang.all.build
......@@ -844,7 +841,7 @@ all.build: native xgcc$(exeext) xcpp$(exeext) $(EXTRA_PARTS) lang.all.build
start.encap: native xgcc$(exeext) xcpp$(exeext) specs $(LIBGCC1) \
xlimits.h lang.start.encap
# These can't be made until after GCC can run.
rest.encap: stmp-headers $(STMP_FIXPROTO) $(LIBGCC) $(EXTRA_PARTS) lang.rest.encap
rest.encap: $(STMP_FIXPROTO) $(LIBGCC) $(EXTRA_PARTS) lang.rest.encap
# This is what is made with the host's compiler
# whether making a cross compiler or not.
native: config.status auto-host.h cpp$(exeext) intl.all $(LANGUAGES) \
......@@ -1047,7 +1044,7 @@ libgcc1.S: libgcc1.c $(CONFIG_H) config.status
# Compiling libgcc2.a requires making sure that cc1, etc. have been compiled.
# But recompiling cc1 should not force recompilation of libgcc2.a.
# If you want to force recompilation, delete libgcc2.a.
libgcc2.ready: $(GCC_PASSES) $(LIBGCC2_DEPS) stmp-int-hdrs $(STMP_FIXPROTO)
libgcc2.ready: $(GCC_PASSES) stmp-int-hdrs $(STMP_FIXPROTO)
-if [ -f libgcc2.ready ] ; then \
true; \
else \
......@@ -2023,7 +2020,7 @@ cccp.o: cccp.c $(CONFIG_H) intl.h pcp.h version.c config.status system.h \
$(PREPROCESSOR_DEFINES) \
-c `echo $(srcdir)/cccp.c | sed 's,^\./,,'`
LIBCPP_OBJS = cpplib.o cpphash.o cppalloc.o cpperror.o cppexp.o cppfiles.o \
LIBCPP_OBJS = cpplib.o cpphash.o cpperror.o cppexp.o cppfiles.o \
cppinit.o cppulp.o prefix.o version.o mbchar.o @extra_cpp_objs@
# All the other archives built/used by this makefile are for targets. This
......@@ -2042,7 +2039,6 @@ cppmain.o: cppmain.c $(CONFIG_H) cpplib.h intl.h system.h
cppulp.o: cppulp.c $(CONFIG_H) system.h output.h
cpplib.o: cpplib.c $(CONFIG_H) cpplib.h intl.h system.h cpphash.h
cpphash.o: cpphash.c $(CONFIG_H) cpplib.h intl.h system.h cpphash.h version.h
cppalloc.o: cppalloc.c $(CONFIG_H) cpplib.h intl.h system.h
cpperror.o: cpperror.c $(CONFIG_H) cpplib.h intl.h system.h
cppexp.o: cppexp.c $(CONFIG_H) cpplib.h intl.h system.h
cppfiles.o: cppfiles.c $(CONFIG_H) cpplib.h intl.h system.h
......@@ -2131,7 +2127,7 @@ gcov$(exeext): $(GCOV_OBJS) $(LIBDEPS)
# Build the include directory including float.h (which no longer depends upon
# enquire).
stmp-int-hdrs: stmp-fixinc $(USER_H) xlimits.h
stmp-int-hdrs: $(STMP_FIXINC) $(USER_H) xlimits.h
# Copy in the headers provided with gcc.
# The sed command gets just the last file name component;
# this is necessary because VPATH could add a dirname.
......@@ -2160,10 +2156,6 @@ stmp-int-hdrs: stmp-fixinc $(USER_H) xlimits.h
chmod a+r include/README
touch $@
# Now that float.h no longer depends upon enquire, this is actually a no-op.
stmp-headers:
touch $@
# fixinc.sh depends on this, not on specs directly.
# The idea is to make sure specs gets built, but not rerun fixinc.sh
# after each stage just because specs' mtime has changed.
......@@ -2215,6 +2207,9 @@ stmp-fixinc: fixinc.sh gsyslimits.h
touch stmp-fixinc
# Files related to the fixproto script.
# gen-protos and fix-header are compiled with HOST_CC, but they are only
# used in native and host-x-target builds, so it's safe to link them with
# libiberty.a.
deduced.h: $(GCC_PASSES) $(srcdir)/scan-types.sh stmp-int-hdrs
if [ -d $(SYSTEM_HEADER_DIR) ]; \
......@@ -2230,7 +2225,7 @@ deduced.h: $(GCC_PASSES) $(srcdir)/scan-types.sh stmp-int-hdrs
GEN_PROTOS_OBJS = gen-protos.o scan.o
gen-protos: $(GEN_PROTOS_OBJS)
${HOST_CC} $(HOST_CFLAGS) $(HOST_LDFLAGS) -o gen-protos \
$(GEN_PROTOS_OBJS)
$(GEN_PROTOS_OBJS) ../libiberty/libiberty.a
gen-protos.o: gen-protos.c scan.h $(build_xm_file) system.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/gen-protos.c
......@@ -2250,7 +2245,7 @@ xsys-protos.h: $(GCC_PASSES) $(srcdir)/sys-protos.h deduced.h gen-protos Makefil
fix-header: fix-header.o scan-decls.o scan.o xsys-protos.h $(HOST_LIBDEPS) \
libcpp.a
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ fix-header.o \
scan-decls.o scan.o libcpp.a $(HOST_LIBS)
scan-decls.o scan.o libcpp.a $(HOST_LIBS) ../libiberty/libiberty.a
fix-header.o: fix-header.c $(srcdir)/../include/obstack.h scan.h \
xsys-protos.h $(build_xm_file) system.h cpplib.h
......@@ -2270,10 +2265,10 @@ fixhdr.ready: fix-header
touch fixhdr.ready; \
fi
# stmp-headers is to make sure fixincludes has already finished.
# stmp-int-headers is to make sure fixincludes has already finished.
# The if statement is so that we don't run fixproto a second time
# if it has already been run on the files in `include'.
stmp-fixproto: fixhdr.ready fixproto stmp-headers
stmp-fixproto: fixhdr.ready fixproto stmp-int-hdrs
@echo "Various warnings and error messages from fixproto are normal"
-if [ -d include ] ; then true; else mkdir include; chmod a+rx include; fi
-if [ -f include/fixed ] ; then true; \
......@@ -2689,7 +2684,7 @@ install-include-dir: installdirs
-chmod a+rx $(libsubdir)/include
# Install the include directory using tar.
install-headers-tar: stmp-headers $(STMP_FIXPROTO) install-include-dir
install-headers-tar: stmp-int-hdrs $(STMP_FIXPROTO) install-include-dir
# We use `pwd`/include instead of just include to problems with CDPATH
# Unless a full pathname is provided, some shells would print the new CWD,
# found in CDPATH, corrupting the output. We could just redirect the
......@@ -2701,7 +2696,7 @@ install-headers-tar: stmp-headers $(STMP_FIXPROTO) install-include-dir
# So use `exit 0' to ignore its exit status.
# Install the include directory using cpio.
install-headers-cpio: stmp-headers $(STMP_FIXPROTO) install-include-dir
install-headers-cpio: stmp-int-hdrs $(STMP_FIXPROTO) install-include-dir
# See discussion about the use of `pwd` above
cd `pwd`/include ; \
find . -print | cpio -pdum $(libsubdir)/include
......
......@@ -123,9 +123,6 @@
/* Whether abort must be declared even if <stdlib.h> is included. */
#undef NEED_DECLARATION_ABORT
/* Whether strerror must be declared even if <string.h> is included. */
#undef NEED_DECLARATION_STRERROR
/* Whether strsignal must be declared even if <string.h> is included. */
#undef NEED_DECLARATION_STRSIGNAL
......
......@@ -22,9 +22,7 @@ HOST_OBSTACK=$(OBSTACK)
# To build the native compiler with the cross compiler, the headers
# for the target are already fixed. And /usr/include is for host, not
# target.
FIXINCLUDES=Makefile.in
# Don't run fixproto either
STMP_FIXINC =
STMP_FIXPROTO =
# Cause installation using install-build. We do nothing here.
......
......@@ -124,9 +124,6 @@
/* Whether abort must be declared even if <stdlib.h> is included. */
#undef NEED_DECLARATION_ABORT
/* Whether strerror must be declared even if <string.h> is included. */
#undef NEED_DECLARATION_STRERROR
/* Whether strsignal must be declared even if <string.h> is included. */
#undef NEED_DECLARATION_STRSIGNAL
......@@ -335,9 +332,6 @@
/* Define if you have the strdup function. */
#undef HAVE_STRDUP
/* Define if you have the strerror function. */
#undef HAVE_STRERROR
/* Define if you have the strrchr function. */
#undef HAVE_STRRCHR
......
......@@ -376,7 +376,7 @@ if test $gcc_cv_header_inttypes_h = yes; then
AC_DEFINE(HAVE_INTTYPES_H)
fi
AC_CHECK_FUNCS(strtoul bsearch strerror putenv popen bcopy bzero bcmp \
AC_CHECK_FUNCS(strtoul bsearch putenv popen bcopy bzero bcmp \
index rindex strchr strrchr kill getrlimit setrlimit atoll atoq \
sysconf isascii gettimeofday strsignal putc_unlocked fputc_unlocked \
fputs_unlocked getrusage valloc)
......@@ -399,7 +399,7 @@ AC_FUNC_VFORK
AC_FUNC_MMAP_ANYWHERE
GCC_NEED_DECLARATIONS(bcopy bzero bcmp \
index rindex getenv atol sbrk abort atof strerror getcwd getwd \
index rindex getenv atol sbrk abort atof getcwd getwd \
strsignal putc_unlocked fputs_unlocked strstr environ)
GCC_NEED_DECLARATIONS(malloc realloc calloc free, [
......
2000-02-26 Zack Weinberg <zack@wolery.cumb.org>
* Make-lang.in: Delete refs to LIBGCC2_DEPS.
Fri Feb 25 14:52:33 2000 Jim Wilson <wilson@cygnus.com>
* optimize.c (expand_call_inline): Emit the return label before
......
......@@ -187,7 +187,7 @@ cplib2.txt: $(CXX_LIB2SRCS) $(CXX_EXTRA_HEADERS) cplib2.ready
# Don't try to do write if `.' is not writable;
# in that case, we're installing from someone else's directory.
# But go ahead and fail if that directory hasn't been properly built.
cplib2.ready: $(GCC_PASSES) $(LIBGCC2_DEPS) stmp-int-hdrs
cplib2.ready: $(GCC_PASSES) stmp-int-hdrs $(STMP_FIXPROTO)
@if [ -r cplib2.txt -a -w . ]; then \
case " $(LANGUAGES) " in \
*" "[cC]"++ "*) \
......
/* Part of CPP library. (memory allocation - xmalloc etc)
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1998, 1999, 2000
Free Software Foundation, Inc.
Written by Per Bothner, 1994.
Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987
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 2, 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, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
#include "config.h"
#include "system.h"
#include "cpplib.h"
#include "intl.h"
static void memory_full PARAMS ((void)) ATTRIBUTE_NORETURN;
static void
memory_full ()
{
fprintf (stderr, _("%s: virtual memory exhausted\n"), progname);
exit (FATAL_EXIT_CODE);
}
PTR
xmalloc (size)
size_t size;
{
register PTR ptr = (PTR) malloc (size);
if (ptr == 0)
memory_full ();
return ptr;
}
PTR
xcalloc (number, size)
size_t number, size;
{
register PTR ptr = (PTR) calloc (number, size);
if (ptr == 0)
memory_full ();
return ptr;
}
PTR
xrealloc (old, size)
PTR old;
size_t size;
{
register PTR ptr;
if (old)
ptr = (PTR) realloc (old, size);
else
ptr = (PTR) malloc (size);
if (ptr == 0)
memory_full ();
return ptr;
}
char *
xstrdup (input)
const char *input;
{
size_t size = strlen (input) + 1;
char *output = xmalloc (size);
memcpy (output, input, size);
return output;
}
......@@ -28,46 +28,12 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "cpplib.h"
#include "intl.h"
static const char *my_strerror PARAMS ((int));
static void cpp_print_containing_files PARAMS ((cpp_reader *, cpp_buffer *));
static void cpp_print_file_and_line PARAMS ((const char *, long, long));
static void v_cpp_message PARAMS ((cpp_reader *, int,
const char *, long, long,
const char *, va_list));
/* my_strerror - return the descriptive text associated with an
`errno' code.
XXX - link with libiberty so we can use its strerror(). */
static const char *
my_strerror (errnum)
int errnum;
{
const char *result;
#ifndef VMS
#ifndef HAVE_STRERROR
result = (char *) ((errnum < sys_nerr) ? sys_errlist[errnum] : 0);
#else
result = strerror (errnum);
#endif
#else /* VMS */
/* VAXCRTL's strerror() takes an optional second argument, which only
matters when the first argument is EVMSERR. However, it's simplest
just to pass it unconditionally. `vaxc$errno' is declared in
<errno.h>, and maintained by the library in parallel with `errno'.
We assume that caller's `errnum' either matches the last setting of
`errno' by the library or else does not have the value `EVMSERR'. */
result = strerror (errnum, vaxc$errno);
#endif
if (!result)
result = "errno = ?";
return result;
}
/* Print the file names and line numbers of the #include
commands which led to the current file. */
......@@ -294,7 +260,7 @@ cpp_error_from_errno (pfile, name)
cpp_reader *pfile;
const char *name;
{
cpp_error (pfile, "%s: %s", name, my_strerror (errno));
cpp_error (pfile, "%s: %s", name, xstrerror (errno));
}
void
......@@ -473,5 +439,5 @@ cpp_notice_from_errno (pfile, name)
cpp_reader *pfile;
const char *name;
{
cpp_notice (pfile, "%s: %s", name, my_strerror (errno));
cpp_notice (pfile, "%s: %s", name, xstrerror (errno));
}
......@@ -46,6 +46,8 @@ main (argc, argv)
while (p != argv[0] && p[-1] != '/') --p;
progname = p;
xmalloc_set_program_name (progname);
#ifdef HAVE_LC_MESSAGES
setlocale (LC_MESSAGES, "");
#endif
......
......@@ -183,7 +183,7 @@ main (argc, argv)
if (freopen (argv[1], "r", stdin) == (FILE*)NULL)
{
fprintf (stderr, "Error %d (%s) reopening %s as stdin\n",
errno, strerror (errno), argv[1] );
errno, xstrerror (errno), argv[1] );
exit (EXIT_FAILURE);
}
break;
......@@ -264,7 +264,7 @@ main (argc, argv)
if (child == NOPROCESS)
{
fprintf (stderr, "Error %d (%s) forking in main\n",
errno, strerror (errno));
errno, xstrerror (errno));
exit (EXIT_FAILURE);
}
......@@ -464,7 +464,7 @@ wait_for_pid(child)
default:
if (NOT_SILENT)
fprintf (stderr, "Error %d (%s) waiting for %d to finish\n",
errno, strerror( errno ), child );
errno, xstrerror( errno ), child );
/* FALLTHROUGH */
case ECHILD: /* no children to wait for?? */
......@@ -492,7 +492,7 @@ load_file ( fname )
{
if (NOT_SILENT)
fprintf (stderr, "error %d (%s) stat-ing %s\n",
errno, strerror (errno), fname );
errno, xstrerror (errno), fname );
return (char *) NULL;
}
if (stbf.st_size == 0)
......@@ -506,7 +506,7 @@ load_file ( fname )
{
if (NOT_SILENT)
fprintf (stderr, "error %d (%s) opening %s for read\n",
errno, strerror (errno), fname);
errno, xstrerror (errno), fname);
return (char*)NULL;
}
......@@ -724,7 +724,7 @@ create_file ()
if (fd < 0)
{
fprintf (stderr, "Error %d (%s) creating %s\n",
errno, strerror (errno), fname);
errno, xstrerror (errno), fname);
exit (EXIT_FAILURE);
}
if (NOT_SILENT)
......@@ -968,7 +968,7 @@ internal_fix (read_fd, p_fixd)
/*
* Parent in error
*/
fprintf (stderr, z_fork_err, errno, strerror (errno),
fprintf (stderr, z_fork_err, errno, xstrerror (errno),
p_fixd->fix_name);
{
static int failCt = 0;
......@@ -1058,7 +1058,7 @@ start_fixer (read_fd, p_fixd, pz_fix_file)
break;
}
fprintf (stderr, z_fork_err, errno, strerror (errno),
fprintf (stderr, z_fork_err, errno, xstrerror (errno),
p_fixd->fix_name);
if ((errno != EAGAIN) || (++failCt > 10))
......@@ -1307,7 +1307,7 @@ process ()
int erno = errno;
fprintf (stderr, "Cannot access %s from %s\n\terror %d (%s)\n",
pz_curr_file, getcwd ((char *) NULL, MAXPATHLEN),
erno, strerror (erno));
erno, xstrerror (erno));
return;
}
......@@ -1352,7 +1352,7 @@ process ()
if (read_fd < 0)
{
fprintf (stderr, "Error %d (%s) opening %s\n", errno,
strerror (errno), pz_curr_file);
xstrerror (errno), pz_curr_file);
exit (EXIT_FAILURE);
}
......
......@@ -63,7 +63,7 @@ load_file_data (fp)
int err = errno;
if (err != EISDIR)
fprintf (stderr, "error %d (%s) reading input\n", err,
strerror (err));
xstrerror (err));
free ((void *) pz_data);
fclose (fp);
return (char *) NULL;
......
......@@ -194,7 +194,7 @@ chain_open (stdin_fd, pp_args, p_child)
execvp (pz_cmd, pp_args);
fprintf (stderr, "Error %d: Could not execvp( '%s', ... ): %s\n",
errno, pz_cmd, strerror (errno));
errno, pz_cmd, xstrerror (errno));
exit (EXIT_PANIC);
}
......
......@@ -192,21 +192,3 @@ main (argc, argv)
return 0;
}
/* Needed by scan.o. We can't use libiberty here. */
PTR
xrealloc (p, s)
PTR p;
size_t s;
{
PTR r;
if (s == 0)
s = 1;
if (p)
r = realloc (p, s);
else
r = malloc (s);
if (!r)
abort ();
return r;
}
......@@ -399,17 +399,6 @@ extern PTR calloc PARAMS ((size_t, size_t));
extern PTR realloc PARAMS ((PTR, size_t));
#endif
#ifdef HAVE_STRERROR
# ifdef NEED_DECLARATION_STRERROR
# ifndef strerror
extern char *strerror PARAMS ((int));
# endif
# endif
#else /* ! HAVE_STRERROR */
extern int sys_nerr;
extern char *sys_errlist[];
#endif /* HAVE_STRERROR */
/* If the system doesn't provide strsignal, we get it defined in
libiberty but no declaration is supplied. */
#ifdef NEED_DECLARATION_STRSIGNAL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment