File: 960416-1.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A12.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 959,712 kB
  • sloc: cpp: 3,275,382; ansic: 2,061,766; ada: 840,956; f90: 208,513; makefile: 76,132; asm: 73,433; xml: 50,448; exp: 34,146; sh: 32,436; objc: 15,637; fortran: 14,012; python: 11,991; pascal: 6,787; awk: 4,779; perl: 3,054; yacc: 338; ml: 285; lex: 201; haskell: 122
file content (63 lines) | stat: -rw-r--r-- 1,019 bytes parent folder | download | duplicates (14)
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
typedef unsigned long int st;
typedef unsigned long long dt;
typedef union
{
  dt d;
  struct
  {
    st h, l;
  }
  s;
} t_be;

typedef union
{
  dt d;
  struct
  {
    st l, h;
  }
  s;
} t_le;

#define df(f, t) \
int \
f (t afh, t bfh) \
{ \
  t hh; \
  t hp, lp, dp, m; \
  st ad, bd; \
  int s; \
  s = 0; \
  ad = afh.s.h - afh.s.l; \
  bd = bfh.s.l - bfh.s.h; \
  if (bd > bfh.s.l) \
    { \
      bd = -bd; \
      s = ~s; \
    } \
  lp.d = (dt) afh.s.l * bfh.s.l; \
  hp.d = (dt) afh.s.h * bfh.s.h; \
  dp.d = (dt) ad *bd; \
  dp.d ^= s; \
  hh.d = hp.d + hp.s.h + lp.s.h + dp.s.h; \
  m.d = (dt) lp.s.h + hp.s.l + lp.s.l + dp.s.l; \
  return hh.s.l + m.s.l; \
}

df(f_le, t_le)
df(f_be, t_be)

main ()
{
  t_be x;
  x.s.h = 0x10000000U;
  x.s.l = 0xe0000000U;
  if (x.d == 0x10000000e0000000ULL
      && f_be ((t_be) 0x100000000ULL, (t_be) 0x100000000ULL) != -1)
    abort ();
  if (x.d == 0xe000000010000000ULL
      && f_le ((t_le) 0x100000000ULL, (t_le) 0x100000000ULL) != -1)
    abort ();
  exit (0);
}