Skip to content

Commit 9fbeafc

Browse files
authored
Fix BSD-specific types on Linux for aarch64 (#329)
The recent addition of aarch64 fenv support uses BSD-specific types (__uint64_t and __uint32_t) that are not defined on Linux systems, causing compilation failures on aarch64-linux targets. This commit replaces BSD-specific types with standard C99 types: - __uint64_t → uint64_t - __uint32_t → uint32_t These standard types are available on all platforms through the included <stdint.h> header. Additionally, this fixes the initialization of __fe_dfl_env from scalar 0 to {0} to match the typedef as a non-scalar type. Fixes build failures on aarch64-linux-gnu and other non-BSD platforms.
1 parent d463259 commit 9fbeafc

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

aarch64/fenv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* Hopefully the system ID byte is immutable, so it's valid to use
3737
* this as a default environment.
3838
*/
39-
const fenv_t __fe_dfl_env = 0;
39+
const fenv_t __fe_dfl_env = {0};
4040

4141
extern inline int feclearexcept(int __excepts);
4242
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);

include/openlibm_fenv_aarch64.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
#endif
3737

3838
/* The high 32 bits contain fpcr, low 32 contain fpsr. */
39-
typedef __uint64_t fenv_t;
40-
typedef __uint64_t fexcept_t;
39+
typedef uint64_t fenv_t;
40+
typedef uint64_t fexcept_t;
4141

4242
/* Exception flags */
4343
#define FE_INVALID 0x00000001
@@ -158,8 +158,8 @@ fesetround(int __round)
158158
__fenv_static inline int
159159
fegetenv(fenv_t *__envp)
160160
{
161-
__uint64_t fpcr;
162-
__uint64_t fpsr;
161+
uint64_t fpcr;
162+
uint64_t fpsr;
163163

164164
__mrs_fpcr(fpcr);
165165
__mrs_fpsr(fpsr);
@@ -179,7 +179,7 @@ feholdexcept(fenv_t *__envp)
179179
__msr_fpcr(__r);
180180

181181
__mrs_fpsr(__r);
182-
*__envp |= (__uint32_t)__r;
182+
*__envp |= (uint32_t)__r;
183183
__r &= ~(_ENABLE_MASK);
184184
__msr_fpsr(__r);
185185
return (0);
@@ -190,7 +190,7 @@ fesetenv(const fenv_t *__envp)
190190
{
191191

192192
__msr_fpcr((*__envp) >> 32);
193-
__msr_fpsr((fenv_t)(__uint32_t)*__envp);
193+
__msr_fpsr((fenv_t)(uint32_t)*__envp);
194194
return (0);
195195
}
196196

0 commit comments

Comments
 (0)