ieee.h revision 1.6
11.6Skleink/*	$NetBSD: ieee.h,v 1.6 2003/10/26 20:59:51 kleink 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.3Skleink#define	EXT_FRACBITS	64
531.1Sfvdl
541.3Skleink/*
551.5Skleink * struct ieee_ext is the raw storage layout of the 80-bit
561.3Skleink * extended-precision type as implemented by the FPU.  Per the
571.3Skleink * respective ABI specifications, it is followed by a tail padding of
581.3Skleink *
591.3Skleink *   amd64: 48 bits,
601.3Skleink *   i386:  16 bits.
611.3Skleink */
621.1Sfvdlstruct ieee_ext {
631.1Sfvdl	u_int	ext_fracl;
641.4Skleink	u_int	ext_frach:31;
651.4Skleink	u_int	ext_int:1;
661.1Sfvdl	u_int	ext_exp:15;
671.1Sfvdl	u_int	ext_sign:1;
681.1Sfvdl};
691.1Sfvdl
701.1Sfvdl/*
711.1Sfvdl * Floats whose exponent is in [1..INFNAN) (of whatever type) are
721.1Sfvdl * `normal'.  Floats whose exponent is INFNAN are either Inf or NaN.
731.1Sfvdl * Floats whose exponent is zero are either zero (iff all fraction
741.1Sfvdl * bits are zero) or subnormal values.
751.1Sfvdl *
761.1Sfvdl * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its
771.1Sfvdl * high fraction; if the bit is set, it is a `quiet NaN'.
781.1Sfvdl */
791.1Sfvdl#define	EXT_EXP_INFNAN	32767
801.1Sfvdl
811.1Sfvdl#if 0
821.6Skleink#define	EXT_QUIETNAN	(1 << 30)
831.1Sfvdl#endif
841.1Sfvdl
851.1Sfvdl/*
861.1Sfvdl * Exponent biases.
871.1Sfvdl */
881.1Sfvdl#define	EXT_EXP_BIAS	16383
89