logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

fenv.h.0p (9712B)


  1. '\" et
  2. .TH fenv.h "0P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. fenv.h
  12. \(em floating-point environment
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <fenv.h>
  17. .fi
  18. .SH DESCRIPTION
  19. The functionality described on this reference page is aligned with the
  20. ISO\ C standard. Any conflict between the requirements described here and the
  21. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  22. .P
  23. The
  24. .IR <fenv.h>
  25. header shall define the following data types through
  26. .BR typedef :
  27. .IP "\fBfenv_t\fR" 10
  28. Represents the entire floating-point environment. The floating-point
  29. environment refers collectively to any floating-point status flags and
  30. control modes supported by the implementation.
  31. .IP "\fBfexcept_t\fR" 10
  32. Represents the floating-point status flags collectively, including any
  33. status the implementation associates with the flags. A floating-point
  34. status flag is a system variable whose value is set (but never cleared)
  35. when a floating-point exception is raised, which occurs as a side-effect
  36. of exceptional floating-point arithmetic to provide auxiliary
  37. information. A floating-point control mode is a system variable whose
  38. value may be set by the user to affect the subsequent behavior of
  39. floating-point arithmetic.
  40. .P
  41. The
  42. .IR <fenv.h>
  43. header shall define each of the following macros if and only if the
  44. implementation supports the floating-point exception by means of the
  45. floating-point functions
  46. \fIfeclearexcept\fR(),
  47. \fIfegetexceptflag\fR(),
  48. \fIferaiseexcept\fR(),
  49. \fIfesetexceptflag\fR(),
  50. and
  51. \fIfetestexcept\fR().
  52. The defined macros shall expand to integer constant expressions with
  53. values that are bitwise-distinct.
  54. .sp
  55. .RS
  56. FE_DIVBYZERO
  57. FE_INEXACT
  58. FE_INVALID
  59. FE_OVERFLOW
  60. FE_UNDERFLOW
  61. .RE
  62. .P
  63. If the implementation supports the IEC 60559 Floating-Point option, all
  64. five macros shall be defined.
  65. Additional implementation-defined floating-point exceptions with
  66. macros beginning with FE_ and an uppercase letter may also be
  67. specified by the implementation.
  68. .P
  69. The
  70. .IR <fenv.h>
  71. header shall define the macro FE_ALL_EXCEPT as the bitwise-inclusive
  72. OR of all floating-point exception macros defined by the
  73. implementation, if any. If no such macros are defined, then the
  74. macro FE_ALL_EXCEPT shall be defined as zero.
  75. .P
  76. The
  77. .IR <fenv.h>
  78. header shall define each of the following macros if and only if the
  79. implementation supports getting and setting the represented rounding
  80. direction by means of the
  81. \fIfegetround\fR()
  82. and
  83. \fIfesetround\fR()
  84. functions. The defined macros shall expand to integer constant
  85. expressions whose values are distinct non-negative values.
  86. .sp
  87. .RS
  88. FE_DOWNWARD
  89. FE_TONEAREST
  90. FE_TOWARDZERO
  91. FE_UPWARD
  92. .RE
  93. .P
  94. If the implementation supports the IEC 60559 Floating-Point option, all
  95. four macros shall be defined.
  96. Additional implementation-defined rounding directions with macros
  97. beginning with FE_ and an uppercase letter may also be specified by the
  98. implementation.
  99. .P
  100. The
  101. .IR <fenv.h>
  102. header shall define the following macro, which represents the
  103. default floating-point environment (that is, the one installed at
  104. program startup) and has type pointer to const-qualified
  105. .BR fenv_t .
  106. It can be used as an argument to the functions within the
  107. .IR <fenv.h>
  108. header that manage the floating-point environment.
  109. .sp
  110. .RS
  111. FE_DFL_ENV
  112. .RE
  113. .P
  114. The following shall be declared as functions and may also be defined as
  115. macros. Function prototypes shall be provided.
  116. .sp
  117. .RS 4
  118. .nf
  119. int feclearexcept(int);
  120. int fegetenv(fenv_t *);
  121. int fegetexceptflag(fexcept_t *, int);
  122. int fegetround(void);
  123. int feholdexcept(fenv_t *);
  124. int feraiseexcept(int);
  125. int fesetenv(const fenv_t *);
  126. int fesetexceptflag(const fexcept_t *, int);
  127. int fesetround(int);
  128. int fetestexcept(int);
  129. int feupdateenv(const fenv_t *);
  130. .fi
  131. .P
  132. .RE
  133. .P
  134. The FENV_ACCESS pragma provides a means to inform the implementation
  135. when an application might access the floating-point environment to test
  136. floating-point status flags or run under non-default floating-point
  137. control modes. The pragma shall occur either outside external
  138. declarations or preceding all explicit declarations and statements
  139. inside a compound statement. When outside external declarations, the
  140. pragma takes effect from its occurrence until another FENV_ACCESS
  141. pragma is encountered, or until the end of the translation unit. When
  142. inside a compound statement, the pragma takes effect from its
  143. occurrence until another FENV_ACCESS pragma is encountered (including
  144. within a nested compound statement), or until the end of the compound
  145. statement; at the end of a compound statement the state for the pragma
  146. is restored to its condition just before the compound statement. If
  147. this pragma is used in any other context, the behavior is undefined. If
  148. part of an application tests floating-point status flags, sets
  149. floating-point control modes, or runs under non-default mode settings,
  150. but was translated with the state for the FENV_ACCESS pragma off, the
  151. behavior is undefined. The default state (on or off) for the pragma is
  152. implementation-defined. (When execution passes from a part of the
  153. application translated with FENV_ACCESS off to a part translated with
  154. FENV_ACCESS on, the state of the floating-point status flags is
  155. unspecified and the floating-point control modes have their default
  156. settings.)
  157. .LP
  158. .IR "The following sections are informative."
  159. .SH "APPLICATION USAGE"
  160. This header is designed to support the floating-point exception status
  161. flags and directed-rounding control modes required by the IEC\ 60559:\|1989 standard, and
  162. other similar floating-point state information. Also it is designed to
  163. facilitate code portability among all systems.
  164. .P
  165. Certain application programming conventions support the intended model
  166. of use for the floating-point environment:
  167. .IP " *" 4
  168. A function call does not alter its caller's floating-point control
  169. modes, clear its caller's floating-point status flags, nor depend on
  170. the state of its caller's floating-point status flags unless the
  171. function is so documented.
  172. .IP " *" 4
  173. A function call is assumed to require default floating-point control
  174. modes, unless its documentation promises otherwise.
  175. .IP " *" 4
  176. A function call is assumed to have the potential for raising
  177. floating-point exceptions, unless its documentation promises otherwise.
  178. .P
  179. With these conventions, an application can safely assume default
  180. floating-point control modes (or be unaware of them). The
  181. responsibilities associated with accessing the floating-point
  182. environment fall on the application that does so explicitly.
  183. .P
  184. Even though the rounding direction macros may expand to constants
  185. corresponding to the values of FLT_ROUNDS, they are not required to do
  186. so.
  187. .P
  188. For example:
  189. .sp
  190. .RS 4
  191. .nf
  192. #include <fenv.h>
  193. void f(double x)
  194. {
  195. #pragma STDC FENV_ACCESS ON
  196. void g(double);
  197. void h(double);
  198. /* ... */
  199. g(x + 1);
  200. h(x + 1);
  201. /* ... */
  202. }
  203. .fi
  204. .P
  205. .RE
  206. .P
  207. If the function
  208. \fIg\fR()
  209. might depend on status flags set as a side-effect of the first
  210. .IR x +1,
  211. or if the second
  212. .IR x +1
  213. might depend on control modes set as a side-effect of the call to
  214. function
  215. \fIg\fR(),
  216. then the application shall contain an appropriately placed invocation
  217. as follows:
  218. .sp
  219. .RS 4
  220. .nf
  221. #pragma STDC FENV_ACCESS ON
  222. .fi
  223. .P
  224. .RE
  225. .SH RATIONALE
  226. .SS "The fexcept_t Type"
  227. .P
  228. .BR fexcept_t
  229. does not have to be an integer type. Its values must be obtained by a
  230. call to
  231. \fIfegetexceptflag\fR(),
  232. and cannot be created by logical operations from the exception macros.
  233. An implementation might simply implement
  234. .BR fexcept_t
  235. as an
  236. .BR int
  237. and use the representations reflected by the exception macros, but is
  238. not required to; other representations might contain extra information
  239. about the exceptions.
  240. .BR fexcept_t
  241. might be a
  242. .BR struct
  243. with a member for each exception (that might hold the address of the
  244. first or last floating-point instruction that caused that exception).
  245. The ISO/IEC\ 9899:\|1999 standard makes no claims about the internals of an
  246. .BR fexcept_t ,
  247. and so the user cannot inspect it.
  248. .SS "Exception and Rounding Macros"
  249. .P
  250. Macros corresponding to unsupported modes and rounding directions are
  251. not defined by the implementation and must not be defined by the
  252. application. An application might use
  253. .BR #ifdef
  254. to test for this.
  255. .SH "FUTURE DIRECTIONS"
  256. None.
  257. .SH "SEE ALSO"
  258. The System Interfaces volume of POSIX.1\(hy2017,
  259. .IR "\fIfeclearexcept\fR\^(\|)",
  260. .IR "\fIfegetenv\fR\^(\|)",
  261. .IR "\fIfegetexceptflag\fR\^(\|)",
  262. .IR "\fIfegetround\fR\^(\|)",
  263. .IR "\fIfeholdexcept\fR\^(\|)",
  264. .IR "\fIferaiseexcept\fR\^(\|)",
  265. .IR "\fIfetestexcept\fR\^(\|)",
  266. .IR "\fIfeupdateenv\fR\^(\|)"
  267. .\"
  268. .SH COPYRIGHT
  269. Portions of this text are reprinted and reproduced in electronic form
  270. from IEEE Std 1003.1-2017, Standard for Information Technology
  271. -- Portable Operating System Interface (POSIX), The Open Group Base
  272. Specifications Issue 7, 2018 Edition,
  273. Copyright (C) 2018 by the Institute of
  274. Electrical and Electronics Engineers, Inc and The Open Group.
  275. In the event of any discrepancy between this version and the original IEEE and
  276. The Open Group Standard, the original IEEE and The Open Group Standard
  277. is the referee document. The original Standard can be obtained online at
  278. http://www.opengroup.org/unix/online.html .
  279. .PP
  280. Any typographical or formatting errors that appear
  281. in this page are most likely
  282. to have been introduced during the conversion of the source files to
  283. man page format. To report such errors, see
  284. https://www.kernel.org/doc/man-pages/reporting_bugs.html .