11.13Schristos/* $NetBSD: ieee.h,v 1.13 2024/01/02 19:28:25 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.12Schristos#ifndef _X86_IEEE_H_ 431.12Schristos#define _X86_IEEE_H_ 441.1Sfvdl 451.1Sfvdl/* 461.1Sfvdl * ieee.h defines the machine-dependent layout of the machine's IEEE 471.1Sfvdl * floating point. It does *not* define (yet?) any of the rounding 481.1Sfvdl * mode bits, exceptions, and so forth. 491.1Sfvdl */ 501.1Sfvdl 511.5Skleink#include <sys/ieee754.h> 521.1Sfvdl 531.1Sfvdl#define EXT_EXPBITS 15 541.10Schristos#define EXT_FRACHBITS 32 551.10Schristos#define EXT_FRACLBITS 32 561.10Schristos#define EXT_FRACBITS (EXT_FRACLBITS + EXT_FRACHBITS) 571.10Schristos 581.10Schristos#define EXT_TO_ARRAY32(u, a) do { \ 591.10Schristos (a)[0] = (uint32_t)(u).extu_ext.ext_fracl; \ 601.10Schristos (a)[1] = (uint32_t)(u).extu_ext.ext_frach; \ 611.10Schristos} while(/*CONSTCOND*/0) 621.1Sfvdl 631.3Skleink/* 641.5Skleink * struct ieee_ext is the raw storage layout of the 80-bit 651.3Skleink * extended-precision type as implemented by the FPU. Per the 661.3Skleink * respective ABI specifications, it is followed by a tail padding of 671.3Skleink * 681.3Skleink * amd64: 48 bits, 691.3Skleink * i386: 16 bits. 701.3Skleink */ 711.1Sfvdlstruct ieee_ext { 721.13Schristos uint32_t ext_fracl:EXT_FRACLBITS; 731.13Schristos uint32_t ext_frach:EXT_FRACHBITS; 741.10Schristos#if 0 751.13Schristos uint32_t ext_int:1; 761.10Schristos#endif 771.13Schristos uint32_t ext_exp:EXT_EXPBITS; 781.13Schristos uint32_t ext_sign:1; 791.1Sfvdl}; 801.1Sfvdl 811.1Sfvdl/* 821.1Sfvdl * Floats whose exponent is in [1..INFNAN) (of whatever type) are 831.1Sfvdl * `normal'. Floats whose exponent is INFNAN are either Inf or NaN. 841.1Sfvdl * Floats whose exponent is zero are either zero (iff all fraction 851.1Sfvdl * bits are zero) or subnormal values. 861.1Sfvdl * 871.1Sfvdl * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its 881.1Sfvdl * high fraction; if the bit is set, it is a `quiet NaN'. 891.1Sfvdl */ 901.11Schristos#define EXT_EXP_INFNAN 0x7fff 911.11Schristos#define EXT_EXP_INF 0x7fff 921.11Schristos#define EXT_EXP_NAN 0x7fff 931.1Sfvdl 941.1Sfvdl#if 0 951.9Skleink#define SNG_QUIETNAN (1 << 22) 961.9Skleink#define DBL_QUIETNAN (1 << 19) 971.6Skleink#define EXT_QUIETNAN (1 << 30) 981.1Sfvdl#endif 991.1Sfvdl 1001.1Sfvdl/* 1011.1Sfvdl * Exponent biases. 1021.1Sfvdl */ 1031.1Sfvdl#define EXT_EXP_BIAS 16383 1041.7Skleink 1051.7Skleink/* 1061.7Skleink * Convenience data structures. 1071.7Skleink */ 1081.7Skleinkunion ieee_ext_u { 1091.7Skleink long double extu_ld; 1101.8Skleink struct ieee_ext extu_ext; 1111.7Skleink}; 1121.11Schristos 1131.11Schristos#define extu_exp extu_ext.ext_exp 1141.11Schristos#define extu_sign extu_ext.ext_sign 1151.11Schristos#define extu_fracl extu_ext.ext_fracl 1161.11Schristos#define extu_frach extu_ext.ext_frach 1171.11Schristos 1181.11Schristos#define LDBL_NBIT 0x80000000 1191.11Schristos#define mask_nbit_l(u) ((u).extu_frach &= ~LDBL_NBIT) 1201.12Schristos 1211.12Schristos#endif /* _X86_IEEE_H_ */ 122