Skip to content

aarch64/fenv: fix fenv_t - #319

Merged
inkydragon merged 3 commits into
JuliaMath:masterfrom
inkydragon:fenv
Feb 10, 2025
Merged

inkydragon merged 3 commits into
JuliaMath:masterfrom
inkydragon:fenv

Conversation

@inkydragon

@inkydragon inkydragon commented Jan 15, 2025 •

Copy link
Copy Markdown
Member

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

@codecov

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

inkydragon commented Jan 15, 2025 •

Copy link
Copy Markdown
Member Author

Tracked by #320

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 thread include/openlibm_fenv_aarch64.h
@inkydragon inkydragon added the arm ARM-based architectures label Jan 15, 2025
@ViralBShah

Copy link
Copy Markdown
Member

Please merge if ready.

@inkydragon inkydragon mentioned this pull request Feb 10, 2025
2 tasks done
@inkydragon

Copy link
Copy Markdown
Member Author

All CI passed. Assume everything works well.

@inkydragon
inkydragon merged commit 1eeb139 into JuliaMath:master Feb 10, 2025
@inkydragon
inkydragon deleted the fenv branch February 10, 2025 11:03
@lazka

lazka commented Mar 10, 2025

Copy link
Copy Markdown

This fails to build on Windows, any ideas?

clang  -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong -Wp,-D__USE_MINGW_ANSI_STDIO=1 -fno-builtin -fno-strict-aliasing  -std=c99 -Wall -I/c/M/B/src/build-CLANGARM64 -I/c/M/B/src/build-CLANGARM64/include -I/c/M/B/src/build-CLANGARM64/aarch64 -I/c/M/B/src/build-CLANGARM64/src -DASSEMBLER -D__BSD_VISIBLE -Wno-implicit-function-declaration -I/c/M/B/src/build-CLANGARM64/ld128 -c src/s_fma.c -o src/s_fma.c.o
In file included from src/s_fma.c:31:
In file included from C:/M/B/src/build-CLANGARM64/include/openlibm_fenv.h:6:
C:/M/B/src/build-CLANGARM64/include/openlibm_fenv_aarch64.h:39:9: error: unknown type name '__uint64_t'; did you mean 'uint64_t'?
   39 | typedef __uint64_t      fenv_t;
      |         ^~~~~~~~~~
      |         uint64_t

lazka added a commit to msys2/MINGW-packages that referenced this pull request Mar 10, 2025
error: unknown type name '__uint64_t'; did you mean 'uint64_t'?
   39 | typedef __uint64_t      fenv_t;

JuliaMath/openlibm#319 (comment)
@jeremyd2019

Copy link
Copy Markdown
Contributor

it looks like other arches' headers (openlibm_fenv_{arm,amd64}.h at least) use the standard non-double-underscore names for these types.

@lazka

lazka commented Mar 10, 2025

Copy link
Copy Markdown

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

4 participants