From 8db2e66d3a78042c17070ea623e54ee667f8c509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Tue, 30 Aug 2022 16:36:32 +0200 Subject: [PATCH] src: make Endianness an enum class PR-URL: https://github.com/nodejs/node/pull/44411 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Darshan Sen --- src/util.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/util.h b/src/util.h index 3f58dd0a86d57b..0fe821e9fa97ce 100644 --- a/src/util.h +++ b/src/util.h @@ -751,26 +751,23 @@ inline v8::MaybeLocal ToV8Value(v8::Local context, .Check(); \ } while (0) -enum Endianness { - kLittleEndian, // _Not_ LITTLE_ENDIAN, clashes with endian.h. - kBigEndian -}; +enum class Endianness { LITTLE, BIG }; -inline enum Endianness GetEndianness() { +inline Endianness GetEndianness() { // Constant-folded by the compiler. const union { uint8_t u8[2]; uint16_t u16; } u = {{1, 0}}; - return u.u16 == 1 ? kLittleEndian : kBigEndian; + return u.u16 == 1 ? Endianness::LITTLE : Endianness::BIG; } inline bool IsLittleEndian() { - return GetEndianness() == kLittleEndian; + return GetEndianness() == Endianness::LITTLE; } inline bool IsBigEndian() { - return GetEndianness() == kBigEndian; + return GetEndianness() == Endianness::BIG; } // Round up a to the next highest multiple of b.