Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/* 	cross.h,v 1.3 1995/05/23 10:54:50 john Exp	 */
32
 
33
/*
34
  cross.h
35
 
36
  This file contains a set of macros & function declarations 
37
  to process the 64 bit integer type INT64.  If compiling on a 
38
  platform with 64 bit longs, INT64 can be represented as a 
39
  long and the operations can be implemented by macros expanding 
40
  to the simple arithmetic operations.  If, however, a 64 bit 
41
  integral type is not available, then INT64 is represented 
42
  by the flt64 type (see flpttypes.h) and the operations are 
43
  represented by a set of functions, defined in cross.c
44
*/
45
 
46
/*
47
  cross.h,v
48
 * Revision 1.3  1995/05/23  10:54:50  john
49
 * Minor fixes to 64 bit support
50
 *
51
 * Revision 1.2  1995/05/16  10:46:21  john
52
 * Cosmetic change
53
 *
54
 * Revision 1.1.1.1  1995/03/23  10:39:05  john
55
 * Entered into CVS
56
 *
57
 * Revision 1.11  1995/03/23  10:03:18  john
58
 * Corrected some definitions
59
 *
60
 * Revision 1.10  1995/01/26  13:32:13  john
61
 * Corrected a few macro definitions
62
 *
63
*/
64
 
65
#ifndef CROSS_H
66
#define CROSS_H
67
#include <limits.h>
68
/*typedef char bool;*/
69
#include "output.h"
70
#include "flpttypes.h"
71
#include "exptypes.h"
72
#include "common_types.h"
73
extern flt64 exp_to_f64 PROTO_S ((exp));
74
typedef int INT32;
75
typedef unsigned int UINT32;
76
#define int8 char
77
#define int16 short
78
#define int32 int
79
 
80
#define is64(X)	((name(X)==u64hd)||(name(X)==s64hd)||(name(X)==ptrhd))
81
#define is32(X) ((name(X)==slonghd)||(name(X)==ulonghd))
82
 
83
/* some macros to access the fields of the flt64/INT64 type */
84
#if FS_64_BIT /* 64 bit ints can be represented as longs */
85
typedef long INT64;
86
#define clear_INT64(x)	((x)=0)
87
#define low_INT64(x)	(x)
88
#define isquad(x)	((unsigned long)(x)>UINT_MAX)
89
 
90
#define INT64_assign(x,y) ((x) = (y))
91
#define out_INT64(x) (void)outlong((x))
92
#define INT64_mult(x,y,z) ((z)?((x)*(y)):((unsigned long)((x)*(y))))
93
#if 0
94
#define INT64_divide(x,y,z) ((z)?((x)/(y)):(unsigned long)((x)/(y)))
95
#else
96
#define INT64_divide(x,y,z) ((x)/(y))
97
#endif
98
#define INT64_mod(x,y,z) ((x)%(y))
99
#define INT64_add(x,y,z) ((z)?((x)+(y)):(unsigned long)((x)+(y)))
100
#if 0
101
#define INT64_subtract(x,y,z) ((z)?((x)-(y)):(unsigned long)((x)-(y)))
102
#else
103
#define INT64_subtract(x,y,z) ((x)-(y))
104
#endif
105
#define INT64_increment(x) ((x)+1)
106
#define INT64_decrement(x) ((x)-1)
107
#define INT64_or(x,y) ((x)|(y))
108
#define INT64_and(x,y) ((x)&(y))
109
#define INT64_not(x) (~(x))
110
#define INT64_xor(x,y) ((x)^(y))
111
#define INT64_shift_left(x,y,z) ((x)<<(y))
112
#define INT64_shift_right(x,y,z) ((x)>>(y))
113
#define INT64_eq(x,y) ((x)==(y))
114
#define INT64_leq(x,y) ((x)<=(y))
115
#define INT64_lt(x,y) ((x)<(y))
116
#define INT64_abs(x) (((x)>0)?(x):-(x))
117
#define make_INT64(big,small)	((small)+(((long)(big))<<32))
118
#define umax 0xffffffffffffffffUL
119
#define smin 0x8000000000000000L
120
#define zero_int64 0L
121
 
122
#else	/* no 64 bit integral type available, use a struct of 2 32s */
123
typedef flt64 INT64;
124
#define clear_INT64(x)	{(x).big=0;(x).small=0;}
125
#define low_INT64(x)	(x).small
126
#define high_INT64(x)	(x).big
127
#define isquad(x)	((x).big!=0)
128
#define flt64_to_INT64(x) (x)		/* the types are identical */
129
 
130
#define INT64_assign(x,y) ((x) = (y))
131
void out_INT64 PROTO_S ((INT64));
132
INT64 INT64_mult PROTO_S ((INT64,INT64,bool));
133
INT64 INT64_divide PROTO_S ((INT64,INT64,bool));
134
INT64 INT64_add PROTO_S ((INT64,INT64,bool));
135
INT64 INT64_subtract PROTO_S ((INT64,INT64,bool));
136
INT64 INT64_mod PROTO_S ((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
 
149
bool INT64_eq  PROTO_S ((INT64,INT64));
150
bool INT64_leq PROTO_S ((INT64,INT64));
151
bool INT64_lt  PROTO_S ((INT64,INT64));
152
 
153
INT64 make_INT64 PROTO_S ((INT32,UINT32));
154
 
155
#define umax {0xffffffff,0xffffffff}
156
#define smin {0x80000000,0x00000000}
157
#define zero_int64 make_INT64(0,0)
158
/*#define zero_int64 {0,0}*/
159
#endif 	/* #if alpha */
160
 
161
INT64  flt64_to_INT64 PROTO_S ((flt64));
162
INT64  exp_to_INT64 PROTO_S ((exp));
163
 
164
 
165
#endif	/* #ifndef CROSS_H */
166
 
167
 
168
 
169
 
170
 
171