chromium/third_party/fast_float/src/include/fast_float/float_common.h

#ifndef FASTFLOAT_FLOAT_COMMON_H
#define FASTFLOAT_FLOAT_COMMON_H

#include <cfloat>
#include <cstdint>
#include <cassert>
#include <cstring>
#include <type_traits>
#include <system_error>
#ifdef __has_include
#if __has_include(<stdfloat>) && (__cplusplus > 202002L || _MSVC_LANG > 202002L)
#include <stdfloat>
#endif
#endif
#include "constexpr_feature_detect.h"

namespace fast_float {

#define FASTFLOAT_JSONFMT
#define FASTFLOAT_FORTRANFMT

enum chars_format {};

template <typename UC> struct from_chars_result_t {};
from_chars_result;

template <typename UC> struct parse_options_t {};
parse_options;

} // namespace fast_float

#if FASTFLOAT_HAS_BIT_CAST
#include <bit>
#endif

#if (defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) ||            \
     defined(__amd64) || defined(__aarch64__) || defined(_M_ARM64) ||          \
     defined(__MINGW64__) || defined(__s390x__) ||                             \
     (defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) ||      \
      defined(__PPC64LE__)) ||                                                 \
     defined(__loongarch64))
#define FASTFLOAT_64BIT
#elif (defined(__i386) || defined(__i386__) || defined(_M_IX86) ||             \
       defined(__arm__) || defined(_M_ARM) || defined(__ppc__) ||              \
       defined(__MINGW32__) || defined(__EMSCRIPTEN__))
#define FASTFLOAT_32BIT
#else
  // Need to check incrementally, since SIZE_MAX is a size_t, avoid overflow.
// We can never tell the register width, but the SIZE_MAX is a good
// approximation. UINTPTR_MAX and INTPTR_MAX are optional, so avoid them for max
// portability.
#if SIZE_MAX == 0xffff
#error Unknown platform (16-bit, unsupported)
#elif SIZE_MAX == 0xffffffff
#define FASTFLOAT_32BIT
#elif SIZE_MAX == 0xffffffffffffffff
#define FASTFLOAT_64BIT
#else
#error Unknown platform (not 32-bit, not 64-bit?)
#endif
#endif

#if ((defined(_WIN32) || defined(_WIN64)) && !defined(__clang__)) ||           \
    (defined(_M_ARM64) && !defined(__MINGW32__))
#include <intrin.h>
#endif

#if defined(_MSC_VER) && !defined(__clang__)
#define FASTFLOAT_VISUAL_STUDIO
#endif

#if defined __BYTE_ORDER__ && defined __ORDER_BIG_ENDIAN__
#define FASTFLOAT_IS_BIG_ENDIAN
#elif defined _WIN32
#define FASTFLOAT_IS_BIG_ENDIAN
#else
#if defined(__APPLE__) || defined(__FreeBSD__)
#include <machine/endian.h>
#elif defined(sun) || defined(__sun)
#include <sys/byteorder.h>
#elif defined(__MVS__)
#include <sys/endian.h>
#else
#ifdef __has_include
#if __has_include(<endian.h>)
#include <endian.h>
#endif //__has_include(<endian.h>)
#endif //__has_include
#endif
#
#ifndef __BYTE_ORDER__
// safe choice
#define FASTFLOAT_IS_BIG_ENDIAN
#endif
#
#ifndef __ORDER_LITTLE_ENDIAN__
// safe choice
#define FASTFLOAT_IS_BIG_ENDIAN
#endif
#
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define FASTFLOAT_IS_BIG_ENDIAN
#else
#define FASTFLOAT_IS_BIG_ENDIAN
#endif
#endif

#if defined(__SSE2__) || (defined(FASTFLOAT_VISUAL_STUDIO) &&                  \
                          (defined(_M_AMD64) || defined(_M_X64) ||             \
                           (defined(_M_IX86_FP) && _M_IX86_FP == 2)))
#define FASTFLOAT_SSE2
#endif

#if defined(__aarch64__) || defined(_M_ARM64)
#define FASTFLOAT_NEON
#endif

#if defined(FASTFLOAT_SSE2) || defined(FASTFLOAT_NEON)
#define FASTFLOAT_HAS_SIMD
#endif

#if defined(__GNUC__)
// disable -Wcast-align=strict (GCC only)
#define FASTFLOAT_SIMD_DISABLE_WARNINGS
#else
#define FASTFLOAT_SIMD_DISABLE_WARNINGS
#endif

#if defined(__GNUC__)
#define FASTFLOAT_SIMD_RESTORE_WARNINGS
#else
#define FASTFLOAT_SIMD_RESTORE_WARNINGS
#endif

#ifdef FASTFLOAT_VISUAL_STUDIO
#define fastfloat_really_inline
#else
#define fastfloat_really_inline
#endif

#ifndef FASTFLOAT_ASSERT
#define FASTFLOAT_ASSERT(x)
#endif

#ifndef FASTFLOAT_DEBUG_ASSERT
#define FASTFLOAT_DEBUG_ASSERT(x)
#endif

// rust style `try!()` macro, or `?` operator
#define FASTFLOAT_TRY(x)

#define FASTFLOAT_ENABLE_IF(...)

namespace fast_float {

fastfloat_really_inline constexpr bool cpp20_and_in_constexpr() {}

template <typename T>
fastfloat_really_inline constexpr bool is_supported_float_type() {}

template <typename UC>
fastfloat_really_inline constexpr bool is_supported_char_type() {}

// Compares two ASCII strings in a case insensitive manner.
template <typename UC>
inline FASTFLOAT_CONSTEXPR14 bool
fastfloat_strncasecmp(UC const *input1, UC const *input2, size_t length) {}

#ifndef FLT_EVAL_METHOD
#error "FLT_EVAL_METHOD should be defined, please include cfloat."
#endif

// a pointer and a length to a contiguous block of memory
template <typename T> struct span {};

struct value128 {};

/* Helper C++14 constexpr generic implementation of leading_zeroes */
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 int
leading_zeroes_generic(uint64_t input_num, int last_bit = 0) {}

/* result might be undefined when input_num is zero */
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 int
leading_zeroes(uint64_t input_num) {}

// slow emulation routine for 32-bit
fastfloat_really_inline constexpr uint64_t emulu(uint32_t x, uint32_t y) {}

fastfloat_really_inline FASTFLOAT_CONSTEXPR14 uint64_t
umul128_generic(uint64_t ab, uint64_t cd, uint64_t *hi) {}

#ifdef FASTFLOAT_32BIT

// slow emulation routine for 32-bit
#if !defined(__MINGW64__)
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 uint64_t _umul128(uint64_t ab,
                                                                uint64_t cd,
                                                                uint64_t *hi) {
  return umul128_generic(ab, cd, hi);
}
#endif // !__MINGW64__

#endif // FASTFLOAT_32BIT

// compute 64-bit a*b
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 value128
full_multiplication(uint64_t a, uint64_t b) {}

struct adjusted_mantissa {};

// Bias so we can get the real exponent with an invalid adjusted_mantissa.
constexpr static int32_t invalid_am_bias =;

// used for binary_format_lookup_tables<T>::max_mantissa
constexpr uint64_t constant_55555 =;

template <typename T, typename U = void> struct binary_format_lookup_tables;

template <typename T> struct binary_format : binary_format_lookup_tables<T> {};

binary_format_lookup_tables<double, U>;

template <typename U>
constexpr double binary_format_lookup_tables<double, U>::powers_of_ten[];

template <typename U>
constexpr uint64_t binary_format_lookup_tables<double, U>::max_mantissa[];

binary_format_lookup_tables<float, U>;

template <typename U>
constexpr float binary_format_lookup_tables<float, U>::powers_of_ten[];

template <typename U>
constexpr uint64_t binary_format_lookup_tables<float, U>::max_mantissa[];

template <>
inline constexpr int binary_format<double>::min_exponent_fast_path() {}

template <>
inline constexpr int binary_format<float>::min_exponent_fast_path() {}

template <>
inline constexpr int binary_format<double>::mantissa_explicit_bits() {}
template <>
inline constexpr int binary_format<float>::mantissa_explicit_bits() {}

template <>
inline constexpr int binary_format<double>::max_exponent_round_to_even() {}

template <>
inline constexpr int binary_format<float>::max_exponent_round_to_even() {}

template <>
inline constexpr int binary_format<double>::min_exponent_round_to_even() {}

template <>
inline constexpr int binary_format<float>::min_exponent_round_to_even() {}

template <> inline constexpr int binary_format<double>::minimum_exponent() {}
template <> inline constexpr int binary_format<float>::minimum_exponent() {}

template <> inline constexpr int binary_format<double>::infinite_power() {}
template <> inline constexpr int binary_format<float>::infinite_power() {}

template <> inline constexpr int binary_format<double>::sign_index() {}
template <> inline constexpr int binary_format<float>::sign_index() {}

template <>
inline constexpr int binary_format<double>::max_exponent_fast_path() {}
template <>
inline constexpr int binary_format<float>::max_exponent_fast_path() {}

template <>
inline constexpr uint64_t binary_format<double>::max_mantissa_fast_path() {}
template <>
inline constexpr uint64_t
binary_format<double>::max_mantissa_fast_path(int64_t power) {}
template <>
inline constexpr uint64_t binary_format<float>::max_mantissa_fast_path() {}
template <>
inline constexpr uint64_t
binary_format<float>::max_mantissa_fast_path(int64_t power) {}

template <>
inline constexpr double
binary_format<double>::exact_power_of_ten(int64_t power) {}
template <>
inline constexpr float binary_format<float>::exact_power_of_ten(int64_t power) {}

template <> inline constexpr int binary_format<double>::largest_power_of_ten() {}
template <> inline constexpr int binary_format<float>::largest_power_of_ten() {}

template <>
inline constexpr int binary_format<double>::smallest_power_of_ten() {}
template <> inline constexpr int binary_format<float>::smallest_power_of_ten() {}

template <> inline constexpr size_t binary_format<double>::max_digits() {}
template <> inline constexpr size_t binary_format<float>::max_digits() {}

template <>
inline constexpr binary_format<float>::equiv_uint
binary_format<float>::exponent_mask() {}
template <>
inline constexpr binary_format<double>::equiv_uint
binary_format<double>::exponent_mask() {}

template <>
inline constexpr binary_format<float>::equiv_uint
binary_format<float>::mantissa_mask() {}
template <>
inline constexpr binary_format<double>::equiv_uint
binary_format<double>::mantissa_mask() {}

template <>
inline constexpr binary_format<float>::equiv_uint
binary_format<float>::hidden_bit_mask() {}
template <>
inline constexpr binary_format<double>::equiv_uint
binary_format<double>::hidden_bit_mask() {}

template <typename T>
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void
to_float(bool negative, adjusted_mantissa am, T &value) {}

#ifdef FASTFLOAT_SKIP_WHITE_SPACE // disabled by default
template <typename = void> struct space_lut {
  static constexpr bool value[] = {
      0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
};

template <typename T> constexpr bool space_lut<T>::value[];

inline constexpr bool is_space(uint8_t c) { return space_lut<>::value[c]; }
#endif

template <typename UC> static constexpr uint64_t int_cmp_zeros() {}
template <typename UC> static constexpr int int_cmp_len() {}
template <typename UC> static constexpr UC const *str_const_nan() {}
template <> constexpr char const *str_const_nan<char>() {}
template <> constexpr wchar_t const *str_const_nan<wchar_t>() {}
template <> constexpr char16_t const *str_const_nan<char16_t>() {}
template <> constexpr char32_t const *str_const_nan<char32_t>() {}
template <typename UC> static constexpr UC const *str_const_inf() {}
template <> constexpr char const *str_const_inf<char>() {}
template <> constexpr wchar_t const *str_const_inf<wchar_t>() {}
template <> constexpr char16_t const *str_const_inf<char16_t>() {}
template <> constexpr char32_t const *str_const_inf<char32_t>() {}

template <typename = void> struct int_luts {};

template <typename T> constexpr uint8_t int_luts<T>::chdigit[];

template <typename T> constexpr size_t int_luts<T>::maxdigits_u64[];

template <typename T> constexpr uint64_t int_luts<T>::min_safe_u64[];

template <typename UC>
fastfloat_really_inline constexpr uint8_t ch_to_digit(UC c) {}

fastfloat_really_inline constexpr size_t max_digits_u64(int base) {}

// If a u64 is exactly max_digits_u64() in length, this is
// the value below which it has definitely overflowed.
fastfloat_really_inline constexpr uint64_t min_safe_u64(int base) {}

} // namespace fast_float

#endif