Coverage Report

Created: 2025-07-25 13:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/be/src/gutil/endian.h
Line
Count
Source
1
// Copyright 2005 Google Inc.
2
//
3
// Licensed to the Apache Software Foundation (ASF) under one
4
// or more contributor license agreements.  See the NOTICE file
5
// distributed with this work for additional information
6
// regarding copyright ownership.  The ASF licenses this file
7
// to you under the Apache License, Version 2.0 (the
8
// "License"); you may not use this file except in compliance
9
// with the License.  You may obtain a copy of the License at
10
//
11
//   http://www.apache.org/licenses/LICENSE-2.0
12
//
13
// Unless required by applicable law or agreed to in writing,
14
// software distributed under the License is distributed on an
15
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
// KIND, either express or implied.  See the License for the
17
// specific language governing permissions and limitations
18
// under the License.
19
//
20
// ---
21
//
22
//
23
// Utility functions that depend on bytesex. We define htonll and ntohll,
24
// as well as "Google" versions of all the standards: ghtonl, ghtons, and
25
// so on. These functions do exactly the same as their standard variants,
26
// but don't require including the dangerous netinet/in.h.
27
//
28
// Buffer routines will copy to and from buffers without causing
29
// a bus error when the architecture requires different byte alignments
30
31
#pragma once
32
33
#include <assert.h>
34
35
#include "olap/uint24.h"
36
#include "vec/core/extended_types.h"
37
38
0
inline uint16_t UNALIGNED_LOAD16(const void* p) {
39
0
    uint16_t t;
40
0
    memcpy(&t, p, sizeof t);
41
0
    return t;
42
0
}
43
44
256k
inline uint32_t UNALIGNED_LOAD32(const void* p) {
45
256k
    uint32_t t;
46
256k
    memcpy(&t, p, sizeof t);
47
256k
    return t;
48
256k
}
49
50
6.12M
inline uint64_t UNALIGNED_LOAD64(const void* p) {
51
6.12M
    uint64_t t;
52
6.12M
    memcpy(&t, p, sizeof t);
53
6.12M
    return t;
54
6.12M
}
55
56
0
inline void UNALIGNED_STORE16(void* p, uint16_t v) {
57
0
    memcpy(p, &v, sizeof v);
58
0
}
59
60
285
inline void UNALIGNED_STORE32(void* p, uint32_t v) {
61
285
    memcpy(p, &v, sizeof v);
62
285
}
63
64
285
inline void UNALIGNED_STORE64(void* p, uint64_t v) {
65
285
    memcpy(p, &v, sizeof v);
66
285
}
67
68
69.5k
inline uint64_t gbswap_64(uint64_t host_int) {
69
69.5k
#if defined(__GNUC__) && defined(__x86_64__) && !defined(__APPLE__)
70
    // Adapted from /usr/include/byteswap.h.  Not available on Mac.
71
69.5k
    if (__builtin_constant_p(host_int)) {
72
0
        return __bswap_constant_64(host_int);
73
69.5k
    } else {
74
69.5k
        uint64_t result;
75
69.5k
        __asm__("bswap %0" : "=r"(result) : "0"(host_int));
76
69.5k
        return result;
77
69.5k
    }
78
#elif defined(bswap_64)
79
    return bswap_64(host_int);
80
#else
81
    return static_cast<uint64_t>(bswap_32(static_cast<uint32_t>(host_int >> 32))) |
82
           (static_cast<uint64_t>(bswap_32(static_cast<uint32_t>(host_int))) << 32);
83
#endif // bswap_64
84
69.5k
}
85
86
14.9M
inline unsigned __int128 gbswap_128(unsigned __int128 host_int) {
87
14.9M
    return static_cast<unsigned __int128>(bswap_64(static_cast<uint64_t>(host_int >> 64))) |
88
14.9M
           (static_cast<unsigned __int128>(bswap_64(static_cast<uint64_t>(host_int))) << 64);
89
14.9M
}
90
91
17.3k
inline wide::UInt256 gbswap_256(wide::UInt256 host_int) {
92
17.3k
    wide::UInt256 result {gbswap_64(host_int.items[3]), gbswap_64(host_int.items[2]),
93
17.3k
                          gbswap_64(host_int.items[1]), gbswap_64(host_int.items[0])};
94
17.3k
    return result;
95
17.3k
}
96
97
// Swap bytes of a 24-bit value.
98
1.40M
inline uint32_t bswap_24(uint32_t x) {
99
1.40M
    return ((x & 0x0000ffULL) << 16) | ((x & 0x00ff00ULL)) | ((x & 0xff0000ULL) >> 16);
100
1.40M
}
101
102
template <typename T>
103
140M
T byte_swap(T x) {
104
140M
    if constexpr (sizeof(T) == sizeof(wide::Int256)) {
105
17.3k
        return gbswap_256(x);
106
11.0M
    } else if constexpr (sizeof(T) == sizeof(__int128)) {
107
11.0M
        return gbswap_128(x);
108
54.5M
    } else if constexpr (sizeof(T) == sizeof(int64_t)) {
109
54.5M
        return bswap_64(x);
110
59.6M
    } else if constexpr (sizeof(T) == sizeof(int32_t)) {
111
59.6M
        return bswap_32(x);
112
59.6M
    } else if constexpr (sizeof(T) == sizeof(doris::uint24_t)) {
113
1.40M
        return bswap_24(x);
114
4.04M
    } else if constexpr (sizeof(T) == sizeof(int16_t)) {
115
4.04M
        return bswap_16(x);
116
9.65M
    } else {
117
9.65M
        static_assert(sizeof(T) == 1, "Unsupported type size for byte_swap");
118
9.65M
        return x; // No byte swap needed for unsupported types
119
9.65M
    }
120
140M
}
_Z9byte_swapItET_S0_
Line
Count
Source
103
4.04M
T byte_swap(T x) {
104
    if constexpr (sizeof(T) == sizeof(wide::Int256)) {
105
        return gbswap_256(x);
106
    } else if constexpr (sizeof(T) == sizeof(__int128)) {
107
        return gbswap_128(x);
108
    } else if constexpr (sizeof(T) == sizeof(int64_t)) {
109
        return bswap_64(x);
110
    } else if constexpr (sizeof(T) == sizeof(int32_t)) {
111
        return bswap_32(x);
112
    } else if constexpr (sizeof(T) == sizeof(doris::uint24_t)) {
113
        return bswap_24(x);
114
4.04M
    } else if constexpr (sizeof(T) == sizeof(int16_t)) {
115
4.04M
        return bswap_16(x);
116
    } else {
117
        static_assert(sizeof(T) == 1, "Unsupported type size for byte_swap");
118
        return x; // No byte swap needed for unsupported types
119
    }
120
4.04M
}
_Z9byte_swapIjET_S0_
Line
Count
Source
103
59.6M
T byte_swap(T x) {
104
    if constexpr (sizeof(T) == sizeof(wide::Int256)) {
105
        return gbswap_256(x);
106
    } else if constexpr (sizeof(T) == sizeof(__int128)) {
107
        return gbswap_128(x);
108
    } else if constexpr (sizeof(T) == sizeof(int64_t)) {
109
        return bswap_64(x);
110
59.6M
    } else if constexpr (sizeof(T) == sizeof(int32_t)) {
111
59.6M
        return bswap_32(x);
112
    } else if constexpr (sizeof(T) == sizeof(doris::uint24_t)) {
113
        return bswap_24(x);
114
    } else if constexpr (sizeof(T) == sizeof(int16_t)) {
115
        return bswap_16(x);
116
    } else {
117
        static_assert(sizeof(T) == 1, "Unsupported type size for byte_swap");
118
        return x; // No byte swap needed for unsupported types
119
    }
120
59.6M
}
_Z9byte_swapImET_S0_
Line
Count
Source
103
54.4M
T byte_swap(T x) {
104
    if constexpr (sizeof(T) == sizeof(wide::Int256)) {
105
        return gbswap_256(x);
106
    } else if constexpr (sizeof(T) == sizeof(__int128)) {
107
        return gbswap_128(x);
108
54.4M
    } else if constexpr (sizeof(T) == sizeof(int64_t)) {
109
54.4M
        return bswap_64(x);
110
    } else if constexpr (sizeof(T) == sizeof(int32_t)) {
111
        return bswap_32(x);
112
    } else if constexpr (sizeof(T) == sizeof(doris::uint24_t)) {
113
        return bswap_24(x);
114
    } else if constexpr (sizeof(T) == sizeof(int16_t)) {
115
        return bswap_16(x);
116
    } else {
117
        static_assert(sizeof(T) == 1, "Unsupported type size for byte_swap");
118
        return x; // No byte swap needed for unsupported types
119
    }
120
54.4M
}
_Z9byte_swapIN5doris8uint24_tEET_S2_
Line
Count
Source
103
1.40M
T byte_swap(T x) {
104
    if constexpr (sizeof(T) == sizeof(wide::Int256)) {
105
        return gbswap_256(x);
106
    } else if constexpr (sizeof(T) == sizeof(__int128)) {
107
        return gbswap_128(x);
108
    } else if constexpr (sizeof(T) == sizeof(int64_t)) {
109
        return bswap_64(x);
110
    } else if constexpr (sizeof(T) == sizeof(int32_t)) {
111
        return bswap_32(x);
112
1.40M
    } else if constexpr (sizeof(T) == sizeof(doris::uint24_t)) {
113
1.40M
        return bswap_24(x);
114
    } else if constexpr (sizeof(T) == sizeof(int16_t)) {
115
        return bswap_16(x);
116
    } else {
117
        static_assert(sizeof(T) == 1, "Unsupported type size for byte_swap");
118
        return x; // No byte swap needed for unsupported types
119
    }
120
1.40M
}
_Z9byte_swapIhET_S0_
Line
Count
Source
103
7.75M
T byte_swap(T x) {
104
    if constexpr (sizeof(T) == sizeof(wide::Int256)) {
105
        return gbswap_256(x);
106
    } else if constexpr (sizeof(T) == sizeof(__int128)) {
107
        return gbswap_128(x);
108
    } else if constexpr (sizeof(T) == sizeof(int64_t)) {
109
        return bswap_64(x);
110
    } else if constexpr (sizeof(T) == sizeof(int32_t)) {
111
        return bswap_32(x);
112
    } else if constexpr (sizeof(T) == sizeof(doris::uint24_t)) {
113
        return bswap_24(x);
114
    } else if constexpr (sizeof(T) == sizeof(int16_t)) {
115
        return bswap_16(x);
116
7.75M
    } else {
117
7.75M
        static_assert(sizeof(T) == 1, "Unsupported type size for byte_swap");
118
7.75M
        return x; // No byte swap needed for unsupported types
119
7.75M
    }
120
7.75M
}
_Z9byte_swapIoET_S0_
Line
Count
Source
103
6.76M
T byte_swap(T x) {
104
    if constexpr (sizeof(T) == sizeof(wide::Int256)) {
105
        return gbswap_256(x);
106
6.76M
    } else if constexpr (sizeof(T) == sizeof(__int128)) {
107
6.76M
        return gbswap_128(x);
108
    } else if constexpr (sizeof(T) == sizeof(int64_t)) {
109
        return bswap_64(x);
110
    } else if constexpr (sizeof(T) == sizeof(int32_t)) {
111
        return bswap_32(x);
112
    } else if constexpr (sizeof(T) == sizeof(doris::uint24_t)) {
113
        return bswap_24(x);
114
    } else if constexpr (sizeof(T) == sizeof(int16_t)) {
115
        return bswap_16(x);
116
    } else {
117
        static_assert(sizeof(T) == 1, "Unsupported type size for byte_swap");
118
        return x; // No byte swap needed for unsupported types
119
    }
120
6.76M
}
_Z9byte_swapIbET_S0_
Line
Count
Source
103
1.89M
T byte_swap(T x) {
104
    if constexpr (sizeof(T) == sizeof(wide::Int256)) {
105
        return gbswap_256(x);
106
    } else if constexpr (sizeof(T) == sizeof(__int128)) {
107
        return gbswap_128(x);
108
    } else if constexpr (sizeof(T) == sizeof(int64_t)) {
109
        return bswap_64(x);
110
    } else if constexpr (sizeof(T) == sizeof(int32_t)) {
111
        return bswap_32(x);
112
    } else if constexpr (sizeof(T) == sizeof(doris::uint24_t)) {
113
        return bswap_24(x);
114
    } else if constexpr (sizeof(T) == sizeof(int16_t)) {
115
        return bswap_16(x);
116
1.89M
    } else {
117
1.89M
        static_assert(sizeof(T) == 1, "Unsupported type size for byte_swap");
118
1.89M
        return x; // No byte swap needed for unsupported types
119
1.89M
    }
120
1.89M
}
_Z9byte_swapIN4wide7integerILm256EjEEET_S3_
Line
Count
Source
103
17.3k
T byte_swap(T x) {
104
17.3k
    if constexpr (sizeof(T) == sizeof(wide::Int256)) {
105
17.3k
        return gbswap_256(x);
106
    } else if constexpr (sizeof(T) == sizeof(__int128)) {
107
        return gbswap_128(x);
108
    } else if constexpr (sizeof(T) == sizeof(int64_t)) {
109
        return bswap_64(x);
110
    } else if constexpr (sizeof(T) == sizeof(int32_t)) {
111
        return bswap_32(x);
112
    } else if constexpr (sizeof(T) == sizeof(doris::uint24_t)) {
113
        return bswap_24(x);
114
    } else if constexpr (sizeof(T) == sizeof(int16_t)) {
115
        return bswap_16(x);
116
    } else {
117
        static_assert(sizeof(T) == 1, "Unsupported type size for byte_swap");
118
        return x; // No byte swap needed for unsupported types
119
    }
120
17.3k
}
_Z9byte_swapIlET_S0_
Line
Count
Source
103
12.1k
T byte_swap(T x) {
104
    if constexpr (sizeof(T) == sizeof(wide::Int256)) {
105
        return gbswap_256(x);
106
    } else if constexpr (sizeof(T) == sizeof(__int128)) {
107
        return gbswap_128(x);
108
12.1k
    } else if constexpr (sizeof(T) == sizeof(int64_t)) {
109
12.1k
        return bswap_64(x);
110
    } else if constexpr (sizeof(T) == sizeof(int32_t)) {
111
        return bswap_32(x);
112
    } else if constexpr (sizeof(T) == sizeof(doris::uint24_t)) {
113
        return bswap_24(x);
114
    } else if constexpr (sizeof(T) == sizeof(int16_t)) {
115
        return bswap_16(x);
116
    } else {
117
        static_assert(sizeof(T) == 1, "Unsupported type size for byte_swap");
118
        return x; // No byte swap needed for unsupported types
119
    }
120
12.1k
}
_Z9byte_swapInET_S0_
Line
Count
Source
103
4.26M
T byte_swap(T x) {
104
    if constexpr (sizeof(T) == sizeof(wide::Int256)) {
105
        return gbswap_256(x);
106
4.26M
    } else if constexpr (sizeof(T) == sizeof(__int128)) {
107
4.26M
        return gbswap_128(x);
108
    } else if constexpr (sizeof(T) == sizeof(int64_t)) {
109
        return bswap_64(x);
110
    } else if constexpr (sizeof(T) == sizeof(int32_t)) {
111
        return bswap_32(x);
112
    } else if constexpr (sizeof(T) == sizeof(doris::uint24_t)) {
113
        return bswap_24(x);
114
    } else if constexpr (sizeof(T) == sizeof(int16_t)) {
115
        return bswap_16(x);
116
    } else {
117
        static_assert(sizeof(T) == 1, "Unsupported type size for byte_swap");
118
        return x; // No byte swap needed for unsupported types
119
    }
120
4.26M
}
Unexecuted instantiation: _Z9byte_swapIN4wide7integerILm256EiEEET_S3_
Unexecuted instantiation: _Z9byte_swapIiET_S0_
121
122
template <std::endian target, typename T>
123
4.15G
T to_endian(T value) {
124
4.15G
    if constexpr (std::endian::native == target) {
125
4.01G
        return value; // No swap needed
126
4.01G
    } else {
127
140M
        static_assert(std::endian::native == std::endian::big ||
128
140M
                              std::endian::native == std::endian::little,
129
140M
                      "Unsupported endianness");
130
140M
        return byte_swap(value);
131
140M
    }
132
4.15G
}
_Z9to_endianILSt6endian1234EtET0_S1_
Line
Count
Source
123
1.16M
T to_endian(T value) {
124
1.16M
    if constexpr (std::endian::native == target) {
125
1.16M
        return value; // No swap needed
126
    } else {
127
        static_assert(std::endian::native == std::endian::big ||
128
                              std::endian::native == std::endian::little,
129
                      "Unsupported endianness");
130
        return byte_swap(value);
131
    }
132
1.16M
}
_Z9to_endianILSt6endian1234EjET0_S1_
Line
Count
Source
123
415M
T to_endian(T value) {
124
415M
    if constexpr (std::endian::native == target) {
125
415M
        return value; // No swap needed
126
    } else {
127
        static_assert(std::endian::native == std::endian::big ||
128
                              std::endian::native == std::endian::little,
129
                      "Unsupported endianness");
130
        return byte_swap(value);
131
    }
132
415M
}
_Z9to_endianILSt6endian1234EmET0_S1_
Line
Count
Source
123
3.59G
T to_endian(T value) {
124
3.59G
    if constexpr (std::endian::native == target) {
125
3.59G
        return value; // No swap needed
126
    } else {
127
        static_assert(std::endian::native == std::endian::big ||
128
                              std::endian::native == std::endian::little,
129
                      "Unsupported endianness");
130
        return byte_swap(value);
131
    }
132
3.59G
}
_Z9to_endianILSt6endian4321EtET0_S1_
Line
Count
Source
123
4.04M
T to_endian(T value) {
124
    if constexpr (std::endian::native == target) {
125
        return value; // No swap needed
126
4.04M
    } else {
127
4.04M
        static_assert(std::endian::native == std::endian::big ||
128
4.04M
                              std::endian::native == std::endian::little,
129
4.04M
                      "Unsupported endianness");
130
4.04M
        return byte_swap(value);
131
4.04M
    }
132
4.04M
}
_Z9to_endianILSt6endian4321EjET0_S1_
Line
Count
Source
123
59.6M
T to_endian(T value) {
124
    if constexpr (std::endian::native == target) {
125
        return value; // No swap needed
126
59.6M
    } else {
127
59.6M
        static_assert(std::endian::native == std::endian::big ||
128
59.6M
                              std::endian::native == std::endian::little,
129
59.6M
                      "Unsupported endianness");
130
59.6M
        return byte_swap(value);
131
59.6M
    }
132
59.6M
}
_Z9to_endianILSt6endian4321EmET0_S1_
Line
Count
Source
123
54.4M
T to_endian(T value) {
124
    if constexpr (std::endian::native == target) {
125
        return value; // No swap needed
126
54.4M
    } else {
127
54.4M
        static_assert(std::endian::native == std::endian::big ||
128
54.4M
                              std::endian::native == std::endian::little,
129
54.4M
                      "Unsupported endianness");
130
54.4M
        return byte_swap(value);
131
54.4M
    }
132
54.4M
}
Unexecuted instantiation: _Z9to_endianILSt6endian1234EoET0_S1_
_Z9to_endianILSt6endian4321EN5doris8uint24_tEET0_S3_
Line
Count
Source
123
1.40M
T to_endian(T value) {
124
    if constexpr (std::endian::native == target) {
125
        return value; // No swap needed
126
1.40M
    } else {
127
1.40M
        static_assert(std::endian::native == std::endian::big ||
128
1.40M
                              std::endian::native == std::endian::little,
129
1.40M
                      "Unsupported endianness");
130
1.40M
        return byte_swap(value);
131
1.40M
    }
132
1.40M
}
_Z9to_endianILSt6endian4321EhET0_S1_
Line
Count
Source
123
7.75M
T to_endian(T value) {
124
    if constexpr (std::endian::native == target) {
125
        return value; // No swap needed
126
7.75M
    } else {
127
7.75M
        static_assert(std::endian::native == std::endian::big ||
128
7.75M
                              std::endian::native == std::endian::little,
129
7.75M
                      "Unsupported endianness");
130
7.75M
        return byte_swap(value);
131
7.75M
    }
132
7.75M
}
_Z9to_endianILSt6endian4321EoET0_S1_
Line
Count
Source
123
6.76M
T to_endian(T value) {
124
    if constexpr (std::endian::native == target) {
125
        return value; // No swap needed
126
6.76M
    } else {
127
6.76M
        static_assert(std::endian::native == std::endian::big ||
128
6.76M
                              std::endian::native == std::endian::little,
129
6.76M
                      "Unsupported endianness");
130
6.76M
        return byte_swap(value);
131
6.76M
    }
132
6.76M
}
_Z9to_endianILSt6endian4321EbET0_S1_
Line
Count
Source
123
1.89M
T to_endian(T value) {
124
    if constexpr (std::endian::native == target) {
125
        return value; // No swap needed
126
1.89M
    } else {
127
1.89M
        static_assert(std::endian::native == std::endian::big ||
128
1.89M
                              std::endian::native == std::endian::little,
129
1.89M
                      "Unsupported endianness");
130
1.89M
        return byte_swap(value);
131
1.89M
    }
132
1.89M
}
_Z9to_endianILSt6endian4321EN4wide7integerILm256EjEEET0_S4_
Line
Count
Source
123
17.3k
T to_endian(T value) {
124
    if constexpr (std::endian::native == target) {
125
        return value; // No swap needed
126
17.3k
    } else {
127
17.3k
        static_assert(std::endian::native == std::endian::big ||
128
17.3k
                              std::endian::native == std::endian::little,
129
17.3k
                      "Unsupported endianness");
130
17.3k
        return byte_swap(value);
131
17.3k
    }
132
17.3k
}
_Z9to_endianILSt6endian4321ElET0_S1_
Line
Count
Source
123
12.1k
T to_endian(T value) {
124
    if constexpr (std::endian::native == target) {
125
        return value; // No swap needed
126
12.1k
    } else {
127
12.1k
        static_assert(std::endian::native == std::endian::big ||
128
12.1k
                              std::endian::native == std::endian::little,
129
12.1k
                      "Unsupported endianness");
130
12.1k
        return byte_swap(value);
131
12.1k
    }
132
12.1k
}
_Z9to_endianILSt6endian4321EnET0_S1_
Line
Count
Source
123
4.26M
T to_endian(T value) {
124
    if constexpr (std::endian::native == target) {
125
        return value; // No swap needed
126
4.26M
    } else {
127
4.26M
        static_assert(std::endian::native == std::endian::big ||
128
4.26M
                              std::endian::native == std::endian::little,
129
4.26M
                      "Unsupported endianness");
130
4.26M
        return byte_swap(value);
131
4.26M
    }
132
4.26M
}
Unexecuted instantiation: _Z9to_endianILSt6endian4321EN4wide7integerILm256EiEEET0_S4_
Unexecuted instantiation: _Z9to_endianILSt6endian4321EiET0_S1_
133
134
// Utilities to convert numbers between the current hosts's native byte
135
// order and little-endian byte order
136
//
137
// Load/Store methods are alignment safe
138
class LittleEndian {
139
public:
140
    // Functions to do unaligned loads and stores in little-endian order.
141
0
    static uint16_t Load16(const void* p) {
142
0
        return to_endian<std::endian::little>(UNALIGNED_LOAD16(p));
143
0
    }
144
145
0
    static void Store16(void* p, uint16_t v) {
146
0
        UNALIGNED_STORE16(p, to_endian<std::endian::little>(v));
147
0
    }
148
149
256k
    static uint32_t Load32(const void* p) {
150
256k
        return to_endian<std::endian::little>(UNALIGNED_LOAD32(p));
151
256k
    }
152
153
285
    static void Store32(void* p, uint32_t v) {
154
285
        UNALIGNED_STORE32(p, to_endian<std::endian::little>(v));
155
285
    }
156
157
6.12M
    static uint64_t Load64(const void* p) {
158
6.12M
        return to_endian<std::endian::little>(UNALIGNED_LOAD64(p));
159
6.12M
    }
160
161
285
    static void Store64(void* p, uint64_t v) {
162
285
        UNALIGNED_STORE64(p, to_endian<std::endian::little>(v));
163
285
    }
164
};
165
166
// Utilities to convert numbers between the current hosts's native byte
167
// order and big-endian byte order (same as network byte order)
168
//
169
// Load/Store methods are alignment safe
170
class BigEndian {
171
public:
172
    // Functions to do unaligned loads and stores in little-endian order.
173
0
    static uint16_t Load16(const void* p) {
174
0
        return to_endian<std::endian::big>(UNALIGNED_LOAD16(p));
175
0
    }
176
177
0
    static void Store16(void* p, uint16_t v) {
178
0
        UNALIGNED_STORE16(p, to_endian<std::endian::big>(v));
179
0
    }
180
181
16
    static uint32_t Load32(const void* p) {
182
16
        return to_endian<std::endian::big>(UNALIGNED_LOAD32(p));
183
16
    }
184
185
0
    static void Store32(void* p, uint32_t v) {
186
0
        UNALIGNED_STORE32(p, to_endian<std::endian::big>(v));
187
0
    }
188
189
0
    static uint64_t Load64(const void* p) {
190
0
        return to_endian<std::endian::big>(UNALIGNED_LOAD64(p));
191
0
    }
192
193
0
    static void Store64(void* p, uint64_t v) {
194
0
        UNALIGNED_STORE64(p, to_endian<std::endian::big>(v));
195
0
    }
196
}; // BigEndian
197
198
// Network byte order is big-endian
199
typedef BigEndian NetworkByteOrder;