1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include <__type_traits/datasizeof.h> |
10 | #include <cstdint> |
11 | |
12 | static_assert(std::__libcpp_datasizeof<std::int8_t>::value == 1, "" ); |
13 | static_assert(std::__libcpp_datasizeof<std::int16_t>::value == 2, "" ); |
14 | static_assert(std::__libcpp_datasizeof<std::int32_t>::value == 4, "" ); |
15 | static_assert(std::__libcpp_datasizeof<std::int64_t>::value == 8, "" ); |
16 | |
17 | struct OneBytePadding { |
18 | OneBytePadding() {} |
19 | |
20 | std::int16_t a; |
21 | std::int8_t b; |
22 | }; |
23 | |
24 | #if defined(_WIN32) && !defined(__MINGW32__) |
25 | static_assert(std::__libcpp_datasizeof<OneBytePadding>::value == 4, "" ); |
26 | #else |
27 | static_assert(std::__libcpp_datasizeof<OneBytePadding>::value == 3, "" ); |
28 | #endif |
29 | |
30 | struct InBetweenPadding { |
31 | InBetweenPadding() {} |
32 | |
33 | std::int32_t a; |
34 | std::int8_t b; |
35 | std::int16_t c; |
36 | }; |
37 | |
38 | static_assert(std::__libcpp_datasizeof<InBetweenPadding>::value == 8, "" ); |
39 | |