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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [testsuite/] [gdb.base/] [return2.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/* Test gdb's "return" command.  */
2
 
3
int void_test = 0;
4
int main_test = 0;
5
 
6
char      char_returnval      = '1';
7
short     short_returnval     = 1;
8
int       int_returnval       = 1;
9
long      long_returnval      = 1;
10
long long long_long_returnval = 1;
11
float     float_returnval     = 1;
12
double    double_returnval    = 1;
13
 
14
union {
15
  char      char_testval;
16
  short     short_testval;
17
  int       int_testval;
18
  long      long_testval;
19
  long long long_long_testval;
20
  float     float_testval;
21
  double    double_testval;
22
  char      ffff[80];
23
} testval;
24
 
25
void void_func ()
26
{
27
  void_test = 1;
28
}
29
 
30
char char_func ()
31
{
32
  return char_returnval;
33
}
34
 
35
short short_func ()
36
{
37
  return short_returnval;
38
}
39
 
40
int int_func ()
41
{
42
  return int_returnval;
43
}
44
 
45
long long_func ()
46
{
47
  return long_returnval;
48
}
49
 
50
long long long_long_func ()
51
{
52
  return long_long_returnval;
53
}
54
 
55
float float_func ()
56
{
57
  return float_returnval;
58
}
59
 
60
double double_func ()
61
{
62
  return double_returnval;
63
}
64
 
65
int main (int argc, char **argv)
66
{
67
  char char_resultval;
68
  short short_resultval;
69
  int int_resultval;
70
  long long_resultval;
71
  long long long_long_resultval;
72
  float float_resultval;
73
  double double_resultval;
74
  int i;
75
 
76
  /* A "test load" that will insure that the function really returns
77
     a ${type} (as opposed to just a truncated or part of a ${type}).  */
78
  for (i = 0; i < sizeof (testval.ffff); i++)
79
    testval.ffff[i] = 0xff;
80
 
81
  void_func ();                                 /* call to void_func */
82
  char_resultval      = char_func ();           /* void_checkpoint */
83
  short_resultval     = short_func ();          /* char_checkpoint */
84
  int_resultval       = int_func ();            /* short_checkpoint */
85
  long_resultval      = long_func ();           /* int_checkpoint */
86
  long_long_resultval = long_long_func ();      /* long_checkpoint */
87
 
88
  /* On machines using IEEE floating point, the test pattern of all
89
     1-bits established above turns out to be a floating-point NaN
90
     ("Not a Number").  According to the IEEE rules, NaN's aren't even
91
     equal to themselves.  This can lead to stupid conversations with
92
     GDB like:
93
 
94
       (gdb) p testval.float_testval == testval.float_testval
95
       $7 = 0
96
       (gdb)
97
 
98
     This is the correct answer, but it's not the sort of thing
99
     return2.exp wants to see.  So to make things work the way they
100
     ought, we'll set aside the `union' cleverness and initialize the
101
     test values explicitly here.  These values have interesting bits
102
     throughout the value, so we'll still detect truncated values.  */
103
 
104
  testval.float_testval = 2.7182818284590452354;/* long_long_checkpoint */
105
  float_resultval     = float_func ();
106
  testval.double_testval = 3.14159265358979323846; /* float_checkpoint */
107
  double_resultval    = double_func ();
108
  main_test = 1;                                /* double_checkpoint */
109
  return 0;
110
}

powered by: WebSVN 2.1.0

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