1 |
3 |
xianfeng |
/*
|
2 |
|
|
-------------------------------------------------------------------------------
|
3 |
|
|
The macro `BITS64' can be defined to indicate that 64-bit integer types are
|
4 |
|
|
supported by the compiler.
|
5 |
|
|
-------------------------------------------------------------------------------
|
6 |
|
|
*/
|
7 |
|
|
#define BITS64
|
8 |
|
|
|
9 |
|
|
/*
|
10 |
|
|
-------------------------------------------------------------------------------
|
11 |
|
|
Each of the following `typedef's defines the most convenient type that holds
|
12 |
|
|
integers of at least as many bits as specified. For example, `uint8' should
|
13 |
|
|
be the most convenient type that can hold unsigned integers of as many as
|
14 |
|
|
8 bits. The `flag' type must be able to hold either a 0 or 1. For most
|
15 |
|
|
implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed
|
16 |
|
|
to the same as `int'.
|
17 |
|
|
-------------------------------------------------------------------------------
|
18 |
|
|
*/
|
19 |
|
|
typedef char flag;
|
20 |
|
|
typedef unsigned char uint8;
|
21 |
|
|
typedef signed char int8;
|
22 |
|
|
typedef int uint16;
|
23 |
|
|
typedef int int16;
|
24 |
|
|
typedef unsigned int uint32;
|
25 |
|
|
typedef signed int int32;
|
26 |
|
|
#ifdef BITS64
|
27 |
|
|
typedef unsigned long long int bits64;
|
28 |
|
|
typedef signed long long int sbits64;
|
29 |
|
|
#endif
|
30 |
|
|
|
31 |
|
|
/*
|
32 |
|
|
-------------------------------------------------------------------------------
|
33 |
|
|
Each of the following `typedef's defines a type that holds integers
|
34 |
|
|
of _exactly_ the number of bits specified. For instance, for most
|
35 |
|
|
implementation of C, `bits16' and `sbits16' should be `typedef'ed to
|
36 |
|
|
`unsigned short int' and `signed short int' (or `short int'), respectively.
|
37 |
|
|
-------------------------------------------------------------------------------
|
38 |
|
|
*/
|
39 |
|
|
typedef unsigned char bits8;
|
40 |
|
|
typedef signed char sbits8;
|
41 |
|
|
typedef unsigned short int bits16;
|
42 |
|
|
typedef signed short int sbits16;
|
43 |
|
|
typedef unsigned int bits32;
|
44 |
|
|
typedef signed int sbits32;
|
45 |
|
|
#ifdef BITS64
|
46 |
|
|
typedef unsigned long long int uint64;
|
47 |
|
|
typedef signed long long int int64;
|
48 |
|
|
#endif
|
49 |
|
|
|
50 |
|
|
#ifdef BITS64
|
51 |
|
|
/*
|
52 |
|
|
-------------------------------------------------------------------------------
|
53 |
|
|
The `LIT64' macro takes as its argument a textual integer literal and if
|
54 |
|
|
necessary ``marks'' the literal as having a 64-bit integer type. For
|
55 |
|
|
example, the Gnu C Compiler (`gcc') requires that 64-bit literals be
|
56 |
|
|
appended with the letters `LL' standing for `long long', which is `gcc's
|
57 |
|
|
name for the 64-bit integer type. Some compilers may allow `LIT64' to be
|
58 |
|
|
defined as the identity macro: `#define LIT64( a ) a'.
|
59 |
|
|
-------------------------------------------------------------------------------
|
60 |
|
|
*/
|
61 |
|
|
#define LIT64( a ) a##LL
|
62 |
|
|
#endif
|
63 |
|
|
|
64 |
|
|
/*
|
65 |
|
|
-------------------------------------------------------------------------------
|
66 |
|
|
The macro `INLINE' can be used before functions that should be inlined. If
|
67 |
|
|
a compiler does not support explicit inlining, this macro should be defined
|
68 |
|
|
to be `static'.
|
69 |
|
|
-------------------------------------------------------------------------------
|
70 |
|
|
*/
|
71 |
|
|
#define INLINE static inline
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
/* For use as a GCC soft-float library we need some special function names. */
|
75 |
|
|
|
76 |
|
|
#ifdef __LIBFLOAT__
|
77 |
|
|
|
78 |
|
|
/* Some 32-bit ops can be mapped straight across by just changing the name. */
|
79 |
|
|
#define float32_add __addsf3
|
80 |
|
|
#define float32_sub __subsf3
|
81 |
|
|
#define float32_mul __mulsf3
|
82 |
|
|
#define float32_div __divsf3
|
83 |
|
|
#define int32_to_float32 __floatsisf
|
84 |
|
|
#define float32_to_int32_round_to_zero __fixsfsi
|
85 |
|
|
#define float32_to_uint32_round_to_zero __fixunssfsi
|
86 |
|
|
|
87 |
|
|
/* These ones go through the glue code. To avoid namespace pollution
|
88 |
|
|
we rename the internal functions too. */
|
89 |
|
|
#define float32_eq ___float32_eq
|
90 |
|
|
#define float32_le ___float32_le
|
91 |
|
|
#define float32_lt ___float32_lt
|
92 |
|
|
|
93 |
|
|
/* All the 64-bit ops have to go through the glue, so we pull the same
|
94 |
|
|
trick. */
|
95 |
|
|
#define float64_add ___float64_add
|
96 |
|
|
#define float64_sub ___float64_sub
|
97 |
|
|
#define float64_mul ___float64_mul
|
98 |
|
|
#define float64_div ___float64_div
|
99 |
|
|
#define int32_to_float64 ___int32_to_float64
|
100 |
|
|
#define float64_to_int32_round_to_zero ___float64_to_int32_round_to_zero
|
101 |
|
|
#define float64_to_uint32_round_to_zero ___float64_to_uint32_round_to_zero
|
102 |
|
|
#define float64_to_float32 ___float64_to_float32
|
103 |
|
|
#define float32_to_float64 ___float32_to_float64
|
104 |
|
|
#define float64_eq ___float64_eq
|
105 |
|
|
#define float64_le ___float64_le
|
106 |
|
|
#define float64_lt ___float64_lt
|
107 |
|
|
|
108 |
|
|
#if 0
|
109 |
|
|
#define float64_add __adddf3
|
110 |
|
|
#define float64_sub __subdf3
|
111 |
|
|
#define float64_mul __muldf3
|
112 |
|
|
#define float64_div __divdf3
|
113 |
|
|
#define int32_to_float64 __floatsidf
|
114 |
|
|
#define float64_to_int32_round_to_zero __fixdfsi
|
115 |
|
|
#define float64_to_uint32_round_to_zero __fixunsdfsi
|
116 |
|
|
#define float64_to_float32 __truncdfsf2
|
117 |
|
|
#define float32_to_float64 __extendsfdf2
|
118 |
|
|
#endif
|
119 |
|
|
|
120 |
|
|
#endif
|