123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #include "cdefs-compat.h"
- #include <limits.h>
- #include <openlibm_fenv.h>
- #include <openlibm_math.h>
- #include "math_private.h"
- #ifndef type
- #define type double
- #define roundit round
- #define dtype long
- #define DTYPE_MIN LONG_MIN
- #define DTYPE_MAX LONG_MAX
- #define fn lround
- #endif
- static const type dtype_min = DTYPE_MIN - 0.5;
- static const type dtype_max = DTYPE_MAX + 0.5;
- #define INRANGE(x) (dtype_max - DTYPE_MAX != 0.5 || \
- ((x) > dtype_min && (x) < dtype_max))
- OLM_DLLEXPORT dtype
- fn(type x)
- {
- if (INRANGE(x)) {
- x = roundit(x);
- return ((dtype)x);
- } else {
- feraiseexcept(FE_INVALID);
- return (DTYPE_MAX);
- }
- }
|