mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-05 15:42:24 +00:00
[libc][NFC] Make few fenv functions work with fexcept_t from other libcs.
This commit is contained in:
parent
c16fef19f6
commit
9550f8ba9a
@ -15,11 +15,8 @@
|
||||
namespace __llvm_libc {
|
||||
|
||||
LLVM_LIBC_FUNCTION(int, fegetexceptflag, (fexcept_t * flagp, int excepts)) {
|
||||
// Since the return type of fetestexcept is int, we ensure that fexcept_t
|
||||
// matches in size.
|
||||
static_assert(sizeof(int) == sizeof(fexcept_t),
|
||||
"sizeof(fexcept_t) != sizeof(int)");
|
||||
*reinterpret_cast<int *>(flagp) = fputil::testExcept(FE_ALL_EXCEPT) & excepts;
|
||||
// TODO: Add a compile time check to see if the excepts actually fit in flagp.
|
||||
*flagp = static_cast<fexcept_t>(fputil::testExcept(FE_ALL_EXCEPT) & excepts);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,9 @@ namespace __llvm_libc {
|
||||
LLVM_LIBC_FUNCTION(int, fesetexceptflag,
|
||||
(const fexcept_t *flagp, int excepts)) {
|
||||
// Since the return type of fetestexcept is int, we ensure that fexcept_t
|
||||
// matches in size.
|
||||
static_assert(sizeof(int) == sizeof(fexcept_t),
|
||||
"sizeof(fexcept_t) != sizeof(int)");
|
||||
// can fit in int type.
|
||||
static_assert(sizeof(int) >= sizeof(fexcept_t),
|
||||
"fexcept_t value cannot fit in an int value.");
|
||||
int excepts_to_set = *reinterpret_cast<const int *>(flagp) & excepts;
|
||||
return fputil::setExcept(excepts_to_set);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user