xref: /csrg-svn/lib/libc/quad/quad.h (revision 53456)
1 /*-
2  * Copyright (c) 1992 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)quad.h	5.3 (Berkeley) 05/12/92
8  */
9 
10 /* More subroutines needed by GCC output code on some machines.  */
11 /* Compile this one with gcc.  */
12 #include <sys/param.h>
13 
14 #define	BITS_PER_WORD	(NBBY * sizeof(long))
15 
16 /* We need this union to unpack/pack longlongs, since we don't have
17    any arithmetic yet.  Incoming long long parameters are stored
18    into the `ll' field, and the unpacked result is read from the struct
19    longlong.  */
20 
21 typedef union {
22 	long long ll;
23 	struct { long val[2]; } s;
24 } long_long;
25 #define high val[_QUAD_HIGHWORD]
26 #define low val[_QUAD_LOWWORD]
27 
28 #define HIGH _QUAD_HIGHWORD
29 #define LOW _QUAD_LOWWORD
30 
31 /* Internally, long long ints are strings of unsigned shorts in the
32    order determined by BYTE_ORDER.  */
33 
34 #define B 0x10000
35 #define low16 (B - 1)
36 
37 #if BYTE_ORDER == BIG_ENDIAN
38 #define big_end(n)	0
39 #define little_end(n)	((n) - 1)
40 #define next_msd(i)	((i) - 1)
41 #define next_lsd(i)	((i) + 1)
42 #define is_not_msd(i,n)	((i) >= 0)
43 #define is_not_lsd(i,n)	((i) < (n))
44 #else
45 #define big_end(n)	((n) - 1)
46 #define little_end(n)	0
47 #define next_msd(i)	((i) + 1)
48 #define next_lsd(i)	((i) - 1)
49 #define is_not_msd(i,n)	((i) < (n))
50 #define is_not_lsd(i,n)	((i) >= 0)
51 #endif
52