File: funcretval_test_struct.c

package info (click to toggle)
elfutils 0.194-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,680 kB
  • sloc: ansic: 114,970; sh: 35,537; cpp: 4,998; makefile: 1,986; yacc: 1,388; lex: 130; asm: 77; sed: 39; awk: 35
file content (86 lines) | stat: -rw-r--r-- 1,614 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* Copyright (C) 2024 Mark J. Wielaard <mark@klomp.org>
   This file is part of elfutils.

   This file is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   elfutils is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

typedef struct
  {
    int q;
    int r;
  } div_t;

typedef struct
  {
    long q;
    long r;
  } ldiv_t;

typedef struct
  {
    float x;
    float y;
  } point_t;

typedef struct
  {
    double x;
    double y;
  } dpoint_t;

div_t __attribute__((__noinline__))
div (int n, int d)
{
  div_t r;
  r.q = n / d;
  r.r = n % d;
  return r;
}

ldiv_t __attribute__((__noinline__))
ldiv (long n, long d)
{
  ldiv_t r;
  r.q = n / d;
  r.r = n % d;
  return r;
}

point_t __attribute__((__noinline__))
mkpt (float x, float y)
{
  point_t r;
  r.x = x;
  r.y = y;
  return r;
}

dpoint_t __attribute__((__noinline__))
dmkpt (double x, double y)
{
  dpoint_t r;
  r.x = x;
  r.y = y;
  return r;
}

int
main (void)
{
  div_t d = div (3, 2);
  ldiv_t ld = ldiv (3, 2);
  point_t p = mkpt (3.0f, 1.0f);
  dpoint_t dp = dmkpt (3.0e0, 1.0e0);

  return d.q - (int) p.y + ld.q - (int) dp.y;
}