mirror of
https://github.com/fmtlib/fmt.git
synced 2025-02-11 18:40:48 +00:00
Remove FMT_SAFEBUFFERS (#1966)
This commit is contained in:
parent
4081b2fe94
commit
112755cf91
@ -1646,8 +1646,7 @@ struct fixed_handler {
|
|||||||
// Implementation of Dragonbox algorithm: https://github.com/jk-jeon/dragonbox.
|
// Implementation of Dragonbox algorithm: https://github.com/jk-jeon/dragonbox.
|
||||||
namespace dragonbox {
|
namespace dragonbox {
|
||||||
// Computes 128-bit result of multiplication of two 64-bit unsigned integers.
|
// Computes 128-bit result of multiplication of two 64-bit unsigned integers.
|
||||||
FMT_SAFEBUFFERS inline uint128_wrapper umul128(uint64_t x,
|
inline uint128_wrapper umul128(uint64_t x, uint64_t y) FMT_NOEXCEPT {
|
||||||
uint64_t y) FMT_NOEXCEPT {
|
|
||||||
#if FMT_USE_INT128
|
#if FMT_USE_INT128
|
||||||
return static_cast<uint128_t>(x) * static_cast<uint128_t>(y);
|
return static_cast<uint128_t>(x) * static_cast<uint128_t>(y);
|
||||||
#elif defined(_MSC_VER) && defined(_M_X64)
|
#elif defined(_MSC_VER) && defined(_M_X64)
|
||||||
@ -1675,8 +1674,7 @@ FMT_SAFEBUFFERS inline uint128_wrapper umul128(uint64_t x,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Computes upper 64 bits of multiplication of two 64-bit unsigned integers.
|
// Computes upper 64 bits of multiplication of two 64-bit unsigned integers.
|
||||||
FMT_SAFEBUFFERS inline uint64_t umul128_upper64(uint64_t x,
|
inline uint64_t umul128_upper64(uint64_t x, uint64_t y) FMT_NOEXCEPT {
|
||||||
uint64_t y) FMT_NOEXCEPT {
|
|
||||||
#if FMT_USE_INT128
|
#if FMT_USE_INT128
|
||||||
auto p = static_cast<uint128_t>(x) * static_cast<uint128_t>(y);
|
auto p = static_cast<uint128_t>(x) * static_cast<uint128_t>(y);
|
||||||
return static_cast<uint64_t>(p >> 64);
|
return static_cast<uint64_t>(p >> 64);
|
||||||
@ -1689,8 +1687,7 @@ FMT_SAFEBUFFERS inline uint64_t umul128_upper64(uint64_t x,
|
|||||||
|
|
||||||
// Computes upper 64 bits of multiplication of a 64-bit unsigned integer and a
|
// Computes upper 64 bits of multiplication of a 64-bit unsigned integer and a
|
||||||
// 128-bit unsigned integer.
|
// 128-bit unsigned integer.
|
||||||
FMT_SAFEBUFFERS inline uint64_t umul192_upper64(uint64_t x, uint128_wrapper y)
|
inline uint64_t umul192_upper64(uint64_t x, uint128_wrapper y) FMT_NOEXCEPT {
|
||||||
FMT_NOEXCEPT {
|
|
||||||
uint128_wrapper g0 = umul128(x, y.high());
|
uint128_wrapper g0 = umul128(x, y.high());
|
||||||
g0 += umul128_upper64(x, y.low());
|
g0 += umul128_upper64(x, y.low());
|
||||||
return g0.high();
|
return g0.high();
|
||||||
@ -1704,8 +1701,7 @@ inline uint32_t umul96_upper32(uint32_t x, uint64_t y) FMT_NOEXCEPT {
|
|||||||
|
|
||||||
// Computes middle 64 bits of multiplication of a 64-bit unsigned integer and a
|
// Computes middle 64 bits of multiplication of a 64-bit unsigned integer and a
|
||||||
// 128-bit unsigned integer.
|
// 128-bit unsigned integer.
|
||||||
FMT_SAFEBUFFERS inline uint64_t umul192_middle64(uint64_t x, uint128_wrapper y)
|
inline uint64_t umul192_middle64(uint64_t x, uint128_wrapper y) FMT_NOEXCEPT {
|
||||||
FMT_NOEXCEPT {
|
|
||||||
uint64_t g01 = x * y.high();
|
uint64_t g01 = x * y.high();
|
||||||
uint64_t g10 = umul128_upper64(x, y.low());
|
uint64_t g10 = umul128_upper64(x, y.low());
|
||||||
return g01 + g10;
|
return g01 + g10;
|
||||||
@ -2124,8 +2120,8 @@ FMT_ALWAYS_INLINE int remove_trailing_zeros(uint64_t& n) FMT_NOEXCEPT {
|
|||||||
|
|
||||||
// The main algorithm for shorter interval case
|
// The main algorithm for shorter interval case
|
||||||
template <class T>
|
template <class T>
|
||||||
FMT_ALWAYS_INLINE FMT_SAFEBUFFERS decimal_fp<T> shorter_interval_case(
|
FMT_ALWAYS_INLINE decimal_fp<T> shorter_interval_case(int exponent)
|
||||||
int exponent) FMT_NOEXCEPT {
|
FMT_NOEXCEPT {
|
||||||
decimal_fp<T> ret_value;
|
decimal_fp<T> ret_value;
|
||||||
// Compute k and beta
|
// Compute k and beta
|
||||||
const int minus_k = floor_log10_pow2_minus_log10_4_over_3(exponent);
|
const int minus_k = floor_log10_pow2_minus_log10_4_over_3(exponent);
|
||||||
@ -2171,8 +2167,7 @@ FMT_ALWAYS_INLINE FMT_SAFEBUFFERS decimal_fp<T> shorter_interval_case(
|
|||||||
return ret_value;
|
return ret_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT {
|
||||||
FMT_SAFEBUFFERS decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT {
|
|
||||||
// Step 1: integer promotion & Schubfach multiplier calculation.
|
// Step 1: integer promotion & Schubfach multiplier calculation.
|
||||||
|
|
||||||
using carrier_uint = typename float_info<T>::carrier_uint;
|
using carrier_uint = typename float_info<T>::carrier_uint;
|
||||||
|
@ -745,8 +745,10 @@ void basic_memory_buffer<T, SIZE, Allocator>::grow(size_t size) {
|
|||||||
const size_t max_size = std::allocator_traits<Allocator>::max_size(alloc_);
|
const size_t max_size = std::allocator_traits<Allocator>::max_size(alloc_);
|
||||||
size_t old_capacity = this->capacity();
|
size_t old_capacity = this->capacity();
|
||||||
size_t new_capacity = old_capacity + old_capacity / 2;
|
size_t new_capacity = old_capacity + old_capacity / 2;
|
||||||
if (size > new_capacity) new_capacity = size;
|
if (size > new_capacity)
|
||||||
else if (new_capacity > max_size) new_capacity = (std::max)(size, max_size);
|
new_capacity = size;
|
||||||
|
else if (new_capacity > max_size)
|
||||||
|
new_capacity = (std::max)(size, max_size);
|
||||||
T* old_data = this->data();
|
T* old_data = this->data();
|
||||||
T* new_data =
|
T* new_data =
|
||||||
std::allocator_traits<Allocator>::allocate(alloc_, new_capacity);
|
std::allocator_traits<Allocator>::allocate(alloc_, new_capacity);
|
||||||
@ -979,13 +981,6 @@ template <> int count_digits<4>(detail::fallback_uintptr n);
|
|||||||
# define FMT_ALWAYS_INLINE inline
|
# define FMT_ALWAYS_INLINE inline
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// To suppress unnecessary security cookie checks
|
|
||||||
#if FMT_MSC_VER && !FMT_CLANG_VERSION
|
|
||||||
# define FMT_SAFEBUFFERS __declspec(safebuffers)
|
|
||||||
#else
|
|
||||||
# define FMT_SAFEBUFFERS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FMT_BUILTIN_CLZ
|
#ifdef FMT_BUILTIN_CLZ
|
||||||
// Optional version of count_digits for better performance on 32-bit platforms.
|
// Optional version of count_digits for better performance on 32-bit platforms.
|
||||||
inline int count_digits(uint32_t n) {
|
inline int count_digits(uint32_t n) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user