-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbitTypes.hpp
121 lines (108 loc) · 1.45 KB
/
bitTypes.hpp
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#pragma once
/*
* File: bitTypes.h
* Author: chtacklind
*
* Created on December 13, 2011, 4:00 PM
*/
#include "basicTypes.hpp"
namespace Basic {
typedef u1 b1;
typedef u1 b2;
typedef u1 b3;
typedef u1 b4;
typedef u1 b5;
typedef u1 b6;
typedef u1 b7;
//#define BITFIELD u1 BYTE; struct {b1 B0:1; b1 B1:1; b1 B2:1;
// b1 B3:1; b1 B4:1; b1 B5:1; b1 B6:1; b1 B7:1;}
typedef union {
u1 byte;
struct {
b2 bits : 2;
};
struct {
b1 B0 : 1;
b1 B1 : 1;
};
} bf2;
typedef union {
u1 byte;
struct {
b3 bits : 3;
};
struct {
b1 B0 : 1;
b1 B1 : 1;
b1 B2 : 1;
};
} bf3;
typedef union {
u1 byte;
struct {
b4 bits : 4;
};
struct {
b1 B0 : 1;
b1 B1 : 1;
b1 B2 : 1;
b1 B3 : 1;
};
} bf4;
typedef union {
u1 byte;
struct {
b5 bits : 5;
};
struct {
b1 B0 : 1;
b1 B1 : 1;
b1 B2 : 1;
b1 B3 : 1;
b1 B4 : 1;
};
} bf5;
typedef union {
u1 byte;
struct {
b6 bits : 6;
};
struct {
b1 B0 : 1;
b1 B1 : 1;
b1 B2 : 1;
b1 B3 : 1;
b1 B4 : 1;
b1 B5 : 1;
};
} bf6;
typedef union {
u1 byte;
struct {
b7 bits : 7;
};
struct {
b1 B0 : 1;
b1 B1 : 1;
b1 B2 : 1;
b1 B3 : 1;
b1 B4 : 1;
b1 B5 : 1;
b1 B6 : 1;
};
} bf7;
typedef union {
u1 byte;
u1 bits;
struct {
b1 B0 : 1;
b1 B1 : 1;
b1 B2 : 1;
b1 B3 : 1;
b1 B4 : 1;
b1 B5 : 1;
b1 B6 : 1;
b1 B7 : 1;
};
} bf8;
}; // namespace Basic