Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aarch64/fenv: fix fenv_t #319

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

inkydragon
Copy link
Member

@inkydragon inkydragon commented Jan 15, 2025

AArch64 has two 64bit regs, AArch32 only has one.
The high 32 bits of both registers are reserved, so we only need to save the low 32 bits and pack them into a uint64.

Fix #278

This comment was marked as outdated.

@inkydragon

This comment was marked as outdated.

@inkydragon inkydragon marked this pull request as draft January 15, 2025 09:25
@inkydragon
Copy link
Member Author

inkydragon commented Jan 15, 2025

Do we want to sync openlibm_fenv_arm.h from FreeBSD too?

Seems there are some bugs:

/* We need to be able to map status flag positions to mask flag positions */
#define _FPUSW_SHIFT 16
#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT)

/* We need to be able to map status flag positions to mask flag positions */
#ifndef __ARM_PCS_VFP
#define	_FPUSW_SHIFT	16
#define	_ENABLE_MASK	(FE_ALL_EXCEPT << _FPUSW_SHIFT)
#endif

And FreeBSD doesn't use _ENABLE_MASK
https://github.com/freebsd/freebsd-src/blob/de1aa3dab23c06fec962a14da3e7b4755c5880cf/lib/msun/arm/fenv.h#L83-L87

#else	/* __ARM_PCS_VFP */

...

#define _FPU_MASK_SHIFT	8

https://github.com/freebsd/freebsd-src/blob/de1aa3dab23c06fec962a14da3e7b4755c5880cf/lib/msun/arm/fenv.h#L113

@inkydragon inkydragon marked this pull request as ready for review January 15, 2025 10:03
Comment on lines +75 to +76
#define __mrs_fpcr(__r) __asm __volatile("mrs %0, fpcr" : "=r" (__r))
#define __msr_fpcr(__r) __asm __volatile("msr fpcr, %0" : : "r" (__r))
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to rename those functions to __read_fpcr, __write_fpcr.
Or reg_fpcr_read(), reg_fpsr_write() (NetBSD style)

@inkydragon inkydragon added the arm ARM-based architectures label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arm ARM-based architectures
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aarch64/fenv.c:41:23: error: invalid initializer
1 participant