1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright (c) 1994-1997, by Sun Microsystems, Inc. 24*0Sstevel@tonic-gate * All rights reserved. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _QUAD_H 28*0Sstevel@tonic-gate #define _QUAD_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #ifdef __cplusplus 33*0Sstevel@tonic-gate extern "C" { 34*0Sstevel@tonic-gate #endif 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate /* 37*0Sstevel@tonic-gate * Common definitions for quadruple precision emulation routines 38*0Sstevel@tonic-gate * (SPARC only) 39*0Sstevel@tonic-gate */ 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate /* macros to simplify dealing with the diferences between V8 and V9 */ 42*0Sstevel@tonic-gate #ifdef __sparcv9 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate #define Z (*pz) 45*0Sstevel@tonic-gate #define QUAD_RETURN(x) return 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate #else 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate #define Z z 50*0Sstevel@tonic-gate #define QUAD_RETURN(x) return (x) 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate #endif 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate /* fsr definitions */ 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate /* current exception bits */ 57*0Sstevel@tonic-gate #define FSR_NXC 0x1 58*0Sstevel@tonic-gate #define FSR_DZC 0x2 59*0Sstevel@tonic-gate #define FSR_UFC 0x4 60*0Sstevel@tonic-gate #define FSR_OFC 0x8 61*0Sstevel@tonic-gate #define FSR_NVC 0x10 62*0Sstevel@tonic-gate #define FSR_CEXC 0x1f /* mask for all cexc bits */ 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate /* accrued exception bits */ 65*0Sstevel@tonic-gate #define FSR_NXA 0x20 66*0Sstevel@tonic-gate #define FSR_DZA 0x40 67*0Sstevel@tonic-gate #define FSR_UFA 0x80 68*0Sstevel@tonic-gate #define FSR_OFA 0x100 69*0Sstevel@tonic-gate #define FSR_NVA 0x200 70*0Sstevel@tonic-gate 71*0Sstevel@tonic-gate /* trap enable bits */ 72*0Sstevel@tonic-gate #define FSR_NXM 0x00800000 73*0Sstevel@tonic-gate #define FSR_DZM 0x01000000 74*0Sstevel@tonic-gate #define FSR_UFM 0x02000000 75*0Sstevel@tonic-gate #define FSR_OFM 0x04000000 76*0Sstevel@tonic-gate #define FSR_NVM 0x08000000 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate /* rounding directions (shifted) */ 79*0Sstevel@tonic-gate #define FSR_RN 0 80*0Sstevel@tonic-gate #define FSR_RZ 1 81*0Sstevel@tonic-gate #define FSR_RP 2 82*0Sstevel@tonic-gate #define FSR_RM 3 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate /* 85*0Sstevel@tonic-gate * in struct longdouble, msw implicitly consists of 86*0Sstevel@tonic-gate * unsigned short sign:1; 87*0Sstevel@tonic-gate * unsigned short exponent:15; 88*0Sstevel@tonic-gate * unsigned short frac1:16; 89*0Sstevel@tonic-gate */ 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate /* structure used to access words within a quad */ 92*0Sstevel@tonic-gate union longdouble { 93*0Sstevel@tonic-gate struct { 94*0Sstevel@tonic-gate unsigned int msw; 95*0Sstevel@tonic-gate unsigned int frac2; 96*0Sstevel@tonic-gate unsigned int frac3; 97*0Sstevel@tonic-gate unsigned int frac4; 98*0Sstevel@tonic-gate } l; 99*0Sstevel@tonic-gate long double d; /* unused; just guarantees correct alignment */ 100*0Sstevel@tonic-gate }; 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate /* macros used internally for readability */ 103*0Sstevel@tonic-gate #define QUAD_ISNAN(x) \ 104*0Sstevel@tonic-gate (((x).l.msw & 0x7fff0000) == 0x7fff0000 && \ 105*0Sstevel@tonic-gate (((x).l.msw & 0xffff) | (x).l.frac2 | (x).l.frac3 | (x).l.frac4)) 106*0Sstevel@tonic-gate 107*0Sstevel@tonic-gate #define QUAD_ISZERO(x) \ 108*0Sstevel@tonic-gate (!(((x).l.msw & 0x7fffffff) | (x).l.frac2 | (x).l.frac3 | (x).l.frac4)) 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gate /* structure used to access words within a double */ 111*0Sstevel@tonic-gate union xdouble { 112*0Sstevel@tonic-gate struct { 113*0Sstevel@tonic-gate unsigned int hi; 114*0Sstevel@tonic-gate unsigned int lo; 115*0Sstevel@tonic-gate } l; 116*0Sstevel@tonic-gate double d; 117*0Sstevel@tonic-gate }; 118*0Sstevel@tonic-gate 119*0Sstevel@tonic-gate /* relationships returned by _Q_cmp and _Q_cmpe */ 120*0Sstevel@tonic-gate enum fcc_type { 121*0Sstevel@tonic-gate fcc_equal = 0, 122*0Sstevel@tonic-gate fcc_less = 1, 123*0Sstevel@tonic-gate fcc_greater = 2, 124*0Sstevel@tonic-gate fcc_unordered = 3 125*0Sstevel@tonic-gate }; 126*0Sstevel@tonic-gate 127*0Sstevel@tonic-gate /* internal routines */ 128*0Sstevel@tonic-gate extern void __quad_mag_add(const union longdouble *, 129*0Sstevel@tonic-gate const union longdouble *, union longdouble *, unsigned int *); 130*0Sstevel@tonic-gate extern void __quad_mag_sub(const union longdouble *, 131*0Sstevel@tonic-gate const union longdouble *, union longdouble *, unsigned int *); 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate /* inline templates */ 134*0Sstevel@tonic-gate extern void __quad_getfsrp(unsigned int *); 135*0Sstevel@tonic-gate extern void __quad_setfsrp(const unsigned int *); 136*0Sstevel@tonic-gate extern double __quad_dp_sqrt(double *); 137*0Sstevel@tonic-gate extern void __quad_faddq(const union longdouble *, const union longdouble *, 138*0Sstevel@tonic-gate union longdouble *); 139*0Sstevel@tonic-gate extern void __quad_fsubq(const union longdouble *, const union longdouble *, 140*0Sstevel@tonic-gate union longdouble *); 141*0Sstevel@tonic-gate extern void __quad_fmulq(const union longdouble *, const union longdouble *, 142*0Sstevel@tonic-gate union longdouble *); 143*0Sstevel@tonic-gate extern void __quad_fdivq(const union longdouble *, const union longdouble *, 144*0Sstevel@tonic-gate union longdouble *); 145*0Sstevel@tonic-gate extern void __quad_fsqrtq(const union longdouble *, union longdouble *); 146*0Sstevel@tonic-gate extern void __quad_fcmpq(const union longdouble *, const union longdouble *, 147*0Sstevel@tonic-gate unsigned int *); 148*0Sstevel@tonic-gate extern void __quad_fcmpeq(const union longdouble *, const union longdouble *, 149*0Sstevel@tonic-gate unsigned int *); 150*0Sstevel@tonic-gate extern void __quad_fstoq(const float *, union longdouble *); 151*0Sstevel@tonic-gate extern void __quad_fdtoq(const double *, union longdouble *); 152*0Sstevel@tonic-gate extern void __quad_fqtoi(const union longdouble *, int *); 153*0Sstevel@tonic-gate extern void __quad_fqtos(const union longdouble *, float *); 154*0Sstevel@tonic-gate extern void __quad_fqtod(const union longdouble *, double *); 155*0Sstevel@tonic-gate #ifdef __sparcv9 156*0Sstevel@tonic-gate extern void __quad_fqtox(const union longdouble *, long *); 157*0Sstevel@tonic-gate #endif 158*0Sstevel@tonic-gate 159*0Sstevel@tonic-gate #ifdef __cplusplus 160*0Sstevel@tonic-gate } 161*0Sstevel@tonic-gate #endif 162*0Sstevel@tonic-gate 163*0Sstevel@tonic-gate #endif /* _QUAD_H */ 164