Remove some MSVC-specific code
Remove MSVC-specific code in byteorder.h to slightly break MSVC.
Bug: 389951208
Change-Id: I43c58af444e8b959906a7aaeca39d525273dcfc4
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/127991
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/byteorder.h b/core/fxcrt/byteorder.h
index 584e5bb..af29b6c 100644
--- a/core/fxcrt/byteorder.h
+++ b/core/fxcrt/byteorder.h
@@ -10,43 +10,28 @@
#include "build/build_config.h"
#include "core/fxcrt/span.h"
-#if defined(COMPILER_MSVC)
-#include <stdlib.h>
-#endif
-
namespace fxcrt {
namespace internal {
-#if defined(COMPILER_MSVC) && !defined(__clang__)
-// TODO(thestig): See
-// https://developercommunity.visualstudio.com/t/Mark-some-built-in-functions-as-constexp/362558
-// https://developercommunity.visualstudio.com/t/constexpr-byte-swapping-optimization/983963
-#define FXCRT_BYTESWAPS_CONSTEXPR
-#else
-#define FXCRT_BYTESWAPS_CONSTEXPR constexpr
-#endif
-
// Returns a value with all bytes in |x| swapped, i.e. reverses the endianness.
// TODO(thestig): Once C++23 is available, replace with std::byteswap.
-inline FXCRT_BYTESWAPS_CONSTEXPR uint16_t ByteSwap(uint16_t x) {
+inline constexpr uint16_t ByteSwap(uint16_t x) {
#if defined(COMPILER_MSVC) && !defined(__clang__)
- return _byteswap_ushort(x);
+#error "MSVC is not supported."
#else
return __builtin_bswap16(x);
#endif
}
-inline FXCRT_BYTESWAPS_CONSTEXPR uint32_t ByteSwap(uint32_t x) {
+inline constexpr uint32_t ByteSwap(uint32_t x) {
#if defined(COMPILER_MSVC) && !defined(__clang__)
- return _byteswap_ulong(x);
+#error "MSVC is not supported."
#else
return __builtin_bswap32(x);
#endif
}
-#undef FXCRT_BYTESWAPS_CONSTEXPR
-
} // namespace internal
// NOTE: Prefer From*() methods when data is known to be aligned.