From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/15099 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alexander Monakov Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] math: move i386 sqrtf to C Date: Mon, 6 Jan 2020 20:43:46 +0300 Message-ID: <20200106174346.6489-1-amonakov@ispras.ru> References: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.11.0" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="11277"; mail-complaints-to="usenet@blaine.gmane.org" To: musl@lists.openwall.com Original-X-From: musl-return-15115-gllmg-musl=m.gmane.org@lists.openwall.com Mon Jan 06 18:44:02 2020 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1ioWQ6-0002qv-1j for gllmg-musl@m.gmane.org; Mon, 06 Jan 2020 18:44:02 +0100 Original-Received: (qmail 3396 invoked by uid 550); 6 Jan 2020 17:43:58 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 3364 invoked from network); 6 Jan 2020 17:43:58 -0000 X-Mailer: git-send-email 2.11.0 In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:15099 Archived-At: This is a multi-part message in MIME format. --------------2.11.0 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit --- Yay, first not entirely trivial function. Apparently that double rounding yields the correct result here was suggested by Stephen Canon in https://stackoverflow.com/a/9689746/4755075 Should his contribution be mentioned somehow in the source code? src/math/i386/sqrtf.c | 8 ++++++++ src/math/i386/sqrtf.s | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 src/math/i386/sqrtf.c delete mode 100644 src/math/i386/sqrtf.s --------------2.11.0 Content-Type: text/x-patch; name="0004-math-move-i386-sqrtf-to-C.patch" Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="0004-math-move-i386-sqrtf-to-C.patch" diff --git a/src/math/i386/sqrtf.c b/src/math/i386/sqrtf.c new file mode 100644 index 00000000..2bcc7754 --- /dev/null +++ b/src/math/i386/sqrtf.c @@ -0,0 +1,8 @@ +#include + +float sqrtf(float x) +{ + long double t; + __asm__ ("fsqrt" : "=t"(t) : "0"(x)); + return (float)t; +} diff --git a/src/math/i386/sqrtf.s b/src/math/i386/sqrtf.s deleted file mode 100644 index 9e944f45..00000000 --- a/src/math/i386/sqrtf.s +++ /dev/null @@ -1,7 +0,0 @@ -.global sqrtf -.type sqrtf,@function -sqrtf: flds 4(%esp) - fsqrt - fstps 4(%esp) - flds 4(%esp) - ret --------------2.11.0--