[all-commits] [llvm/llvm-project] 30dae3: Fix LLP64 detection in SwapByteOrder.h
Reid Kleckner via All-commits
all-commits at lists.llvm.org
Wed Feb 26 10:59:50 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 30dae38349cbe293bee0705b313dc747e53afd49
https://github.com/llvm/llvm-project/commit/30dae38349cbe293bee0705b313dc747e53afd49
Author: Reid Kleckner <rnk at google.com>
Date: 2020-02-26 (Wed, 26 Feb 2020)
Changed paths:
M llvm/include/llvm/Support/SwapByteOrder.h
Log Message:
-----------
Fix LLP64 detection in SwapByteOrder.h
MSVC does not define __LONG_MAX__, so we were just getting lucky in this
conditional:
#if __LONG_MAX__ == __INT_MAX__
Undefined identifiers evaluate to zero in preprocessor conditionals, so
this became true, which happens to work for MSVC platforms.
Instead, use this pattern and let the compiler constant fold:
return sizeof(long) == sizeof(int) ? SwapByteOrder_32((uint32_t)C)
: SwapByteOrder_64((uint64_t)C);
More information about the All-commits
mailing list