File: test.c

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (44 lines) | stat: -rw-r--r-- 900 bytes parent folder | download | duplicates (28)
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
#include <stdio.h>

#if defined(__arm__) || defined(__aarch64__) || defined (__mips__) || defined(__powerpc64__)
// Clang does not accept regparm attribute on these platforms.
// Fortunately, the default calling convention passes arguments in registers
// anyway.
#define REGPARM(N)
#else
#define REGPARM(N) __attribute__((regparm(N)))
#endif

struct bar {
  int m1;
  int m2;
};

void f1(int a, struct bar *b) __attribute__((noinline)) REGPARM(2);
void f1(int a, struct bar *b)
{
  b->m2 = b->m1 + a; // set breakpoint here
}

void f2(struct bar *b) __attribute__((noinline)) REGPARM(1);
void f2(struct bar *b)
{
  int c = b->m2;
  printf("%d\n", c); // set breakpoint here
}

float f3() __attribute__((noinline));
float f3() {
  return 3.14f;
}

int main()
{
  struct bar myBar = { 3, 4 };
  f1(2, &myBar);
  f2(&myBar);

  float f = f3();
  printf("%f\n", f); // set breakpoint here
  return 0;
}