-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmask_ext.cpp
More file actions
27 lines (23 loc) · 814 Bytes
/
mask_ext.cpp
File metadata and controls
27 lines (23 loc) · 814 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
#include <iostream>
using namespace std;
static constexpr size_t EID_BITS_PER_LEVEL = 8;
static constexpr size_t RVT_MAX_LEVELS = 2 << EID_BITS_PER_LEVEL;
static constexpr uint64_t kMaskMSByte = 0x00FFFFFFFFFFFFFF;
struct ENID {
ENID(uint64_t num) : level(num >> 56), rvb_index(num & kMaskMSByte) {}
ENID(uint8_t l, uint64_t idx) : level(l), rvb_index(idx & kMaskMSByte) {}
uint64_t level : EID_BITS_PER_LEVEL;
uint64_t rvb_index : (64 - EID_BITS_PER_LEVEL);
uint64_t get() {
uint64_t l = level << 56;
return level | rvb_index;
}
};
int main() {
//ENID num(0x1010000000000000);
ENID num(0x10, 0x1110000000000000);
cout << std::hex << num.level << std::endl;
cout << std::hex << num.rvb_index << std::endl;
cout << std::hex << num.get()<< std::endl;
return 0;
}