This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[patch] use platform specific size_t's in fixinc


 

Originally, the fixincludes script set __PTRDIFF_TYPE__ et. al.
to strings (types) defined within fixincludes.  The correct thing
is to get such strings (types) from the headers defined by the
people that actually do the porting work.  This patch will do that.

2000-07-20  Bruce Korb  <bkorb@gnu.org>

	* 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

check.tpl fixfixes.c fixincl.tpl fixlib.h inclhack.def ../ChangeLog

Index: check.tpl
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/check.tpl,v
retrieving revision 1.9
diff -u -r1.9 check.tpl
--- check.tpl	2000/07/19 14:10:41	1.9
+++ check.tpl	2000/07/20 14:19:01
@@ -110,6 +110,18 @@
 
 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
Index: fixfixes.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixfixes.c,v
retrieving revision 1.30
diff -u -r1.30 fixfixes.c
--- fixfixes.c	2000/07/16 17:17:46	1.30
+++ fixfixes.c	2000/07/20 14:19:01
@@ -164,19 +164,28 @@
   /*
    *  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;
 }
Index: fixincl.tpl
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixincl.tpl,v
retrieving revision 1.14
diff -u -r1.14 fixincl.tpl
--- fixincl.tpl	2000/07/13 14:47:55	1.14
+++ fixincl.tpl	2000/07/20 14:19:01
@@ -207,19 +207,18 @@
 #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=]
 };
Index: fixlib.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixlib.h,v
retrieving revision 1.14
diff -u -r1.14 fixlib.h
--- fixlib.h	2000/07/19 14:10:41	1.14
+++ fixlib.h	2000/07/20 14:19:01
@@ -33,6 +33,8 @@
 #include "machname.h"
 #include "libiberty.h"
 
+#include "tm.h"
+
 #ifndef STDIN_FILENO
 # define STDIN_FILENO   0
 #endif
@@ -175,7 +177,6 @@
   tCC*        pz_type;
   tCC*        pz_TYPE;
   tCC*        pz_gtype;
-  tCC*        pz_cxx_guard;
 } t_gnu_type_map;
 
 extern int gnu_type_map_ct;
Index: inclhack.def
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/inclhack.def,v
retrieving revision 1.84
diff -u -r1.84 inclhack.def
--- inclhack.def	2000/07/13 14:47:55	1.84
+++ inclhack.def	2000/07/20 14:19:21
@@ -2520,7 +2520,13 @@
 /*
  * 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 @@
                 "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;
 
 
 /*

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]