Skip to content

Commit a711080

Browse files
tniessenjuanarbol
authored andcommitted
src: make Endianness an enum class
PR-URL: #44411 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent aa80826 commit a711080

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/util.h

+5-8
Original file line numberDiff line numberDiff line change
@@ -748,26 +748,23 @@ inline v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
748748
.Check(); \
749749
} while (0)
750750

751-
enum Endianness {
752-
kLittleEndian, // _Not_ LITTLE_ENDIAN, clashes with endian.h.
753-
kBigEndian
754-
};
751+
enum class Endianness { LITTLE, BIG };
755752

756-
inline enum Endianness GetEndianness() {
753+
inline Endianness GetEndianness() {
757754
// Constant-folded by the compiler.
758755
const union {
759756
uint8_t u8[2];
760757
uint16_t u16;
761758
} u = {{1, 0}};
762-
return u.u16 == 1 ? kLittleEndian : kBigEndian;
759+
return u.u16 == 1 ? Endianness::LITTLE : Endianness::BIG;
763760
}
764761

765762
inline bool IsLittleEndian() {
766-
return GetEndianness() == kLittleEndian;
763+
return GetEndianness() == Endianness::LITTLE;
767764
}
768765

769766
inline bool IsBigEndian() {
770-
return GetEndianness() == kBigEndian;
767+
return GetEndianness() == Endianness::BIG;
771768
}
772769

773770
// Round up a to the next highest multiple of b.

0 commit comments

Comments
 (0)