-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.hpp
67 lines (54 loc) · 1.41 KB
/
common.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
#pragma once
#include <cstdint>
#include <string>
#include <string_view>
#include <vector>
#if defined(__GNUC__) || defined(__clang__)
#define HLCUP_LIKELY(x) __builtin_expect(!!(x), 1)
#define HLCUP_UNLIKELY(x) __builtin_expect(!!(x), 0)
#define HLCUP_ALWAYS_INLINE __attribute__((always_inline))
#define HLCUP_UNREACHABLE() __builtin_unreachable()
#elif defined(_MSC_VER)
#define HLCUP_LIKELY(x) x
#define HLCUP_UNLIKELY(x) x
#define HLCUP_ALWAYS_INLINE __forceinline
#define HLCUP_UNREACHABLE() __assume(0)
#else
#define HLCUP_LIKELY(x) x
#define HLCUP_UNLIKELY(x) x
#define HLCUP_ALWAYS_INLINE inline
#define HLCUP_UNREACHABLE() assert(!"unreachable")
#endif
namespace hlcup {
using i64 = std::int64_t;
using i32 = std::int32_t;
using i16 = std::int16_t;
using i8 = std::int8_t;
using u64 = std::uint64_t;
using u32 = std::uint32_t;
using u16 = std::uint16_t;
using u8 = std::uint8_t;
struct StringRef {
u32 offset;
u32 size;
void set_by_size(u32 offset, u32 size) {
this->offset = offset;
this->size = size;
}
void set_by_offset(u32 o1, u32 o2) {
offset = o1;
size = o2 - o1;
}
};
using Timestamp = i32;
const static constexpr Timestamp kInvalidTimestamp = std::numeric_limits<Timestamp>::max();
enum Sex : u8 {
kFemale = 0,
kMale = 1,
};
enum Status : u8 {
kFree = 0,
kComplicated = 1,
kOccupied = 2,
};
} // namespace hlcup