1 | /*
|
---|
2 | (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
---|
3 | See the copyright notice in the ACK home directory, in the file "Copyright".
|
---|
4 | */
|
---|
5 |
|
---|
6 | /* $Header: /cvsup/minix/src/lib/ack/float/get_put.h,v 1.1 2005/10/10 15:27:43 beng Exp $ */
|
---|
7 |
|
---|
8 | #include <byte_order.h>
|
---|
9 |
|
---|
10 | #if CHAR_UNSIGNED
|
---|
11 | #define Xchar(ch) (ch)
|
---|
12 | #else
|
---|
13 | #define Xchar(ch) ((ch) & 0377)
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | #define BYTES_REVERSED (MSB_AT_LOW_ADDRESS != FL_MSB_AT_LOW_ADDRESS)
|
---|
17 | #define WORDS_REVERSED (MSW_AT_LOW_ADDRESS != FL_MSW_AT_LOW_ADDRESS)
|
---|
18 | #define LONGS_REVERSED (FL_MSL_AT_LOW_ADDRESS)
|
---|
19 |
|
---|
20 | #if BYTES_REVERSED
|
---|
21 | #define uget2(c) (Xchar((c)[1]) | ((unsigned) Xchar((c)[0]) << 8))
|
---|
22 | #define Xput2(i, c) (((c)[1] = (i)), ((c)[0] = (i) >> 8))
|
---|
23 | #define put2(i, c) { register int j = (i); Xput2(j, c); }
|
---|
24 | #else
|
---|
25 | #define uget2(c) (* ((unsigned short *) (c)))
|
---|
26 | #define Xput2(i, c) (* ((short *) (c)) = (i))
|
---|
27 | #define put2(i, c) Xput2(i, c)
|
---|
28 | #endif
|
---|
29 |
|
---|
30 | #define get2(c) ((short) uget2(c))
|
---|
31 |
|
---|
32 | #if WORDS_REVERSED || BYTES_REVERSED
|
---|
33 | #define get4(c) (uget2((c)+2) | ((long) uget2(c) << 16))
|
---|
34 | #define put4(l, c) { register long x=(l); \
|
---|
35 | Xput2((int)x,(c)+2); \
|
---|
36 | Xput2((int)(x>>16),(c)); \
|
---|
37 | }
|
---|
38 | #else
|
---|
39 | #define get4(c) (* ((long *) (c)))
|
---|
40 | #define put4(l, c) (* ((long *) (c)) = (l))
|
---|
41 | #endif
|
---|