From a83b3e4f5de7fc6fce1bdd98fd38c0cd461598fb Mon Sep 17 00:00:00 2001 From: Bruce Korb Date: Thu, 20 Jul 2000 13:29:29 +0000 Subject: [PATCH] use platform specific types in gnu_type_fix From-SVN: r35143 --- gcc/ChangeLog | 9 +++++++++ gcc/fixinc/check.tpl | 12 ++++++++++++ gcc/fixinc/fixfixes.c | 33 +++++++++++++++++++++------------ gcc/fixinc/fixincl.tpl | 15 +++++++-------- gcc/fixinc/fixincl.x | 14 ++++++++------ gcc/fixinc/fixlib.h | 3 ++- gcc/fixinc/inclhack.def | 26 ++++++++++---------------- 7 files changed, 69 insertions(+), 43 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bcd6f9bea5e..4c4138a6a81 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2000-07-20 Bruce Korb + + * fixincl/check.tpl: strip the platform specific types before testing + * fixincl/fixfixes.c(gnu_type_fix): use platform specific types + * fixincl/fixincl.tpl: use platform specific types + * fixincl/fixlib.h: include the platform specific types + * fixincl/inclhack.def(gnu_types): don't supply the types + * fixincl/fixincl.x: regen + 2000-07-19 Jim Wilson * config/ia64/ia64.h (HARD_REGNO_MODE_OK): Don't allow XFmode in diff --git a/gcc/fixinc/check.tpl b/gcc/fixinc/check.tpl index 249636b7677..196d928df08 100644 --- a/gcc/fixinc/check.tpl +++ b/gcc/fixinc/check.tpl @@ -110,6 +110,18 @@ exitok=true find * -type f -print > ${TESTDIR}/LIST +# Special hack for sys/types.h: the #define-d types for size_t, +# ptrdiff_t and wchar_t are different for each port. Therefore, +# strip off the defined-to type so that the test results are the +# same for all platforms. +# +sed 's/\(#define __[A-Z_]*_TYPE__\).*/\1/' sys/types.h > XX +mv -f XX sys/types.h + +# The following subshell weirdness is for saving an exit +# status from within a while loop that reads input. If you can +# think of a cleaner way, suggest away, please... +# exitok=` exec < ${TESTDIR}/LIST while read f diff --git a/gcc/fixinc/fixfixes.c b/gcc/fixinc/fixfixes.c index 526cc699961..7a9ff617102 100644 --- a/gcc/fixinc/fixfixes.c +++ b/gcc/fixinc/fixfixes.c @@ -164,19 +164,28 @@ emit_gnu_type ( text, rm ) /* * Now print out the reformed typedef */ - printf ("\ -#ifndef __%s_TYPE__\n\ -#define __%s_TYPE__ %s\n\ -#endif\n", - p_tm->pz_TYPE, p_tm->pz_TYPE, p_tm->pz_gtype ); - - printf ("\ + { + 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\n\ -typedef __%s_TYPE__ %s_t;\n\ -#endif\n", - p_tm->pz_TYPE, p_tm->pz_cxx_guard, - p_tm->pz_TYPE, p_tm->pz_TYPE, p_tm->pz_type); +\ +#define _GCC_%s_T\ntypedef __%s_TYPE__ %s_t;\n#endif\n"; + + const char* pz_guard; + + /* + * 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); + } return text; } diff --git a/gcc/fixinc/fixincl.tpl b/gcc/fixinc/fixincl.tpl index ec7c8121715..6a898594867 100644 --- a/gcc/fixinc/fixincl.tpl +++ b/gcc/fixinc/fixincl.tpl @@ -207,19 +207,18 @@ _FOR fix ",\n" =] #define GNU_TYPE_CT [=_eval type_map _count =] int gnu_type_map_ct = GNU_TYPE_CT; -tSCC z_cxx_guard[] = " && !defined(__cplusplus)"; -tSCC z_nil[] = ""; - +/* + * 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_name _len=], "[=type_name=]", "[=type_name _up=]", "[= - gnu_type=]", [= - _IF cxx_type _exist =]z_cxx_guard[= - _ELSE =]z_nil[= - _ENDIF=] }[= + { [=_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 9fb8dd1e141..62307bd2fa9 100644 --- a/gcc/fixinc/fixincl.x +++ b/gcc/fixinc/fixincl.x @@ -5799,11 +5799,13 @@ tFixDesc fixDescList[ FIX_COUNT ] = { #define GNU_TYPE_CT 3 int gnu_type_map_ct = GNU_TYPE_CT; -tSCC z_cxx_guard[] = " && !defined(__cplusplus)"; -tSCC z_nil[] = ""; - +/* + * 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 ] = { - { 7, "ptrdiff", "PTRDIFF", "long int", z_nil }, - { 4, "size", "SIZE", "long unsigned int", z_nil }, - { 5, "wchar", "WCHAR", "int", z_cxx_guard } + { 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 dc422b181b5..5cb0089193a 100644 --- a/gcc/fixinc/fixlib.h +++ b/gcc/fixinc/fixlib.h @@ -33,6 +33,8 @@ Boston, MA 02111-1307, USA. */ #include "machname.h" #include "libiberty.h" +#include "tm.h" + #ifndef STDIN_FILENO # define STDIN_FILENO 0 #endif @@ -175,7 +177,6 @@ typedef struct { tCC* pz_type; tCC* pz_TYPE; tCC* pz_gtype; - tCC* pz_cxx_guard; } t_gnu_type_map; extern int gnu_type_map_ct; diff --git a/gcc/fixinc/inclhack.def b/gcc/fixinc/inclhack.def index 0dd80f5b3d6..5364bd42b01 100644 --- a/gcc/fixinc/inclhack.def +++ b/gcc/fixinc/inclhack.def @@ -2520,7 +2520,13 @@ 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. + * 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; @@ -2539,21 +2545,9 @@ fix = { "typedef ushort_t wchar_t; /* ushort_t */"; }; -type_map = { - type_name = ptrdiff; - gnu_type = "long int"; -}; - -type_map = { - type_name = size; - gnu_type = "long unsigned int"; -}; - -type_map = { - type_name = wchar; - gnu_type = int; - cxx_type; -}; +type_map = wchar; +type_map = ptrdiff; +type_map = size; /* -- 2.30.2