xref: /csrg-svn/lib/libc/quad/quad.h (revision 53453)
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.2 (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 #include <stddef.h>
15 
16 #define	BITS_PER_WORD	(NBBY * sizeof(long))
17 
18 #ifndef SItype
19 #define SItype long int
20 #endif
21 
22 /* long long ints are pairs of long ints in the order determined by
23    WORDS_BIG_ENDIAN.  */
24 
25 #ifdef WORDS_BIG_ENDIAN
26   struct longlong {long high, low;};
27 #else
28   struct longlong {long low, high;};
29 #endif
30 
31 /* We need this union to unpack/pack longlongs, since we don't have
32    any arithmetic yet.  Incoming long long parameters are stored
33    into the `ll' field, and the unpacked result is read from the struct
34    longlong.  */
35 
36 typedef union
37 {
38   struct longlong s;
39   long long ll;
40   SItype i[2];
41   unsigned SItype ui[2];
42 } long_long;
43 
44 /* Internally, long long ints are strings of unsigned shorts in the
45    order determined by BYTES_BIG_ENDIAN.  */
46 
47 #define B 0x10000
48 #define low16 (B - 1)
49 
50 #ifdef BYTES_BIG_ENDIAN
51 
52 /* Note that HIGH and LOW do not describe the order
53    of words in a long long.  They describe the order of words
54    in vectors ordered according to the byte order.  */
55 
56 #define HIGH 0
57 #define LOW 1
58 
59 #define big_end(n)	0
60 #define little_end(n)	((n) - 1)
61 #define next_msd(i)	((i) - 1)
62 #define next_lsd(i)	((i) + 1)
63 #define is_not_msd(i,n)	((i) >= 0)
64 #define is_not_lsd(i,n)	((i) < (n))
65 
66 #else
67 
68 #define LOW 0
69 #define HIGH 1
70 
71 #define big_end(n)	((n) - 1)
72 #define little_end(n)	0
73 #define next_msd(i)	((i) + 1)
74 #define next_lsd(i)	((i) - 1)
75 #define is_not_msd(i,n)	((i) < (n))
76 #define is_not_lsd(i,n)	((i) >= 0)
77 
78 #endif
79