Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aarch64/fenv.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* Hopefully the system ID byte is immutable, so it's valid to use
* this as a default environment.
*/
const fenv_t __fe_dfl_env = 0;
const fenv_t __fe_dfl_env = {0};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a uint64_t, so what was here was originally ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a struct on musl, which is what I think the AI was looking at: https://github.com/cloudius-systems/musl/blob/master/arch/arm/bits/fenv.h#L19-L21.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://en.cppreference.com/w/c/language/scalar_initialization.html, = {0} is valid for scalar initialization, so I think this fix is correct and will work for both libcs.


extern inline int feclearexcept(int __excepts);
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
Expand Down
12 changes: 6 additions & 6 deletions include/openlibm_fenv_aarch64.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
#endif

/* The high 32 bits contain fpcr, low 32 contain fpsr. */
typedef __uint64_t fenv_t;
typedef __uint64_t fexcept_t;
typedef uint64_t fenv_t;
typedef uint64_t fexcept_t;

/* Exception flags */
#define FE_INVALID 0x00000001
Expand Down Expand Up @@ -158,8 +158,8 @@ fesetround(int __round)
__fenv_static inline int
fegetenv(fenv_t *__envp)
{
__uint64_t fpcr;
__uint64_t fpsr;
uint64_t fpcr;
uint64_t fpsr;

__mrs_fpcr(fpcr);
__mrs_fpsr(fpsr);
Expand All @@ -179,7 +179,7 @@ feholdexcept(fenv_t *__envp)
__msr_fpcr(__r);

__mrs_fpsr(__r);
*__envp |= (__uint32_t)__r;
*__envp |= (uint32_t)__r;
__r &= ~(_ENABLE_MASK);
__msr_fpsr(__r);
return (0);
Expand All @@ -190,7 +190,7 @@ fesetenv(const fenv_t *__envp)
{

__msr_fpcr((*__envp) >> 32);
__msr_fpsr((fenv_t)(__uint32_t)*__envp);
__msr_fpsr((fenv_t)(uint32_t)*__envp);
return (0);
}

Expand Down