Subversion Repositories tendra.SVN

Rev

Rev 5 | Details | Compare with Previous | Last modification | View Log | RSS feed

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