Subversion Repositories tendra.SVN

Rev

Rev 5 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 6
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
29
 
59
 
30
 
60
 
31
/* 	cross.h,v 1.3 1995/05/23 10:54:50 john Exp	 */
61
/* 	cross.h,v 1.3 1995/05/23 10:54:50 john Exp	 */
32
 
62
 
33
/*
63
/*
34
  cross.h
64
  cross.h
35
 
65
 
36
  This file contains a set of macros & function declarations 
66
  This file contains a set of macros & function declarations
37
  to process the 64 bit integer type INT64.  If compiling on a 
67
  to process the 64 bit integer type INT64.  If compiling on a
38
  platform with 64 bit longs, INT64 can be represented as a 
68
  platform with 64 bit longs, INT64 can be represented as a
39
  long and the operations can be implemented by macros expanding 
69
  long and the operations can be implemented by macros expanding
40
  to the simple arithmetic operations.  If, however, a 64 bit 
70
  to the simple arithmetic operations.  If, however, a 64 bit
41
  integral type is not available, then INT64 is represented 
71
  integral type is not available, then INT64 is represented
42
  by the flt64 type (see flpttypes.h) and the operations are 
72
  by the flt64 type (see flpttypes.h) and the operations are
43
  represented by a set of functions, defined in cross.c
73
  represented by a set of functions, defined in cross.c
44
*/
74
*/
45
 
75
 
46
/*
76
/*
47
  cross.h,v
77
  cross.h,v
Line 68... Line 98...
68
/*typedef char bool;*/
98
/*typedef char bool;*/
69
#include "output.h"
99
#include "output.h"
70
#include "flpttypes.h"
100
#include "flpttypes.h"
71
#include "exptypes.h"
101
#include "exptypes.h"
72
#include "common_types.h"
102
#include "common_types.h"
73
extern flt64 exp_to_f64 PROTO_S ((exp));
103
extern flt64 exp_to_f64(exp);
74
typedef int INT32;
104
typedef int INT32;
75
typedef unsigned int UINT32;
105
typedef unsigned int UINT32;
76
#define int8 char
106
#define int8 char
77
#define int16 short
107
#define int16 short
78
#define int32 int
108
#define int32 int
79
 
109
 
80
#define is64(X)	((name(X)==u64hd)||(name(X)==s64hd)||(name(X)==ptrhd))
110
#define is64(X)	((name(X) ==u64hd) || (name(X) ==s64hd) || (name(X) ==ptrhd))
81
#define is32(X) ((name(X)==slonghd)||(name(X)==ulonghd))
111
#define is32(X)((name(X) ==slonghd) || (name(X) ==ulonghd))
82
 
112
 
83
/* some macros to access the fields of the flt64/INT64 type */
113
/* some macros to access the fields of the flt64/INT64 type */
84
#if FS_64_BIT /* 64 bit ints can be represented as longs */
114
#if FS_64_BIT /* 64 bit ints can be represented as longs */
85
typedef long INT64;
115
typedef long INT64;
86
#define clear_INT64(x)	((x)=0)
116
#define clear_INT64(x)	((x) =0)
87
#define low_INT64(x)	(x)
117
#define low_INT64(x)	(x)
88
#define isquad(x)	((unsigned long)(x)>UINT_MAX)
118
#define isquad(x)	((unsigned long)(x) >UINT_MAX)
89
 
119
 
90
#define INT64_assign(x,y) ((x) = (y))
120
#define INT64_assign(x,y)((x) = (y))
91
#define out_INT64(x) (void)outlong((x))
121
#define out_INT64(x)(void)outlong((x))
92
#define INT64_mult(x,y,z) ((z)?((x)*(y)):((unsigned long)((x)*(y))))
122
#define INT64_mult(x,y,z)((z)?((x)*(y)):((unsigned long)((x)*(y))))
93
#if 0
123
#if 0
94
#define INT64_divide(x,y,z) ((z)?((x)/(y)):(unsigned long)((x)/(y)))
124
#define INT64_divide(x,y,z)((z)?((x) / (y)):(unsigned long)((x) / (y)))
95
#else
125
#else
96
#define INT64_divide(x,y,z) ((x)/(y))
126
#define INT64_divide(x,y,z)((x) / (y))
97
#endif
127
#endif
98
#define INT64_mod(x,y,z) ((x)%(y))
128
#define INT64_mod(x,y,z)((x)%(y))
99
#define INT64_add(x,y,z) ((z)?((x)+(y)):(unsigned long)((x)+(y)))
129
#define INT64_add(x,y,z)((z)?((x) + (y)):(unsigned long)((x) + (y)))
100
#if 0
130
#if 0
101
#define INT64_subtract(x,y,z) ((z)?((x)-(y)):(unsigned long)((x)-(y)))
131
#define INT64_subtract(x,y,z)((z)?((x) - (y)):(unsigned long)((x) - (y)))
102
#else
132
#else
103
#define INT64_subtract(x,y,z) ((x)-(y))
133
#define INT64_subtract(x,y,z)((x) - (y))
104
#endif
134
#endif
105
#define INT64_increment(x) ((x)+1)
135
#define INT64_increment(x)((x) +1)
106
#define INT64_decrement(x) ((x)-1)
136
#define INT64_decrement(x)((x) -1)
107
#define INT64_or(x,y) ((x)|(y))
137
#define INT64_or(x,y)((x) | (y))
108
#define INT64_and(x,y) ((x)&(y))
138
#define INT64_and(x,y)((x) & (y))
109
#define INT64_not(x) (~(x))
139
#define INT64_not(x)(~(x))
110
#define INT64_xor(x,y) ((x)^(y))
140
#define INT64_xor(x,y)((x)^(y))
111
#define INT64_shift_left(x,y,z) ((x)<<(y))
141
#define INT64_shift_left(x,y,z)((x) << (y))
112
#define INT64_shift_right(x,y,z) ((x)>>(y))
142
#define INT64_shift_right(x,y,z)((x) >> (y))
113
#define INT64_eq(x,y) ((x)==(y))
143
#define INT64_eq(x,y)((x) == (y))
114
#define INT64_leq(x,y) ((x)<=(y))
144
#define INT64_leq(x,y)((x) <= (y))
115
#define INT64_lt(x,y) ((x)<(y))
145
#define INT64_lt(x,y)((x) < (y))
116
#define INT64_abs(x) (((x)>0)?(x):-(x))
146
#define INT64_abs(x)(((x) >0)?(x):- (x))
117
#define make_INT64(big,small)	((small)+(((long)(big))<<32))
147
#define make_INT64(big,small)	((small) + (((long)(big)) <<32))
118
#define umax 0xffffffffffffffffUL
148
#define umax 0xffffffffffffffffUL
119
#define smin 0x8000000000000000L
149
#define smin 0x8000000000000000L
120
#define zero_int64 0L
150
#define zero_int64 0L
121
 
151
 
122
#else	/* no 64 bit integral type available, use a struct of 2 32s */
152
#else	/* no 64 bit integral type available, use a struct of 2 32s */
Line 125... Line 155...
125
#define low_INT64(x)	(x).small
155
#define low_INT64(x)	(x).small
126
#define high_INT64(x)	(x).big
156
#define high_INT64(x)	(x).big
127
#define isquad(x)	((x).big!=0)
157
#define isquad(x)	((x).big!=0)
128
#define flt64_to_INT64(x) (x)		/* the types are identical */
158
#define flt64_to_INT64(x) (x)		/* the types are identical */
129
 
159
 
130
#define INT64_assign(x,y) ((x) = (y))
160
#define INT64_assign(x,y)((x) = (y))
131
void out_INT64 PROTO_S ((INT64));
161
void out_INT64(INT64);
132
INT64 INT64_mult PROTO_S ((INT64,INT64,bool));
162
INT64 INT64_mult(INT64,INT64,bool);
133
INT64 INT64_divide PROTO_S ((INT64,INT64,bool));
163
INT64 INT64_divide(INT64,INT64,bool);
134
INT64 INT64_add PROTO_S ((INT64,INT64,bool));
164
INT64 INT64_add(INT64,INT64,bool);
135
INT64 INT64_subtract PROTO_S ((INT64,INT64,bool));
165
INT64 INT64_subtract(INT64,INT64,bool);
136
INT64 INT64_mod PROTO_S ((INT64,INT64,bool));
166
INT64 INT64_mod(INT64,INT64,bool);
137
 
-
 
138
INT64 INT64_increment PROTO_S ((INT64));
-
 
139
INT64 INT64_decrement PROTO_S ((INT64));
-
 
140
 
-
 
141
INT64 INT64_or PROTO_S ((INT64,INT64));
-
 
142
INT64 INT64_and PROTO_S ((INT64,INT64));
-
 
143
INT64 INT64_not PROTO_S ((INT64));
-
 
144
INT64 INT64_xor PROTO_S ((INT64,INT64));
-
 
145
 
-
 
146
INT64 INT64_shift_left PROTO_S ((INT64,int,int));
-
 
147
INT64 INT64_shift_right PROTO_S ((INT64,int,int));
-
 
148
 
167
 
149
bool INT64_eq  PROTO_S ((INT64,INT64));
168
INT64 INT64_increment(INT64);
150
bool INT64_leq PROTO_S ((INT64,INT64));
169
INT64 INT64_decrement(INT64);
151
bool INT64_lt  PROTO_S ((INT64,INT64));
-
 
152
 
170
 
-
 
171
INT64 INT64_or(INT64,INT64);
-
 
172
INT64 INT64_and(INT64,INT64);
-
 
173
INT64 INT64_not(INT64);
-
 
174
INT64 INT64_xor(INT64,INT64);
-
 
175
 
-
 
176
INT64 INT64_shift_left(INT64,int,int);
-
 
177
INT64 INT64_shift_right(INT64,int,int);
-
 
178
 
-
 
179
bool INT64_eq(INT64,INT64);
-
 
180
bool INT64_leq(INT64,INT64);
-
 
181
bool INT64_lt(INT64,INT64);
-
 
182
 
153
INT64 make_INT64 PROTO_S ((INT32,UINT32));
183
INT64 make_INT64(INT32,UINT32);
154
 
184
 
155
#define umax {0xffffffff,0xffffffff}
185
#define umax {0xffffffff,0xffffffff}
156
#define smin {0x80000000,0x00000000}
186
#define smin {0x80000000,0x00000000}
157
#define zero_int64 make_INT64(0,0)
187
#define zero_int64 make_INT64(0,0)
158
/*#define zero_int64 {0,0}*/
188
/*#define zero_int64 {0,0}*/
159
#endif 	/* #if alpha */
189
#endif 	/* #if alpha */
160
 
190
 
161
INT64  flt64_to_INT64 PROTO_S ((flt64));
191
INT64  flt64_to_INT64(flt64);
162
INT64  exp_to_INT64 PROTO_S ((exp));
192
INT64  exp_to_INT64(exp);
-
 
193
 
-
 
194
 
-
 
195
#endif	/* #ifndef CROSS_H */
-
 
196
 
-
 
197
 
163
 
198
 
164
 
199
 
165
#endif	/* #ifndef CROSS_H */
-
 
166
 
200
 
167
			 
-
 
168
 
201
 
169
			   
-
 
170
  
-
 
171
   
-