Fix libm fesetround namespace (bug 17748).

Continuing the fixes for C90 libm functions calling C99 fe* functions,
this patch fixes the case of fesetround by making it a weak alias of
__fesetround and making the affected code call __fesetround.  An
existing __fesetround function in fenv_libc.h for powerpc is renamed
to __fesetround_inline.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch).  Also tested for ARM
(soft-float) that fesetround failures disappear from the linknamespace
test results (feupdateenv remains to be addressed to complete fixing
bug 17748).

	[BZ #17748]
	* include/fenv.h (__fesetround): Declare.  Use libm_hidden_proto.
	* math/fesetround.c (fesetround): Rename to __fesetround and
	define as weak alias of __fesetround.  Use libm_hidden_weak.
	* sysdeps/aarch64/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/alpha/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/arm/fesetround.c (fesetround): Likewise.
	* sysdeps/hppa/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/i386/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/ia64/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/m68k/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/mips/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/powerpc/fpu/fenv_libc.h (__fesetround): Rename to
	__fesetround_inline.
	* sysdeps/powerpc/fpu/fenv_private.h (libc_fesetround_ppc): Call
	__fesetround_inline instead of __fesetround.
	* sysdeps/powerpc/fpu/fesetround.c (fesetround): Rename to
	__fesetround and define as weak alias of __fesetround.  Use
	libm_hidden_weak.  Call __fesetround_inline instead of
	__fesetround.
	* sysdeps/powerpc/nofpu/fesetround.c (fesetround): Rename to
	__fesetround and define as weak alias of __fesetround.  Use
	libm_hidden_weak.
	* sysdeps/powerpc/powerpc32/e500/nofpu/fesetround.c (fesetround):
	Likewise.
	* sysdeps/s390/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/sh/sh4/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/sparc/fpu/fesetround.c (fesetround): Likewise.
	* sysdeps/tile/math_private.h (__fesetround): New inline function.
	* sysdeps/x86_64/fpu/fesetround.c (fesetround): Rename to
	__fesetround and define as weak alias of __fesetround.  Use
	libm_hidden_weak.
	* sysdeps/generic/math_private.h (default_libc_fesetround): Call
	__fesetround instead of fesetround.
	(default_libc_feholdexcept_setround): Likewise.
	(libc_feholdsetround_ctx): Likewise.
	(libc_feholdsetround_noex_ctx): Likewise.
This commit is contained in:
Joseph Myers 2015-01-07 00:41:23 +00:00
parent cd42798aef
commit 01238691bb
22 changed files with 112 additions and 39 deletions

View File

@ -1,5 +1,43 @@
2015-01-06 Joseph Myers <joseph@codesourcery.com> 2015-01-06 Joseph Myers <joseph@codesourcery.com>
[BZ #17748]
* include/fenv.h (__fesetround): Declare. Use libm_hidden_proto.
* math/fesetround.c (fesetround): Rename to __fesetround and
define as weak alias of __fesetround. Use libm_hidden_weak.
* sysdeps/aarch64/fpu/fesetround.c (fesetround): Likewise.
* sysdeps/alpha/fpu/fesetround.c (fesetround): Likewise.
* sysdeps/arm/fesetround.c (fesetround): Likewise.
* sysdeps/hppa/fpu/fesetround.c (fesetround): Likewise.
* sysdeps/i386/fpu/fesetround.c (fesetround): Likewise.
* sysdeps/ia64/fpu/fesetround.c (fesetround): Likewise.
* sysdeps/m68k/fpu/fesetround.c (fesetround): Likewise.
* sysdeps/mips/fpu/fesetround.c (fesetround): Likewise.
* sysdeps/powerpc/fpu/fenv_libc.h (__fesetround): Rename to
__fesetround_inline.
* sysdeps/powerpc/fpu/fenv_private.h (libc_fesetround_ppc): Call
__fesetround_inline instead of __fesetround.
* sysdeps/powerpc/fpu/fesetround.c (fesetround): Rename to
__fesetround and define as weak alias of __fesetround. Use
libm_hidden_weak. Call __fesetround_inline instead of
__fesetround.
* sysdeps/powerpc/nofpu/fesetround.c (fesetround): Rename to
__fesetround and define as weak alias of __fesetround. Use
libm_hidden_weak.
* sysdeps/powerpc/powerpc32/e500/nofpu/fesetround.c (fesetround):
Likewise.
* sysdeps/s390/fpu/fesetround.c (fesetround): Likewise.
* sysdeps/sh/sh4/fpu/fesetround.c (fesetround): Likewise.
* sysdeps/sparc/fpu/fesetround.c (fesetround): Likewise.
* sysdeps/tile/math_private.h (__fesetround): New inline function.
* sysdeps/x86_64/fpu/fesetround.c (fesetround): Rename to
__fesetround and define as weak alias of __fesetround. Use
libm_hidden_weak.
* sysdeps/generic/math_private.h (default_libc_fesetround): Call
__fesetround instead of fesetround.
(default_libc_feholdexcept_setround): Likewise.
(libc_feholdsetround_ctx): Likewise.
(libc_feholdsetround_noex_ctx): Likewise.
[BZ #17748] [BZ #17748]
* include/fenv.h (__fesetenv): Use libm_hidden_proto. * include/fenv.h (__fesetenv): Use libm_hidden_proto.
* math/fesetenv.c (__fesetenv): Use libm_hidden_def. * math/fesetenv.c (__fesetenv): Use libm_hidden_def.

View File

@ -15,6 +15,7 @@ extern int __fesetenv (const fenv_t *__envp);
extern int __feupdateenv (const fenv_t *__envp); extern int __feupdateenv (const fenv_t *__envp);
extern __typeof (fegetround) __fegetround; extern __typeof (fegetround) __fegetround;
extern __typeof (feholdexcept) __feholdexcept; extern __typeof (feholdexcept) __feholdexcept;
extern __typeof (fesetround) __fesetround;
libm_hidden_proto (feraiseexcept) libm_hidden_proto (feraiseexcept)
libm_hidden_proto (__feraiseexcept) libm_hidden_proto (__feraiseexcept)
@ -25,6 +26,7 @@ libm_hidden_proto (__fegetround)
libm_hidden_proto (fesetenv) libm_hidden_proto (fesetenv)
libm_hidden_proto (__fesetenv) libm_hidden_proto (__fesetenv)
libm_hidden_proto (fesetround) libm_hidden_proto (fesetround)
libm_hidden_proto (__fesetround)
libm_hidden_proto (feholdexcept) libm_hidden_proto (feholdexcept)
libm_hidden_proto (__feholdexcept) libm_hidden_proto (__feholdexcept)
libm_hidden_proto (feupdateenv) libm_hidden_proto (feupdateenv)

View File

@ -20,7 +20,7 @@
#include <fenv.h> #include <fenv.h>
int int
fesetround (int round) __fesetround (int round)
{ {
#ifdef FE_TONEAREST #ifdef FE_TONEAREST
return (round == FE_TONEAREST) ? 0 : 1; return (round == FE_TONEAREST) ? 0 : 1;
@ -28,5 +28,7 @@ fesetround (int round)
return 1; /* Signal we are unable to set the direction. */ return 1; /* Signal we are unable to set the direction. */
#endif #endif
} }
libm_hidden_def (fesetround) libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)
stub_warning (fesetround) stub_warning (fesetround)

View File

@ -21,7 +21,7 @@
#include <fpu_control.h> #include <fpu_control.h>
int int
fesetround (int round) __fesetround (int round)
{ {
if (round & ~_FPU_FPCR_RM_MASK) if (round & ~_FPU_FPCR_RM_MASK)
return 1; return 1;
@ -29,4 +29,6 @@ fesetround (int round)
libc_fesetround_aarch64 (round); libc_fesetround_aarch64 (round);
return 0; return 0;
} }
libm_hidden_def (fesetround) libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)

View File

@ -20,7 +20,7 @@
#include <fenv_libc.h> #include <fenv_libc.h>
int int
fesetround (int round) __fesetround (int round)
{ {
unsigned long fpcr; unsigned long fpcr;
@ -39,4 +39,6 @@ fesetround (int round)
return 0; return 0;
} }
libm_hidden_def (fesetround) libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)

View File

@ -21,7 +21,7 @@
int int
fesetround (int round) __fesetround (int round)
{ {
/* FE_TONEAREST is the only supported rounding mode /* FE_TONEAREST is the only supported rounding mode
if a VFP unit isn't present. */ if a VFP unit isn't present. */
@ -34,4 +34,6 @@ fesetround (int round)
libc_fesetround_vfp (round); libc_fesetround_vfp (round);
return 0; return 0;
} }
libm_hidden_def (fesetround) libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)

View File

@ -415,7 +415,7 @@ default_libc_feholdexcept (fenv_t *e)
static __always_inline void static __always_inline void
default_libc_fesetround (int r) default_libc_fesetround (int r)
{ {
(void) fesetround (r); (void) __fesetround (r);
} }
#ifndef libc_fesetround #ifndef libc_fesetround
@ -432,7 +432,7 @@ static __always_inline void
default_libc_feholdexcept_setround (fenv_t *e, int r) default_libc_feholdexcept_setround (fenv_t *e, int r)
{ {
__feholdexcept (e); __feholdexcept (e);
fesetround (r); __fesetround (r);
} }
#ifndef libc_feholdexcept_setround #ifndef libc_feholdexcept_setround
@ -599,7 +599,7 @@ libc_feholdsetround_ctx (struct rm_ctx *ctx, int round)
{ {
ctx->updated_status = true; ctx->updated_status = true;
__fegetenv (&ctx->env); __fegetenv (&ctx->env);
fesetround (round); __fesetround (round);
} }
} }
@ -619,7 +619,7 @@ libc_feholdsetround_noex_ctx (struct rm_ctx *ctx, int round)
/* Update rounding mode only if different. */ /* Update rounding mode only if different. */
if (__glibc_unlikely (round != get_rounding_mode ())) if (__glibc_unlikely (round != get_rounding_mode ()))
fesetround (round); __fesetround (round);
} }
static __always_inline void static __always_inline void

View File

@ -20,7 +20,7 @@
#include <fenv.h> #include <fenv.h>
int int
fesetround (int round) __fesetround (int round)
{ {
union { unsigned long long l; unsigned int sw[2]; } s; union { unsigned long long l; unsigned int sw[2]; } s;
@ -37,4 +37,6 @@ fesetround (int round)
return 0; return 0;
} }
libm_hidden_def (fesetround) libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)

View File

@ -23,7 +23,7 @@
#include <dl-procinfo.h> #include <dl-procinfo.h>
int int
fesetround (int round) __fesetround (int round)
{ {
unsigned short int cw; unsigned short int cw;
@ -49,4 +49,6 @@ fesetround (int round)
return 0; return 0;
} }
libm_hidden_def (fesetround) libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)

View File

@ -20,7 +20,7 @@
#include <fenv.h> #include <fenv.h>
int int
fesetround (int round) __fesetround (int round)
{ {
fenv_t fpsr; fenv_t fpsr;
@ -38,4 +38,6 @@ fesetround (int round)
return 0; return 0;
} }
libm_hidden_def (fesetround) libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)

View File

@ -20,7 +20,7 @@
#include <fenv.h> #include <fenv.h>
int int
fesetround (int round) __fesetround (int round)
{ {
fexcept_t fpcr; fexcept_t fpcr;
@ -35,4 +35,6 @@ fesetround (int round)
return 0; return 0;
} }
libm_hidden_def (fesetround); libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)

View File

@ -21,7 +21,7 @@
#include <fpu_control.h> #include <fpu_control.h>
int int
fesetround (int round) __fesetround (int round)
{ {
fpu_control_t cw; fpu_control_t cw;
@ -41,4 +41,6 @@ fesetround (int round)
return 0; return 0;
} }
libm_hidden_def (fesetround) libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)

View File

@ -76,7 +76,7 @@ typedef union
static inline int static inline int
__fesetround (int round) __fesetround_inline (int round)
{ {
if ((unsigned int) round < 2) if ((unsigned int) round < 2)
{ {

View File

@ -57,7 +57,7 @@ libc_feholdexcept_ppc (fenv_t *envp)
static __always_inline void static __always_inline void
libc_fesetround_ppc (int r) libc_fesetround_ppc (int r)
{ {
__fesetround (r); __fesetround_inline (r);
} }
static __always_inline void static __always_inline void

View File

@ -21,11 +21,13 @@
#undef fesetround #undef fesetround
int int
fesetround (int round) __fesetround (int round)
{ {
if ((unsigned int) round > 3) if ((unsigned int) round > 3)
return 1; return 1;
else else
return __fesetround(round); return __fesetround_inline(round);
} }
libm_hidden_def (fesetround) libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)

View File

@ -21,7 +21,7 @@
#include "soft-supp.h" #include "soft-supp.h"
int int
fesetround (int round) __fesetround (int round)
{ {
if ((unsigned int) round > FE_DOWNWARD) if ((unsigned int) round > FE_DOWNWARD)
return 1; return 1;
@ -31,4 +31,6 @@ fesetround (int round)
return 0; return 0;
} }
libm_hidden_def (fesetround) libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)

View File

@ -19,7 +19,7 @@
#include <fenv_libc.h> #include <fenv_libc.h>
int int
fesetround (int round) __fesetround (int round)
{ {
unsigned long fpescr; unsigned long fpescr;
@ -32,4 +32,6 @@ fesetround (int round)
return 0; return 0;
} }
libm_hidden_def (fesetround) libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)

View File

@ -21,7 +21,7 @@
#include <fpu_control.h> #include <fpu_control.h>
int int
fesetround (int round) __fesetround (int round)
{ {
if ((round|FPC_RM_MASK) != FPC_RM_MASK) if ((round|FPC_RM_MASK) != FPC_RM_MASK)
{ {
@ -34,4 +34,6 @@ fesetround (int round)
return 0; return 0;
} }
libm_hidden_def (fesetround) libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)

View File

@ -21,7 +21,7 @@
#include <fpu_control.h> #include <fpu_control.h>
int int
fesetround (int round) __fesetround (int round)
{ {
fpu_control_t cw; fpu_control_t cw;
@ -40,4 +40,6 @@ fesetround (int round)
return 0; return 0;
} }
libm_hidden_def (fesetround) libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)

View File

@ -19,7 +19,7 @@
#include <fenv.h> #include <fenv.h>
int int
fesetround (int round) __fesetround (int round)
{ {
fenv_t tmp; fenv_t tmp;
@ -34,4 +34,6 @@ fesetround (int round)
return 0; return 0;
} }
libm_hidden_def (fesetround) libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)

View File

@ -37,5 +37,6 @@ extern inline int feupdateenv (const fenv_t *__e) { return 0; }
extern inline int fegetround (void) { return FE_TONEAREST; } extern inline int fegetround (void) { return FE_TONEAREST; }
extern inline int __fegetround (void) { return FE_TONEAREST; } extern inline int __fegetround (void) { return FE_TONEAREST; }
extern inline int fesetround (int __d) { return 0; } extern inline int fesetround (int __d) { return 0; }
extern inline int __fesetround (int __d) { return 0; }
#endif #endif

View File

@ -19,7 +19,7 @@
#include <fenv.h> #include <fenv.h>
int int
fesetround (int round) __fesetround (int round)
{ {
unsigned short int cw; unsigned short int cw;
int mxcsr; int mxcsr;
@ -43,4 +43,6 @@ fesetround (int round)
return 0; return 0;
} }
libm_hidden_def (fesetround) libm_hidden_def (__fesetround)
weak_alias (__fesetround, fesetround)
libm_hidden_weak (fesetround)