From 642e4c0cb181538041ae2d033c37186e1a4d31dc Mon Sep 17 00:00:00 2001 From: miod Date: Fri, 27 Jan 2023 16:43:33 +0000 Subject: [PATCH] Use the same inline assembly constraints as for libc fp*(), when operating on the floating-point control register. --- lib/libm/arch/hppa/fenv.c | 16 ++++++++-------- lib/libm/arch/hppa/s_ceil.c | 8 ++++---- lib/libm/arch/hppa/s_ceilf.c | 8 ++++---- lib/libm/arch/hppa/s_floor.c | 8 ++++---- lib/libm/arch/hppa/s_floorf.c | 8 ++++---- lib/libm/arch/hppa/s_trunc.c | 8 ++++---- lib/libm/arch/hppa/s_truncf.c | 8 ++++---- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/lib/libm/arch/hppa/fenv.c b/lib/libm/arch/hppa/fenv.c index 398129afbee..9c60d85b4e0 100644 --- a/lib/libm/arch/hppa/fenv.c +++ b/lib/libm/arch/hppa/fenv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fenv.c,v 1.6 2022/12/27 17:10:07 jmc Exp $ */ +/* $OpenBSD: fenv.c,v 1.7 2023/01/27 16:43:33 miod Exp $ */ /* * Copyright (c) 2011 Martynas Venckus @@ -53,7 +53,7 @@ feclearexcept(int excepts) u.bits[0] &= ~(excepts << _MASK_SHIFT); /* Load the floating-point status register */ - __asm__ volatile ("fldd 0(%0), %%fr0" : : "r" (&u.fpsr)); + __asm__ volatile ("fldd 0(%0), %%fr0" : : "r" (&u.fpsr), "m" (u.fpsr)); return (0); } @@ -146,7 +146,7 @@ fesetexceptflag(const fexcept_t *flagp, int excepts) u.bits[0] |= (*flagp & excepts) << _MASK_SHIFT; /* Load the floating-point status register */ - __asm__ volatile ("fldd 0(%0), %%fr0" : : "r" (&u.fpsr)); + __asm__ volatile ("fldd 0(%0), %%fr0" : : "r" (&u.fpsr), "m" (u.fpsr)); return (0); } @@ -211,7 +211,7 @@ fesetround(int round) u.bits[0] |= round; /* Load the floating-point status register */ - __asm__ volatile ("fldd 0(%0), %%fr0" : : "r" (&u.fpsr)); + __asm__ volatile ("fldd 0(%0), %%fr0" : : "r" (&u.fpsr), "m"(u.fpsr)); return (0); } @@ -258,7 +258,7 @@ feholdexcept(fenv_t *envp) /* Mask all exceptions */ u.bits[0] &= ~FE_ALL_EXCEPT; - __asm__ volatile ("fldd 0(%0), %%fr0" : : "r" (&u.fpsr)); + __asm__ volatile ("fldd 0(%0), %%fr0" : : "r" (&u.fpsr), "m"(u.fpsr)); return (0); } @@ -288,7 +288,7 @@ fesetenv(const fenv_t *envp) (FE_ALL_EXCEPT << _MASK_SHIFT)); /* Load the floating-point status register */ - __asm__ volatile ("fldd 0(%0), %%fr0" : : "r" (&u.fpsr)); + __asm__ volatile ("fldd 0(%0), %%fr0" : : "r" (&u.fpsr), "m"(u.fpsr)); return (0); } @@ -340,7 +340,7 @@ feenableexcept(int mask) u.bits[0] |= mask; /* Load the floating-point status register */ - __asm__ volatile ("fldd 0(%0), %%fr0" : : "r" (&u.fpsr)); + __asm__ volatile ("fldd 0(%0), %%fr0" : : "r" (&u.fpsr), "m"(u.fpsr)); return (omask); @@ -362,7 +362,7 @@ fedisableexcept(int mask) u.bits[0] &= ~mask; /* Load the floating-point status register */ - __asm__ volatile ("fldd 0(%0), %%fr0" : : "r" (&u.fpsr)); + __asm__ volatile ("fldd 0(%0), %%fr0" : : "r" (&u.fpsr), "m"(u.fpsr)); return (omask); } diff --git a/lib/libm/arch/hppa/s_ceil.c b/lib/libm/arch/hppa/s_ceil.c index 7844ccf1533..4e0aec6c7a2 100644 --- a/lib/libm/arch/hppa/s_ceil.c +++ b/lib/libm/arch/hppa/s_ceil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_ceil.c,v 1.10 2016/09/12 19:47:01 guenther Exp $ */ +/* $OpenBSD: s_ceil.c,v 1.11 2023/01/27 16:43:33 miod Exp $ */ /* * Written by Michael Shalayeff. Public Domain */ @@ -12,14 +12,14 @@ ceil(double x) { u_int64_t ofpsr, fpsr; - __asm__ volatile("fstds %%fr0,0(%0)" :: "r" (&ofpsr) : "memory"); + __asm__ volatile("fstds %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr)); fpsr = (ofpsr & ~((u_int64_t)FP_RM << (9 + 32))) | ((u_int64_t)FP_RP << (9 + 32)); - __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&fpsr) : "memory"); + __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&fpsr), "m" (fpsr)); __asm__ volatile("frnd,dbl %0,%0" : "+f" (x)); - __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&ofpsr) : "memory"); + __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&ofpsr), "m" (ofpsr)); return (x); } DEF_STD(ceil); diff --git a/lib/libm/arch/hppa/s_ceilf.c b/lib/libm/arch/hppa/s_ceilf.c index 516b8af61b9..c9c1ef5b7e1 100644 --- a/lib/libm/arch/hppa/s_ceilf.c +++ b/lib/libm/arch/hppa/s_ceilf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_ceilf.c,v 1.8 2016/09/12 19:47:01 guenther Exp $ */ +/* $OpenBSD: s_ceilf.c,v 1.9 2023/01/27 16:43:33 miod Exp $ */ /* * Written by Michael Shalayeff. Public Domain */ @@ -12,14 +12,14 @@ ceilf(float x) { u_int64_t ofpsr, fpsr; - __asm__ volatile("fstds %%fr0,0(%0)" :: "r" (&ofpsr) : "memory"); + __asm__ volatile("fstds %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr)); fpsr = (ofpsr & ~((u_int64_t)FP_RM << (9 + 32))) | ((u_int64_t)FP_RP << (9 + 32)); - __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&fpsr) : "memory"); + __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&fpsr), "m" (fpsr)); __asm__ volatile("frnd,sgl %0,%0" : "+f" (x)); - __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&ofpsr) : "memory"); + __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&ofpsr), "m" (ofpsr)); return (x); } DEF_STD(ceilf); diff --git a/lib/libm/arch/hppa/s_floor.c b/lib/libm/arch/hppa/s_floor.c index f925b896157..e93d0bb9578 100644 --- a/lib/libm/arch/hppa/s_floor.c +++ b/lib/libm/arch/hppa/s_floor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_floor.c,v 1.12 2016/09/12 19:47:01 guenther Exp $ */ +/* $OpenBSD: s_floor.c,v 1.13 2023/01/27 16:43:33 miod Exp $ */ /* * Written by Michael Shalayeff. Public Domain */ @@ -12,13 +12,13 @@ floor(double x) { u_int64_t ofpsr, fpsr; - __asm__ volatile("fstds %%fr0,0(%0)" :: "r" (&ofpsr) : "memory"); + __asm__ volatile("fstds %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr)); fpsr = ofpsr | ((u_int64_t)FP_RM << (9 + 32)); - __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&fpsr) : "memory"); + __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&fpsr), "m" (fpsr)); __asm__ volatile("frnd,dbl %0,%0" : "+f" (x)); - __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&ofpsr) : "memory"); + __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&ofpsr), "m" (fpsr)); return (x); } DEF_STD(floor); diff --git a/lib/libm/arch/hppa/s_floorf.c b/lib/libm/arch/hppa/s_floorf.c index 533f7361b8c..b508ef76d3b 100644 --- a/lib/libm/arch/hppa/s_floorf.c +++ b/lib/libm/arch/hppa/s_floorf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_floorf.c,v 1.10 2016/09/12 19:47:01 guenther Exp $ */ +/* $OpenBSD: s_floorf.c,v 1.11 2023/01/27 16:43:33 miod Exp $ */ /* * Written by Michael Shalayeff. Public Domain */ @@ -12,13 +12,13 @@ floorf(float x) { u_int64_t ofpsr, fpsr; - __asm__ volatile("fstds %%fr0,0(%0)" :: "r" (&ofpsr) : "memory"); + __asm__ volatile("fstds %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr)); fpsr = ofpsr | ((u_int64_t)FP_RM << (9 + 32)); - __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&fpsr) : "memory"); + __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&fpsr), "m" (fpsr)); __asm__ volatile("frnd,sgl %0,%0" : "+f" (x)); - __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&ofpsr) : "memory"); + __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&ofpsr), "m" (ofpsr)); return (x); } DEF_STD(floorf); diff --git a/lib/libm/arch/hppa/s_trunc.c b/lib/libm/arch/hppa/s_trunc.c index 7c4dcd4348b..8e914c11362 100644 --- a/lib/libm/arch/hppa/s_trunc.c +++ b/lib/libm/arch/hppa/s_trunc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_trunc.c,v 1.8 2016/09/12 19:47:02 guenther Exp $ */ +/* $OpenBSD: s_trunc.c,v 1.9 2023/01/27 16:43:33 miod Exp $ */ /* * Written by Michael Shalayeff. Public Domain */ @@ -12,14 +12,14 @@ trunc(double x) { u_int64_t ofpsr, fpsr; - __asm__ volatile("fstds %%fr0,0(%0)" :: "r" (&ofpsr) : "memory"); + __asm__ volatile("fstds %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr)); fpsr = (ofpsr & ~((u_int64_t)FP_RM << (9 + 32))) | ((u_int64_t)FP_RZ << (9 + 32)); - __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&fpsr) : "memory"); + __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&fpsr), "m" (fpsr)); __asm__ volatile("frnd,dbl %0,%0" : "+f" (x)); - __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&ofpsr) : "memory"); + __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&ofpsr), "m" (ofpsr)); return (x); } DEF_STD(trunc); diff --git a/lib/libm/arch/hppa/s_truncf.c b/lib/libm/arch/hppa/s_truncf.c index 3901d22c097..a543dcb7ab0 100644 --- a/lib/libm/arch/hppa/s_truncf.c +++ b/lib/libm/arch/hppa/s_truncf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_truncf.c,v 1.5 2015/01/20 04:41:01 krw Exp $ */ +/* $OpenBSD: s_truncf.c,v 1.6 2023/01/27 16:43:33 miod Exp $ */ /* * Written by Michael Shalayeff. Public Domain */ @@ -12,13 +12,13 @@ truncf(float x) { u_int64_t ofpsr, fpsr; - __asm__ volatile("fstds %%fr0,0(%0)" :: "r" (&ofpsr) : "memory"); + __asm__ volatile("fstds %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr)); fpsr = (ofpsr & ~((u_int64_t)FP_RM << (9 + 32))) | ((u_int64_t)FP_RZ << (9 + 32)); - __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&fpsr) : "memory"); + __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&fpsr), "m" (fpsr)); __asm__ volatile("frnd,sgl %0,%0" : "+f" (x)); - __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&ofpsr) : "memory"); + __asm__ volatile("fldds 0(%0), %%fr0" :: "r" (&ofpsr), "m" (ofpsr)); return (x); } -- 2.20.1