xref: /netbsd-src/sys/arch/vax/include/vaxfp.h (revision 91d4704c12a10b4a5342b04ef0a12f227cef808c)
1*91d4704cSmatt /*	$NetBSD: vaxfp.h,v 1.8 2008/08/05 16:47:42 matt Exp $	*/
28b8e22cbSkleink 
38b8e22cbSkleink /*-
48b8e22cbSkleink  * Copyright (c) 2003 The NetBSD Foundation, Inc.
58b8e22cbSkleink  * All rights reserved.
68b8e22cbSkleink  *
78b8e22cbSkleink  * This code is derived from software contributed to The NetBSD Foundation
88b8e22cbSkleink  * by Klaus Klein.
98b8e22cbSkleink  *
108b8e22cbSkleink  * Redistribution and use in source and binary forms, with or without
118b8e22cbSkleink  * modification, are permitted provided that the following conditions
128b8e22cbSkleink  * are met:
138b8e22cbSkleink  * 1. Redistributions of source code must retain the above copyright
148b8e22cbSkleink  *    notice, this list of conditions and the following disclaimer.
158b8e22cbSkleink  * 2. Redistributions in binary form must reproduce the above copyright
168b8e22cbSkleink  *    notice, this list of conditions and the following disclaimer in the
178b8e22cbSkleink  *    documentation and/or other materials provided with the distribution.
188b8e22cbSkleink  *
198b8e22cbSkleink  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
208b8e22cbSkleink  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
218b8e22cbSkleink  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
228b8e22cbSkleink  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
238b8e22cbSkleink  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
248b8e22cbSkleink  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
258b8e22cbSkleink  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
268b8e22cbSkleink  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
278b8e22cbSkleink  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
288b8e22cbSkleink  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
298b8e22cbSkleink  * POSSIBILITY OF SUCH DAMAGE.
308b8e22cbSkleink  */
318b8e22cbSkleink 
328b8e22cbSkleink /*
338b8e22cbSkleink  * vaxfp.h defines the layout of VAX Floating-Point data types.
348b8e22cbSkleink  * Only F_floating and D_floating types are defined here;
358b8e22cbSkleink  * G_floating and H_floating are not supported by NetBSD.
368b8e22cbSkleink  */
375ba92ad7Skleink #ifndef _VAX_VAXFP_H_
385ba92ad7Skleink #define	_VAX_VAXFP_H_
398b8e22cbSkleink 
40*91d4704cSmatt #include <sys/featuretest.h>
41*91d4704cSmatt 
42*91d4704cSmatt #if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE)
43*91d4704cSmatt 
44*91d4704cSmatt typedef int fenv_t;
45*91d4704cSmatt typedef int fexcept_t;
46*91d4704cSmatt 
47*91d4704cSmatt #define	FE_UNDERFLOW	0x01	/* underflow exception */
48*91d4704cSmatt 
49*91d4704cSmatt #define	FE_ALL_EXCEPT	0x01
50*91d4704cSmatt 
51*91d4704cSmatt #if !defined(_ISOC99_SOURCE)
528b8e22cbSkleink 
53c581ede6Schristos #define	FFLT_EXPBITS	8
54c581ede6Schristos #define	FFLT_FRACHBITS	7
55c581ede6Schristos #define	FFLT_FRACLBITS	16
56c581ede6Schristos #define	FFLT_FRACBITS	(FFLT_FRACLBITS + FFLT_FRACHBITS)
578b8e22cbSkleink 
588b8e22cbSkleink struct vax_f_floating {
59c581ede6Schristos 	unsigned int	fflt_frach:FFLT_FRACHBITS;
60c581ede6Schristos 	unsigned int	fflt_exp:FFLT_EXPBITS;
6185d908afSmatt 	unsigned int	fflt_sign:1;
62c581ede6Schristos 	unsigned int	fflt_fracl:FFLT_FRACLBITS;
638b8e22cbSkleink };
648b8e22cbSkleink 
65c581ede6Schristos #define	DFLT_EXPBITS	8
66c581ede6Schristos #define	DFLT_FRACHBITS	7
67c581ede6Schristos #define	DFLT_FRACMBITS	16
68c581ede6Schristos #define	DFLT_FRACLBITS	32
69c581ede6Schristos #define	DFLT_FRACBITS	(DFLT_FRACLBITS + DFLT_FRACMBITS + DFLT_FRACHBITS)
70c581ede6Schristos 
718b8e22cbSkleink struct vax_d_floating {
72c581ede6Schristos 
73c581ede6Schristos 	unsigned int	dflt_frach:DFLT_FRACHBITS;
74c581ede6Schristos 	unsigned int	dflt_exp:DFLT_EXPBITS;
7585d908afSmatt 	unsigned int	dflt_sign:1;
76c581ede6Schristos 	unsigned int	dflt_fracm:DFLT_FRACMBITS;
77c581ede6Schristos 	unsigned int	dflt_fracl:DFLT_FRACLBITS;
788b8e22cbSkleink };
798b8e22cbSkleink 
808b8e22cbSkleink /*
818b8e22cbSkleink  * Exponent biases.
828b8e22cbSkleink  */
838b8e22cbSkleink #define	FFLT_EXP_BIAS	128
848b8e22cbSkleink #define	DFLT_EXP_BIAS	128
858b8e22cbSkleink 
868b8e22cbSkleink /*
878b8e22cbSkleink  * Convenience data structures.
888b8e22cbSkleink  */
898b8e22cbSkleink union vax_ffloating_u {
908b8e22cbSkleink 	float			ffltu_f;
918b8e22cbSkleink 	struct vax_f_floating	ffltu_fflt;
928b8e22cbSkleink };
938b8e22cbSkleink 
948b8e22cbSkleink union vax_dfloating_u {
958b8e22cbSkleink 	double			dfltu_d;
968b8e22cbSkleink 	struct vax_d_floating	dfltu_dflt;
9785d908afSmatt };
9885d908afSmatt 
99*91d4704cSmatt #endif /* !_ISOC99_SOURCE */
100*91d4704cSmatt 
101*91d4704cSmatt #endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */
102*91d4704cSmatt 
1035ba92ad7Skleink #endif /* _VAX_VAXFP_H_ */
104