> Date: Wed, 20 Jul 2016 21:24:17 +0200
> From: Philip Guenther <[email protected]>
> 
> Wrap fpgetround() so internal calls to it (seen on arm, powerpc, and sh) 
> go direct instead of through the PLT.
> 
> The first two diff files below pull in the missing <ieeefp.h> so the 
> wrapping is seen; the rest of the diff chunks perform the wrapping.
> 
> ok?

Looks ok, but I think this turd polishing should wait until after 6.0
is out of the door.

> Index: arch/powerpc/gen/flt_rounds.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/arch/powerpc/gen/flt_rounds.c,v
> retrieving revision 1.6
> diff -u -p -r1.6 flt_rounds.c
> --- arch/powerpc/gen/flt_rounds.c     27 Oct 2015 05:54:49 -0000      1.6
> +++ arch/powerpc/gen/flt_rounds.c     18 Jul 2016 14:05:04 -0000
> @@ -34,6 +34,7 @@
>  
>  #include <sys/types.h>
>  #include <float.h>
> +#include <ieeefp.h>
>  
>  
>  static const int map[] = {
> @@ -44,7 +45,7 @@ static const int map[] = {
>  };
>  
>  int
> -__flt_rounds()
> +__flt_rounds(void)
>  {
>  #ifdef _SOFT_FLOAT
>       return map[fpgetround()];
> Index: arch/sh/gen/flt_rounds.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/arch/sh/gen/flt_rounds.c,v
> retrieving revision 1.5
> diff -u -p -r1.5 flt_rounds.c
> --- arch/sh/gen/flt_rounds.c  27 Oct 2015 05:54:49 -0000      1.5
> +++ arch/sh/gen/flt_rounds.c  18 Jul 2016 14:04:53 -0000
> @@ -18,7 +18,7 @@
>  
>  #include <sys/types.h>
>  #include <float.h>
> -#include <machine/ieeefp.h>
> +#include <ieeefp.h>
>  
>  static const int rndmap[] = {
>       1,      /* round to nearest */
> Index: hidden/ieeefp.h
> ===================================================================
> RCS file: hidden/ieeefp.h
> diff -N hidden/ieeefp.h
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ hidden/ieeefp.h   18 Jul 2016 14:02:01 -0000
> @@ -0,0 +1,30 @@
> +/*   $OpenBSD$       */
> +/*
> + * Copyright (c) 2016 Philip Guenther <[email protected]>
> + *
> + * Permission to use, copy, modify, and distribute this software for any
> + * purpose with or without fee is hereby granted, provided that the above
> + * copyright notice and this permission notice appear in all copies.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> + */
> +
> +#ifndef _LIBC_IEEEFP_H_
> +#define _LIBC_IEEEFP_H_
> +
> +#include_next <ieeefp.h>
> +
> +PROTO_DEPRECATED(fpgetmask);
> +PROTO_NORMAL(fpgetround);
> +PROTO_DEPRECATED(fpgetsticky);
> +PROTO_DEPRECATED(fpsetmask);
> +PROTO_DEPRECATED(fpsetround);
> +PROTO_DEPRECATED(fpsetsticky);
> +
> +#endif /* _LIBC_IEEEFP_H_ */
> Index: arch/alpha/gen/fpgetround.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/arch/alpha/gen/fpgetround.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 fpgetround.c
> --- arch/alpha/gen/fpgetround.c       7 Aug 2005 16:40:13 -0000       1.4
> +++ arch/alpha/gen/fpgetround.c       18 Jul 2016 14:37:15 -0000
> @@ -36,7 +36,7 @@
>  #include <ieeefp.h>
>  
>  fp_rnd
> -fpgetround()
> +fpgetround(void)
>  {
>       double fpcrval;
>       u_int64_t old;
> @@ -48,3 +48,4 @@ fpgetround()
>  
>       return ((old >> 58) & 0x3);
>  }
> +DEF_WEAK(fpgetround);
> Index: arch/hppa/gen/fpgetround.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/arch/hppa/gen/fpgetround.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 fpgetround.c
> --- arch/hppa/gen/fpgetround.c        18 Apr 2014 15:09:52 -0000      1.4
> +++ arch/hppa/gen/fpgetround.c        18 Jul 2016 14:37:18 -0000
> @@ -8,10 +8,11 @@
>  #include <ieeefp.h>
>  
>  fp_rnd
> -fpgetround()
> +fpgetround(void)
>  {
>       u_int64_t fpsr;
>  
>       __asm__ volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr));
>       return ((fpsr >> 41) & 0x3);
>  }
> +DEF_WEAK(fpgetround);
> Index: arch/m88k/gen/fpgetround.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/arch/m88k/gen/fpgetround.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 fpgetround.c
> --- arch/m88k/gen/fpgetround.c        5 Jan 2013 11:20:55 -0000       1.4
> +++ arch/m88k/gen/fpgetround.c        18 Jul 2016 14:37:20 -0000
> @@ -9,10 +9,11 @@
>  #include <ieeefp.h>
>  
>  fp_rnd
> -fpgetround()
> +fpgetround(void)
>  {
>       int x;
>  
>       __asm__ volatile ("fldcr %0, %%fcr63" : "=r" (x));
>       return (x >> 14) & 0x03;
>  }
> +DEF_WEAK(fpgetround);
> Index: arch/mips64/gen/fpgetround.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/arch/mips64/gen/fpgetround.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 fpgetround.c
> --- arch/mips64/gen/fpgetround.c      7 Aug 2005 16:40:15 -0000       1.2
> +++ arch/mips64/gen/fpgetround.c      18 Jul 2016 14:37:22 -0000
> @@ -7,10 +7,11 @@
>  #include <ieeefp.h>
>  
>  fp_rnd
> -fpgetround()
> +fpgetround(void)
>  {
>       int x;
>  
>       __asm__("cfc1 %0,$31" : "=r" (x));
>       return x & 0x03;
>  }
> +DEF_WEAK(fpgetround);
> Index: arch/powerpc/gen/fpgetround.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/arch/powerpc/gen/fpgetround.c,v
> retrieving revision 1.3
> diff -u -p -r1.3 fpgetround.c
> --- arch/powerpc/gen/fpgetround.c     17 Apr 2014 09:01:25 -0000      1.3
> +++ arch/powerpc/gen/fpgetround.c     18 Jul 2016 14:37:23 -0000
> @@ -34,10 +34,11 @@
>  #include <ieeefp.h>
>  
>  fp_rnd
> -fpgetround()
> +fpgetround(void)
>  {
>       u_int64_t fpscr;
>  
>       __asm__ volatile("mffs %0" : "=f"(fpscr));
>       return (fpscr & 0x3);
>  }
> +DEF_WEAK(fpgetround);
> Index: arch/sh/gen/fpgetround.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/arch/sh/gen/fpgetround.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 fpgetround.c
> --- arch/sh/gen/fpgetround.c  18 Apr 2014 15:09:52 -0000      1.2
> +++ arch/sh/gen/fpgetround.c  18 Jul 2016 14:37:25 -0000
> @@ -20,10 +20,11 @@
>  #include <ieeefp.h>
>  
>  fp_rnd
> -fpgetround()
> +fpgetround(void)
>  {
>       register_t fpscr;
>  
>       __asm__ volatile ("sts fpscr, %0" : "=r" (fpscr));
>       return (fpscr & 0x3);
>  }
> +DEF_WEAK(fpgetround);
> Index: arch/sparc/gen/fpgetround.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/arch/sparc/gen/fpgetround.c,v
> retrieving revision 1.3
> diff -u -p -r1.3 fpgetround.c
> --- arch/sparc/gen/fpgetround.c       7 Aug 2005 16:40:15 -0000       1.3
> +++ arch/sparc/gen/fpgetround.c       18 Jul 2016 14:05:19 -0000
> @@ -7,10 +7,11 @@
>  #include <ieeefp.h>
>  
>  fp_rnd
> -fpgetround()
> +fpgetround(void)
>  {
>       int x;
>  
>       __asm__("st %%fsr,%0" : "=m" (*&x));
>       return (x >> 30) & 0x03;
>  }
> +DEF_WEAK(fpgetround);
> Index: arch/sparc64/gen/fpgetround.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/arch/sparc64/gen/fpgetround.c,v
> retrieving revision 1.1
> diff -u -p -r1.1 fpgetround.c
> --- arch/sparc64/gen/fpgetround.c     29 Aug 2001 01:34:56 -0000      1.1
> +++ arch/sparc64/gen/fpgetround.c     18 Jul 2016 14:05:49 -0000
> @@ -8,10 +8,11 @@
>  #include <ieeefp.h>
>  
>  fp_rnd
> -fpgetround()
> +fpgetround(void)
>  {
>       int x;
>  
>       __asm__("st %%fsr,%0" : "=m" (*&x));
>       return (x >> 30) & 0x03;
>  }
> +DEF_WEAK(fpgetround);
> Index: softfloat/fpgetround.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/softfloat/fpgetround.c,v
> retrieving revision 1.6
> diff -u -p -r1.6 fpgetround.c
> --- softfloat/fpgetround.c    18 Jul 2016 19:05:22 -0000      1.6
> +++ softfloat/fpgetround.c    18 Jul 2016 19:05:45 -0000
> @@ -45,3 +45,4 @@ fpgetround(void)
>  
>       return float_rounding_mode;
>  }
> +DEF_WEAK(fpgetround);
> 
> 

Reply via email to