+ /* At least one of the arguments must be of decimal float type. */
+ gdb_assert (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT
+ || TYPE_CODE (type2) == TYPE_CODE_DECFLOAT);
+
+ if (TYPE_CODE (type1) == TYPE_CODE_FLT
+ || TYPE_CODE (type2) == TYPE_CODE_FLT)
+ /* The DFP extension to the C language does not allow mixing of
+ * decimal float types with other float types in expressions
+ * (see WDTR 24732, page 12). */
+ error (_("Mixing decimal floating types with other floating types is not allowed."));
+
+ /* Obtain decimal value of arg1, converting from other types
+ if necessary. */
+
+ if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT)
+ {
+ *byte_order_x = gdbarch_byte_order (get_type_arch (type1));
+ *len_x = TYPE_LENGTH (type1);
+ memcpy (x, value_contents (arg1), *len_x);
+ }
+ else if (is_integral_type (type1))
+ {
+ *byte_order_x = gdbarch_byte_order (get_type_arch (type2));
+ *len_x = TYPE_LENGTH (type2);
+ decimal_from_integral (arg1, x, *len_x, *byte_order_x);
+ }
+ else
+ error (_("Don't know how to convert from %s to %s."), TYPE_NAME (type1),
+ TYPE_NAME (type2));
+
+ /* Obtain decimal value of arg2, converting from other types
+ if necessary. */
+
+ if (TYPE_CODE (type2) == TYPE_CODE_DECFLOAT)
+ {
+ *byte_order_y = gdbarch_byte_order (get_type_arch (type2));
+ *len_y = TYPE_LENGTH (type2);
+ memcpy (y, value_contents (arg2), *len_y);
+ }
+ else if (is_integral_type (type2))
+ {
+ *byte_order_y = gdbarch_byte_order (get_type_arch (type1));
+ *len_y = TYPE_LENGTH (type1);
+ decimal_from_integral (arg2, y, *len_y, *byte_order_y);
+ }
+ else
+ error (_("Don't know how to convert from %s to %s."), TYPE_NAME (type1),
+ TYPE_NAME (type2));
+}