xref: /titanic_51/usr/src/lib/libbc/libc/gen/common/_Qquad.h (revision 5d54f3d8999eac1762fe0a8c7177d20f1f201fae)
1 /*
2  * CDDL HEADER START
3  *
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
7  * with the License.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1989 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _QUAD_INCLUDED_
28 #define	_QUAD_INCLUDED_		/* Render harmless multiple inclusions. */
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Header file for long double == quadruple-precision run-time support. C
34  * "long double" and Fortran "real*16" are implemented identically on all
35  * architectures.
36  *
37  * Thus the quad run-time support is intentionally coded as C-callable routines
38  * for portability.
39  *
40  * Mixed-case identifiers with leading _ are intentionally chosen to minimize
41  * conflicts with user-defined C and Fortran identifiers.
42  */
43 
44 #include <math.h>		/* to get float macros */
45 
46 #ifdef __STDC__			/* are we there yet */
47 
48 #define QUAD long double
49 #define SINGLE float
50 #define SINGLERESULT float
51 #define RETURNSINGLE(x) return x
52 #define ASSIGNSINGLERESULT(x,y) x = y
53 
54 #else
55 
56 struct quadstruct {
57 	unsigned        parts[4]
58 };
59 
60 #define QUAD struct quadstruct
61 
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;}
66 
67 #endif
68 
69 /******		Phase I Quad support: C run-time in libc/crt		*****/
70 
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) */
77 extern enum fcc_type
78 	_Q_cmp(QUAD, QUAD);		/* x compare y , exception */
79 					/* only on signaling NaN */
80 extern enum fcc_type
81 	_Q_cmpe(QUAD, QUAD);		/* x compare y , exception */
82 					/* on quiet NaN */
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 */
89 
90 /* Conversion routines are pretty straightforward. */
91 
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);
100 
101 /******
102     Phase I Quad support: scanf/printf support in libc/gen/common
103 *****/
104 
105 enum fcc_type 	 		/* relationships for loading into cc */
106 	{
107 	fcc_equal	= 0,
108 	fcc_less	= 1,
109 	fcc_greater	= 2,
110 	fcc_unordered	= 3
111 	} ;
112 
113 typedef			/* FPU register viewed as single components. */
114 	struct
115 	{
116 	unsigned sign :		 1 ;
117 	unsigned exponent :	 8 ;
118 	unsigned significand :	23 ;
119 	}
120 	single_type ;
121 
122 typedef			/* FPU register viewed as double components. */
123 	struct
124 	{
125 	unsigned sign :		 1 ;
126 	unsigned exponent :	11 ;
127 	unsigned significand :	20 ;
128 	}
129 	double_type ;
130 typedef			/* FPU register viewed as extended components. */
131 	struct
132 	{
133 	unsigned sign :		 1 ;
134 	unsigned exponent :	15 ;
135 	unsigned significand :	16 ;
136 	}
137 	extended_type ;
138 
139 enum fp_op_type		/* Type specifiers in FPU instructions. */
140 	{
141 	fp_op_integer	= 0,	/* Not in hardware, but convenient to define. */
142 	fp_op_single	= 1,
143 	fp_op_double	= 2,
144 	fp_op_extended	= 3
145 	} ;
146 
147 
148 extern void	_Q_get_rp_rd(void);
149 extern void	_Q_set_exception(unsigned);
150 
151 #endif				/* QUAD_INCLUDED */
152