OSDN Git Service

* config/linux.h (ASM_COMMENT_START): Remove from here,
[pf3gnuchains/gcc-fork.git] / gcc / rtl.c
index acfe6c2..712a9c5 100644 (file)
--- a/gcc/rtl.c
+++ b/gcc/rtl.c
@@ -20,11 +20,7 @@ Boston, MA 02111-1307, USA.  */
 
 
 #include "config.h"
-#include <ctype.h>
-#include <stdio.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
+#include "system.h"
 #include "rtl.h"
 #include "real.h"
 
@@ -39,10 +35,6 @@ Boston, MA 02111-1307, USA.  */
    During optimization and output, this is function_obstack.  */
 
 extern struct obstack *rtl_obstack;
-
-#ifdef NEED_DECLARATION_ATOL
-extern long atol();
-#endif
 \f
 /* Indexed by rtx code, gives number of operands for an rtx with that code.
    Does NOT include rtx header data (code and links).
@@ -500,7 +492,8 @@ read_skip_spaces (infile)
        ;
       else if (c == ';')
        {
-         while ((c = getc (infile)) && c != '\n') ;
+         while ((c = getc (infile)) && c != '\n' && c != EOF)
+           ;
        }
       else if (c == '/')
        {
@@ -510,7 +503,7 @@ read_skip_spaces (infile)
            dump_and_abort ('*', c, infile);
          
          prevc = 0;
-         while ((c = getc (infile)))
+         while ((c = getc (infile)) && c != EOF)
            {
              if (prevc == '*' && c == '/')
                break;
@@ -558,6 +551,43 @@ read_name (str, infile)
   *p = 0;
 }
 \f
+/* Provide a version of a function to read a long long if the system does
+   not provide one.  */
+#if HOST_BITS_PER_WIDE_INT > HOST_BITS_PER_LONG && !defined(HAVE_ATOLL) && !defined(HAVE_ATOQ)
+HOST_WIDE_INT
+atoll(p)
+    const char *p;
+{
+  int neg = 0;
+  HOST_WIDE_INT tmp_wide;
+
+  while (ISSPACE(*p))
+    p++;
+  if (*p == '-')
+    neg = 1, p++;
+  else if (*p == '+')
+    p++;
+
+  tmp_wide = 0;
+  while (ISDIGIT(*p))
+    {
+      HOST_WIDE_INT new_wide = tmp_wide*10 + (*p - '0');
+      if (new_wide < tmp_wide)
+       {
+         /* Return INT_MAX equiv on overflow.  */
+         tmp_wide = (~(unsigned HOST_WIDE_INT)0) >> 1;
+         break;
+       }
+      tmp_wide = new_wide;
+      p++;
+    }
+
+  if (neg)
+    tmp_wide = -tmp_wide;
+  return tmp_wide;
+}
+#endif
+
 /* Read an rtx in printed representation from INFILE
    and return an actual rtx in core constructed accordingly.
    read_rtx is not used in the compiler proper, but rather in
@@ -768,15 +798,15 @@ read_rtx (infile)
 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
        tmp_wide = atol (tmp_char);
 #else
-#ifdef HAVE_ATOLL
+       /* Prefer atoll over atoq, since the former is in the ISO C9X draft. 
+          But prefer not to use our hand-rolled function above either.  */
+#if defined(HAVE_ATOLL) || !defined(HAVE_ATOQ)
        tmp_wide = atoll (tmp_char);
 #else
-#ifdef HAVE_ATOQ
        tmp_wide = atoq (tmp_char);
 #endif
 #endif
 #endif
-#endif
        XWINT (return_rtx, i) = tmp_wide;
        break;