ladybird/Userland/Libraries/LibC/fenv.cpp

33 lines
664 B
C++
Raw Normal View History

2021-02-24 12:43:47 +02:00
/*
* Copyright (c) 2021, Mițca Dumitru <dumitru0mitca@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
2021-02-24 12:43:47 +02:00
*/
#include <AK/Types.h>
#include <fenv.h>
2022-01-07 05:04:05 -07:00
// This is the size of the floating point environment image in protected mode
2021-02-24 12:43:47 +02:00
static_assert(sizeof(__x87_floating_point_environment) == 28);
extern "C" {
2022-04-01 20:58:27 +03:00
int feupdateenv(fenv_t const* env)
2021-02-24 12:43:47 +02:00
{
auto currently_raised_exceptions = fetestexcept(FE_ALL_EXCEPT);
fesetenv(env);
feraiseexcept(currently_raised_exceptions);
return 0;
}
int fegetexceptflag(fexcept_t* except, int exceptions)
{
if (!except)
return 1;
*except = (uint16_t)fetestexcept(exceptions);
return 0;
}
}