--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-O0 -mfpmath=sse -msse2" } */
+/* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target fenv } */
+/* { dg-require-effective-target dfp } */
+
+#include <fenv.h>
+
+int main() {
+ fesetround( FE_UPWARD );
+ _Decimal128 x1 = 9825, x2 = 10000 ;
+
+ double c = (double) (x1 / x2);
+
+ if (c != 0.9825)
+ __builtin_abort ();
+
+ return 0 ;
+}
ifeq ($(decimal_float),yes)
ifeq ($(enable_decimal_float),bid)
-DECNUMINC = -I$(srcdir)/config/libbid -DENABLE_DECIMAL_BID_FORMAT
+DECNUMINC = -I$(srcdir)/config/$(cpu_type) -I$(srcdir)/config/libbid \
+ -DENABLE_DECIMAL_BID_FORMAT
else
DECNUMINC = -I$(srcdir)/../libdecnumber/$(enable_decimal_float) \
-I$(srcdir)/../libdecnumber
--- /dev/null
+#ifndef _SOFT_FLOAT
+/* Get the rounding mode. */
+#define DFP_GET_ROUNDMODE \
+ unsigned int _frnd_orig; \
+ do \
+ { \
+ __asm__ __volatile__ ("fnstcw\t%0" : "=m" (_frnd_orig)); \
+ _frnd_orig &= FP_RND_MASK; \
+ } \
+ while (0);
+
+/* Set the rounding mode. */
+#define DFP_SET_ROUNDMODE(round) \
+ do \
+ { \
+ unsigned int _cw; \
+ __asm__ __volatile__ ("fnstcw\t%0" : "=m" (_cw)); \
+ _cw &= ~FP_RND_MASK; \
+ _cw |= round; \
+ __asm__ __volatile__ ("fldcw\t%0" :: "m" (_cw)); \
+ if (__builtin_cpu_supports ("sse")) \
+ { \
+ __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_cw)); \
+ _cw &= ~0x6000; \
+ _cw |= round << 3; \
+ __asm__ __volatile__ ("%vldmxcsr\t%0" :: "m" (_cw)); \
+ } \
+ } \
+ while (0);
+#endif
--- /dev/null
+/* Get the rounding mode. */
+#define DFP_GET_ROUNDMODE \
+ unsigned int _frnd_orig; \
+ do \
+ { \
+ __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_frnd_orig)); \
+ _frnd_orig &= FP_RND_MASK; \
+ } \
+ while (0);
+
+/* Set the rounding mode. */
+#define DFP_SET_ROUNDMODE(round) \
+ do \
+ { \
+ unsigned int _cw; \
+ __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_cw)); \
+ _cw &= ~FP_RND_MASK; \
+ _cw |= round; \
+ __asm__ __volatile__ ("%vldmxcsr\t%0" :: "m" (_cw)); \
+ } \
+ while (0);
--- /dev/null
+/* Rounding mode macros for DFP libbid. x86 version.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+
+ This file is part of GCC.
+
+ GCC is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ GCC is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ Under Section 7 of GPL version 3, you are granted additional
+ permissions described in the GCC Runtime Library Exception, version
+ 3.1, as published by the Free Software Foundation.
+
+ You should have received a copy of the GNU General Public License and
+ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _X86_DFP_MACHINE_H
+#define _X86_DFP_MACHINE_H
+
+#ifdef _SOFT_FLOAT
+#include_next <dfp-machine.h>
+#else
+#include "config/i386/sfp-machine.h"
+
+#ifdef __x86_64__
+#include "config/i386/64/dfp-machine.h"
+#else
+#include "config/i386/32/dfp-machine.h"
+#endif
+
+/* Initialize the rounding mode to round-to-nearest if needed. */
+#define DFP_INIT_ROUNDMODE \
+ DFP_GET_ROUNDMODE; \
+ do \
+ { \
+ if (_frnd_orig != FP_RND_NEAREST) \
+ DFP_SET_ROUNDMODE (FP_RND_NEAREST); \
+ } \
+ while (0);
+
+/* Restore the rounding mode to round-to-nearest if changed. */
+#define DFP_RESTORE_ROUNDMODE \
+ do \
+ { \
+ if (_frnd_orig != FP_RND_NEAREST) \
+ DFP_SET_ROUNDMODE (_frnd_orig); \
+ } \
+ while (0);
+#endif
+
+#endif /* _X86_DFP_MACHINE_H */
fexcept_t binaryflags = 0;
#endif
+ // Set the rounding mode to round-to-nearest (if different).
+ DFP_INIT_ROUNDMODE;
+
valid_y = unpack_BID128_value (&sign_y, &exponent_y, &CY, y);
// unpack arguments, check for NaN or Infinity
#endif
res.w[1] = (CX.w[1]) & QUIET_MASK64;
res.w[0] = CX.w[0];
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// x is Infinity?
#endif
res.w[1] = 0x7c00000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is NaN?
res.w[1] = ((x.w[1] ^ y.w[1]) & 0x8000000000000000ull) |
0x7800000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
// x=y=0, return NaN
res.w[1] = 0x7c00000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// return 0
exponent_x = 0;
res.w[1] |= (((UINT64) exponent_x) << 49);
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
#endif
res.w[1] = CY.w[1] & QUIET_MASK64;
res.w[0] = CY.w[0];
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is Infinity?
// return +/-0
res.w[1] = sign_x ^ sign_y;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is 0, return +/-Inf
res.w[1] =
((x.w[1] ^ y.w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// get number of decimal digits in CQ
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#endif
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+// restore the rounding mode back if it has been changed
+DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
fexcept_t binaryflags = 0;
#endif
+ // Set the rounding mode to round-to-nearest (if different).
+ DFP_INIT_ROUNDMODE;
+
valid_y = unpack_BID64 (&sign_y, &exponent_y, &CY.w[0], y);
// unpack arguments, check for NaN or Infinity
res.w[0] = (CX.w[0] & 0x0003ffffffffffffull);
__mul_64x64_to_128 (res, res.w[0], power10_table_128[18].w[0]);
res.w[1] |= ((CX.w[0]) & 0xfc00000000000000ull);
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// x is Infinity?
#endif
res.w[1] = 0x7c00000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
if ((((y) & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
res.w[1] =
(((x) ^ (y)) & 0x8000000000000000ull) | 0x7800000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
// x=y=0, return NaN
res.w[1] = 0x7c00000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// return 0
exponent_x = 0;
res.w[1] |= (((UINT64) exponent_x) << 49);
res.w[0] = 0;
+// restore the rounding mode back if it has been changed
+DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
res.w[0] = (CY.w[0] & 0x0003ffffffffffffull);
__mul_64x64_to_128 (res, res.w[0], power10_table_128[18].w[0]);
res.w[1] |= ((CY.w[0]) & 0xfc00000000000000ull);
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is Infinity?
// return +/-0
res.w[1] = sign_x ^ sign_y;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is 0, return +/-Inf
#ifdef SET_STATUS_FLAGS
__set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// get number of decimal digits in CQ
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#endif
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+// restore the rounding mode back if it has been changed
+DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
fexcept_t binaryflags = 0;
#endif
+ // Set the rounding mode to round-to-nearest (if different)
+ DFP_INIT_ROUNDMODE;
+
valid_y = unpack_BID128_value (&sign_y, &exponent_y, &CY, y);
// unpack arguments, check for NaN or Infinity
res.w[0] = (CX.w[0] & 0x0003ffffffffffffull);
__mul_64x64_to_128 (res, res.w[0], power10_table_128[18].w[0]);
res.w[1] |= ((CX.w[0]) & 0xfc00000000000000ull);
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// x is Infinity?
#endif
res.w[1] = 0x7c00000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
if (((y.w[1] & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
res.w[1] =
((x ^ y.w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
// x=y=0, return NaN
res.w[1] = 0x7c00000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// return 0
exponent_x = 0;
res.w[1] |= (((UINT64) exponent_x) << 49);
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
#endif
res.w[1] = CY.w[1] & QUIET_MASK64;
res.w[0] = CY.w[0];
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is Infinity?
// return +/-0
res.w[1] = sign_x ^ sign_y;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is 0, return +/-Inf
#ifdef SET_STATUS_FLAGS
__set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// get number of decimal digits in CQ
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#endif
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+// restore the rounding mode back if it has been changed
+DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
fexcept_t binaryflags = 0;
#endif
+ // Set the rounding mode to round-to-nearest (if different)
+ DFP_INIT_ROUNDMODE;
valid_y = unpack_BID64 (&sign_y, &exponent_y, &CY.w[0], y);
// unpack arguments, check for NaN or Infinity
#endif
res.w[1] = (CX.w[1]) & QUIET_MASK64;
res.w[0] = CX.w[0];
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// x is Infinity?
#endif
res.w[1] = 0x7c00000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is NaN?
res.w[1] = ((x.w[1] ^ y) & 0x8000000000000000ull) |
0x7800000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
// x=y=0, return NaN
res.w[1] = 0x7c00000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// return 0
exponent_x = 0;
res.w[1] |= (((UINT64) exponent_x) << 49);
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
res.w[0] = (CY.w[0] & 0x0003ffffffffffffull);
__mul_64x64_to_128 (res, res.w[0], power10_table_128[18].w[0]);
res.w[1] |= ((CY.w[0]) & 0xfc00000000000000ull);
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is Infinity?
// return +/-0
res.w[1] = ((x.w[1] ^ y) & 0x8000000000000000ull);
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is 0
#endif
res.w[1] = (sign_x ^ sign_y) | INFINITY_MASK64;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// get number of decimal digits in CQ
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#endif
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+// restore the rounding mode back if it has been changed
+DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
int exponent_x, exponent_y, diff_expon, bin_expon_cx, scale,
scale0;
+ // Set the rounding mode to round-to-nearest (if different)
+ DFP_INIT_ROUNDMODE;
+
// unpack arguments, check for NaN or Infinity
valid_y = unpack_BID128_value (&sign_y, &exponent_y, &CY, y);
#endif
res.w[1] = CX.w[1] & QUIET_MASK64;
res.w[0] = CX.w[0];
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// x is Infinity?
#endif
res.w[1] = 0x7c00000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// x=y=0, return NaN
res.w[1] = 0x7c00000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
if (valid_y || ((y.w[1] & NAN_MASK64) == INFINITY_MASK64)) {
res.w[1] = sign_x | (((UINT64) exponent_x) << 49);
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
#endif
res.w[1] = CY.w[1] & QUIET_MASK64;
res.w[0] = CY.w[0];
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is Infinity?
// return x
res.w[1] = x.w[1];
res.w[0] = x.w[0];
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is 0
#endif
res.w[1] = 0x7c00000000000000ull;
res.w[0] = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
if (diff_expon > 34) {
// |x|<|y| in this case
res = x;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// set exponent of y to exponent_x, scale coefficient_y
if (P256.w[2] || P256.w[3]) {
// |x|<|y| in this case
res = x;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
if (__unsigned_compare_ge_128 (P256, CX2)) {
// |x|<|y| in this case
res = x;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
get_BID128_very_fast (&res, sign_x, exponent_x, CR);
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// 2^64
// check for remainder == 0
if (!CX.w[1] && !CX.w[0]) {
get_BID128_very_fast (&res, sign_x, exponent_y, CX);
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
}
get_BID128_very_fast (&res, sign_x, exponent_y, CX);
+// restore the rounding mode back if it has been changed
+DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
fexcept_t binaryflags = 0;
#endif
+ // Set the rounding mode to round-to-nearest (if different)
+ DFP_INIT_ROUNDMODE;
+
// unpack arguments, check for NaN or Infinity
if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
res.w[1] = CX.w[1];
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
res.w[1] = CX.w[1] & QUIET_MASK64;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// x is Infinity?
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
}
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// x is 0 otherwise
sign_x |
((((UINT64) (exponent_x + DECIMAL_EXPONENT_BIAS_128)) >> 1) << 49);
res.w[0] = 0;
+// restore the rounding mode back if it has been changed
+DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
if (sign_x) {
#ifdef SET_STATUS_FLAGS
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+// restore the rounding mode back if it has been changed
+DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
int_float fx, f64;
int exponent_x, bin_expon_cx;
int digits, scale, exponent_q;
+
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
fexcept_t binaryflags = 0;
#endif
+ // Set the rounding mode to round-to-nearest (if different)
+ DFP_INIT_ROUNDMODE;
+
// unpack arguments, check for NaN or Infinity
// unpack arguments, check for NaN or Infinity
CX.w[1] = 0;
res.w[0] = (CX.w[0] & 0x0003ffffffffffffull);
__mul_64x64_to_128 (res, res.w[0], power10_table_128[18].w[0]);
res.w[1] |= ((CX.w[0]) & 0xfc00000000000000ull);
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// x is Infinity?
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
}
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// x is 0 otherwise
sign_x | ((((UINT64) (exponent_x + DECIMAL_EXPONENT_BIAS_128)) >> 1)
<< 49);
res.w[0] = 0;
+// restore the rounding mode back if it has been changed
+DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
if (sign_x) {
#ifdef SET_STATUS_FLAGS
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+// restore the rounding mode back if it has been changed
+DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
y = *py;
#endif
+ // Set the rounding mode to round-to-nearest (if different)
+ DFP_INIT_ROUNDMODE;
+
valid_x = unpack_BID64 (&sign_x, &exponent_x, &coefficient_x, x);
valid_y = unpack_BID64 (&sign_y, &exponent_y, &coefficient_y, y);
if ((x & SNAN_MASK64) == SNAN_MASK64) // sNaN
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (coefficient_x & QUIET_MASK64);
}
// x is Infinity?
#ifdef SET_STATUS_FLAGS
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (NAN_MASK64);
}
} else {
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
// otherwise return +/-Inf
BID_RETURN (((x ^ y) & 0x8000000000000000ull) |
INFINITY_MASK64);
#ifdef SET_STATUS_FLAGS
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (NAN_MASK64);
}
if (((y & INFINITY_MASK64) != INFINITY_MASK64)) {
exponent_x = DECIMAL_MAX_EXPON_64;
else if (exponent_x < 0)
exponent_x = 0;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN ((sign_x ^ sign_y) | (((UINT64) exponent_x) << 53));
}
if ((y & SNAN_MASK64) == SNAN_MASK64) // sNaN
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (coefficient_y & QUIET_MASK64);
}
// y is Infinity?
if ((y & INFINITY_MASK64) == INFINITY_MASK64) {
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
// return +/-0
BID_RETURN (((x ^ y) & 0x8000000000000000ull));
}
#ifdef SET_STATUS_FLAGS
__set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN ((sign_x ^ sign_y) | INFINITY_MASK64);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// get decimal digits of Q
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
} else {
// UF occurs
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
fexcept_t binaryflags = 0;
#endif
+// Set the rounding mode to round-to-nearest (if different)
+DFP_INIT_ROUNDMODE;
+
valid_y = unpack_BID128_value (&sign_y, &exponent_y, &CY, y);
// unpack arguments, check for NaN or Infinity
// test if x is NaN
if (((x) & 0x7c00000000000000ull) == 0x7c00000000000000ull) {
res = CX.w[0];
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res & QUIET_MASK64);
}
// x is Infinity?
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
res = 0x7c00000000000000ull;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
if (((y.w[1] & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
// otherwise return +/-Inf
res =
(((x) ^ y.w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
#endif
// x=y=0, return NaN
res = 0x7c00000000000000ull;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// return 0
else if (exponent_x < 0)
exponent_x = 0;
res |= (((UINT64) exponent_x) << 53);
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
amount = recip_scale[18];
__shr_128 (Tmp, Qh, amount);
res = (CY.w[1] & 0xfc00000000000000ull) | Tmp.w[0];
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is Infinity?
if ((y.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
// return +/-0
res = sign_x ^ sign_y;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is 0, return +/-Inf
#ifdef SET_STATUS_FLAGS
__set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
} else {
// UF occurs
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
fexcept_t binaryflags = 0;
#endif
+// Set the rounding mode to round-to-nearest (if different)
+DFP_INIT_ROUNDMODE;
+
valid_y = unpack_BID64 (&sign_y, &exponent_y, &CY.w[0], (y));
// unpack arguments, check for NaN or Infinity
amount = recip_scale[18];
__shr_128 (Tmp, Qh, amount);
res = (CX.w[1] & 0xfc00000000000000ull) | Tmp.w[0];
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// x is Infinity?
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
res = 0x7c00000000000000ull;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
if (((y & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
// otherwise return +/-Inf
res =
((x.w[1] ^ (y)) & 0x8000000000000000ull) | 0x7800000000000000ull;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
#endif
// x=y=0, return NaN
res = 0x7c00000000000000ull;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// return 0
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
res = 0x7c00000000000000ull;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
exponent_x =
else if (exponent_x < 0)
exponent_x = 0;
res = (sign_x ^ sign_y) | (((UINT64) exponent_x) << 53);
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
if ((y & SNAN_MASK64) == SNAN_MASK64) // sNaN
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (CY.w[0] & QUIET_MASK64);
}
// y is Infinity?
if (((y) & 0x7800000000000000ull) == 0x7800000000000000ull) {
// return +/-0
res = sign_x ^ sign_y;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is 0, return +/-Inf
#ifdef SET_STATUS_FLAGS
__set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
} else {
// UF occurs
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
fexcept_t binaryflags = 0;
#endif
+// Set the rounding mode to round-to-nearest (if different)
+DFP_INIT_ROUNDMODE;
+
valid_y = unpack_BID128_value (&sign_y, &exponent_y, &CY, y);
// unpack arguments, check for NaN or Infinity
amount = recip_scale[18];
__shr_128 (Tmp, Qh, amount);
res = (CX.w[1] & 0xfc00000000000000ull) | Tmp.w[0];
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// x is Infinity?
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
res = 0x7c00000000000000ull;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
if (((y.w[1] & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
res =
((x.w[1] ^ y.
w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
#endif
// x=y=0, return NaN
res = 0x7c00000000000000ull;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// return 0
else if (exponent_x < 0)
exponent_x = 0;
res |= (((UINT64) exponent_x) << 53);
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
amount = recip_scale[18];
__shr_128 (Tmp, Qh, amount);
res = (CY.w[1] & 0xfc00000000000000ull) | Tmp.w[0];
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is Infinity?
if ((y.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
// return +/-0
res = sign_x ^ sign_y;
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// y is 0, return +/-Inf
#ifdef SET_STATUS_FLAGS
__set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
} else {
// UF occurs
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
int exponent_x, exponent_q, bin_expon_cx;
int digits_x;
int scale;
+
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
fexcept_t binaryflags = 0;
#endif
x = *px;
#endif
+ // Set the rounding mode to round-to-nearest (if different)
+ DFP_INIT_ROUNDMODE;
+
// unpack arguments, check for NaN or Infinity
if (!unpack_BID64 (&sign_x, &exponent_x, &coefficient_x, x)) {
// x is Inf. or NaN or 0
if ((x & SNAN_MASK64) == SNAN_MASK64) // sNaN
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res & QUIET_MASK64);
}
// x is 0
exponent_x = (exponent_x + DECIMAL_EXPONENT_BIAS) >> 1;
res = sign_x | (((UINT64) exponent_x) << 53);
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// x<0?
#ifdef SET_STATUS_FLAGS
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// if exponent is odd, scale coefficient by 10
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
fexcept_t binaryflags = 0;
#endif
+// Set the rounding mode to round-to-nearest (if different)
+DFP_INIT_ROUNDMODE;
+
// unpack arguments, check for NaN or Infinity
if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
res = CX.w[1];
amount = recip_scale[18];
__shr_128 (Tmp, Qh, amount);
res = (CX.w[1] & 0xfc00000000000000ull) | Tmp.w[0];
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// x is Infinity?
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
}
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
// x is 0 otherwise
exponent_x = DECIMAL_MAX_EXPON_64;
//res= sign_x | (((UINT64)exponent_x)<<53);
res = get_BID64 (sign_x, exponent_x, 0, rnd_mode, pfpsf);
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
if (sign_x) {
#ifdef SET_STATUS_FLAGS
__set_status_flags (pfpsf, INVALID_EXCEPTION);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+ // restore the rounding mode back if it has been changed
+ DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
}
}
#ifdef UNCHANGED_BINARY_STATUS_FLAGS
(void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
#endif
+// restore the rounding mode back if it has been changed
+DFP_RESTORE_ROUNDMODE;
BID_RETURN (res);
#endif
// #define HPUX_OS
+#include <dfp-machine.h>
+
// If DECIMAL_CALL_BY_REFERENCE is defined then numerical arguments and results
// are passed by reference otherwise they are passed by value (except that
// a pointer is always passed to the status flags)
--- /dev/null
+/* Rounding mode macros for DFP libbid. Dummy version.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+
+ This file is part of GCC.
+
+ GCC is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ GCC is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ Under Section 7 of GPL version 3, you are granted additional
+ permissions described in the GCC Runtime Library Exception, version
+ 3.1, as published by the Free Software Foundation.
+
+ You should have received a copy of the GNU General Public License and
+ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _DFP_MACHINE_H
+#define _DFP_MACHINE_H
+
+/* Initialize the rounding mode to round-to-nearest if needed. */
+#define DFP_INIT_ROUNDMODE
+
+/* Restore the rounding mode to round-to-nearest if changed. */
+#define DFP_RESTORE_ROUNDMODE
+
+#endif /* _DFP_MACHINE_H */