diff options
| author | 2016-09-18 09:38:01 +0900 | |
|---|---|---|
| committer | 2016-09-18 09:38:01 +0900 | |
| commit | dc8479928c5aee4c6ad6fe4f59006fb604cee701 (patch) | |
| tree | 569a7f13128450bbab973236615587ff00bced5f /src/common/bit_field.h | |
| parent | Travis: Import Dolphin’s clang-format hook. (diff) | |
| download | yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.tar.gz yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.tar.xz yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.zip | |
Sources: Run clang-format on everything.
Diffstat (limited to 'src/common/bit_field.h')
| -rw-r--r-- | src/common/bit_field.h | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 4748999ed..8d45743e2 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | // Licensed under GPLv2 or any later version | 1 | // Licensed under GPLv2 or any later version |
| 2 | // Refer to the license.txt file included. | 2 | // Refer to the license.txt file included. |
| 3 | 3 | ||
| 4 | |||
| 5 | // Copyright 2014 Tony Wasserka | 4 | // Copyright 2014 Tony Wasserka |
| 6 | // All rights reserved. | 5 | // All rights reserved. |
| 7 | // | 6 | // |
| @@ -29,7 +28,6 @@ | |||
| 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | 30 | ||
| 32 | |||
| 33 | #pragma once | 31 | #pragma once |
| 34 | 32 | ||
| 35 | #include <cstddef> | 33 | #include <cstddef> |
| @@ -111,9 +109,8 @@ | |||
| 111 | * symptoms. | 109 | * symptoms. |
| 112 | */ | 110 | */ |
| 113 | #pragma pack(1) | 111 | #pragma pack(1) |
| 114 | template<std::size_t position, std::size_t bits, typename T> | 112 | template <std::size_t position, std::size_t bits, typename T> |
| 115 | struct BitField | 113 | struct BitField { |
| 116 | { | ||
| 117 | private: | 114 | private: |
| 118 | // We hide the copy assigment operator here, because the default copy | 115 | // We hide the copy assigment operator here, because the default copy |
| 119 | // assignment would copy the full storage value, rather than just the bits | 116 | // assignment would copy the full storage value, rather than just the bits |
| @@ -141,13 +138,10 @@ public: | |||
| 141 | } | 138 | } |
| 142 | 139 | ||
| 143 | FORCE_INLINE T Value() const { | 140 | FORCE_INLINE T Value() const { |
| 144 | if (std::numeric_limits<T>::is_signed) | 141 | if (std::numeric_limits<T>::is_signed) { |
| 145 | { | 142 | std::size_t shift = 8 * sizeof(T) - bits; |
| 146 | std::size_t shift = 8 * sizeof(T)-bits; | ||
| 147 | return (T)((storage << (shift - position)) >> shift); | 143 | return (T)((storage << (shift - position)) >> shift); |
| 148 | } | 144 | } else { |
| 149 | else | ||
| 150 | { | ||
| 151 | return (T)((storage & GetMask()) >> position); | 145 | return (T)((storage & GetMask()) >> position); |
| 152 | } | 146 | } |
| 153 | } | 147 | } |
| @@ -162,15 +156,14 @@ private: | |||
| 162 | // T is an enumeration. Note that T is wrapped within an enable_if in the | 156 | // T is an enumeration. Note that T is wrapped within an enable_if in the |
| 163 | // former case to workaround compile errors which arise when using | 157 | // former case to workaround compile errors which arise when using |
| 164 | // std::underlying_type<T>::type directly. | 158 | // std::underlying_type<T>::type directly. |
| 165 | typedef typename std::conditional < std::is_enum<T>::value, | 159 | typedef typename std::conditional<std::is_enum<T>::value, std::underlying_type<T>, |
| 166 | std::underlying_type<T>, | 160 | std::enable_if<true, T>>::type::type StorageType; |
| 167 | std::enable_if < true, T >> ::type::type StorageType; | ||
| 168 | 161 | ||
| 169 | // Unsigned version of StorageType | 162 | // Unsigned version of StorageType |
| 170 | typedef typename std::make_unsigned<StorageType>::type StorageTypeU; | 163 | typedef typename std::make_unsigned<StorageType>::type StorageTypeU; |
| 171 | 164 | ||
| 172 | FORCE_INLINE StorageType GetMask() const { | 165 | FORCE_INLINE StorageType GetMask() const { |
| 173 | return (((StorageTypeU)~0) >> (8 * sizeof(T)-bits)) << position; | 166 | return (((StorageTypeU)~0) >> (8 * sizeof(T) - bits)) << position; |
| 174 | } | 167 | } |
| 175 | 168 | ||
| 176 | StorageType storage; | 169 | StorageType storage; |
| @@ -186,5 +179,6 @@ private: | |||
| 186 | #pragma pack() | 179 | #pragma pack() |
| 187 | 180 | ||
| 188 | #if (__GNUC__ >= 5) || defined(__clang__) || defined(_MSC_VER) | 181 | #if (__GNUC__ >= 5) || defined(__clang__) || defined(_MSC_VER) |
| 189 | static_assert(std::is_trivially_copyable<BitField<0, 1, unsigned>>::value, "BitField must be trivially copyable"); | 182 | static_assert(std::is_trivially_copyable<BitField<0, 1, unsigned>>::value, |
| 183 | "BitField must be trivially copyable"); | ||
| 190 | #endif | 184 | #endif |