1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2017 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker *
4*795d594fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker *
8*795d594fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker *
10*795d594fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker */
16*795d594fSAndroid Build Coastguard Worker
17*795d594fSAndroid Build Coastguard Worker #ifndef ART_LIBARTBASE_BASE_BIT_STRUCT_H_
18*795d594fSAndroid Build Coastguard Worker #define ART_LIBARTBASE_BASE_BIT_STRUCT_H_
19*795d594fSAndroid Build Coastguard Worker
20*795d594fSAndroid Build Coastguard Worker #include <type_traits>
21*795d594fSAndroid Build Coastguard Worker
22*795d594fSAndroid Build Coastguard Worker #include "base/casts.h"
23*795d594fSAndroid Build Coastguard Worker #include "bit_struct_detail.h"
24*795d594fSAndroid Build Coastguard Worker #include "bit_utils.h"
25*795d594fSAndroid Build Coastguard Worker
26*795d594fSAndroid Build Coastguard Worker //
27*795d594fSAndroid Build Coastguard Worker // Zero-cost, type-safe, well-defined "structs" of bit fields.
28*795d594fSAndroid Build Coastguard Worker //
29*795d594fSAndroid Build Coastguard Worker // ---------------------------------------------
30*795d594fSAndroid Build Coastguard Worker // Usage example:
31*795d594fSAndroid Build Coastguard Worker // ---------------------------------------------
32*795d594fSAndroid Build Coastguard Worker //
33*795d594fSAndroid Build Coastguard Worker // // Definition for type 'Example'
34*795d594fSAndroid Build Coastguard Worker // BITSTRUCT_DEFINE_START(Example, 10)
35*795d594fSAndroid Build Coastguard Worker // BITSTRUCT_UINT(0, 2) u2; // Every field must be a BitStruct[*] with the same StorageType,
36*795d594fSAndroid Build Coastguard Worker // BITSTRUCT_INT(2, 7) i7; // preferably using BITSTRUCT_{FIELD,UINT,INT}
37*795d594fSAndroid Build Coastguard Worker // BITSTRUCT_UINT(9, 1) i1; // to fill in the StorageType parameter.
38*795d594fSAndroid Build Coastguard Worker // BITSTRUCT_DEFINE_END(Example);
39*795d594fSAndroid Build Coastguard Worker //
40*795d594fSAndroid Build Coastguard Worker // Would define a bit struct with this layout:
41*795d594fSAndroid Build Coastguard Worker // <- 1 -> <-- 7 --> <- 2 ->
42*795d594fSAndroid Build Coastguard Worker // +--------+---------------+-----+
43*795d594fSAndroid Build Coastguard Worker // | i1 | i7 | u2 +
44*795d594fSAndroid Build Coastguard Worker // +--------+---------------+-----+
45*795d594fSAndroid Build Coastguard Worker // 10 9 2 0
46*795d594fSAndroid Build Coastguard Worker //
47*795d594fSAndroid Build Coastguard Worker // // Read-write just like regular values.
48*795d594fSAndroid Build Coastguard Worker // Example ex;
49*795d594fSAndroid Build Coastguard Worker // ex.u2 = 3;
50*795d594fSAndroid Build Coastguard Worker // ex.i7 = -25;
51*795d594fSAndroid Build Coastguard Worker // ex.i1 = true;
52*795d594fSAndroid Build Coastguard Worker // size_t u2 = ex.u2;
53*795d594fSAndroid Build Coastguard Worker // int i7 = ex.i7;
54*795d594fSAndroid Build Coastguard Worker // bool i1 = ex.i1;
55*795d594fSAndroid Build Coastguard Worker //
56*795d594fSAndroid Build Coastguard Worker // // It's packed down to the smallest # of machine words.
57*795d594fSAndroid Build Coastguard Worker // assert(sizeof(Example) == 2);
58*795d594fSAndroid Build Coastguard Worker // // The exact bit pattern is well-defined by the template parameters.
59*795d594fSAndroid Build Coastguard Worker // uint16_t cast = *reinterpret_cast<uint16_t*>(ex);
60*795d594fSAndroid Build Coastguard Worker // assert(cast == ((3) | (0b100111 << 2) | (true << 9);
61*795d594fSAndroid Build Coastguard Worker //
62*795d594fSAndroid Build Coastguard Worker // ---------------------------------------------
63*795d594fSAndroid Build Coastguard Worker // Why not just use C++ bitfields?
64*795d594fSAndroid Build Coastguard Worker // ---------------------------------------------
65*795d594fSAndroid Build Coastguard Worker //
66*795d594fSAndroid Build Coastguard Worker // The layout is implementation-defined.
67*795d594fSAndroid Build Coastguard Worker // We do not know whether the fields are packed left-to-right or
68*795d594fSAndroid Build Coastguard Worker // right-to-left, so it makes it useless when the memory layout needs to be
69*795d594fSAndroid Build Coastguard Worker // precisely controlled.
70*795d594fSAndroid Build Coastguard Worker //
71*795d594fSAndroid Build Coastguard Worker // ---------------------------------------------
72*795d594fSAndroid Build Coastguard Worker // More info:
73*795d594fSAndroid Build Coastguard Worker // ---------------------------------------------
74*795d594fSAndroid Build Coastguard Worker // Currently uintmax_t is the largest supported underlying storage type,
75*795d594fSAndroid Build Coastguard Worker // all (kBitOffset + kBitWidth) must fit into BitSizeOf<uintmax_t>();
76*795d594fSAndroid Build Coastguard Worker //
77*795d594fSAndroid Build Coastguard Worker // Using BitStruct[U]int will automatically select an underlying type
78*795d594fSAndroid Build Coastguard Worker // that's the smallest to fit your (offset + bitwidth).
79*795d594fSAndroid Build Coastguard Worker //
80*795d594fSAndroid Build Coastguard Worker // BitStructNumber can be used to manually select an underlying type.
81*795d594fSAndroid Build Coastguard Worker //
82*795d594fSAndroid Build Coastguard Worker // BitStructField can be used with custom standard-layout structs,
83*795d594fSAndroid Build Coastguard Worker // thus allowing for arbitrary nesting of bit structs.
84*795d594fSAndroid Build Coastguard Worker //
85*795d594fSAndroid Build Coastguard Worker namespace art {
86*795d594fSAndroid Build Coastguard Worker // Zero-cost wrapper around a struct 'T', allowing it to be stored as a bitfield
87*795d594fSAndroid Build Coastguard Worker // at offset 'kBitOffset' and width 'kBitWidth'.
88*795d594fSAndroid Build Coastguard Worker // The storage is plain unsigned int, whose size is the smallest required to fit
89*795d594fSAndroid Build Coastguard Worker // 'kBitOffset + kBitWidth'. All operations to this become BitFieldExtract/BitFieldInsert
90*795d594fSAndroid Build Coastguard Worker // operations to the underlying uint.
91*795d594fSAndroid Build Coastguard Worker //
92*795d594fSAndroid Build Coastguard Worker // Field memory representation:
93*795d594fSAndroid Build Coastguard Worker //
94*795d594fSAndroid Build Coastguard Worker // MSB <-- width --> LSB
95*795d594fSAndroid Build Coastguard Worker // +--------+------------+--------+
96*795d594fSAndroid Build Coastguard Worker // | ?????? | u bitfield | ?????? +
97*795d594fSAndroid Build Coastguard Worker // +--------+------------+--------+
98*795d594fSAndroid Build Coastguard Worker // offset 0
99*795d594fSAndroid Build Coastguard Worker //
100*795d594fSAndroid Build Coastguard Worker // Reading/writing the bitfield (un)packs it into a temporary T:
101*795d594fSAndroid Build Coastguard Worker //
102*795d594fSAndroid Build Coastguard Worker // MSB <-- width --> LSB
103*795d594fSAndroid Build Coastguard Worker // +-----------------+------------+
104*795d594fSAndroid Build Coastguard Worker // | 0.............0 | T bitfield |
105*795d594fSAndroid Build Coastguard Worker // +-----------------+------------+
106*795d594fSAndroid Build Coastguard Worker // 0
107*795d594fSAndroid Build Coastguard Worker //
108*795d594fSAndroid Build Coastguard Worker // It's the responsibility of the StorageType to ensure the bit representation
109*795d594fSAndroid Build Coastguard Worker // of T can be represented by kBitWidth.
110*795d594fSAndroid Build Coastguard Worker template <typename T,
111*795d594fSAndroid Build Coastguard Worker size_t kBitOffset,
112*795d594fSAndroid Build Coastguard Worker size_t kBitWidth,
113*795d594fSAndroid Build Coastguard Worker typename StorageType>
114*795d594fSAndroid Build Coastguard Worker struct BitStructField {
115*795d594fSAndroid Build Coastguard Worker static_assert(std::is_standard_layout_v<T>, "T must be standard layout");
116*795d594fSAndroid Build Coastguard Worker
TBitStructField117*795d594fSAndroid Build Coastguard Worker operator T() const {
118*795d594fSAndroid Build Coastguard Worker return Get();
119*795d594fSAndroid Build Coastguard Worker }
120*795d594fSAndroid Build Coastguard Worker
121*795d594fSAndroid Build Coastguard Worker // Exclude overload when T==StorageType.
122*795d594fSAndroid Build Coastguard Worker template <typename _ = void,
123*795d594fSAndroid Build Coastguard Worker typename = std::enable_if_t<std::is_same_v<T, StorageType>, _>>
StorageTypeBitStructField124*795d594fSAndroid Build Coastguard Worker explicit operator StorageType() const {
125*795d594fSAndroid Build Coastguard Worker return BitFieldExtract(storage_, kBitOffset, kBitWidth);
126*795d594fSAndroid Build Coastguard Worker }
127*795d594fSAndroid Build Coastguard Worker
128*795d594fSAndroid Build Coastguard Worker BitStructField& operator=(T value) {
129*795d594fSAndroid Build Coastguard Worker return Assign(*this, value);
130*795d594fSAndroid Build Coastguard Worker }
131*795d594fSAndroid Build Coastguard Worker
BitStructSizeOfBitStructField132*795d594fSAndroid Build Coastguard Worker static constexpr size_t BitStructSizeOf() {
133*795d594fSAndroid Build Coastguard Worker return kBitWidth;
134*795d594fSAndroid Build Coastguard Worker }
135*795d594fSAndroid Build Coastguard Worker
136*795d594fSAndroid Build Coastguard Worker BitStructField& operator=(const BitStructField& other) {
137*795d594fSAndroid Build Coastguard Worker // Warning. The default operator= will overwrite the entire storage!
138*795d594fSAndroid Build Coastguard Worker return *this = static_cast<T>(other);
139*795d594fSAndroid Build Coastguard Worker }
140*795d594fSAndroid Build Coastguard Worker
BitStructFieldBitStructField141*795d594fSAndroid Build Coastguard Worker BitStructField(const BitStructField& other) {
142*795d594fSAndroid Build Coastguard Worker Assign(*this, static_cast<T>(other));
143*795d594fSAndroid Build Coastguard Worker }
144*795d594fSAndroid Build Coastguard Worker
145*795d594fSAndroid Build Coastguard Worker BitStructField() = default;
146*795d594fSAndroid Build Coastguard Worker ~BitStructField() = default;
147*795d594fSAndroid Build Coastguard Worker
148*795d594fSAndroid Build Coastguard Worker protected:
149*795d594fSAndroid Build Coastguard Worker template <typename T2>
AssignBitStructField150*795d594fSAndroid Build Coastguard Worker T2& Assign(T2& what, T value) {
151*795d594fSAndroid Build Coastguard Worker // Since C++ doesn't allow the type of operator= to change out
152*795d594fSAndroid Build Coastguard Worker // in the subclass, reimplement operator= in each subclass
153*795d594fSAndroid Build Coastguard Worker // manually and call this helper function.
154*795d594fSAndroid Build Coastguard Worker static_assert(std::is_base_of_v<BitStructField, T2>, "T2 must inherit BitStructField");
155*795d594fSAndroid Build Coastguard Worker what.Set(value);
156*795d594fSAndroid Build Coastguard Worker return what;
157*795d594fSAndroid Build Coastguard Worker }
158*795d594fSAndroid Build Coastguard Worker
GetBitStructField159*795d594fSAndroid Build Coastguard Worker T Get() const {
160*795d594fSAndroid Build Coastguard Worker ExtractionType storage = static_cast<ExtractionType>(storage_);
161*795d594fSAndroid Build Coastguard Worker ExtractionType extracted = BitFieldExtract(storage, kBitOffset, kBitWidth);
162*795d594fSAndroid Build Coastguard Worker ConversionType to_convert = dchecked_integral_cast<ConversionType>(extracted);
163*795d594fSAndroid Build Coastguard Worker return ValueConverter::FromUnderlyingStorage(to_convert);
164*795d594fSAndroid Build Coastguard Worker }
165*795d594fSAndroid Build Coastguard Worker
SetBitStructField166*795d594fSAndroid Build Coastguard Worker void Set(T value) {
167*795d594fSAndroid Build Coastguard Worker ConversionType converted = ValueConverter::ToUnderlyingStorage(value);
168*795d594fSAndroid Build Coastguard Worker ExtractionType extracted = dchecked_integral_cast<ExtractionType>(converted);
169*795d594fSAndroid Build Coastguard Worker storage_ = BitFieldInsert(storage_, extracted, kBitOffset, kBitWidth);
170*795d594fSAndroid Build Coastguard Worker }
171*795d594fSAndroid Build Coastguard Worker
172*795d594fSAndroid Build Coastguard Worker private:
173*795d594fSAndroid Build Coastguard Worker using ValueConverter = detail::ValueConverter<T>;
174*795d594fSAndroid Build Coastguard Worker using ConversionType = typename ValueConverter::StorageType;
175*795d594fSAndroid Build Coastguard Worker using ExtractionType = std::conditional_t<std::is_signed_v<ConversionType>,
176*795d594fSAndroid Build Coastguard Worker std::make_signed_t<StorageType>,
177*795d594fSAndroid Build Coastguard Worker StorageType>;
178*795d594fSAndroid Build Coastguard Worker
179*795d594fSAndroid Build Coastguard Worker StorageType storage_;
180*795d594fSAndroid Build Coastguard Worker };
181*795d594fSAndroid Build Coastguard Worker
182*795d594fSAndroid Build Coastguard Worker // Base class for number-like BitStruct fields.
183*795d594fSAndroid Build Coastguard Worker // T is the type to store in as a bit field.
184*795d594fSAndroid Build Coastguard Worker // kBitOffset, kBitWidth define the position and length of the bitfield.
185*795d594fSAndroid Build Coastguard Worker //
186*795d594fSAndroid Build Coastguard Worker // (Common usage should be BitStructInt, BitStructUint -- this
187*795d594fSAndroid Build Coastguard Worker // intermediate template allows a user-defined integer to be used.)
188*795d594fSAndroid Build Coastguard Worker template <typename T, size_t kBitOffset, size_t kBitWidth, typename StorageType>
189*795d594fSAndroid Build Coastguard Worker struct BitStructNumber : public BitStructField<T, kBitOffset, kBitWidth, StorageType> {
190*795d594fSAndroid Build Coastguard Worker BitStructNumber& operator=(T value) {
191*795d594fSAndroid Build Coastguard Worker return BaseType::Assign(*this, value);
192*795d594fSAndroid Build Coastguard Worker }
193*795d594fSAndroid Build Coastguard Worker
TBitStructNumber194*795d594fSAndroid Build Coastguard Worker /*implicit*/ operator T() const {
195*795d594fSAndroid Build Coastguard Worker return Get();
196*795d594fSAndroid Build Coastguard Worker }
197*795d594fSAndroid Build Coastguard Worker
198*795d594fSAndroid Build Coastguard Worker explicit operator bool() const {
199*795d594fSAndroid Build Coastguard Worker return static_cast<bool>(Get());
200*795d594fSAndroid Build Coastguard Worker }
201*795d594fSAndroid Build Coastguard Worker
202*795d594fSAndroid Build Coastguard Worker BitStructNumber& operator++() {
203*795d594fSAndroid Build Coastguard Worker *this = Get() + 1u;
204*795d594fSAndroid Build Coastguard Worker return *this;
205*795d594fSAndroid Build Coastguard Worker }
206*795d594fSAndroid Build Coastguard Worker
207*795d594fSAndroid Build Coastguard Worker StorageType operator++(int) {
208*795d594fSAndroid Build Coastguard Worker return Get() + 1u;
209*795d594fSAndroid Build Coastguard Worker }
210*795d594fSAndroid Build Coastguard Worker
211*795d594fSAndroid Build Coastguard Worker BitStructNumber& operator--() {
212*795d594fSAndroid Build Coastguard Worker *this = Get() - 1u;
213*795d594fSAndroid Build Coastguard Worker return *this;
214*795d594fSAndroid Build Coastguard Worker }
215*795d594fSAndroid Build Coastguard Worker
216*795d594fSAndroid Build Coastguard Worker StorageType operator--(int) {
217*795d594fSAndroid Build Coastguard Worker return Get() - 1u;
218*795d594fSAndroid Build Coastguard Worker }
219*795d594fSAndroid Build Coastguard Worker
220*795d594fSAndroid Build Coastguard Worker private:
221*795d594fSAndroid Build Coastguard Worker using BaseType = BitStructField<T, kBitOffset, kBitWidth, StorageType>;
222*795d594fSAndroid Build Coastguard Worker using BaseType::Get;
223*795d594fSAndroid Build Coastguard Worker };
224*795d594fSAndroid Build Coastguard Worker
225*795d594fSAndroid Build Coastguard Worker // Create a BitStruct field which uses the smallest underlying int storage type,
226*795d594fSAndroid Build Coastguard Worker // in order to be large enough to fit (kBitOffset + kBitWidth).
227*795d594fSAndroid Build Coastguard Worker //
228*795d594fSAndroid Build Coastguard Worker // Values are sign-extended when they are read out.
229*795d594fSAndroid Build Coastguard Worker template <size_t kBitOffset, size_t kBitWidth, typename StorageType>
230*795d594fSAndroid Build Coastguard Worker using BitStructInt =
231*795d594fSAndroid Build Coastguard Worker BitStructNumber<typename detail::MinimumTypeHelper<int, kBitOffset + kBitWidth>::type,
232*795d594fSAndroid Build Coastguard Worker kBitOffset,
233*795d594fSAndroid Build Coastguard Worker kBitWidth,
234*795d594fSAndroid Build Coastguard Worker StorageType>;
235*795d594fSAndroid Build Coastguard Worker
236*795d594fSAndroid Build Coastguard Worker // Create a BitStruct field which uses the smallest underlying uint storage type,
237*795d594fSAndroid Build Coastguard Worker // in order to be large enough to fit (kBitOffset + kBitWidth).
238*795d594fSAndroid Build Coastguard Worker //
239*795d594fSAndroid Build Coastguard Worker // Values are zero-extended when they are read out.
240*795d594fSAndroid Build Coastguard Worker template <size_t kBitOffset, size_t kBitWidth, typename StorageType>
241*795d594fSAndroid Build Coastguard Worker using BitStructUint =
242*795d594fSAndroid Build Coastguard Worker BitStructNumber<typename detail::MinimumTypeHelper<unsigned int, kBitOffset + kBitWidth>::type,
243*795d594fSAndroid Build Coastguard Worker kBitOffset,
244*795d594fSAndroid Build Coastguard Worker kBitWidth,
245*795d594fSAndroid Build Coastguard Worker StorageType>;
246*795d594fSAndroid Build Coastguard Worker
247*795d594fSAndroid Build Coastguard Worker // Start a definition for a bitstruct.
248*795d594fSAndroid Build Coastguard Worker // A bitstruct is defined to be a union with a common initial subsequence
249*795d594fSAndroid Build Coastguard Worker // that we call 'DefineBitStructSize<bitwidth>'.
250*795d594fSAndroid Build Coastguard Worker //
251*795d594fSAndroid Build Coastguard Worker // See top of file for usage example.
252*795d594fSAndroid Build Coastguard Worker //
253*795d594fSAndroid Build Coastguard Worker // This marker is required by the C++ standard in order to
254*795d594fSAndroid Build Coastguard Worker // have a "common initial sequence".
255*795d594fSAndroid Build Coastguard Worker //
256*795d594fSAndroid Build Coastguard Worker // See C++ 9.5.1 [class.union]:
257*795d594fSAndroid Build Coastguard Worker // If a standard-layout union contains several standard-layout structs that share a common
258*795d594fSAndroid Build Coastguard Worker // initial sequence ... it is permitted to inspect the common initial sequence of any of
259*795d594fSAndroid Build Coastguard Worker // standard-layout struct members.
260*795d594fSAndroid Build Coastguard Worker #define BITSTRUCT_DEFINE_START(name, bitwidth) \
261*795d594fSAndroid Build Coastguard Worker union name { /* NOLINT */ \
262*795d594fSAndroid Build Coastguard Worker using StorageType = \
263*795d594fSAndroid Build Coastguard Worker typename detail::MinimumTypeUnsignedHelper<(bitwidth)>::type; \
264*795d594fSAndroid Build Coastguard Worker art::detail::DefineBitStructSize<(bitwidth)> _; \
265*795d594fSAndroid Build Coastguard Worker static constexpr size_t BitStructSizeOf() { return (bitwidth); } \
266*795d594fSAndroid Build Coastguard Worker name& operator=(const name& other) { _ = other._; return *this; } /* NOLINT */ \
267*795d594fSAndroid Build Coastguard Worker name(const name& other) : _(other._) {} \
268*795d594fSAndroid Build Coastguard Worker name() = default; \
269*795d594fSAndroid Build Coastguard Worker ~name() = default;
270*795d594fSAndroid Build Coastguard Worker
271*795d594fSAndroid Build Coastguard Worker // Define a field. See top of file for usage example.
272*795d594fSAndroid Build Coastguard Worker #define BITSTRUCT_FIELD(type, bit_offset, bit_width) \
273*795d594fSAndroid Build Coastguard Worker BitStructField<type, (bit_offset), (bit_width), StorageType>
274*795d594fSAndroid Build Coastguard Worker #define BITSTRUCT_INT(bit_offset, bit_width) \
275*795d594fSAndroid Build Coastguard Worker BitStructInt<(bit_offset), (bit_width), StorageType>
276*795d594fSAndroid Build Coastguard Worker #define BITSTRUCT_UINT(bit_offset, bit_width) \
277*795d594fSAndroid Build Coastguard Worker BitStructUint<(bit_offset), (bit_width), StorageType>
278*795d594fSAndroid Build Coastguard Worker
279*795d594fSAndroid Build Coastguard Worker // End the definition of a bitstruct, and insert a check
280*795d594fSAndroid Build Coastguard Worker // to ensure that the bitstruct did not exceed the specified size.
281*795d594fSAndroid Build Coastguard Worker //
282*795d594fSAndroid Build Coastguard Worker // See top of file for usage example.
283*795d594fSAndroid Build Coastguard Worker #define BITSTRUCT_DEFINE_END(name) \
284*795d594fSAndroid Build Coastguard Worker }; \
285*795d594fSAndroid Build Coastguard Worker static_assert(art::detail::ValidateBitStructSize<name>(), \
286*795d594fSAndroid Build Coastguard Worker #name "bitsize incorrect: " \
287*795d594fSAndroid Build Coastguard Worker "did you insert extra fields that weren't BitStructX, " \
288*795d594fSAndroid Build Coastguard Worker "and does the size match the sum of the field widths?")
289*795d594fSAndroid Build Coastguard Worker
290*795d594fSAndroid Build Coastguard Worker // Determine the minimal bit size for a user-defined type T.
291*795d594fSAndroid Build Coastguard Worker // Used by BitStructField to determine how small a custom type is.
292*795d594fSAndroid Build Coastguard Worker template <typename T>
BitStructSizeOf()293*795d594fSAndroid Build Coastguard Worker static constexpr size_t BitStructSizeOf() {
294*795d594fSAndroid Build Coastguard Worker return T::BitStructSizeOf();
295*795d594fSAndroid Build Coastguard Worker }
296*795d594fSAndroid Build Coastguard Worker
297*795d594fSAndroid Build Coastguard Worker } // namespace art
298*795d594fSAndroid Build Coastguard Worker
299*795d594fSAndroid Build Coastguard Worker #endif // ART_LIBARTBASE_BASE_BIT_STRUCT_H_
300