From patchwork Sun Jan 16 18:06:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 50082 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A5CD2385842C for ; Sun, 16 Jan 2022 18:10:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A5CD2385842C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1642356618; bh=SmuXr21uwjaZryx3WxHBrlNtpyvOylcCVAK1T/5Na1w=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=UCLg/qajfSxO50p1M1ozobYTr3Y7x8KPFecpP+/1g4m0kiPjPUUQ7JfZhU0vL3Rrv ld3y+rK4aEqTQblZhyFW7zw4O6F4ofcmRXnlqx1OQBF4A8ojzHdzHbMHaSn6zLZu+K sDw2bbHLb+hrg7QBnrfXYQsm0UWJ3dENLSFPUwGk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 1013B3858C39 for ; Sun, 16 Jan 2022 18:07:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1013B3858C39 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-543-hLStsTKUO6y2xC2hN_0_CQ-1; Sun, 16 Jan 2022 13:06:59 -0500 X-MC-Unique: hLStsTKUO6y2xC2hN_0_CQ-1 Received: by mail-qk1-f200.google.com with SMTP id b189-20020a3780c6000000b0047b06f34f4cso1871647qkd.17 for ; Sun, 16 Jan 2022 10:06:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SmuXr21uwjaZryx3WxHBrlNtpyvOylcCVAK1T/5Na1w=; b=J1WSMFcq641hCUcqQKnI8MzSieshwlxX24y4ENs9raPGrqKCbmgy1RhF4DsD9/90Gk sz7oB0kLsg3694hW6wuxdgEpel3AWLvInl4kItJVg3IM77tFqPyPW4cQyL1f55D2LAuG bPgL9tXO18pm1w+ciFWbBMSzmhc8fsJpXzCk6d+1HbF+1ktfZtVAfFr232NnK8B+6TCx TrSdvn22Ng3CKEd9MBW4xhNDpV3vnnT5vBE4QmyYS+3CMxw2+7V4Rrr5CGaMFYY/4hA5 gT29lUf6NXgp1ElvDZBjovTKLOJg1FSCBqe4vwZkunnXFC2AUq/KvXRccF43s2oFKL6t e4TQ== X-Gm-Message-State: AOAM533LT9GQWGCVyrEXmcEeMMDEEnNLDVRewxeQm9kn2Es8rbnvu2ND a+BzdNYerNXYgqMjE/SIE1GpSmAceEIJ0XbiE9tJ3yrtNOZduzTprR1y8jbtqQFOBSNp6e24gf3 gtlhE/H/UdcNRAWy0IEC4s+aPX5mDVvU5Vs6/BzHM5be/F8DmUuMUdw07bvegT5Ss7ik= X-Received: by 2002:ac8:7009:: with SMTP id x9mr14442865qtm.420.1642356418707; Sun, 16 Jan 2022 10:06:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyI+SulRav1fl8oT3Z97ZEaLn9CPDMiQm+1Muo0iVSS16roG6ge0vMe0URUNisIeKLXcjwOpQ== X-Received: by 2002:ac8:7009:: with SMTP id x9mr14442852qtm.420.1642356418398; Sun, 16 Jan 2022 10:06:58 -0800 (PST) Received: from localhost.localdomain (ool-18e40894.dyn.optonline.net. [24.228.8.148]) by smtp.gmail.com with ESMTPSA id o10sm7994149qtx.33.2022.01.16.10.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jan 2022 10:06:57 -0800 (PST) To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/6] libstdc++: Apply modifications to our local copy of fast_float Date: Sun, 16 Jan 2022 13:06:49 -0500 Message-Id: <20220116180652.3694791-3-ppalka@redhat.com> X-Mailer: git-send-email 2.35.0.rc1 In-Reply-To: <20220116180652.3694791-1-ppalka@redhat.com> References: <20220116180652.3694791-1-ppalka@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Cc: libstdc++@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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 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 - 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 -#include -#include -#include - #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 -#include -#include -#include - 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 - namespace fast_float { /** @@ -1399,13 +1376,6 @@ using powers = powers_template<>; #ifndef FASTFLOAT_DECIMAL_TO_BINARY_H #define FASTFLOAT_DECIMAL_TO_BINARY_H -#include -#include -#include -#include -#include -#include - 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 -#include -#include -#include - namespace fast_float { @@ -2182,11 +2147,6 @@ struct bigint { #ifndef FASTFLOAT_ASCII_NUMBER_H #define FASTFLOAT_ASCII_NUMBER_H -#include -#include -#include -#include - 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 -#include -#include -#include - namespace fast_float { @@ -2835,11 +2790,6 @@ inline adjusted_mantissa digit_comp(parsed_number_string& num, adjusted_mantissa #define FASTFLOAT_PARSE_NUMBER_H -#include -#include -#include -#include - namespace fast_float {