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
|
#include "../pkmem-types.h"
#include "../pkmacros.h"
#include <cstdio>
int main(int argc, char *argv[])
{
(void)argc;
(void)argv;
(void)stdout;
// pk_handle operator==
{
struct pk_handle h, bh;
bool res;
constexpr struct pk_handle ch1 { .bucketIndex = 0xAAAAAAAA, .itemIndex = 0x55555555 };
constexpr struct pk_handle cbh1 { .bucketIndex = 0xAAAAAAAA, .itemIndex = 0x55555555 };
constexpr bool ret1 = (ch1 == cbh1);
PK_LOGV_INF("pk_handle constexpr operator== 000: %s\n", ret1 ? "true" : "false");
constexpr struct pk_handle ch2 { .bucketIndex = 0x00000000, .itemIndex = 0x00000000 };
constexpr struct pk_handle cbh2 { .bucketIndex = 0xFFFFFFFF, .itemIndex = 0xFFFFFFFF };
constexpr bool ret2 = (ch2 == cbh2);
PK_LOGV_INF("pk_handle constexpr operator== 001: %s\n", ret2 ? "true" : "false");
h.bucketIndex = 0xCAFE;
h.itemIndex = 0xBABE;
bh.bucketIndex = 0xCAFE;
bh.itemIndex = 0xBABE;
res = h == bh;
PK_LOGV_INF("pk_handle operator== 000: %s\n", res ? "true" : "false");
h.bucketIndex = 0x00000000;
h.itemIndex = 0x00000000;
bh.bucketIndex = 0xFFFFFFFF;
bh.itemIndex = 0xFFFFFFFF;
res = h == bh;
PK_LOGV_INF("pk_handle operator== 001: %s\n", res ? "true" : "false");
}
// pk_handle_validate_constexpr
{
constexpr struct pk_handle cbh { .bucketIndex = 2, .itemIndex = 2 };
constexpr struct pk_handle ch1 { .bucketIndex = 0, .itemIndex = 0 };
constexpr enum PK_HANDLE_VALIDATION ret1 = pk_handle_validate_constexpr<ch1, cbh, 1024ULL>();
PK_LOGV_INF("pk_handle_validate_constexpr: 000: %i\n", ret1);
constexpr struct pk_handle ch2 { .bucketIndex = 3, .itemIndex = 0 };
constexpr enum PK_HANDLE_VALIDATION ret2 = pk_handle_validate_constexpr<ch2, cbh, 1024ULL>();
PK_LOGV_INF("pk_handle_validate_constexpr: 000: %i\n", ret2);
constexpr struct pk_handle ch3 { .bucketIndex = 2, .itemIndex = 3 };
constexpr enum PK_HANDLE_VALIDATION ret3 = pk_handle_validate_constexpr<ch3, cbh, 1024ULL>();
PK_LOGV_INF("pk_handle_validate_constexpr: 000: %i\n", ret3);
constexpr struct pk_handle ch4 = pk_handle_MAX_constexpr;
constexpr enum PK_HANDLE_VALIDATION ret4 = pk_handle_validate_constexpr<ch4, cbh, 1024ULL>();
PK_LOGV_INF("pk_handle_validate_constexpr: 000: %i\n", ret4);
}
// custom pk_handle_validate
{
struct custom_handle : public pk_handle{};
struct custom_handle h, bh;
bool res;
struct custom_handle ch1; ch1.bucketIndex = 0xAAAAAAAA; ch1.itemIndex = 0x55555555;
struct custom_handle cbh1; cbh1.bucketIndex = 0xAAAAAAAA; cbh1.itemIndex = 0x55555555;
bool ret1 = (ch1 == cbh1);
PK_LOGV_INF("custom_handle constexpr operator== 000: %s\n", ret1 ? "true" : "false");
struct custom_handle ch2; ch2.bucketIndex = 0x00000000; ch2.itemIndex = 0x00000000;
struct custom_handle cbh2; cbh2.bucketIndex = 0xFFFFFFFF; cbh2.itemIndex = 0xFFFFFFFF;
bool ret2 = (ch2 == cbh2);
PK_LOGV_INF("custom_handle constexpr operator== 001: %s\n", ret2 ? "true" : "false");
h.bucketIndex = 0xCAFE;
h.itemIndex = 0xBABE;
bh.bucketIndex = 0xCAFE;
bh.itemIndex = 0xBABE;
res = h == bh;
PK_LOGV_INF("custom_handle operator== 000: %s\n", res ? "true" : "false");
h.bucketIndex = 0x00000000;
h.itemIndex = 0x00000000;
bh.bucketIndex = 0xFFFFFFFF;
bh.itemIndex = 0xFFFFFFFF;
res = h == bh;
PK_LOGV_INF("custom_handle operator== 001: %s\n", res ? "true" : "false");
}
return 0;
}
|