From: Paolo Bonzini Date: Mon, 30 Aug 2004 13:32:57 +0000 (+0000) Subject: Makefile.in (machname.h): Remove. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=89b8abbf7d1d832e0597def81e243e47fc662cee;p=gcc.git Makefile.in (machname.h): Remove. 2004-08-30 Paolo Bonzini * fixinc/Makefile.in (machname.h): Remove. (fixincl.x): Do not pass $@ to genfixes. * fixinc/genfixes: Remove code to produce machname.h. * fixinc/fixincl.sh: Move it here instead. * fixinc/fixlib.c: Do not conditionalize on MN_NAME_PAT's presence, instead check if pz_mn_name_pat is NULL. Make mn_get_regexps return a bool indicating whether pz_mn_name_pat is NULL. * fixinc/fixlib.h: Do not conditionalize on MN_NAME_PAT's presence. Declare extern C variables for the ENV_TABLE. * fixinc/fixfixes.c: Do not conditionalize on MN_NAME_PAT's presence, instead use the result of mn_get_regexps. * fixinc/fixtests.c: Likewise. From-SVN: r86771 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ba3f8847f7c..3bf8503f499 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -3,6 +3,21 @@ * tree.h (BINFO_PRIMARY_BASE_OF): Remove. (struct tree_binfo): Remove primary field. +2004-08-30 Paolo Bonzini + + * fixinc/Makefile.in (machname.h): Remove. + (fixincl.x): Do not pass $@ to genfixes. + * fixinc/genfixes: Remove code to produce machname.h. + * fixinc/fixincl.sh: Move it here instead. + * fixinc/fixlib.c: Do not conditionalize on MN_NAME_PAT's presence, + instead check if pz_mn_name_pat is NULL. Make mn_get_regexps + return a bool indicating whether pz_mn_name_pat is NULL. + * fixinc/fixlib.h: Do not conditionalize on MN_NAME_PAT's presence. + Declare extern C variables for the ENV_TABLE. + * fixinc/fixfixes.c: Do not conditionalize on MN_NAME_PAT's presence, + instead use the result of mn_get_regexps. + * fixinc/fixtests.c: Likewise. + 2004-08-30 Paolo Bonzini * configure.ac: Do not run fixincludes after stage1 during diff --git a/gcc/fixinc/Makefile.in b/gcc/fixinc/Makefile.in index ae410e14386..a148665c15f 100644 --- a/gcc/fixinc/Makefile.in +++ b/gcc/fixinc/Makefile.in @@ -73,7 +73,7 @@ ALLOBJ = fixincl.o fixtests.o fixfixes.o server.o procopen.o \ TESTOBJ = fixincl.o fixlib.o fixtests.o FIXOBJ = fixfixes.o fixlib.o -HDR = server.h fixlib.h machname.h +HDR = server.h fixlib.h FI = fixincl@build_exeext@ AF = applyfix@build_exeext@ @@ -102,17 +102,11 @@ server.o : server.c procopen.o : procopen.c fixlib.o : fixlib.c -# 'machname.h' is built in the build directory. -# 'fixincl.x' in the source dir. -# -machname.h: ../specs - $(SHELL) $(srcdir)/genfixes $@ - $(srcdir)/fixincl.x: @MAINT@ fixincl.tpl inclhack.def - cd $(srcdir) ; $(SHELL) ./genfixes $@ + cd $(srcdir) ; $(SHELL) ./genfixes clean: - rm -f *.o *-stamp $(AF) $(FI) machname.h *~ + rm -f *.o *-stamp $(AF) $(FI) *~ maintainer-clean : clean rm -f $(srcdir)/fixincl.x @@ -129,8 +123,7 @@ install-bin : $(TARGETS) Makefile: Makefile.in ../config.status cd .. \ - && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \ - $(SHELL) ./config.status + && $(SHELL) ./config.status $(subdir)/Makefile check : $(TARGETS) autogen -T $(srcdir)/check.tpl $(srcdir)/inclhack.def diff --git a/gcc/fixinc/fixfixes.c b/gcc/fixinc/fixfixes.c index a8901ffdf0f..19fa27ed121 100644 --- a/gcc/fixinc/fixfixes.c +++ b/gcc/fixinc/fixfixes.c @@ -488,9 +488,6 @@ FIX_PROC_HEAD( char_macro_def_fix ) FIX_PROC_HEAD( machine_name_fix ) { -#ifndef MN_NAME_PAT - fputs( "The target machine has no needed machine name fixes\n", stderr ); -#else regmatch_t match[2]; const char *line, *base, *limit, *p, *q; regex_t *label_re, *name_re; @@ -499,7 +496,11 @@ FIX_PROC_HEAD( machine_name_fix ) IGNORE_ARG(filname); IGNORE_ARG(p_fixd); - mn_get_regexps (&label_re, &name_re, "machine_name_fix"); + if (!mn_get_regexps (&label_re, &name_re, "machine_name_fix")) + { + fputs( "The target machine has no needed machine name fixes\n", stderr ); + goto done; + } scratch[0] = '_'; scratch[1] = '_'; @@ -577,7 +578,6 @@ FIX_PROC_HEAD( machine_name_fix ) } } done: -#endif fputs (text, stdout); } diff --git a/gcc/fixinc/fixincl.sh b/gcc/fixinc/fixincl.sh index 80a77971818..85ec95abe56 100755 --- a/gcc/fixinc/fixincl.sh +++ b/gcc/fixinc/fixincl.sh @@ -131,6 +131,36 @@ else LINKS=false fi +# # # # # # # # # # # # # # # # # # # # # +# +# Extract from the gcc -dM and from the specs file all the predefined +# macros that are not in the C89 reserved namespace (the reserved +# namespace is all identifiers beginnning with two underscores or one +# underscore followed by a capital letter). The specs file is in +# ${ORIGDIR}, as is cc1. A regular expression to find any of those +# macros in a header file is written to MN_NAME_PAT. +# +# Note dependency on ASCII. \012 = newline. +# tr ' ' '\n' is, alas, not portable. + +echo | ${ORIGDIR}/cc1 -quiet -dM -E - | + sed -n 's/^#define \([a-zA-Z][a-zA-Z0-9_]*\).*/\1/p' > mn.T +tr -s '\040\011' '\012\012' < ${ORIGDIR}/specs | + sed -n 's/^.*-D\([a-zA-Z_][a-zA-Z0-9_]*\).*/\1/p' >> mn.T + +if sort -u mn.T | grep -v '^_[_A-Z]' > mn.U +then + if test $VERBOSE -gt 0 + then echo "Forbidden identifiers: `tr '\012' ' ' /; $!s/$/|/' < mn.U | tr -d '\012' > mn.V + MN_NAME_PAT="`cat mn.V`" + export MN_NAME_PAT +else + if test $VERBOSE -gt 0 + then echo "No forbidden identifiers defined by this target" ; fi +fi +rm -f mn.[TUV] + # # # # # # # # # # # # # # # # # # # # # # # Search each input directory for broken header files. diff --git a/gcc/fixinc/fixlib.c b/gcc/fixinc/fixlib.c index 99d04cc5531..e0fa94a14ba 100644 --- a/gcc/fixinc/fixlib.c +++ b/gcc/fixinc/fixlib.c @@ -204,32 +204,30 @@ compile_re( tCC* pat, regex_t* re, int match, tCC* e1, tCC* e2 ) /* * * * * * * * * * * * * - Helper routine and data for the machine_name test and fix. - machname.h is created by black magic in the Makefile. */ - -#ifdef MN_NAME_PAT + Helper routine and data for the machine_name test and fix. */ tSCC mn_label_pat[] = "^[ \t]*#[ \t]*(if|ifdef|ifndef)[ \t]+"; static regex_t mn_label_re; - -tSCC mn_name_pat[] = MN_NAME_PAT; static regex_t mn_name_re; static int mn_compiled = 0; -void +t_bool mn_get_regexps(regex_t** label_re, regex_t** name_re, tCC* who ) { + if (! pz_mn_name_pat) + return BOOL_FALSE; + if (! mn_compiled) { compile_re (mn_label_pat, &mn_label_re, 1, "label pattern", who); - compile_re (mn_name_pat, &mn_name_re, 1, "name pattern", who); + compile_re (pz_mn_name_pat, &mn_name_re, 1, "name pattern", who); mn_compiled++; } *label_re = &mn_label_re; *name_re = &mn_name_re; + return BOOL_TRUE; } -#endif #ifdef SEPARATE_FIX_PROC diff --git a/gcc/fixinc/fixlib.h b/gcc/fixinc/fixlib.h index 25e97d48ba1..1cce4a5b516 100644 --- a/gcc/fixinc/fixlib.h +++ b/gcc/fixinc/fixlib.h @@ -33,7 +33,6 @@ Boston, MA 02111-1307, USA. */ #include #include "xregex.h" -#include "machname.h" #include "libiberty.h" #ifndef STDIN_FILENO @@ -117,12 +116,19 @@ typedef int apply_fix_p_t; /* Apply Fix Predicate Type */ _ENV_( pz_dest_dir, BOOL_TRUE, "DESTDIR", \ "output directory" ) \ \ + _ENV_( pz_mn_name_pat, BOOL_FALSE, "MN_NAME_PAT", \ + "regex matching forbidden identifiers" ) \ + \ _ENV_( pz_verbose, BOOL_FALSE, "VERBOSE", \ "amount of user entertainment" ) \ \ _ENV_( pz_find_base, BOOL_TRUE, "FIND_BASE", \ "leader to trim from file names" ) +#define _ENV_(v,m,n,t) extern tCC* v; +ENV_TABLE +#undef _ENV_ + /* Test Descriptor Each fix may have associated tests that determine @@ -219,7 +225,5 @@ apply_fix_p_t char* make_raw_shell_str ( char* pz_d, tCC* pz_s, size_t smax ); #endif -#ifdef MN_NAME_PAT -void mn_get_regexps ( regex_t** label_re, regex_t** name_re, tCC *who ); -#endif +t_bool mn_get_regexps ( regex_t** label_re, regex_t** name_re, tCC *who ); #endif /* ! GCC_FIXLIB_H */ diff --git a/gcc/fixinc/fixtests.c b/gcc/fixinc/fixtests.c index 33ea65208f9..44ef97253f5 100644 --- a/gcc/fixinc/fixtests.c +++ b/gcc/fixinc/fixtests.c @@ -68,15 +68,13 @@ static apply_fix_p_t test ( tCC* fname ATTRIBUTE_UNUSED, \ TEST_FOR_FIX_PROC_HEAD( machine_name_test ) { -#ifndef MN_NAME_PAT - return SKIP_FIX; -#else regex_t *label_re, *name_re; regmatch_t match[2]; tCC *base, *limit; IGNORE_ARG(fname); - mn_get_regexps(&label_re, &name_re, "machine_name_test"); + if (!mn_get_regexps (&label_re, &name_re, "machine_name_test")) + return SKIP_FIX; for (base = text; xregexec (label_re, base, 2, match, 0) == 0; @@ -114,7 +112,6 @@ TEST_FOR_FIX_PROC_HEAD( machine_name_test ) /* Otherwise, keep looking... */ } return SKIP_FIX; -#endif } diff --git a/gcc/fixinc/genfixes b/gcc/fixinc/genfixes index 8028e558de3..b151153dbf6 100755 --- a/gcc/fixinc/genfixes +++ b/gcc/fixinc/genfixes @@ -45,11 +45,8 @@ do ;; '-?' ) - echo "USAGE: gendefs [ -D ... ] [ ]" + echo "USAGE: gendefs [ -D ... ]" echo "WHERE: '' specifies a #define test name from inclhack.def" - echo " and '' is one of:" - echo " fixincl.x machine.h" - echo "The default is to produce the first three outputs." exit 0 ;; @@ -66,53 +63,15 @@ fi AG="autogen $AG" set -e -case "$1" in -fixincl.x | */fixincl.x ) - if [ -z "`${AG} -v | fgrep 'Ver. 5.'`" ] - then - echo "AutoGen appears to be out of date or not correctly installed." - echo "Please download and install:" - echo " ftp://gcc.gnu.org/pub/gcc/infrastructure/autogen.tar.gz" - touch fixincl.x - else - echo AutoGen-ing fixincl.x - $AG inclhack.def - fi - ;; - -machname.h | */machname.h ) - # This script extracts from the specs file all the predefined macros - # that are not in the C89 reserved namespace (the reserved namespace - # is all identifiers beginnning with two underscores or one underscore - # followed by a capital letter). The specs file is on standard input. - # A #define for a regular expression to find any of those macros in a - # header file is written to standard output. - - # Note dependency on ASCII. \040 = space, \011 = tab, \012 = newline. - # tr ' ' '\n' is, alas, not portable. - - tr -s '\040\011' '\012\012' < ../specs | - sed -n 's/^.*-D\([a-zA-Z_][a-zA-Z0-9_]*\).*$/\1/p' | - sort -u > mn.T - - if grep -v '^_[_A-Z]' mn.T > mn.U - then - echo "Forbidden identifiers: `tr '\012' ' ' &2 - sed 's/^/\\\\/' mn.V - echo '' >>mn.V - sed 's/^/#define MN_NAME_PAT "/; s/|$/"/' < mn.V > machname.T - else - echo "No forbidden identifiers defined by this target" >&2 - echo '#undef MN_NAME_PAT' > machname.T - fi - rm -f mn.[TUV] - mv -f machname.T machname.h - ;; - -* ) - echo genfixes cannot create $1 - exit 1 - ;; -esac +if [ -z "`${AG} -v | fgrep 'Ver. 5.'`" ] +then + echo "AutoGen appears to be out of date or not correctly installed." + echo "Please download and install:" + echo " ftp://gcc.gnu.org/pub/gcc/infrastructure/autogen.tar.gz" + touch fixincl.x +else + echo AutoGen-ing fixincl.x + $AG inclhack.def +fi exit 0