Skip to content

Commit

Permalink
Be more explicit.
Browse files Browse the repository at this point in the history
  • Loading branch information
olupton committed Nov 4, 2021
1 parent 79ab452 commit eafdd3e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
17 changes: 16 additions & 1 deletion include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,33 @@
// The fmt library version in the form major * 10000 + minor * 100 + patch.
#define FMT_VERSION 80001

#if defined(__NVCOMPILER)
# define FMT_NVHPC_VERSION \
(__NVCOMPILER_MAJOR__ * 10000 + __NVCOMPILER_MINOR__ * 100 + \
__NVCOMPILER_PATCHLEVEL__)
#else
# define FMT_NVHPC_VERSION 0
#endif

#if defined (__clang__ ) && !defined(__ibmxl__)
# define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
#else
# define FMT_CLANG_VERSION 0
#endif

#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__NVCOMPILER)
#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && \
!defined(__NVCOMPILER)
# define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
#else
# define FMT_GCC_VERSION 0
#endif

#if FMT_NVHPC_VERSION > 0
# define FMT_NVHPC_PRAGMA(arg) _Pragma(arg)
#else
# define FMT_NVHPC_PRAGMA(arg)
#endif

#ifndef FMT_GCC_PRAGMA
// Workaround _Pragma bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59884.
# if FMT_GCC_VERSION >= 504
Expand Down
17 changes: 8 additions & 9 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -967,17 +967,16 @@ FMT_CONSTEXPR20 inline auto count_digits(uint64_t n) -> int {
template <int BITS, typename UInt>
FMT_CONSTEXPR auto count_digits(UInt n) -> int {
#ifdef FMT_BUILTIN_CLZ
if (num_bits<UInt>() == 32) {
if (num_bits<UInt>() == 32)
return (FMT_BUILTIN_CLZ(static_cast<uint32_t>(n) | 1) ^ 31) / BITS + 1;
} else
#endif
{
int num_digits = 0;
do {
++num_digits;
} while ((n >>= BITS) != 0);
return num_digits;
}
FMT_NVHPC_PRAGMA("diag_suppress initialization_not_reachable")
int num_digits = 0;
FMT_NVHPC_PRAGMA("diag_default initialization_not_reachable")
do {
++num_digits;
} while ((n >>= BITS) != 0);
return num_digits;
}

template <> auto count_digits<4>(detail::fallback_uintptr n) -> int;
Expand Down

0 comments on commit eafdd3e

Please sign in to comment.