bitfll.c
1003 Bytes
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
#include <rmon.h>
#include "corefunc.h"
bitfll()
{
int numFailures = 0;
unsigned long i = 0x01010101LU;
unsigned long long j = 0x20101010aLLU;
struct rec {
unsigned f1 : 4;
unsigned long f2 : 28;
} vrec;
struct brec {
unsigned bf1 : 4;
unsigned long long bf2 : 60;
unsigned long long bf3 : 8;
unsigned long long bf4 : 48;
unsigned long long bf5 : 8;
} vbrec;
vrec.f1 = 3;
vrec.f2 = i;
numFailures += check_equal(vrec.f1, 3);
numFailures += check_equal(vrec.f2, i);
vbrec.bf1 = 3;
vbrec.bf2 = j;
vbrec.bf3 = vbrec.bf1+1;
vbrec.bf4 = vbrec.bf2;
vbrec.bf5 = vbrec.bf3;
numFailures += check_equal(vbrec.bf1, vrec.f1);
numFailures += check_equal(vbrec.bf2, j);
numFailures += check_equal(vbrec.bf3, 4);
numFailures += check_equal(vbrec.bf4, vbrec.bf2);
numFailures += check_equal(vbrec.bf5, vbrec.bf3);
return(numFailures);
}
int
check_equal (long long a, long long b)
{
if (a != b) {
osSyncPrintf("a=%llx b=%llx\n", a, b);
return(1);
}
return(0);
}