root / tests / tcg / cris / check_int64.c @ c09015dd
History | View | Annotate | Download (584 Bytes)
1 | dd43edf4 | ths | #include <stdio.h> |
---|---|---|---|
2 | dd43edf4 | ths | #include <stdlib.h> |
3 | dd43edf4 | ths | #include <stdint.h> |
4 | dd43edf4 | ths | #include "sys.h" |
5 | dd43edf4 | ths | #include "crisutils.h" |
6 | dd43edf4 | ths | |
7 | dd43edf4 | ths | |
8 | 4a6648f4 | Blue Swirl | static inline int64_t add64(const int64_t a, const int64_t b) |
9 | 4a6648f4 | Blue Swirl | { |
10 | dd43edf4 | ths | return a + b;
|
11 | dd43edf4 | ths | } |
12 | dd43edf4 | ths | |
13 | 4a6648f4 | Blue Swirl | static inline int64_t sub64(const int64_t a, const int64_t b) |
14 | 4a6648f4 | Blue Swirl | { |
15 | dd43edf4 | ths | return a - b;
|
16 | dd43edf4 | ths | } |
17 | dd43edf4 | ths | |
18 | dd43edf4 | ths | int main(void) |
19 | dd43edf4 | ths | { |
20 | dd43edf4 | ths | int64_t a = 1;
|
21 | dd43edf4 | ths | int64_t b = 2;
|
22 | dd43edf4 | ths | |
23 | dd43edf4 | ths | /* FIXME: add some tests. */
|
24 | dd43edf4 | ths | a = add64(a, b); |
25 | dd43edf4 | ths | if (a != 3) |
26 | dd43edf4 | ths | err(); |
27 | dd43edf4 | ths | |
28 | dd43edf4 | ths | a = sub64(a, b); |
29 | dd43edf4 | ths | if (a != 1) |
30 | dd43edf4 | ths | err(); |
31 | dd43edf4 | ths | |
32 | dd43edf4 | ths | a = add64(a, -4);
|
33 | dd43edf4 | ths | if (a != -3) |
34 | dd43edf4 | ths | err(); |
35 | dd43edf4 | ths | |
36 | dd43edf4 | ths | a = add64(a, 3);
|
37 | dd43edf4 | ths | if (a != 0) |
38 | dd43edf4 | ths | err(); |
39 | dd43edf4 | ths | |
40 | dd43edf4 | ths | a = 0;
|
41 | dd43edf4 | ths | a = sub64(a, 1);
|
42 | dd43edf4 | ths | if (a != -1) |
43 | dd43edf4 | ths | err(); |
44 | dd43edf4 | ths | |
45 | dd43edf4 | ths | pass(); |
46 | dd43edf4 | ths | return 0; |
47 | dd43edf4 | ths | } |