NetBSD Problem Report #57684

From www@netbsd.org  Mon Nov  6 16:03:22 2023
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 0518E1A9238
	for <gnats-bugs@gnats.NetBSD.org>; Mon,  6 Nov 2023 16:03:22 +0000 (UTC)
Message-Id: <20231106160321.058461A9239@mollari.NetBSD.org>
Date: Mon,  6 Nov 2023 16:03:20 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: fpsetround(3) fails to set SSE rounding mode
X-Send-Pr-Version: www-1.0

>Number:         57684
>Category:       port-i386
>Synopsis:       fpsetround(3) fails to set SSE rounding mode
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-i386-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 06 16:05:00 +0000 2023
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
The 387BSD Foundation
>Environment:
>Description:
The i386 fpsetround function only sets the i387 rounding mode in the FP  control word with fldcw:

https://nxr.netbsd.org/xref/src/lib/libc/arch/i386/gen/fpsetround.S?r=1.6

If machdep.sse is true, it needs to also set the SSE rounding mode in the MXCSR with ldmxcsr like fesetround does:

https://nxr.netbsd.org/xref/src/lib/libm/arch/i387/fenv.c?r=1.10#335

However, fpsetround can't simply call fesetround because fpsetround lives in libc while fesetround lives in libm.
>How-To-Repeat:
call fpsetround, read the mxcsr or do SSE floating-point
>Fix:
Yes, please!

Copy & paste of the i387/fenv.c approach should work.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.