ieee.h revision 1.10
11.10Schristos/* $NetBSD: ieee.h,v 1.10 2007/02/02 23:07:44 christos Exp $ */ 21.1Sfvdl 31.1Sfvdl/* 41.1Sfvdl * Copyright (c) 1992, 1993 51.1Sfvdl * The Regents of the University of California. All rights reserved. 61.1Sfvdl * 71.1Sfvdl * This software was developed by the Computer Systems Engineering group 81.1Sfvdl * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 91.1Sfvdl * contributed to Berkeley. 101.1Sfvdl * 111.1Sfvdl * All advertising materials mentioning features or use of this software 121.1Sfvdl * must display the following acknowledgement: 131.1Sfvdl * This product includes software developed by the University of 141.1Sfvdl * California, Lawrence Berkeley Laboratory. 151.1Sfvdl * 161.1Sfvdl * Redistribution and use in source and binary forms, with or without 171.1Sfvdl * modification, are permitted provided that the following conditions 181.1Sfvdl * are met: 191.1Sfvdl * 1. Redistributions of source code must retain the above copyright 201.1Sfvdl * notice, this list of conditions and the following disclaimer. 211.1Sfvdl * 2. Redistributions in binary form must reproduce the above copyright 221.1Sfvdl * notice, this list of conditions and the following disclaimer in the 231.1Sfvdl * documentation and/or other materials provided with the distribution. 241.2Sagc * 3. Neither the name of the University nor the names of its contributors 251.1Sfvdl * may be used to endorse or promote products derived from this software 261.1Sfvdl * without specific prior written permission. 271.1Sfvdl * 281.1Sfvdl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 291.1Sfvdl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 301.1Sfvdl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 311.1Sfvdl * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 321.1Sfvdl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 331.1Sfvdl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 341.1Sfvdl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 351.1Sfvdl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 361.1Sfvdl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 371.1Sfvdl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 381.1Sfvdl * SUCH DAMAGE. 391.1Sfvdl * 401.1Sfvdl * @(#)ieee.h 8.1 (Berkeley) 6/11/93 411.1Sfvdl */ 421.1Sfvdl 431.1Sfvdl/* 441.1Sfvdl * ieee.h defines the machine-dependent layout of the machine's IEEE 451.1Sfvdl * floating point. It does *not* define (yet?) any of the rounding 461.1Sfvdl * mode bits, exceptions, and so forth. 471.1Sfvdl */ 481.1Sfvdl 491.5Skleink#include <sys/ieee754.h> 501.1Sfvdl 511.1Sfvdl#define EXT_EXPBITS 15 521.10Schristos#define EXT_FRACHBITS 32 531.10Schristos#define EXT_FRACLBITS 32 541.10Schristos#define EXT_FRACBITS (EXT_FRACLBITS + EXT_FRACHBITS) 551.10Schristos 561.10Schristos#define EXT_TO_ARRAY32(u, a) do { \ 571.10Schristos (a)[0] = (uint32_t)(u).extu_ext.ext_fracl; \ 581.10Schristos (a)[1] = (uint32_t)(u).extu_ext.ext_frach; \ 591.10Schristos} while(/*CONSTCOND*/0) 601.1Sfvdl 611.3Skleink/* 621.5Skleink * struct ieee_ext is the raw storage layout of the 80-bit 631.3Skleink * extended-precision type as implemented by the FPU. Per the 641.3Skleink * respective ABI specifications, it is followed by a tail padding of 651.3Skleink * 661.3Skleink * amd64: 48 bits, 671.3Skleink * i386: 16 bits. 681.3Skleink */ 691.1Sfvdlstruct ieee_ext { 701.10Schristos u_int ext_fracl:EXT_FRACLBITS; 711.10Schristos u_int ext_frach:EXT_FRACHBITS; 721.10Schristos#if 0 731.4Skleink u_int ext_int:1; 741.10Schristos#endif 751.10Schristos u_int ext_exp:EXT_EXPBITS; 761.1Sfvdl u_int ext_sign:1; 771.1Sfvdl}; 781.1Sfvdl 791.1Sfvdl/* 801.1Sfvdl * Floats whose exponent is in [1..INFNAN) (of whatever type) are 811.1Sfvdl * `normal'. Floats whose exponent is INFNAN are either Inf or NaN. 821.1Sfvdl * Floats whose exponent is zero are either zero (iff all fraction 831.1Sfvdl * bits are zero) or subnormal values. 841.1Sfvdl * 851.1Sfvdl * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its 861.1Sfvdl * high fraction; if the bit is set, it is a `quiet NaN'. 871.1Sfvdl */ 881.1Sfvdl#define EXT_EXP_INFNAN 32767 891.1Sfvdl 901.1Sfvdl#if 0 911.9Skleink#define SNG_QUIETNAN (1 << 22) 921.9Skleink#define DBL_QUIETNAN (1 << 19) 931.6Skleink#define EXT_QUIETNAN (1 << 30) 941.1Sfvdl#endif 951.1Sfvdl 961.1Sfvdl/* 971.1Sfvdl * Exponent biases. 981.1Sfvdl */ 991.1Sfvdl#define EXT_EXP_BIAS 16383 1001.7Skleink 1011.7Skleink/* 1021.7Skleink * Convenience data structures. 1031.7Skleink */ 1041.7Skleinkunion ieee_ext_u { 1051.7Skleink long double extu_ld; 1061.8Skleink struct ieee_ext extu_ext; 1071.7Skleink}; 108