This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Which POWER implementations need the HWCAP_DFP check?
- From: Tulio Magno Quites Machado Filho <tuliom at linux dot vnet dot ibm dot com>
- To: Florian Weimer <fweimer at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Cc:
- Date: Mon, 14 May 2018 12:22:49 -0300
- Subject: Re: Which POWER implementations need the HWCAP_DFP check?
- References: <c6631e1a-fdce-99b8-2602-b73330caffc7@redhat.com>
Florian Weimer <fweimer@redhat.com> writes:
> I think this run-time check is unnecessary on POWER6 and later:
>
> double d = (env); \
> if(GLRO(dl_hwcap) & PPC_FEATURE_HAS_DFP) \
> asm volatile (".machine push; " \
> ".machine \"power6\"; " \
> "mtfsf 0xff,%0,1,0; " \
> ".machine pop" : : "f" (d)); \
> else \
> asm volatile ("mtfsf 0xff,%0" : : "f" (d)); \
I think it's still necessary when building glibc for an older processor,
e.g. POWER4, and run it on processors that support DFP, e.g. POWER6.
> In particularly, we do not need it on ppc64le. Correct?
Agreed, unless the kernel has the right to disable DFP support.
> It's one of the GLIBC_PRIVATE references in libm.so.6, which is why I'm
> asking.
Would the following code solve this problem?
#include <tls.h>
/* Equivalent to fesetenv, but takes a fenv_t instead of a pointer. */
#define fesetenv_register(env) \
do { \
double d = (env); \
if(THREAD_GET_HWCAP() & PPC_FEATURE_HAS_DFP) \
asm volatile (".machine push; " \
".machine \"power6\"; " \
"mtfsf 0xff,%0,1,0; " \
".machine pop" : : "f" (d)); \
else \
asm volatile ("mtfsf 0xff,%0" : : "f" (d)); \
} while(0)
--
Tulio Magno