From: miod Date: Fri, 27 Jan 2023 11:25:16 +0000 (+0000) Subject: Use stricter constraints in the assembly statements in fpset{mask,round,sticky} X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e4e9d57ba097cabb7ff86297789439b71d446208;p=openbsd Use stricter constraints in the assembly statements in fpset{mask,round,sticky} and make them behave as intended again. The existing constraints are too weak; this used to work in older days, but got broken when the system compiler was updated to gcc 4 (or maybe even gcc 3). --- diff --git a/lib/libc/arch/hppa/gen/fpsetmask.c b/lib/libc/arch/hppa/gen/fpsetmask.c index 8ccbe320bc5..eecba14fa79 100644 --- a/lib/libc/arch/hppa/gen/fpsetmask.c +++ b/lib/libc/arch/hppa/gen/fpsetmask.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpsetmask.c,v 1.5 2014/04/18 15:09:52 guenther Exp $ */ +/* $OpenBSD: fpsetmask.c,v 1.6 2023/01/27 11:25:16 miod Exp $ */ /* * Written by Miodrag Vallat. Public domain @@ -17,6 +17,6 @@ fpsetmask(mask) __asm__ volatile("fstd %%fr0,0(%1)" : "=m"(fpsr) : "r"(&fpsr)); old = (fpsr >> 32) & 0x1f; fpsr = (fpsr & 0xffffffe000000000LL) | ((u_int64_t)(mask & 0x1f) << 32); - __asm__ volatile("fldd 0(%0),%%fr0" : : "r"(&fpsr)); + __asm__ volatile("fldd 0(%0),%%fr0" : : "r"(&fpsr), "m"(fpsr)); return (old); } diff --git a/lib/libc/arch/hppa/gen/fpsetround.c b/lib/libc/arch/hppa/gen/fpsetround.c index 086b29a5a9e..54712a50af6 100644 --- a/lib/libc/arch/hppa/gen/fpsetround.c +++ b/lib/libc/arch/hppa/gen/fpsetround.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpsetround.c,v 1.4 2014/04/18 15:09:52 guenther Exp $ */ +/* $OpenBSD: fpsetround.c,v 1.5 2023/01/27 11:25:16 miod Exp $ */ /* * Written by Miodrag Vallat. Public domain @@ -18,6 +18,6 @@ fpsetround(rnd_dir) old = (fpsr >> 41) & 0x03; fpsr = (fpsr & 0xfffff9ff00000000LL) | ((u_int64_t)(rnd_dir & 0x03) << 41); - __asm__ volatile("fldd 0(%0),%%fr0" : : "r" (&fpsr)); + __asm__ volatile("fldd 0(%0),%%fr0" : : "r"(&fpsr), "m"(fpsr)); return (old); } diff --git a/lib/libc/arch/hppa/gen/fpsetsticky.c b/lib/libc/arch/hppa/gen/fpsetsticky.c index fa506c10464..58cecffb9da 100644 --- a/lib/libc/arch/hppa/gen/fpsetsticky.c +++ b/lib/libc/arch/hppa/gen/fpsetsticky.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpsetsticky.c,v 1.6 2014/04/18 15:09:52 guenther Exp $ */ +/* $OpenBSD: fpsetsticky.c,v 1.7 2023/01/27 11:25:16 miod Exp $ */ /* * Written by Miodrag Vallat. Public domain @@ -17,6 +17,6 @@ fpsetsticky(mask) __asm__ volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr)); old = (fpsr >> 59) & 0x1f; fpsr = (fpsr & 0x07ffffff00000000LL) | ((u_int64_t)(mask & 0x1f) << 59); - __asm__ volatile("fldd 0(%0),%%fr0" : : "r" (&fpsr)); + __asm__ volatile("fldd 0(%0),%%fr0" : : "r"(&fpsr), "m"(fpsr)); return (old); }