FPEnvironment_QNX.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //
  2. // FPEnvironment_QNX.h
  3. //
  4. // Library: Foundation
  5. // Package: Core
  6. // Module: FPEnvironment
  7. //
  8. // Definitions of class FPEnvironmentImpl for QNX.
  9. //
  10. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #ifndef Foundation_FPEnvironment_QNX_INCLUDED
  16. #define Foundation_FPEnvironment_QNX_INCLUDED
  17. #include "Poco/Foundation.h"
  18. #include <fenv.h>
  19. #include <cmath>
  20. namespace Poco {
  21. class FPEnvironmentImpl
  22. {
  23. protected:
  24. enum RoundingModeImpl
  25. {
  26. FP_ROUND_DOWNWARD_IMPL = FE_DOWNWARD,
  27. FP_ROUND_UPWARD_IMPL = FE_UPWARD,
  28. FP_ROUND_TONEAREST_IMPL = FE_TONEAREST,
  29. FP_ROUND_TOWARDZERO_IMPL = FE_TOWARDZERO
  30. };
  31. enum FlagImpl
  32. {
  33. FP_DIVIDE_BY_ZERO_IMPL = FE_DIVBYZERO,
  34. FP_INEXACT_IMPL = FE_INEXACT,
  35. FP_OVERFLOW_IMPL = FE_OVERFLOW,
  36. FP_UNDERFLOW_IMPL = FE_UNDERFLOW,
  37. FP_INVALID_IMPL = FE_INVALID
  38. };
  39. FPEnvironmentImpl();
  40. FPEnvironmentImpl(const FPEnvironmentImpl& env);
  41. ~FPEnvironmentImpl();
  42. FPEnvironmentImpl& operator = (const FPEnvironmentImpl& env);
  43. void keepCurrentImpl();
  44. static void clearFlagsImpl();
  45. static bool isFlagImpl(FlagImpl flag);
  46. static void setRoundingModeImpl(RoundingModeImpl mode);
  47. static RoundingModeImpl getRoundingModeImpl();
  48. static bool isInfiniteImpl(float value);
  49. static bool isInfiniteImpl(double value);
  50. static bool isInfiniteImpl(long double value);
  51. static bool isNaNImpl(float value);
  52. static bool isNaNImpl(double value);
  53. static bool isNaNImpl(long double value);
  54. static float copySignImpl(float target, float source);
  55. static double copySignImpl(double target, double source);
  56. static long double copySignImpl(long double target, long double source);
  57. private:
  58. fenv_t _env;
  59. };
  60. //
  61. // inlines
  62. //
  63. inline bool FPEnvironmentImpl::isInfiniteImpl(float value)
  64. {
  65. using namespace std;
  66. return isinf(value) != 0;
  67. }
  68. inline bool FPEnvironmentImpl::isInfiniteImpl(double value)
  69. {
  70. using namespace std;
  71. return isinf(value) != 0;
  72. }
  73. inline bool FPEnvironmentImpl::isInfiniteImpl(long double value)
  74. {
  75. using namespace std;
  76. return isinf((double) value) != 0;
  77. }
  78. inline bool FPEnvironmentImpl::isNaNImpl(float value)
  79. {
  80. using namespace std;
  81. return isnan(value) != 0;
  82. }
  83. inline bool FPEnvironmentImpl::isNaNImpl(double value)
  84. {
  85. using namespace std;
  86. return isnan(value) != 0;
  87. }
  88. inline bool FPEnvironmentImpl::isNaNImpl(long double value)
  89. {
  90. using namespace std;
  91. return isnan((double) value) != 0;
  92. }
  93. inline float FPEnvironmentImpl::copySignImpl(float target, float source)
  94. {
  95. using namespace std;
  96. return copysignf(target, source);
  97. }
  98. inline double FPEnvironmentImpl::copySignImpl(double target, double source)
  99. {
  100. using namespace std;
  101. return copysign(target, source);
  102. }
  103. } // namespace Poco
  104. #endif // Foundation_FPEnvironment_QNX_INCLUDED