MicrOS
fenv.h File Reference
#include <stddef.h>

Go to the source code of this file.

Classes

struct  fcontrol_t
 Type represent state of floating point control word. More...
 
struct  fexcept_t
 Type represent state of floating point status word. More...
 
struct  ftag_word_t
 Tag words. More...
 
struct  fenv_t
 Type represent state of floating point environment. More...
 

Macros

#define FE_INVALID   1
 Invalid argument exception. More...
 
#define FE_DENORMAL   2
 Denormal operand exception. More...
 
#define FE_DIVBYZERO   4
 Pole error exception. More...
 
#define FE_OVERFLOW   8
 Overflow exception. More...
 
#define FE_UNDERFLOW   16
 Underflow exception. More...
 
#define FE_INEXACT   32
 Pole error exception. More...
 
#define FE_ALL_EXCEPT   (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
 All exceptions. More...
 
#define FE_TONEAREST   0
 Rounding to nearest. More...
 
#define FE_DOWNWARD   1
 Rounding downward. More...
 
#define FE_UPWARD   2
 Rounding upward. More...
 
#define FE_TOWARDZERO   3
 Rounding towards zero. More...
 
#define FE_DFL_ENV   (env)
 macro that provides access to pointer to environment. More...
 
#define __FPU_TAG_WORD_VALID   0
 Number value in tag word. More...
 
#define __FPU_TAG_ZERO   1
 Zero value in tag word. More...
 
#define __FPU_TAG_SPECIAL   2
 Sepcial value in tag word. More...
 
#define __FPU_TAG_EMPTY   3
 Empty value in tag word. More...
 
#define __FPU_PRECISION_SINGLE   0
 Single precision. (32 bit) More...
 
#define __FPU_PRECISION_DOUBLE   1
 Double precision. (53 bit) More...
 
#define __FPU_PRECISION_EXTENDED   3
 Extended precision. (64 bit) More...
 
#define __FPU_ROUNDING_NEAREST_EVEN   0
 Rounding to nearest. More...
 
#define __FPU_ROUNDING_FLOOR   1
 Rounding downward. More...
 
#define __FPU_ROUNDING_CEIL   2
 Rounding upward. More...
 
#define __FPU_ROUNDING_TRUNCATE   3
 Rounding towards zero. More...
 
#define __FPU_INFINITY_CONTROL_PROJECTIVE   0
 Projective infinity control. More...
 
#define __FPU_INFINITY_CONTROL_AFFINE   1
 Affine infinity control. More...
 

Functions

int feclearexcept (int excepts)
 Clear FPU exception flags. More...
 
int fegetexceptflag (fexcept_t *flagp, int excepts)
 Get exception flags. More...
 
int feraiseexcept (int excepts)
 Raise FPU exception flags. More...
 
int fesetexceptflag (const fexcept_t *flagp, int excepts)
 Set exception flags. More...
 
int fetestexcept (int excepts)
 Test for floating-point exceptions. More...
 
int fegetround (void)
 Get current rounding direction. More...
 
int fesetround (int round)
 Set rounding direction. More...
 
int fegetenv (fenv_t *envp)
 Get entire environment. More...
 
int fesetenv (const fenv_t *envp)
 Set entire environment. More...
 
int feholdexcept (fenv_t *envp)
 Hold floating-point exceptions. More...
 
int feupdateenv (const fenv_t *envp)
 Update floating-point environment. More...
 
fcontrol_t __FPU_read_control_word ()
 Read FPU control word. More...
 
void __FPU_write_control_word (fcontrol_t control_word)
 Write FPU control word. More...
 
fenv_t __FPU_read_environment ()
 Read FPU environment. More...
 
void __FPU_write_environment (fenv_t environment)
 Write FPU environment. More...
 
fexcept_t __FPU_read_status_word ()
 Read FPU status word. More...
 
void __FPU_clear_exceptions ()
 Clear all FPU exceptions. More...
 

Variables

const fenv_tenv
 Pointer to environment. More...
 

Macro Definition Documentation

◆ __FPU_INFINITY_CONTROL_AFFINE

#define __FPU_INFINITY_CONTROL_AFFINE   1

Affine infinity control.

◆ __FPU_INFINITY_CONTROL_PROJECTIVE

#define __FPU_INFINITY_CONTROL_PROJECTIVE   0

Projective infinity control.

◆ __FPU_PRECISION_DOUBLE

#define __FPU_PRECISION_DOUBLE   1

Double precision. (53 bit)

◆ __FPU_PRECISION_EXTENDED

#define __FPU_PRECISION_EXTENDED   3

Extended precision. (64 bit)

◆ __FPU_PRECISION_SINGLE

#define __FPU_PRECISION_SINGLE   0

Single precision. (32 bit)

◆ __FPU_ROUNDING_CEIL

#define __FPU_ROUNDING_CEIL   2

Rounding upward.

◆ __FPU_ROUNDING_FLOOR

#define __FPU_ROUNDING_FLOOR   1

Rounding downward.

◆ __FPU_ROUNDING_NEAREST_EVEN

#define __FPU_ROUNDING_NEAREST_EVEN   0

Rounding to nearest.

◆ __FPU_ROUNDING_TRUNCATE

#define __FPU_ROUNDING_TRUNCATE   3

Rounding towards zero.

◆ __FPU_TAG_EMPTY

#define __FPU_TAG_EMPTY   3

Empty value in tag word.

Set when given FPU register is empty.

◆ __FPU_TAG_SPECIAL

#define __FPU_TAG_SPECIAL   2

Sepcial value in tag word.

Set when value at given FPU register is invalid (NaN, unsupported), infinity or denormal.

◆ __FPU_TAG_WORD_VALID

#define __FPU_TAG_WORD_VALID   0

Number value in tag word.

Set when value at given FPU register is valid number.

◆ __FPU_TAG_ZERO

#define __FPU_TAG_ZERO   1

Zero value in tag word.

Set when value at given FPU register is zero.

◆ FE_ALL_EXCEPT

#define FE_ALL_EXCEPT   (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)

All exceptions.

◆ FE_DENORMAL

#define FE_DENORMAL   2

Denormal operand exception.

◆ FE_DFL_ENV

#define FE_DFL_ENV   (env)

macro that provides access to pointer to environment.

Points to default environment. It's set during program startup.

◆ FE_DIVBYZERO

#define FE_DIVBYZERO   4

Pole error exception.

◆ FE_DOWNWARD

#define FE_DOWNWARD   1

Rounding downward.

◆ FE_INEXACT

#define FE_INEXACT   32

Pole error exception.

◆ FE_INVALID

#define FE_INVALID   1

Invalid argument exception.

◆ FE_OVERFLOW

#define FE_OVERFLOW   8

Overflow exception.

◆ FE_TONEAREST

#define FE_TONEAREST   0

Rounding to nearest.

◆ FE_TOWARDZERO

#define FE_TOWARDZERO   3

Rounding towards zero.

◆ FE_UNDERFLOW

#define FE_UNDERFLOW   16

Underflow exception.

◆ FE_UPWARD

#define FE_UPWARD   2

Rounding upward.

Function Documentation

◆ __FPU_clear_exceptions()

void __FPU_clear_exceptions ( )

Clear all FPU exceptions.

◆ __FPU_read_control_word()

fcontrol_t __FPU_read_control_word ( )

Read FPU control word.

Returns
Current FPU control word.

◆ __FPU_read_environment()

fenv_t __FPU_read_environment ( )

Read FPU environment.

Returns
Current FPU environment.

◆ __FPU_read_status_word()

fexcept_t __FPU_read_status_word ( )

Read FPU status word.

Returns
Current FPU status word.

◆ __FPU_write_control_word()

void __FPU_write_control_word ( fcontrol_t  control_word)

Write FPU control word.

It also clears FPU exception before write value.

Parameters
control_wordControl word to write into FPU.

◆ __FPU_write_environment()

void __FPU_write_environment ( fenv_t  environment)

Write FPU environment.

Parameters
environmentenvironment to write into FPU.

◆ feclearexcept()

int feclearexcept ( int  excepts)

Clear FPU exception flags.

Function attempts to clear the supported floating-point exceptions represented by its argument.

Parameters
exceptsException flags to clear.
Returns
Function returns zero if the excepts argument is zero or if all the specified exceptions were successfully cleared. Otherwise, it returns a nonzero value.

◆ fegetenv()

int fegetenv ( fenv_t envp)

Get entire environment.

Function attempts to store the current floating-point environment in the object pointed to by envp/

Parameters
envpPointer to struct where environment will be stored.
Returns
Function returns zero if the environment was successfully stored. Otherwise, it returns a nonzero value.

◆ fegetexceptflag()

int fegetexceptflag ( fexcept_t flagp,
int  excepts 
)

Get exception flags.

Function attempts to store an implementation-defined representation of the states of the floating-point status flags indicated by the argument excepts in the object pointed to by the argument flagp.

Parameters
flagpPointer to structure where expection flags will be stored.
exceptsDefines which excepts will be checked.
Returns
Function returns zero if the representation was successfully stored. Otherwise, it returns a nonzero value.

◆ fegetround()

int fegetround ( void  )

Get current rounding direction.

Returns
Function returns the value of the rounding direction macro representing the current rounding direction or a negative value if there is no such rounding direction macro or the current rounding direction is not determinable.

◆ feholdexcept()

int feholdexcept ( fenv_t envp)

Hold floating-point exceptions.

Function saves the current floating-point environment in the object pointed to by envp, clears the floating-point status flags, and then installs a non-stop (continue on floating-point exceptions) mode, if available, for all floating-point exceptions.

Parameters
envpPointer to struct where environment will be saved.
Returns
Function returns zero if and only if non-stop floating-point exception handling was successfully installed.

◆ feraiseexcept()

int feraiseexcept ( int  excepts)

Raise FPU exception flags.

Function attempts to raise the supported floating-point exceptions represented by its argument.

Parameters
exceptsException flags to raise.
Returns
Function returns zero if the excepts argument is zero or if all the specified exceptions were successfully raised. Otherwise, it returns a nonzero value.

◆ fesetenv()

int fesetenv ( const fenv_t envp)

Set entire environment.

The fesetenv function attempts to establish the floating-point environment represented by the object pointed to by envp. The argument envp shall point to an object set by a call to fegetenv or feholdexcept, or equal a floating-point environment macro. Note that fesetenv merely installs the state of the floating-point status flags represented through its argument, and does not raise these floating-point exceptions.

Parameters
envpPointer to struct from where environment will read environment.
Returns
Function returns zero if the environment was successfully wrote. Otherwise, it returns a nonzero value.

◆ fesetexceptflag()

int fesetexceptflag ( const fexcept_t flagp,
int  excepts 
)

Set exception flags.

Function attempts to set the floating-point status flags indicated by the argument excepts to the states stored in the object pointed to by flagp. The value of *flagp shall have been set by a previous call to fegetexceptflag whose second argument represented at least those floating-point exceptions represented by the argument excepts. This function does not raise floatingpoint exceptions, but only sets the state of the flags.

Parameters
flagpPointer to structure from where we will read expection.
exceptsDefines which excepts will be set.
Returns
Function returns zero if the excepts argument is zero or if all the specified flags were successfully set to the appropriate state. Otherwise, it returns a nonzero value.

◆ fesetround()

int fesetround ( int  round)

Set rounding direction.

Function establishes the rounding direction represented by its argument round. If the argument is not equal to the value of a rounding direction macro, the rounding direction is not changed.

Parameters
roundRounding direction to set.
Returns
Function returns zero if and only if the requested rounding direction was established.

◆ fetestexcept()

int fetestexcept ( int  excepts)

Test for floating-point exceptions.

Function determines which of a specified subset of the floatingpoint exception flags are currently set. The excepts argument specifies the floatingpoint status flags to be queried.

Parameters
exceptsException flags to check.
Returns
Function returns the value of the bitwise OR of the floating-point exception macros corresponding to the currently set floating-point exceptions included in excepts.

◆ feupdateenv()

int feupdateenv ( const fenv_t envp)

Update floating-point environment.

function attempts to save the currently raised floating-point exceptions in its automatic storage, install the floating-point environment represented by the object pointed to by envp, and then raise the saved floating-point exceptions. The argument envp shall point to an object set by a call to feholdexcept or fegetenv, or equal a floating-point environment macro.

Parameters
envpPointer to struct from where environment will read environment.
Returns
Function returns zero if all the actions were successfully carried out. Otherwise, it returns a nonzero value.

Variable Documentation

◆ env

const fenv_t* env

Pointer to environment.

Points to default environment. It's set during program startup.