OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.target/] [i386/] [pr46939.c] - Blame information for rev 724

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 691 jeremybenn
/* { dg-do compile } */
2
/* { dg-options "-O2" } */
3
 
4
__extension__ typedef __SIZE_TYPE__ size_t;
5
 
6
int
7
php_filter_parse_int (char const *str, unsigned int str_len, long *ret)
8
{
9
  long ctx_value;
10
  int sign;
11
  int digit;
12
  char const *end;
13
  int tmp;
14
  char const *tmp___0;
15
  char const *tmp___1;
16
 
17
  sign = 0;
18
  digit = 0;
19
  end = str + str_len;
20
  switch ((int) *str)
21
    {
22
    case 45:
23
      sign = 1;
24
    case 43:
25
      str++;
26
    default:;
27
      break;
28
    }
29
  if ((size_t) str < (size_t) end)
30
    {
31
      if ((int const) *str >= 49)
32
        {
33
          if ((int const) *str <= 57)
34
            {
35
              if (sign)
36
                {
37
                  tmp = -1;
38
                }
39
              else
40
                {
41
                  tmp = 1;
42
                }
43
              tmp___0 = str;
44
              str++;
45
              ctx_value = (long) (tmp * (int) ((int const) *tmp___0 - 48));
46
            }
47
          else
48
            {
49
              return (-1);
50
            }
51
        }
52
      else
53
        {
54
          return (-1);
55
        }
56
    }
57
  else
58
    {
59
      return (-1);
60
    }
61
  if (end - str > 19)
62
    {
63
      return (-1);
64
    }
65
  while ((size_t) str < (size_t) end)
66
    {
67
      if ((int const) *str >= 48)
68
        {
69
          if ((int const) *str <= 57)
70
            {
71
              tmp___1 = str;
72
              str++;
73
              digit = (int) ((int const) *tmp___1 - 48);
74
              if (!sign)
75
                {
76
                  if (ctx_value <=
77
                      (9223372036854775807L - (long) digit) / 10L)
78
                    {
79
                      ctx_value = ctx_value * 10L + (long) digit;
80
                    }
81
                  else
82
                    {
83
                      goto _L;
84
                    }
85
                }
86
              else
87
                {
88
                _L:
89
                  if (sign)
90
                    {
91
                      if (ctx_value >=
92
                          ((-0x7FFFFFFFFFFFFFFF - 1) + (long) digit) / 10L)
93
                        {
94
                          ctx_value = ctx_value * 10L - (long) digit;
95
                        }
96
                      else
97
                        {
98
                          return (-1);
99
                        }
100
                    }
101
                  else
102
                    {
103
                      return (-1);
104
                    }
105
                }
106
            }
107
          else
108
            {
109
              return (-1);
110
            }
111
        }
112
      else
113
        {
114
          return (-1);
115
        }
116
    }
117
  *ret = ctx_value;
118
  return (1);
119
}
120
 
121
/* { dg-final { scan-assembler-not "idiv" } } */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.