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