4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _QUAD_INCLUDED_
28 #define _QUAD_INCLUDED_ /* Render harmless multiple inclusions. */
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 * Header file for long double == quadruple-precision run-time support. C
34 * "long double" and Fortran "real*16" are implemented identically on all
37 * Thus the quad run-time support is intentionally coded as C-callable routines
40 * Mixed-case identifiers with leading _ are intentionally chosen to minimize
41 * conflicts with user-defined C and Fortran identifiers.
44 #include <math.h> /* to get float macros */
46 #ifdef __STDC__ /* are we there yet */
48 #define QUAD long double
50 #define SINGLERESULT float
51 #define RETURNSINGLE(x) return x
52 #define ASSIGNSINGLERESULT(x,y) x = y
60 #define QUAD struct quadstruct
62 #define SINGLE FLOATPARAMETER
63 #define SINGLERESULT FLOATFUNCTIONTYPE
64 #define RETURNSINGLE(x) RETURNFLOAT(x)
65 #define ASSIGNSINGLERESULT(x,y) {SINGLERESULT _kug = y; *(int *)&x = *(int*)&_kug;}
69 /****** Phase I Quad support: C run-time in libc/crt *****/
71 extern QUAD
_Q_neg(QUAD
); /* returns -x */
72 extern QUAD
_Q_add(QUAD
, QUAD
); /* returns x + y */
73 extern QUAD
_Q_sub(QUAD
, QUAD
); /* returns x - y */
74 extern QUAD
_Q_mul(QUAD
, QUAD
); /* returns x * y */
75 extern QUAD
_Q_div(QUAD
, QUAD
); /* returns x / y */
76 extern QUAD
_Q_sqrt(QUAD
); /* return sqrt(x) */
78 _Q_cmp(QUAD
, QUAD
); /* x compare y , exception */
79 /* only on signaling NaN */
81 _Q_cmpe(QUAD
, QUAD
); /* x compare y , exception */
83 extern int _Q_feq(QUAD
, QUAD
); /* return TRUE if x == y */
84 extern int _Q_fne(QUAD
, QUAD
); /* return TRUE if x != y */
85 extern int _Q_fgt(QUAD
, QUAD
); /* return TRUE if x > y */
86 extern int _Q_fge(QUAD
, QUAD
); /* return TRUE if x >= y */
87 extern int _Q_flt(QUAD
, QUAD
); /* return TRUE if x < y */
88 extern int _Q_fle(QUAD
, QUAD
); /* return TRUE if x <= y */
90 /* Conversion routines are pretty straightforward. */
92 extern QUAD
_Q_stoq(SINGLE
);
93 extern QUAD
_Q_dtoq(double);
94 extern QUAD
_Q_itoq(int);
95 extern QUAD
_Q_utoq(unsigned);
96 extern SINGLERESULT
_Q_qtos(QUAD
);
97 extern double _Q_qtod(QUAD
);
98 extern int _Q_qtoi(QUAD
);
99 extern unsigned _Q_qtou(QUAD
);
102 Phase I Quad support: scanf/printf support in libc/gen/common
105 enum fcc_type
/* relationships for loading into cc */
113 typedef /* FPU register viewed as single components. */
117 unsigned exponent
: 8 ;
118 unsigned significand
: 23 ;
122 typedef /* FPU register viewed as double components. */
126 unsigned exponent
: 11 ;
127 unsigned significand
: 20 ;
130 typedef /* FPU register viewed as extended components. */
134 unsigned exponent
: 15 ;
135 unsigned significand
: 16 ;
139 enum fp_op_type
/* Type specifiers in FPU instructions. */
141 fp_op_integer
= 0, /* Not in hardware, but convenient to define. */
148 extern void _Q_get_rp_rd(void);
149 extern void _Q_set_exception(unsigned);
151 #endif /* QUAD_INCLUDED */