aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/builtins/lib/abs.c
blob: ac21ca32a9f8707bf9c5d0fd4037e0a06a6aa6c6 (plain)
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
extern int inside_main;
extern void abort (void);
#ifdef __OPTIMIZE__
#define ABORT_INSIDE_MAIN do { if (inside_main) abort (); } while (0)
#else
#define ABORT_INSIDE_MAIN do { } while (0)
#endif

typedef __INTMAX_TYPE__ intmax_t;
typedef unsigned __INTMAX_TYPE__ uintmax_t;

__attribute__ ((__noinline__))
int
abs (int x)
{
  ABORT_INSIDE_MAIN;
  return x < 0 ? -x : x;
}

__attribute__ ((__noinline__))
long
labs (long x)
{
  ABORT_INSIDE_MAIN;
  return x < 0 ? -x : x;
}

__attribute__ ((__noinline__))
long long
llabs (long long x)
{
  ABORT_INSIDE_MAIN;
  return x < 0 ? -x : x;
}

__attribute__ ((__noinline__))
intmax_t
imaxabs (intmax_t x)
{
  ABORT_INSIDE_MAIN;
  return x < 0 ? -x : x;
}

__attribute__ ((__noinline__))
unsigned int
uabs (int x)
{
  ABORT_INSIDE_MAIN;
  return x < 0 ? -(unsigned int) x : x;
}

__attribute__ ((__noinline__))
unsigned long
ulabs (long x)
{
  ABORT_INSIDE_MAIN;
  return x < 0 ? -(unsigned long) x : x;
}

__attribute__ ((__noinline__))
unsigned long long
ullabs (long long x)
{
  ABORT_INSIDE_MAIN;
  return x < 0 ? -(unsigned long long) x : x;
}

__attribute__ ((__noinline__))
uintmax_t
uimaxabs (intmax_t x)
{
  ABORT_INSIDE_MAIN;
  return x < 0 ? -(uintmax_t) x : x;
}