summaryrefslogtreecommitdiff
path: root/src/fenv
diff options
context:
space:
mode:
Diffstat (limited to 'src/fenv')
-rw-r--r--src/fenv/FE_ALL_EXCEPT.c12
-rw-r--r--src/fenv/FE_DFL_ENV.c18
-rw-r--r--src/fenv/FE_DIVBYZERO.c14
-rw-r--r--src/fenv/FE_DOWNWARD.c14
-rw-r--r--src/fenv/FE_INEXACT.c14
-rw-r--r--src/fenv/FE_INVALID.c14
-rw-r--r--src/fenv/FE_OVERFLOW.c14
-rw-r--r--src/fenv/FE_TONEAREST.c14
-rw-r--r--src/fenv/FE_TOWARDZERO.c14
-rw-r--r--src/fenv/FE_UNDERFLOW.c14
-rw-r--r--src/fenv/FE_UPWARD.c14
-rw-r--r--src/fenv/feclearexcept.c16
-rw-r--r--src/fenv/fegetenv.c16
-rw-r--r--src/fenv/fegetexceptflag.c17
-rw-r--r--src/fenv/fegetround.c21
-rw-r--r--src/fenv/feholdexcept.c23
-rw-r--r--src/fenv/fenv_t.c10
-rw-r--r--src/fenv/feraiseexcept.c19
-rw-r--r--src/fenv/fesetenv.c19
-rw-r--r--src/fenv/fesetexceptflag.c20
-rw-r--r--src/fenv/fesetround.c23
-rw-r--r--src/fenv/fetestexcept.c33
-rw-r--r--src/fenv/feupdateenv.c19
-rw-r--r--src/fenv/fexcept_t.c11
24 files changed, 403 insertions, 0 deletions
diff --git a/src/fenv/FE_ALL_EXCEPT.c b/src/fenv/FE_ALL_EXCEPT.c
new file mode 100644
index 00000000..bf470e4c
--- /dev/null
+++ b/src/fenv/FE_ALL_EXCEPT.c
@@ -0,0 +1,12 @@
+#include <fenv.h>
+
+#define FE_ALL_EXCEPT (FE_DIVBYZERO|FE_INEXACT|FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW)
+
+/* The bitwise OR of all supported macros */
+
+/* see appendix F regarding __STDC_IEC_559__ == 1 */
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/FE_DFL_ENV.c b/src/fenv/FE_DFL_ENV.c
new file mode 100644
index 00000000..0cde32e9
--- /dev/null
+++ b/src/fenv/FE_DFL_ENV.c
@@ -0,0 +1,18 @@
+#include <fenv.h>
+ extern fenv_t const *FE_DFL_ENV;
+#define FE_DFL_ENV ((const fenv_t*)FE_DFL_ENV)
+
+/* */
+/* represents the default floating-point environment — the one installed at program startup */
+/* — and has type ‘‘pointer to const-qualified fenv_t’’. It can be used as an argument to */
+/* <fenv.h> functions that manage the floating-point environment. */
+/* */
+/* Additional implementation-defined environments, with macro definitions beginning with */
+/* FE_ and an uppercase letter, and having type ‘‘pointer to const-qualified fenv_t’’, may */
+/* also be specified by the implementation. */
+/* */
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/FE_DIVBYZERO.c b/src/fenv/FE_DIVBYZERO.c
new file mode 100644
index 00000000..80542670
--- /dev/null
+++ b/src/fenv/FE_DIVBYZERO.c
@@ -0,0 +1,14 @@
+#include <fenv.h>
+
+#if 0
+#define FE_DIVBYZERO (1<<0)
+#else
+#undef FE_DIVBYZERO
+#endif
+
+/* Defined iff this exception is supported */
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/FE_DOWNWARD.c b/src/fenv/FE_DOWNWARD.c
new file mode 100644
index 00000000..702a50e9
--- /dev/null
+++ b/src/fenv/FE_DOWNWARD.c
@@ -0,0 +1,14 @@
+#include <fenv.h>
+
+#if 0
+#define FE_DOWNWARD (3)
+#else
+#undef FE_DOWNWARD
+#endif
+
+/* Defined iff this operation is supported */
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/FE_INEXACT.c b/src/fenv/FE_INEXACT.c
new file mode 100644
index 00000000..59428fd4
--- /dev/null
+++ b/src/fenv/FE_INEXACT.c
@@ -0,0 +1,14 @@
+#include <fenv.h>
+
+#if 0
+#define FE_INEXACT (1<<1)
+#else
+#undef FE_INEXACT
+#endif
+
+/* Defined iff this exception is supported */
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/FE_INVALID.c b/src/fenv/FE_INVALID.c
new file mode 100644
index 00000000..975ef8c6
--- /dev/null
+++ b/src/fenv/FE_INVALID.c
@@ -0,0 +1,14 @@
+#include <fenv.h>
+
+#if 0
+#define FE_INVALID (1<<2)
+#else
+#undef FE_INVALID
+#endif
+
+/* Defined iff this exception is supported */
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/FE_OVERFLOW.c b/src/fenv/FE_OVERFLOW.c
new file mode 100644
index 00000000..f2edcf93
--- /dev/null
+++ b/src/fenv/FE_OVERFLOW.c
@@ -0,0 +1,14 @@
+#include <fenv.h>
+
+#if 0
+#define FE_OVERFLOW (1<<3)
+#else
+#undef FE_OVERFLOW
+#endif
+
+/* Defined iff this exception is supported */
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/FE_TONEAREST.c b/src/fenv/FE_TONEAREST.c
new file mode 100644
index 00000000..df11a2bb
--- /dev/null
+++ b/src/fenv/FE_TONEAREST.c
@@ -0,0 +1,14 @@
+#include <fenv.h>
+
+#if 0
+#define FE_TONEAREST (1)
+#else
+#undef FE_TONEAREST
+#endif
+
+/* Defined iff this operation is supported */
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/FE_TOWARDZERO.c b/src/fenv/FE_TOWARDZERO.c
new file mode 100644
index 00000000..5f3454a7
--- /dev/null
+++ b/src/fenv/FE_TOWARDZERO.c
@@ -0,0 +1,14 @@
+#include <fenv.h>
+
+#if 0
+#define FE_TOWARDZERO (0)
+#else
+#undef FE_TOWARDZERO
+#endif
+
+/* Defined iff this operation is supported */
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/FE_UNDERFLOW.c b/src/fenv/FE_UNDERFLOW.c
new file mode 100644
index 00000000..96fe5b75
--- /dev/null
+++ b/src/fenv/FE_UNDERFLOW.c
@@ -0,0 +1,14 @@
+#include <fenv.h>
+
+#if 0
+#define FE_UNDERFLOW (1<<4)
+#else
+#undef FE_UNDERFLOW
+#endif
+
+/* Defined iff this exception is supported */
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/FE_UPWARD.c b/src/fenv/FE_UPWARD.c
new file mode 100644
index 00000000..dbba8275
--- /dev/null
+++ b/src/fenv/FE_UPWARD.c
@@ -0,0 +1,14 @@
+#include <fenv.h>
+
+#if 0
+#define FE_UPWARD (2)
+#else
+#undef FE_UPWARD
+#endif
+
+/* Defined iff this operation is supported */
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/feclearexcept.c b/src/fenv/feclearexcept.c
new file mode 100644
index 00000000..646b4669
--- /dev/null
+++ b/src/fenv/feclearexcept.c
@@ -0,0 +1,16 @@
+#include <fenv.h>
+
+int feclearexcept(int excepts)
+{
+ return excepts;
+}
+
+/*d
+The feclearexcept function clears the supported floating-point exceptions
+represented by its argument.
+d*/
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/fegetenv.c b/src/fenv/fegetenv.c
new file mode 100644
index 00000000..b4795af7
--- /dev/null
+++ b/src/fenv/fegetenv.c
@@ -0,0 +1,16 @@
+#include <fenv.h>
+
+int fegetenv(fenv_t *envp)
+{
+ return 0;
+}
+
+/*d
+The fegetenv function stores the current floating-point environment in the object
+pointed to by envp.
+d*/
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/fegetexceptflag.c b/src/fenv/fegetexceptflag.c
new file mode 100644
index 00000000..45e4bf98
--- /dev/null
+++ b/src/fenv/fegetexceptflag.c
@@ -0,0 +1,17 @@
+#include <fenv.h>
+
+int fegetexceptflag(fexcept_t *flagp, int excepts)
+{
+ return excepts;
+}
+
+/*d
+The fegetexceptflag function stores 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.
+d*/
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/fegetround.c b/src/fenv/fegetround.c
new file mode 100644
index 00000000..13e5bf34
--- /dev/null
+++ b/src/fenv/fegetround.c
@@ -0,0 +1,21 @@
+#include <fenv.h>
+
+int fegetround(void)
+{
+ return 0;
+}
+
+/*d
+The fegetround function gets the current rounding direction.
+d*/
+
+/*r
+The fegetround 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.
+r*/
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/feholdexcept.c b/src/fenv/feholdexcept.c
new file mode 100644
index 00000000..11b46ede
--- /dev/null
+++ b/src/fenv/feholdexcept.c
@@ -0,0 +1,23 @@
+#include <fenv.h>
+
+int feholdexcept(fenv_t *envp)
+{
+ return 0;
+}
+
+/*d
+The feholdexcept 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. 180)
+d*/
+
+/*r
+The feholdexcept function returns zero if and only if non-stop floating-point
+exception handling was successfully installed.
+r*/
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/fenv_t.c b/src/fenv/fenv_t.c
new file mode 100644
index 00000000..2d644c75
--- /dev/null
+++ b/src/fenv/fenv_t.c
@@ -0,0 +1,10 @@
+#include <fenv.h>
+
+typedef unsigned long long int fenv_t;
+
+/*d Represents the entire floating-point environment d*/
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/feraiseexcept.c b/src/fenv/feraiseexcept.c
new file mode 100644
index 00000000..9f555dde
--- /dev/null
+++ b/src/fenv/feraiseexcept.c
@@ -0,0 +1,19 @@
+#include <fenv.h>
+
+int feraiseexcept(int excepts)
+{
+ return excepts;
+}
+
+/*d
+The feraiseexcept function raises the supported floating-point exceptions
+represented by its argument. 178) The order in which these floating-point exceptions are
+raised is unspecified, except as stated in F.7.6. Whether the feraiseexcept function
+additionally raises the ‘‘inexact’’ floating-point exception whenever it raises the
+‘‘overflow’’ or ‘‘underflow’’ floating-point exception is implementation-defined.
+d*/
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/fesetenv.c b/src/fenv/fesetenv.c
new file mode 100644
index 00000000..1d6ea32a
--- /dev/null
+++ b/src/fenv/fesetenv.c
@@ -0,0 +1,19 @@
+#include <fenv.h>
+
+int fesetenv(const fenv_t *envp)
+{
+ return 0;
+}
+
+/*d
+The fesetenv function establishes 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.
+d*/
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/fesetexceptflag.c b/src/fenv/fesetexceptflag.c
new file mode 100644
index 00000000..07fc7f5f
--- /dev/null
+++ b/src/fenv/fesetexceptflag.c
@@ -0,0 +1,20 @@
+#include <fenv.h>
+
+int fesetexceptflag(const fexcept_t *flagp, int excepts)
+{
+ return 0;
+}
+
+/*d
+The fesetexceptflag function sets 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 floating-point exceptions, but only sets the state
+of the flags.
+d*/
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/fesetround.c b/src/fenv/fesetround.c
new file mode 100644
index 00000000..d0f50c76
--- /dev/null
+++ b/src/fenv/fesetround.c
@@ -0,0 +1,23 @@
+#include <fenv.h>
+
+int fesetround(int round)
+{
+ return round;
+}
+
+/*d */
+/* The fesetround 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. */
+/* d*/
+
+/*r */
+/* The fesetround function returns a zero value if and only if the argument is equal to a */
+/* rounding direction macro (that is, if and only if the requested rounding direction was */
+/* established). */
+/* r*/
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/fetestexcept.c b/src/fenv/fetestexcept.c
new file mode 100644
index 00000000..185fc530
--- /dev/null
+++ b/src/fenv/fetestexcept.c
@@ -0,0 +1,33 @@
+#include <fenv.h>
+
+int fetestexcept(int excepts)
+{
+ return excepts;
+}
+
+/*d
+The fetestexcept function determines which of a specified subset of the floating-
+point exception flags are currently set. The excepts argument specifies the floating-
+point status flags to be queried. 179)
+d*/
+
+/*r
+The fetestexcept 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.
+r*/
+
+/* example
+ #pragma STDC FENV_ACCESS ON
+ int set_excepts;
+ feclearexcept(FE_INVALID | FE_OVERFLOW);
+ // maybe raise exceptions
+ set_excepts = fetestexcept(FE_INVALID | FE_OVERFLOW);
+ if (set_excepts & FE_INVALID) f();
+ if (set_excepts & FE_OVERFLOW) g();
+*/
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/feupdateenv.c b/src/fenv/feupdateenv.c
new file mode 100644
index 00000000..b11a20fc
--- /dev/null
+++ b/src/fenv/feupdateenv.c
@@ -0,0 +1,19 @@
+#include <fenv.h>
+
+int feupdateenv(const fenv_t *envp)
+{
+ return 0;
+}
+
+/*d */
+/* The feupdateenv function saves the currently raised floating-point exceptions in its */
+/* automatic storage, installs the floating-point environment represented by the object */
+/* pointed to by envp, and then raises 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. */
+/* d*/
+
+/*
+STDC(199901)
+LINK(m)
+*/
diff --git a/src/fenv/fexcept_t.c b/src/fenv/fexcept_t.c
new file mode 100644
index 00000000..9bc9303b
--- /dev/null
+++ b/src/fenv/fexcept_t.c
@@ -0,0 +1,11 @@
+#include <fenv.h>
+
+typedef unsigned long long int fexcept_t;
+
+/*d Represents the floating-point status flags collectively, including any status the */
+/* implementation associates with the flags. d*/
+
+/*
+STDC(199901)
+LINK(m)
+*/