Skip to content

Commit 76d6b2f

Browse files
committed
fenv: fix aarch64 fenv_t
1 parent 5a88ede commit 76d6b2f

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

aarch64/fenv.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
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 = {
40+
.__fpcr = 0x0,
41+
.__fpsr = 0x0
42+
};
4043

4144
extern inline int feclearexcept(int __excepts);
4245
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);

include/openlibm_fenv_arm.h

+22-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,28 @@
3737
#define __fenv_static static
3838
#endif
3939

40-
typedef uint32_t fenv_t;
40+
/* Test Arm Procedure Call Standard */
41+
#ifdef __ARM_PCS_AAPCS64
42+
/* AArch64 */
43+
typedef struct {
44+
/** FPCR, Floating-point Control Register
45+
* FPCR is a 64-bit register, but Bits [63:27] is reserved, so we only need 32 bits.
46+
* https://developer.arm.com/documentation/ddi0601/2024-12/AArch64-Registers/FPCR--Floating-point-Control-Register?lang=en
47+
*/
48+
uint32_t __fpcr;
49+
/** FPSR, Floating-point Status Register
50+
* FPSR is a 64-bit register, but Bits [63:32] is reserved, so we only need 32 bits.
51+
* https://developer.arm.com/documentation/ddi0601/2024-12/AArch64-Registers/FPSR--Floating-point-Status-Register?lang=en
52+
*/
53+
uint32_t __fpsr;
54+
} fenv_t;
55+
#else /* AArch32 */
56+
/** FPSCR, Floating-Point Status and Control Register
57+
* FPSCR is a 32-bit register.
58+
* https://developer.arm.com/documentation/ddi0601/2024-12/AArch32-Registers/FPSCR--Floating-Point-Status-and-Control-Register?lang=en
59+
*/
60+
typedef uint32_t fenv_t;
61+
#endif /* __ARM_PCS_AAPCS64 */
4162
typedef uint32_t fexcept_t;
4263

4364
/* Exception flags */

0 commit comments

Comments
 (0)