diff options
author | Marcus Shawcroft <marcus.shawcroft@arm.com> | 2014-03-07 14:05:20 +0000 |
---|---|---|
committer | Will Newton <will.newton@linaro.org> | 2014-06-06 11:16:47 +0100 |
commit | 20f978e31e19d075f0e81212debee36804e60c0f (patch) | |
tree | ea5e10c38dd63983d9bc30eedf2c0f74fb6f6333 | |
parent | 6e38657c659c79aa01301e5f6e4c1f0a67ce9600 (diff) |
Optional trapping exceptions support.
Trapping exceptions in AArch64 are optional. The relevant exception
control bits in FPCR are are defined as RES0 hence the absence of
support can be detected by reading back the FPCR and comparing with
the desired value.
-rw-r--r-- | libc/ports/ChangeLog.aarch64.linaro | 6 | ||||
-rw-r--r-- | libc/ports/sysdeps/aarch64/fpu/feenablxcpt.c | 13 | ||||
-rw-r--r-- | libc/ports/sysdeps/aarch64/fpu/fesetenv.c | 10 |
3 files changed, 29 insertions, 0 deletions
diff --git a/libc/ports/ChangeLog.aarch64.linaro b/libc/ports/ChangeLog.aarch64.linaro index 6e7504574..c54c181a9 100644 --- a/libc/ports/ChangeLog.aarch64.linaro +++ b/libc/ports/ChangeLog.aarch64.linaro @@ -1,3 +1,9 @@ +2014-03-07 Marcus Shawcroft <marcus.shawcroft@arm.com> + + * sysdeps/aarch64/fpu/feenablxcpt.c (feenableexcept): Detect and + error absence of trapping exception support. + * sysdeps/aarch64/fpu/fesetenv.c (fesetenv): Likewise. + 2014-04-22 Will Newton <will.newton@linaro.org> Venkataramanan Kumar <venkataramanan.kumar@linaro.org> diff --git a/libc/ports/sysdeps/aarch64/fpu/feenablxcpt.c b/libc/ports/sysdeps/aarch64/fpu/feenablxcpt.c index d97699981..07a4bbb58 100644 --- a/libc/ports/sysdeps/aarch64/fpu/feenablxcpt.c +++ b/libc/ports/sysdeps/aarch64/fpu/feenablxcpt.c @@ -35,5 +35,18 @@ feenableexcept (int excepts) _FPU_SETCW (fpcr); + /* Trapping exceptions are optional in AArch64 the relevant enable + bits in FPCR are RES0 hence the absence of support can be + detected by reading back the FPCR and comparing with the required + value. */ + if (excepts) + { + fpu_control_t updated_fpcr; + + _FPU_GETCW (updated_fpcr); + if (((updated_fpcr >> FE_EXCEPT_SHIFT) & excepts) != excepts) + return -1; + } + return original_excepts; } diff --git a/libc/ports/sysdeps/aarch64/fpu/fesetenv.c b/libc/ports/sysdeps/aarch64/fpu/fesetenv.c index 443c705d2..a2434e37b 100644 --- a/libc/ports/sysdeps/aarch64/fpu/fesetenv.c +++ b/libc/ports/sysdeps/aarch64/fpu/fesetenv.c @@ -24,6 +24,7 @@ fesetenv (const fenv_t *envp) { fpu_control_t fpcr; fpu_fpsr_t fpsr; + fpu_control_t updated_fpcr; _FPU_GETCW (fpcr); _FPU_GETFPSR (fpsr); @@ -51,6 +52,15 @@ fesetenv (const fenv_t *envp) _FPU_SETCW (fpcr); + /* Trapping exceptions are optional in AArch64 the relevant enable + bits in FPCR are RES0 hence the absence of support can be + detected by reading back the FPCR and comparing with the required + value. */ + + _FPU_GETCW (updated_fpcr); + if ((updated_fpcr & fpcr) != fpcr) + return 1; + return 0; } |