From 74b2f853021e78f2cd2238c1ae8ac2fbd2ce84be 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 4ca1004b0fd896..f4e074eb425586 100644 --- a/src/util.h +++ b/src/util.h @@ -748,26 +748,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.