[2/5] libstdc++: Apply modifications to our local copy of fast_float
Commit Message
This performs the following modifications to our local copy of fast_float
in order to make it more readily usable in our std::from_chars
implementation:
* Remove system #includes
* Replace stray call to assert
* Use the standard library chars_format and from_chars_result types
libstdc++-v3/ChangeLog:
* src/c++17/fast_float/LOCAL_PATCHES: Update.
* src/c++17/fast_float/ascii_number.h,
src/c++17/fast_float/bigint.h,
src/c++17/fast_float/decimal_to_binary.h,
src/c++17/fast_float/digit_comparison.h,
src/c++17/fast_float/fast_float.h,
src/c++17/fast_float/fast_table.h,
src/c++17/fast_float/float_common.h,
src/c++17/fast_float/parse_number.h: Apply local modifications.
---
libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES | 1 +
libstdc++-v3/src/c++17/fast_float/ascii_number.h | 11 +++--------
libstdc++-v3/src/c++17/fast_float/bigint.h | 5 -----
.../src/c++17/fast_float/decimal_to_binary.h | 6 ------
.../src/c++17/fast_float/digit_comparison.h | 5 -----
libstdc++-v3/src/c++17/fast_float/fast_float.h | 15 ++-------------
libstdc++-v3/src/c++17/fast_float/fast_table.h | 2 --
libstdc++-v3/src/c++17/fast_float/float_common.h | 7 +------
libstdc++-v3/src/c++17/fast_float/parse_number.h | 5 -----
9 files changed, 7 insertions(+), 50 deletions(-)
Comments
On Mon, 15 Nov 2021, Patrick Palka wrote:
> This performs the following modifications to our local copy of fast_float
> in order to make it more readily usable in our std::from_chars
> implementation:
>
> * Remove system #includes
> * Replace stray call to assert
> * Use the standard library chars_format and from_chars_result types
>
> libstdc++-v3/ChangeLog:
>
> * src/c++17/fast_float/LOCAL_PATCHES: Update.
> * src/c++17/fast_float/ascii_number.h,
> src/c++17/fast_float/bigint.h,
> src/c++17/fast_float/decimal_to_binary.h,
> src/c++17/fast_float/digit_comparison.h,
> src/c++17/fast_float/fast_float.h,
> src/c++17/fast_float/fast_table.h,
> src/c++17/fast_float/float_common.h,
> src/c++17/fast_float/parse_number.h: Apply local modifications.
v2: Now in terms of the amalgamated version of the library.
-- >8 --
Subject: [PATCH 2/5] libstdc++: Apply modifications to our local copy of
fast_float
This performs the following modifications to our local copy of fast_float
in order to make it more readily usable in our std::from_chars
implementation:
* Remove system #includes
* Replace stray call to assert
* Use the standard library chars_format and from_chars_result types
libstdc++-v3/ChangeLog:
* src/c++17/fast_float/LOCAL_PATCHES: Update.
* src/c++17/fast_float/fast_float.h: Apply local modifications.
---
.../src/c++17/fast_float/LOCAL_PATCHES | 1 +
.../src/c++17/fast_float/fast_float.h | 62 ++-----------------
2 files changed, 7 insertions(+), 56 deletions(-)
diff --git a/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES b/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES
index e69de29bb2d..e9d7bba6195 100644
--- a/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES
+++ b/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES
@@ -0,0 +1 @@
+r12-????
diff --git a/libstdc++-v3/src/c++17/fast_float/fast_float.h b/libstdc++-v3/src/c++17/fast_float/fast_float.h
index 8a45ebca8a8..c908719ec3a 100644
--- a/libstdc++-v3/src/c++17/fast_float/fast_float.h
+++ b/libstdc++-v3/src/c++17/fast_float/fast_float.h
@@ -42,21 +42,10 @@
#ifndef FASTFLOAT_FAST_FLOAT_H
#define FASTFLOAT_FAST_FLOAT_H
-#include <system_error>
-
namespace fast_float {
-enum chars_format {
- scientific = 1<<0,
- fixed = 1<<2,
- hex = 1<<3,
- general = fixed | scientific
-};
-
-struct from_chars_result {
- const char *ptr;
- std::errc ec;
-};
+using std::chars_format;
+using std::from_chars_result;
struct parse_options {
constexpr explicit parse_options(chars_format fmt = chars_format::general,
@@ -105,11 +94,6 @@ from_chars_result from_chars_advanced(const char *first, const char *last,
#ifndef FASTFLOAT_FLOAT_COMMON_H
#define FASTFLOAT_FLOAT_COMMON_H
-#include <cfloat>
-#include <cstdint>
-#include <cassert>
-#include <cstring>
-
#if (defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) \
|| defined(__amd64) || defined(__aarch64__) || defined(_M_ARM64) \
|| defined(__MINGW64__) \
@@ -233,7 +217,7 @@ struct value128 {
/* result might be undefined when input_num is zero */
fastfloat_really_inline int leading_zeroes(uint64_t input_num) {
- assert(input_num > 0);
+ FASTFLOAT_DEBUG_ASSERT(input_num > 0);
#ifdef FASTFLOAT_VISUAL_STUDIO
#if defined(_M_X64) || defined(_M_ARM64)
unsigned long leading_zero = 0;
@@ -468,11 +452,6 @@ fastfloat_really_inline void to_float(bool negative, adjusted_mantissa am, T &va
#ifndef FASTFLOAT_ASCII_NUMBER_H
#define FASTFLOAT_ASCII_NUMBER_H
-#include <cctype>
-#include <cstdint>
-#include <cstring>
-#include <iterator>
-
namespace fast_float {
@@ -610,7 +589,7 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_
return answer;
}
int64_t exp_number = 0; // explicit exponential part
- if ((fmt & chars_format::scientific) && (p != pend) && (('e' == *p) || ('E' == *p))) {
+ if (bool(fmt & chars_format::scientific) && (p != pend) && (('e' == *p) || ('E' == *p))) {
const char * location_of_e = p;
++p;
bool neg_exp = false;
@@ -621,7 +600,7 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_
++p;
}
if ((p == pend) || !is_integer(*p)) {
- if(!(fmt & chars_format::fixed)) {
+ if(!bool(fmt & chars_format::fixed)) {
// We are in error.
return answer;
}
@@ -640,7 +619,7 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_
}
} else {
// If it scientific and not fixed, we have to bail out.
- if((fmt & chars_format::scientific) && !(fmt & chars_format::fixed)) { return answer; }
+ if(bool(fmt & chars_format::scientific) && !bool(fmt & chars_format::fixed)) { return answer; }
}
answer.lastmatch = p;
answer.valid = true;
@@ -699,8 +678,6 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_
#ifndef FASTFLOAT_FAST_TABLE_H
#define FASTFLOAT_FAST_TABLE_H
-#include <cstdint>
-
namespace fast_float {
/**
@@ -1399,13 +1376,6 @@ using powers = powers_template<>;
#ifndef FASTFLOAT_DECIMAL_TO_BINARY_H
#define FASTFLOAT_DECIMAL_TO_BINARY_H
-#include <cfloat>
-#include <cinttypes>
-#include <cmath>
-#include <cstdint>
-#include <cstdlib>
-#include <cstring>
-
namespace fast_float {
// This will compute or rather approximate w * 5**q and return a pair of 64-bit words approximating
@@ -1592,11 +1562,6 @@ adjusted_mantissa compute_float(int64_t q, uint64_t w) noexcept {
#ifndef FASTFLOAT_BIGINT_H
#define FASTFLOAT_BIGINT_H
-#include <algorithm>
-#include <cstdint>
-#include <climits>
-#include <cstring>
-
namespace fast_float {
@@ -2182,11 +2147,6 @@ struct bigint {
#ifndef FASTFLOAT_ASCII_NUMBER_H
#define FASTFLOAT_ASCII_NUMBER_H
-#include <cctype>
-#include <cstdint>
-#include <cstring>
-#include <iterator>
-
namespace fast_float {
@@ -2413,11 +2373,6 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_
#ifndef FASTFLOAT_DIGIT_COMPARISON_H
#define FASTFLOAT_DIGIT_COMPARISON_H
-#include <algorithm>
-#include <cstdint>
-#include <cstring>
-#include <iterator>
-
namespace fast_float {
@@ -2835,11 +2790,6 @@ inline adjusted_mantissa digit_comp(parsed_number_string& num, adjusted_mantissa
#define FASTFLOAT_PARSE_NUMBER_H
-#include <cmath>
-#include <cstring>
-#include <limits>
-#include <system_error>
-
namespace fast_float {
@@ -0,0 +1 @@
+r12-????
@@ -1,11 +1,6 @@
#ifndef FASTFLOAT_ASCII_NUMBER_H
#define FASTFLOAT_ASCII_NUMBER_H
-#include <cctype>
-#include <cstdint>
-#include <cstring>
-#include <iterator>
-
#include "float_common.h"
namespace fast_float {
@@ -144,7 +139,7 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_
return answer;
}
int64_t exp_number = 0; // explicit exponential part
- if ((fmt & chars_format::scientific) && (p != pend) && (('e' == *p) || ('E' == *p))) {
+ if (bool(fmt & chars_format::scientific) && (p != pend) && (('e' == *p) || ('E' == *p))) {
const char * location_of_e = p;
++p;
bool neg_exp = false;
@@ -155,7 +150,7 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_
++p;
}
if ((p == pend) || !is_integer(*p)) {
- if(!(fmt & chars_format::fixed)) {
+ if(!bool(fmt & chars_format::fixed)) {
// We are in error.
return answer;
}
@@ -174,7 +169,7 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_
}
} else {
// If it scientific and not fixed, we have to bail out.
- if((fmt & chars_format::scientific) && !(fmt & chars_format::fixed)) { return answer; }
+ if(bool(fmt & chars_format::scientific) && !bool(fmt & chars_format::fixed)) { return answer; }
}
answer.lastmatch = p;
answer.valid = true;
@@ -1,11 +1,6 @@
#ifndef FASTFLOAT_BIGINT_H
#define FASTFLOAT_BIGINT_H
-#include <algorithm>
-#include <cstdint>
-#include <climits>
-#include <cstring>
-
#include "float_common.h"
namespace fast_float {
@@ -3,12 +3,6 @@
#include "float_common.h"
#include "fast_table.h"
-#include <cfloat>
-#include <cinttypes>
-#include <cmath>
-#include <cstdint>
-#include <cstdlib>
-#include <cstring>
namespace fast_float {
@@ -1,11 +1,6 @@
#ifndef FASTFLOAT_DIGIT_COMPARISON_H
#define FASTFLOAT_DIGIT_COMPARISON_H
-#include <algorithm>
-#include <cstdint>
-#include <cstring>
-#include <iterator>
-
#include "float_common.h"
#include "bigint.h"
#include "ascii_number.h"
@@ -1,21 +1,10 @@
#ifndef FASTFLOAT_FAST_FLOAT_H
#define FASTFLOAT_FAST_FLOAT_H
-#include <system_error>
-
namespace fast_float {
-enum chars_format {
- scientific = 1<<0,
- fixed = 1<<2,
- hex = 1<<3,
- general = fixed | scientific
-};
-
-struct from_chars_result {
- const char *ptr;
- std::errc ec;
-};
+using std::chars_format;
+using std::from_chars_result;
struct parse_options {
constexpr explicit parse_options(chars_format fmt = chars_format::general,
@@ -1,8 +1,6 @@
#ifndef FASTFLOAT_FAST_TABLE_H
#define FASTFLOAT_FAST_TABLE_H
-#include <cstdint>
-
namespace fast_float {
/**
@@ -1,11 +1,6 @@
#ifndef FASTFLOAT_FLOAT_COMMON_H
#define FASTFLOAT_FLOAT_COMMON_H
-#include <cfloat>
-#include <cstdint>
-#include <cassert>
-#include <cstring>
-
#if (defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) \
|| defined(__amd64) || defined(__aarch64__) || defined(_M_ARM64) \
|| defined(__MINGW64__) \
@@ -129,7 +124,7 @@ struct value128 {
/* result might be undefined when input_num is zero */
fastfloat_really_inline int leading_zeroes(uint64_t input_num) {
- assert(input_num > 0);
+ FASTFLOAT_DEBUG_ASSERT(input_num > 0);
#ifdef FASTFLOAT_VISUAL_STUDIO
#if defined(_M_X64) || defined(_M_ARM64)
unsigned long leading_zero = 0;
@@ -5,11 +5,6 @@
#include "decimal_to_binary.h"
#include "digit_comparison.h"
-#include <cmath>
-#include <cstring>
-#include <limits>
-#include <system_error>
-
namespace fast_float {