LibC: Implement fegetenv() and fesetenv() on AArch64

These functions simply store/restore the floating-point control and
status flags.
This commit is contained in:
Sönke Holz
2026-04-05 17:04:49 +02:00
committed by Nico Weber
parent 24a7479c43
commit fb229083d7
2 changed files with 9 additions and 6 deletions

View File

@@ -77,8 +77,9 @@ int fegetenv(fenv_t* env)
if (!env)
return 1;
(void)env;
TODO_AARCH64();
asm volatile("mrs %0, fpcr" : "=r"(env->fpcr));
asm volatile("mrs %0, fpsr" : "=r"(env->fpsr));
return 0;
}
@@ -87,8 +88,9 @@ int fesetenv(fenv_t const* env)
if (!env)
return 1;
(void)env;
TODO_AARCH64();
asm volatile("msr fpcr, %0" ::"r"(env->fpcr));
asm volatile("msr fpsr, %0" ::"r"(env->fpsr));
return 0;
}

View File

@@ -6,6 +6,7 @@
#pragma once
#include <stdint.h>
#include <sys/cdefs.h>
#ifndef __aarch64__
@@ -14,9 +15,9 @@
__BEGIN_DECLS
// TODO: Implement this.
typedef struct fenv_t {
char __dummy; // NOTE: This silences -Wextern-c-compat.
uint64_t fpcr;
uint64_t fpsr;
} fenv_t;
__END_DECLS