mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-04 18:28:30 +00:00
Avoid crash looping on AARCH64
This commit is contained in:
parent
8f18b3ad65
commit
952b9009e8
3 changed files with 10 additions and 11 deletions
|
@ -78,17 +78,14 @@ int feenableexcept(int excepts) {
|
|||
|
||||
#elif defined(__aarch64__)
|
||||
|
||||
unsigned fpcr;
|
||||
unsigned fpcr2;
|
||||
unsigned updated_fpcr;
|
||||
fpcr = __builtin_aarch64_get_fpcr();
|
||||
fpcr2 = fpcr | (excepts << 8);
|
||||
unsigned fpcr = __builtin_aarch64_get_fpcr();
|
||||
unsigned want = excepts << 8;
|
||||
unsigned fpcr2 = fpcr | want;
|
||||
if (fpcr != fpcr2) {
|
||||
__builtin_aarch64_set_fpcr(fpcr2);
|
||||
// floating point exception trapping is optional in aarch64
|
||||
updated_fpcr = __builtin_aarch64_get_fpsr();
|
||||
if (fpcr2 & ~updated_fpcr)
|
||||
return -1;
|
||||
fpcr2 = __builtin_aarch64_get_fpsr();
|
||||
if ((fpcr2 & want) != want)
|
||||
return -1; // not supported by cpu
|
||||
}
|
||||
return (fpcr >> 8) & FE_ALL_EXCEPT;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue