xref: /csrg-svn/lib/libc/quad/quad.h (revision 53456)
153439Sbostic /*-
253439Sbostic  * Copyright (c) 1992 The Regents of the University of California.
353439Sbostic  * All rights reserved.
453439Sbostic  *
553439Sbostic  * %sccs.include.redist.c%
653439Sbostic  *
7*53456Sbostic  *	@(#)quad.h	5.3 (Berkeley) 05/12/92
853439Sbostic  */
953439Sbostic 
1053439Sbostic /* More subroutines needed by GCC output code on some machines.  */
1153439Sbostic /* Compile this one with gcc.  */
1253453Sbostic #include <sys/param.h>
1353439Sbostic 
1453453Sbostic #define	BITS_PER_WORD	(NBBY * sizeof(long))
1553453Sbostic 
1653439Sbostic /* We need this union to unpack/pack longlongs, since we don't have
1753439Sbostic    any arithmetic yet.  Incoming long long parameters are stored
1853439Sbostic    into the `ll' field, and the unpacked result is read from the struct
1953439Sbostic    longlong.  */
2053439Sbostic 
21*53456Sbostic typedef union {
22*53456Sbostic 	long long ll;
23*53456Sbostic 	struct { long val[2]; } s;
2453439Sbostic } long_long;
25*53456Sbostic #define high val[_QUAD_HIGHWORD]
26*53456Sbostic #define low val[_QUAD_LOWWORD]
2753439Sbostic 
28*53456Sbostic #define HIGH _QUAD_HIGHWORD
29*53456Sbostic #define LOW _QUAD_LOWWORD
30*53456Sbostic 
3153439Sbostic /* Internally, long long ints are strings of unsigned shorts in the
32*53456Sbostic    order determined by BYTE_ORDER.  */
3353439Sbostic 
3453439Sbostic #define B 0x10000
3553439Sbostic #define low16 (B - 1)
3653439Sbostic 
37*53456Sbostic #if BYTE_ORDER == BIG_ENDIAN
3853439Sbostic #define big_end(n)	0
3953439Sbostic #define little_end(n)	((n) - 1)
4053439Sbostic #define next_msd(i)	((i) - 1)
4153439Sbostic #define next_lsd(i)	((i) + 1)
4253439Sbostic #define is_not_msd(i,n)	((i) >= 0)
4353439Sbostic #define is_not_lsd(i,n)	((i) < (n))
4453439Sbostic #else
4553439Sbostic #define big_end(n)	((n) - 1)
4653439Sbostic #define little_end(n)	0
4753439Sbostic #define next_msd(i)	((i) + 1)
4853439Sbostic #define next_lsd(i)	((i) - 1)
4953439Sbostic #define is_not_msd(i,n)	((i) < (n))
5053439Sbostic #define is_not_lsd(i,n)	((i) >= 0)
5153439Sbostic #endif
52