From patchwork Thu Mar 18 01:54:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 42668 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 3C8DB385DC39; Thu, 18 Mar 2021 01:54:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C8DB385DC39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1616032461; bh=ntg0ImM+MOv7QkLl+h6uqv2jcrfr04U9fipgIKJKQyk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=qziRpt5fJVmqhWt2/9/cqlU567xuh/YLfvwJucWyXSTdwEPGD9ph0A6nkKCGWw+Az In6BunGT+NEuR+8VOLXMnNQFzrj9ga/IQtSFwMTRq30d7k0PvBWaQIwwDQKWLrya39 0T3hgrLjPUTOMt7Dnz8A6ipwP/8Y9F8o45o3Gqsc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id 440C2384800B for ; Thu, 18 Mar 2021 01:54:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 440C2384800B Received: by mail-pf1-x42f.google.com with SMTP id j25so2390858pfe.2 for ; Wed, 17 Mar 2021 18:54:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ntg0ImM+MOv7QkLl+h6uqv2jcrfr04U9fipgIKJKQyk=; b=DUEH/M1xEVnIrofcWhmdiI+fnwF2qakU+7jG3ZzGeCMaCCe0qi9RYYvGpaSjNTgo2S /BjO024Y6bEvi1gUGpHLekC/1HxP4lZq8arjjS4SEp26dlM0qa5cQwAhx9yYa3zAl/6r JcnV72nO2qu8jZlNI4OK9WQ0D0odgK7kzZCXtT7Sxybe4wT9Jzvjl69adpQQynlg4UbN BHUj87moylgk2QpgEjkeCOMy1LxiXYv6AOkSYG72cjI19inivJf7+QtByAHm05yL9IOy LA+J2gjSdHsMcpqcPZV5T38fGqRqOd71kXBo0PlCDHrfM9H6LIaunuD2n9kutE6q6w27 579A== X-Gm-Message-State: AOAM532V4MeYaOke8UwkYWU6lHsr7pgeInMnsqcZ1bScj/VRf0CbiCqk fJq5SCLR3Z/y5pALF0wLl7kBc9DJ014= X-Google-Smtp-Source: ABdhPJyJOmy3v2zaSahGvYkuW4nV11/6OLnhA0p6Q2C3HnXd35fY3OnX5Uq35sW7fiEOqT6p4i7cKQ== X-Received: by 2002:aa7:860f:0:b029:200:851:1bff with SMTP id p15-20020aa7860f0000b029020008511bffmr1816940pfn.64.1616032457031; Wed, 17 Mar 2021 18:54:17 -0700 (PDT) Received: from gnu-cfl-2.localdomain ([172.56.38.37]) by smtp.gmail.com with ESMTPSA id 14sm321939pfo.141.2021.03.17.18.54.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Mar 2021 18:54:16 -0700 (PDT) Received: from gnu-cfl-2.?040none?041 (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 4B00D1A1502 for ; Wed, 17 Mar 2021 18:54:15 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] x86-64: Don't inline atof without SSE2 [BZ #27600] Date: Wed, 17 Mar 2021 18:54:14 -0700 Message-Id: <20210318015414.902129-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-3036.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Since without SSE2, inlined atof fails with /usr/include/bits/stdlib-float.h: In function ‘atof’: /usr/include/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled 26 | { | ^ don't inline atof without SSE2 for x86-64. --- include/bits/stdlib-float.h | 4 ++-- sysdeps/x86/Makefile | 7 +++++++ sysdeps/x86/bits/stdlib-float.h | 29 +++++++++++++++++++++++++++++ sysdeps/x86/tst-stdlib.c | 27 +++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 sysdeps/x86/bits/stdlib-float.h create mode 100644 sysdeps/x86/tst-stdlib.c diff --git a/include/bits/stdlib-float.h b/include/bits/stdlib-float.h index 54ab571981..4474d1d2dc 100644 --- a/include/bits/stdlib-float.h +++ b/include/bits/stdlib-float.h @@ -1,8 +1,8 @@ /* No floating-point inline functions in rtld and for the conform tests. */ #ifdef _ISOMAC -# include +# include_next #else # if !IS_IN (rtld) -# include +# include_next # endif #endif diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile index 3ca7bfefe4..d6381e73af 100644 --- a/sysdeps/x86/Makefile +++ b/sysdeps/x86/Makefile @@ -221,3 +221,10 @@ tests += \ tests-static += \ tst-sysconf-cache-linesize-static endif + +ifeq ($(subdir),stdlib) +tests += \ + tst-stdlib + +CFLAGS-tst-stdlib.c += -mno-sse +endif diff --git a/sysdeps/x86/bits/stdlib-float.h b/sysdeps/x86/bits/stdlib-float.h new file mode 100644 index 0000000000..17be04b927 --- /dev/null +++ b/sysdeps/x86/bits/stdlib-float.h @@ -0,0 +1,29 @@ +/* Floating-point inline functions for stdlib.h. + Copyright (C) 2012-2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _STDLIB_H +# error "Never use directly; include instead." +#endif + +#if defined __USE_EXTERN_INLINES && (!defined __x86_64__ || defined __SSE2__) +__extern_inline double +__NTH (atof (const char *__nptr)) +{ + return strtod (__nptr, (char **) NULL); +} +#endif /* Optimizing and Inlining. */ diff --git a/sysdeps/x86/tst-stdlib.c b/sysdeps/x86/tst-stdlib.c new file mode 100644 index 0000000000..226eb35a5d --- /dev/null +++ b/sysdeps/x86/tst-stdlib.c @@ -0,0 +1,27 @@ +/* Test with -mno-sse. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +static int +do_test (void) +{ + return 0; +} + +#include