cpp issues

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Wed Feb 24 10:49:00 GMT 1999


	Here is my patch to change HOST_WIDE_INT -> HOST_WIDEST_INT in
cpp*.[ch].  Unfortunately, it doesn't seem to be enough to fix the
problems with cpp long long truncation on mips-irix6. 

	We should install it though as it is a starting point for
finishing the bugfix.  I'll submit a testcase in a followup patch.

Okay to install?

		--Kaveh



Wed Feb 24 11:09:11 1999  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* Makefile.in (cppmain.o, cpplib.o, cpphash.o, cppalloc.o,
 	cpperror.o, cppexp.o, cppfiles.o, cppinit.o, fix-header.o,
 	scan-decls.o): Don't depend on machmode.h.
	
        * cppexp.c: Don't define CHAR_BIT or HOST_BITS_PER_WIDE_INT anymore.
  	Replace all instances of HOST_WIDE_INT with HOST_WIDEST_INT.
	
	* cppfiles.c: Likewise.

 	* cpplib.c: Likewise.
	 
 	* cpplib.h: Likewise.  Also don't include machmode.h anymore.


diff -rup orig/egcs-CVS19990223/gcc/Makefile.in egcs-CVS19990223/gcc/Makefile.in
--- orig/egcs-CVS19990223/gcc/Makefile.in	Mon Feb 22 16:42:58 1999
+++ egcs-CVS19990223/gcc/Makefile.in	Wed Feb 24 11:05:12 1999
@@ -1968,17 +1968,17 @@ cppmain$(exeext): cppmain.o libcpp.a $(L
 	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o cppmain$(exeext) cppmain.o \
 	libcpp.a $(LIBS)
 
-cppmain.o: cppmain.c $(CONFIG_H) cpplib.h intl.h machmode.h system.h
+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 machmode.h system.h cpphash.h
-cpphash.o: cpphash.c $(CONFIG_H) cpplib.h intl.h machmode.h system.h cpphash.h
-cppalloc.o: cppalloc.c $(CONFIG_H) cpplib.h intl.h machmode.h system.h
-cpperror.o: cpperror.c $(CONFIG_H) cpplib.h intl.h machmode.h system.h
-cppexp.o:   cppexp.c   $(CONFIG_H) cpplib.h intl.h machmode.h system.h
-cppfiles.o: cppfiles.c $(CONFIG_H) cpplib.h intl.h machmode.h system.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
+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
 
-cppinit.o:  cppalloc.c $(CONFIG_H) cpplib.h intl.h machmode.h system.h \
+cppinit.o:  cppalloc.c $(CONFIG_H) cpplib.h intl.h system.h \
 		cpphash.h prefix.h output.h Makefile
 	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 	  -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
@@ -2193,10 +2193,10 @@ fix-header: fix-header.o scan-decls.o sc
 	   scan-decls.o scan.o libcpp.a $(HOST_LIBS)
 
 fix-header.o: fix-header.c $(srcdir)/../include/obstack.h scan.h \
-	xsys-protos.h $(build_xm_file) system.h cpplib.h machmode.h cpphash.h
+	xsys-protos.h $(build_xm_file) system.h cpplib.h cpphash.h
 	$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/fix-header.c
 
-scan-decls.o: scan-decls.c scan.h cpplib.h machmode.h $(build_xm_file) system.h
+scan-decls.o: scan-decls.c scan.h cpplib.h $(build_xm_file) system.h
 	$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/scan-decls.c
 
 # stmp-fixproto depends on this, not on fix-header directly.
diff -rup orig/egcs-CVS19990223/gcc/cppexp.c egcs-CVS19990223/gcc/cppexp.c
--- orig/egcs-CVS19990223/gcc/cppexp.c	Thu Feb 18 19:46:17 1999
+++ egcs-CVS19990223/gcc/cppexp.c	Wed Feb 24 10:56:58 1999
@@ -64,13 +64,13 @@ Written by Per Bothner 1994.  */
 #define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE
 #endif
 
-#define MAX_CHAR_TYPE_MASK (MAX_CHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT \
-			    ? (~ (~ (HOST_WIDE_INT) 0 << MAX_CHAR_TYPE_SIZE)) \
-			    : ~ (HOST_WIDE_INT) 0)
-
-#define MAX_WCHAR_TYPE_MASK (MAX_WCHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT \
-			     ? ~ (~ (HOST_WIDE_INT) 0 << MAX_WCHAR_TYPE_SIZE) \
-			     : ~ (HOST_WIDE_INT) 0)
+#define MAX_CHAR_TYPE_MASK (MAX_CHAR_TYPE_SIZE < HOST_BITS_PER_WIDEST_INT \
+			    ? (~ (~ (HOST_WIDEST_INT) 0 << MAX_CHAR_TYPE_SIZE)) \
+			    : ~ (HOST_WIDEST_INT) 0)
+
+#define MAX_WCHAR_TYPE_MASK (MAX_WCHAR_TYPE_SIZE < HOST_BITS_PER_WIDEST_INT \
+			     ? ~ (~ (HOST_WIDEST_INT) 0 << MAX_WCHAR_TYPE_SIZE) \
+			     : ~ (HOST_WIDEST_INT) 0)
 
 /* Yield nonzero if adding two numbers with A's and B's signs can yield a
    number with SUM's sign, where A, B, and SUM are all C integers.  */
@@ -101,14 +101,6 @@ static long right_shift PARAMS ((cpp_rea
 #define SKIP_OPERAND 8
 /*#define UNSIGNEDP 16*/
 
-#ifndef CHAR_BIT
-#define CHAR_BIT 8
-#endif
-
-#ifndef HOST_BITS_PER_WIDE_INT
-#define HOST_BITS_PER_WIDE_INT (CHAR_BIT * sizeof (HOST_WIDE_INT))
-#endif
-
 #define SKIP_WHITE_SPACE(p) do { while (is_hor_space[*p]) p++; } while (0)
 
 struct operation {
@@ -116,7 +108,7 @@ struct operation {
     char rprio; /* Priority of op (relative to it right operand).  */
     char flags;
     char unsignedp;    /* true if value should be treated as unsigned */
-    HOST_WIDE_INT value;        /* The value logically "right" of op.  */
+    HOST_WIDEST_INT value;        /* The value logically "right" of op.  */
 };
 
 /* Parse and convert an integer for #if.  Accepts decimal, hex, or octal
@@ -131,7 +123,7 @@ parse_number (pfile, start, end)
   struct operation op;
   U_CHAR *p = start;
   int c;
-  unsigned HOST_WIDE_INT n = 0, nd, MAX_over_base;
+  unsigned HOST_WIDEST_INT n = 0, nd, MAX_over_base;
   int base = 10;
   int overflow = 0;
   int digit, largest_digit = 0;
@@ -154,8 +146,8 @@ parse_number (pfile, start, end)
     }
 
   /* Some buggy compilers (e.g. MPW C) seem to need both casts.  */
-  MAX_over_base = (((unsigned HOST_WIDE_INT) -1)
-		   / ((unsigned HOST_WIDE_INT) base));
+  MAX_over_base = (((unsigned HOST_WIDEST_INT) -1)
+		   / ((unsigned HOST_WIDEST_INT) base));
 
   while (p < end)
     {
@@ -229,7 +221,7 @@ parse_number (pfile, start, end)
     cpp_pedwarn (pfile, "integer constant out of range");
 
   /* If too big to be signed, consider it unsigned.  */
-  else if ((HOST_WIDE_INT) n < 0 && ! op.unsignedp)
+  else if ((HOST_WIDEST_INT) n < 0 && ! op.unsignedp)
     {
       if (base == 10)
 	cpp_warning (pfile,
@@ -255,7 +247,7 @@ parse_charconst (pfile, start, end)
      U_CHAR *end;
 {
   struct operation op;
-  HOST_WIDE_INT result = 0;
+  HOST_WIDEST_INT result = 0;
   int num_chars = 0;
   int num_bits;
   unsigned int width = MAX_CHAR_TYPE_SIZE, mask = MAX_CHAR_TYPE_MASK;
@@ -521,11 +513,11 @@ cpp_lex (pfile, skip_evaluation)
    If \ is followed by 000, we return 0 and leave the string pointer
    after the zeros.  A value of 0 does not mean end of string.  */
 
-HOST_WIDE_INT
+HOST_WIDEST_INT
 cpp_parse_escape (pfile, string_ptr, result_mask)
      cpp_reader *pfile;
      char **string_ptr;
-     HOST_WIDE_INT result_mask;
+     HOST_WIDEST_INT result_mask;
 {
   register int c = *(*string_ptr)++;
   switch (c)
@@ -564,7 +556,7 @@ cpp_parse_escape (pfile, string_ptr, res
     case '6':
     case '7':
       {
-	register HOST_WIDE_INT i = c - '0';
+	register HOST_WIDEST_INT i = c - '0';
 	register int count = 0;
 	while (++count < 3)
 	  {
@@ -586,7 +578,7 @@ cpp_parse_escape (pfile, string_ptr, res
       }
     case 'x':
       {
-	register unsigned HOST_WIDE_INT i = 0, overflow = 0;
+	register unsigned HOST_WIDEST_INT i = 0, overflow = 0;
 	register int digits_found = 0, digit;
 	for (;;)
 	  {
@@ -692,7 +684,7 @@ right_shift (pfile, a, unsignedp, b)
 /* Parse and evaluate a C expression, reading from PFILE.
    Returns the value of the expression.  */
 
-HOST_WIDE_INT
+HOST_WIDEST_INT
 cpp_parse_expr (pfile)
      cpp_reader *pfile;
 {
diff -rup orig/egcs-CVS19990223/gcc/cppfiles.c egcs-CVS19990223/gcc/cppfiles.c
--- orig/egcs-CVS19990223/gcc/cppfiles.c	Tue Feb  9 08:48:33 1999
+++ egcs-CVS19990223/gcc/cppfiles.c	Wed Feb 24 11:01:30 1999
@@ -705,8 +705,8 @@ finclude (pfile, fd, ihash)
          a single source file bigger than 4GB needs to rethink
 	 their coding style.)  */
       st_size = (size_t) st.st_size;
-      if ((unsigned HOST_WIDE_INT) st_size
-	  != (unsigned HOST_WIDE_INT) st.st_size)
+      if ((unsigned HOST_WIDEST_INT) st_size
+	  != (unsigned HOST_WIDEST_INT) st.st_size)
 	{
 	  cpp_error (pfile, "file `%s' is too large", ihash->name);
 	  goto fail;
diff -rup orig/egcs-CVS19990223/gcc/cpplib.c egcs-CVS19990223/gcc/cpplib.c
--- orig/egcs-CVS19990223/gcc/cpplib.c	Thu Feb 18 19:51:24 1999
+++ egcs-CVS19990223/gcc/cpplib.c	Wed Feb 24 10:48:00 1999
@@ -55,7 +55,7 @@ Foundation, 59 Temple Place - Suite 330,
 
 static char *my_strerror		PROTO ((int));
 static void validate_else		PROTO ((cpp_reader *, char *));
-static HOST_WIDE_INT eval_if_expression	PROTO ((cpp_reader *));
+static HOST_WIDEST_INT eval_if_expression	PROTO ((cpp_reader *));
 
 static void conditional_skip		PROTO ((cpp_reader *, int,
 						enum node_type, U_CHAR *));
@@ -64,7 +64,7 @@ static int parse_name                   
 
 /* External declarations.  */
 
-extern HOST_WIDE_INT cpp_parse_expr PARAMS ((cpp_reader *));
+extern HOST_WIDEST_INT cpp_parse_expr PARAMS ((cpp_reader *));
 
 /* `struct directive' defines one #-directive, including how to handle it.  */
 
@@ -1595,7 +1595,7 @@ do_if (pfile, keyword)
      cpp_reader *pfile;
      struct directive *keyword ATTRIBUTE_UNUSED;
 {
-  HOST_WIDE_INT value = eval_if_expression (pfile);
+  HOST_WIDEST_INT value = eval_if_expression (pfile);
   conditional_skip (pfile, value == 0, T_IF, NULL_PTR);
   return 0;
 }
@@ -1631,7 +1631,7 @@ do_elif (pfile, keyword)
   if (pfile->if_stack->if_succeeded)
     skip_if_group (pfile);
   else {
-    HOST_WIDE_INT value = eval_if_expression (pfile);
+    HOST_WIDEST_INT value = eval_if_expression (pfile);
     if (value == 0)
       skip_if_group (pfile);
     else {
@@ -1647,11 +1647,11 @@ do_elif (pfile, keyword)
  * then parse the result as a C expression and return the value as an int.
  */
 
-static HOST_WIDE_INT
+static HOST_WIDEST_INT
 eval_if_expression (pfile)
      cpp_reader *pfile;
 {
-  HOST_WIDE_INT value;
+  HOST_WIDEST_INT value;
   long old_written = CPP_WRITTEN (pfile);
 
   pfile->pcp_inside_if = 1;
diff -rup orig/egcs-CVS19990223/gcc/cpplib.h egcs-CVS19990223/gcc/cpplib.h
--- orig/egcs-CVS19990223/gcc/cpplib.h	Thu Feb 18 19:51:25 1999
+++ egcs-CVS19990223/gcc/cpplib.h	Wed Feb 24 10:59:06 1999
@@ -666,13 +666,6 @@ struct if_stack {
 };
 typedef struct if_stack IF_STACK_FRAME;
 
-/* Find the largest host integer type and set its size and type.
-   Watch out: on some crazy hosts `long' is shorter than `int'.  */
-
-#ifndef HOST_WIDE_INT
-#include "machmode.h"
-#endif
-
 extern void cpp_buf_line_and_col PARAMS((cpp_buffer *, long *, long *));
 extern cpp_buffer* cpp_file_buffer PARAMS((cpp_reader *));
 extern void cpp_define PARAMS ((cpp_reader *, unsigned char *));
@@ -699,7 +692,7 @@ extern void cpp_perror_with_name PROTO (
 extern void v_cpp_message PROTO ((cpp_reader *, int, const char *, va_list));
 
 extern void cpp_grow_buffer PARAMS ((cpp_reader *, long));
-extern HOST_WIDE_INT cpp_parse_escape PARAMS ((cpp_reader *, char **, HOST_WIDE_INT));
+extern HOST_WIDEST_INT cpp_parse_escape PARAMS ((cpp_reader *, char **, HOST_WIDEST_INT));
 extern cpp_buffer *cpp_push_buffer PARAMS ((cpp_reader *,
 					    unsigned char *, long));
 extern cpp_buffer *cpp_pop_buffer PARAMS ((cpp_reader *));


More information about the Gcc-patches mailing list