From 71e06bdeedb1a528715bad12f1b92c07d311cfae Mon Sep 17 00:00:00 2001 From: Bruce Korb Date: Thu, 27 Jul 2000 13:29:21 +0000 Subject: [PATCH] rely* on GCC defining the __xxx_TYPE__ macros From-SVN: r35288 --- gcc/ChangeLog | 8 ++++ gcc/fixinc/fixfixes.c | 96 +++++++++-------------------------------- gcc/fixinc/fixincl.tpl | 19 -------- gcc/fixinc/fixincl.x | 14 ------ gcc/fixinc/fixlib.h | 5 +-- gcc/fixinc/inclhack.def | 12 ------ 6 files changed, 31 insertions(+), 123 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b0642f00bd4..c53c163ad3c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2000-07-24 Bruce Korb + + * fixincl/fixfixes.c(emit_gnu_type): rewrote to *rely* on GCC + defining the __xxx_TYPE__ macros. + * fixincl/fixincl.tpl(gnu_type_map): now obsolete + * fixincl/fixlib.h: don't need to include "tm.h" anymore + * fixincl/inclhack.def(type_map): now obsolete + Thu Jul 27 11:54:17 2000 Andrew Cagney * cpp.texi: Append a trailing full-stop to xrefs where needed. diff --git a/gcc/fixinc/fixfixes.c b/gcc/fixinc/fixfixes.c index 7a9ff617102..a68699b7db2 100644 --- a/gcc/fixinc/fixfixes.c +++ b/gcc/fixinc/fixfixes.c @@ -136,58 +136,41 @@ emit_gnu_type ( text, rm ) const char* text; regmatch_t* rm; { - extern t_gnu_type_map gnu_type_map[]; - extern int gnu_type_map_ct; - - const char* pzt = text + rm[GTYPE_SE_CT].rm_so; - t_gnu_type_map* p_tm = gnu_type_map; - int ct = gnu_type_map_ct; + char z_TYPE[ 64 ]; + char z_type[ 64 ]; fwrite (text, rm[0].rm_so, 1, stdout); - text += rm[0].rm_eo; - for (;;) - { - if (strncmp (pzt, p_tm->pz_type, p_tm->type_name_len) == 0) - break; + { + const char* ps = text + rm[1].rm_so; + const char* pe = text + rm[1].rm_eo; + char* pd = z_type; + char* pD = z_TYPE; -#ifdef DEBUG - if (--ct <= 0) - return (const char*)NULL; -#else - if (--ct <= 0) - return text; -#endif - p_tm++; - } + while (ps < pe) + *(pD++) = toupper( *(pd++) = *(ps++) ); + + *pD = *pd = NUL; + } /* - * Now print out the reformed typedef + * Now print out the reformed typedef, + * with a C++ guard for WCHAR */ { tSCC z_fmt[] = "\ -#ifndef __%s_TYPE__\n#define __%s_TYPE__ %s\n#endif\n\ -\ #if !defined(_GCC_%s_T)%s\n\ -\ -#define _GCC_%s_T\ntypedef __%s_TYPE__ %s_t;\n#endif\n"; +#define _GCC_%s_T\n\ +typedef __%s_TYPE__ %s_t;\n\ +#endif\n"; - const char* pz_guard; + const char* pz_guard = (strcmp (z_type, "wchar") == 0) + ? " && ! defined(__cplusplus)" : ""; - /* - * We magically know that the first entry and only the first - * entry needs guarding against __cplusplus (it is "wchar_t"). - * If others wind up needing similar special treatment, then - * go look into inclhack.def. This code, obviously, works closely - * with that file :-) - */ - pz_guard = (p_tm == gnu_type_map) ? " && ! defined(__cplusplus)" : ""; - printf (z_fmt, p_tm->pz_TYPE, p_tm->pz_TYPE, p_tm->pz_gtype, - p_tm->pz_TYPE, pz_guard, - p_tm->pz_TYPE, p_tm->pz_TYPE, p_tm->pz_type); + printf (z_fmt, z_TYPE, pz_guard, z_TYPE, z_TYPE, z_type); } - return text; + return text += rm[0].rm_eo; } @@ -694,44 +677,7 @@ FIX_PROC_HEAD( gnu_type_fix ) while (regexec (&re, text, GTYPE_SE_CT+1, rm, 0) == 0) { -#ifndef DEBUG text = emit_gnu_type (text, rm); -#else - tSCC z_mismatch[] = "``%s'' mismatched:\n"; - - /* - * Make sure we matched *all* subexpressions - */ - if (rm[GTYPE_SE_CT].rm_so == -1) - { - int i; - - fprintf (stderr, z_mismatch, pz_pat); - - for (i=0; i <= GTYPE_SE_CT; i++) - { - if (rm[i].rm_so != -1) - { - fprintf( stderr, "%4d: ``", i ); - fwrite( text + rm[i].rm_so, rm[i].rm_eo - rm[i].rm_so, - 1, stderr ); - fputs( "''\n", stderr ); - } - else - { - fprintf( stderr, "%4d: BROKEN\n", i ); - } - } - exit (EXIT_BROKEN); - } - - text = emit_gnu_type (text, rm); - if (text == NULL) - { - fprintf (stderr, z_mismatch, pz_pat); - exit (EXIT_BROKEN); - } -#endif } /* diff --git a/gcc/fixinc/fixincl.tpl b/gcc/fixinc/fixincl.tpl index 6a898594867..a68dec85cac 100644 --- a/gcc/fixinc/fixincl.tpl +++ b/gcc/fixinc/fixincl.tpl @@ -203,22 +203,3 @@ _FOR fix ",\n" =] /fix=] }; - -#define GNU_TYPE_CT [=_eval type_map _count =] -int gnu_type_map_ct = GNU_TYPE_CT; - -/* - * The following table depends upon XXX_TYPE being #define-d to the - * correct string via defines in a header file pointed to by the - * generated file "tm.h". - */ -t_gnu_type_map gnu_type_map[ GNU_TYPE_CT ] = {[= - -_FOR type_map , - -=] - { [=_EVAL type_map _len=], "[=type_map=]", "[=type_map _up=]", [= - type_map _up=]_TYPE }[= - -/type_map=] -}; diff --git a/gcc/fixinc/fixincl.x b/gcc/fixinc/fixincl.x index 62307bd2fa9..e5b59a88364 100644 --- a/gcc/fixinc/fixincl.x +++ b/gcc/fixinc/fixincl.x @@ -5795,17 +5795,3 @@ tFixDesc fixDescList[ FIX_COUNT ] = { X11_SPRINTF_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, aX11_SprintfTests, apzX11_SprintfPatch } }; - -#define GNU_TYPE_CT 3 -int gnu_type_map_ct = GNU_TYPE_CT; - -/* - * The following table depends upon XXX_TYPE being #define-d to the - * correct string via defines in a header file pointed to by the - * generated file "tm.h". - */ -t_gnu_type_map gnu_type_map[ GNU_TYPE_CT ] = { - { 5, "wchar", "WCHAR", WCHAR_TYPE }, - { 7, "ptrdiff", "PTRDIFF", PTRDIFF_TYPE }, - { 4, "size", "SIZE", SIZE_TYPE } -}; diff --git a/gcc/fixinc/fixlib.h b/gcc/fixinc/fixlib.h index 5cb0089193a..7a110860e87 100644 --- a/gcc/fixinc/fixlib.h +++ b/gcc/fixinc/fixlib.h @@ -33,8 +33,6 @@ Boston, MA 02111-1307, USA. */ #include "machname.h" #include "libiberty.h" -#include "tm.h" - #ifndef STDIN_FILENO # define STDIN_FILENO 0 #endif @@ -149,7 +147,8 @@ typedef struct patch_desc tPatchDesc; a particular fix (which files, how to qualify them, how to actually make the fix, etc...) - NB: the FD_ defines are BIT FLAGS + NB: the FD_ defines are BIT FLAGS, even though + some are mutually exclusive */ #define FD_MACH_ONLY 0x0000 diff --git a/gcc/fixinc/inclhack.def b/gcc/fixinc/inclhack.def index 5364bd42b01..f040130a588 100644 --- a/gcc/fixinc/inclhack.def +++ b/gcc/fixinc/inclhack.def @@ -2519,14 +2519,6 @@ fix = { /* * Fix these files to use the same types that we think they should. - * Each type must be present in two places: the select clause - * and a "type_map" entry below. The types mapped to are found from - * the "tm.h" header, which is a generated file that refers to - * a header in the gcc/config/ tree. Keep these in sync!! - * - * Also, "wchar" is first and known to need guarding against __cplusplus. - * Keep *that* in mind, too, when hacking the gnu_type_fix routine - * in fixfixes.c. */ fix = { hackname = gnu_types; @@ -2545,10 +2537,6 @@ fix = { "typedef ushort_t wchar_t; /* ushort_t */"; }; -type_map = wchar; -type_map = ptrdiff; -type_map = size; - /* * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}