longlong.c
1.21 KB
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
#include <rmon.h>
#include "corefunc.h"
longlong()
{
int numFailures = 0;
long long a, b;
unsigned long long c, d;
int i, j;
long long arr[4];
long long arri[2] = {0x100001000LL, 3};
struct rec {
int one;
long long two;
} vrec;
numFailures += check_equal(sizeof(long long), 8);
numFailures += check_equal(__builtin_alignof(long long), 8);
a = 0x10000000aLL;
b = a;
b++;
d = b - 1;
numFailures += check_equal(a, d);
c = a + b;
numFailures += check_equal(c, 0x200000015LLU);
i = 5;
b = i * 2;
b = -b;
numFailures += check_equal(b, -10);
a >>= 30;
numFailures += check_equal(a, 4);
a = a << 1;
numFailures += check_equal(a, 8);
b = a % 5;
numFailures += check_equal(b, 3);
arr[0] = arri[1];
arr[3] = arr[0];
a = arr[3];
numFailures += check_equal(a, 3);
vrec.one = 1;
a--;
vrec.two = a;
numFailures += check_equal(vrec.two, 2LL);
c = 1 << ((a < 3 ? 1 : 3)*4%3+1);
numFailures += check_equal(c, 4LLU);
c ^= 1;
/* c == 5 */
c = ~c & (c | 2);
numFailures += check_equal(c, 2);
switch (b) {
case 0:
osSyncPrintf("longlong switch 0 fail\n");
numFailures++;
break;
case 3LL:
break;
default:
osSyncPrintf("longlong switch fail\n");
numFailures++;
break;
}
return(numFailures);
}