|
|
1.1.1.5 root 1: /* platform.h - computer platform customization for PGP
2: multiprecision math package. #Included in mpilib.h.
3: */
4: #ifndef PLATFORM_H
5: #define PLATFORM_H
6:
7: /* Platform customization:
8: * A version which runs on almost any computer can be implemented by
9: * defining PORTABLE and MPORTABLE, preferably as a command line
10: * parameter. Faster versions can be generated by specifying specific
11: * parameters, such as size of unit and MULTUNIT, and by supplying some
12: * of the critical in assembly.
13: *
14: * This file holds customizations for different environments.
15: * This is done in one of two ways:
16: * 1. A symbol is defined on the command line which designates a
17: * particular environment, such as MSDOS. This file detects the
18: * environment symbol and sets the appropriate low-level defines.
19: *
20: * 2. If no environment is named, the low-level defines are set in
21: * the same manner as for PGP 2.0, thereby providing an easy upgrade.
22: *
23: * Following are a description of the low-level definition symbols:
24: *
25: * The following preprocessor symbols should be conditionally set to
26: * optimize for a particular environment.
27: *
28: * Define one of the following:
29: * UNIT8, UNIT16, or UNIT32 - specifies size of operands for
30: * multiprecision add, subtract, shift, and initialization operations.
31: * Define one of the following:
32: * MUNIT8, MUNIT16, MUNIT32 - specified size of operands for
33: * multiprecision multiply and mod_mult. This must be less than or
34: * equal to unit size. It should be the word size for the native
35: * atomic multiply instruction. For a 16x16 bit multiply yielding a
36: * 32-bit product, MUNIT16 should be set.
37: * Define one (or more) of the following:
1.1.1.6 ! root 38: * PEASANT, MERRITT, UPTON, SMITH -algorithm used for modmult.All defined
1.1.1.5 root 39: * algorithms are compiled, but the first defined name listed will be
40: * assigned to the generic entry point symbols. Multiple algorithms are
41: * used primarily for testing.
42: * HIGHFIRST - specified if longs are stored with the most significant
43: * bit at the lowest address (Motorola), undefined otherwise. This should
44: * be defined on the command line, normally in the makefile.
45: *
46: * The following symbol, if initialized, is set to specific values:
47: * ALIGN - variable declaration attribute which forces optimum alignment
48: * of words, e.g. for VAX C: ALIGN=_align(quadword)
49: *
50: * The following symbols correspond to individual multiprecision routines
51: * that may be implemented with assembly language. If they are implemented
52: * in assembly, the symbols should be defined with the name of the
53: * corresponding external entry points, e.g., mp_addc=P_ADDC
54: * mp_setp - set precision for external routines
55: * mp_addc - add with carry
56: * mp_subb - subtract with borrow
57: * mp_rotate_left - rotate left
58: * mp_compare - compare
59: * mp_move - move
60: * unitfill0 - zero fill
61: * mp_smul - multiply vector by single word *
62: * mp_smula - multiply vector by single word and accumulate *
63: * mp_dmul - full multiply
64: * mp_set_recip - setup for mp_quo_digit
65: * mp_quo_digit - quotient digit for modulus reduction
66: *
67: * Either mp_smul or mp_smula should be defined. mp_smula provides
68: * for accumulation to an existing value, while mp_smul is for use of the
69: * older definition of mp_smul, used in PGP 2.0, which assumed that the high
70: * order accumulator word is zero. Use of mp_smula causes one less word of
71: * precision to be used, thereby slightly increasing speed.
72: */
73:
74: /********************************************************************
75: * Environment customization. Please send any additions or corrections
76: * to Philip Zimmermann.
77: */
78: #ifndef PORTABLE
79:
80: #ifdef MSDOS
81: #ifndef i386 /* gcc */
82: #define UNIT16
83: #define MUNIT16
84: #define mp_setp P_SETP
85: #define mp_addc P_ADDC
86: #define mp_subb P_SUBB
87: #define mp_rotate_left P_ROTL
88: #define mp_smula P_SMULA
89: #define mp_quo_digit P_QUO_DIGIT
90: #define mp_set_recip P_SETRECIP
91: #define SMITH
92: #define PLATFORM_SPECIFIED
93: #endif /* i386 */
94: #endif /* MSDOS */
95:
96: #ifdef VMS
97: #define UNIT32 /* use 32-bit units */
98: #define MUNIT32 /* not used in C code, only in assembler */
99: #define UPTON
100: #define mp_setp p_setp
101: #define mp_addc p_addc
102: #define mp_subb p_subb
103: #define mp_rotate_left p_rotl
104: #define mp_smul p_smul
105: #define mp_dmul p_dmul
106: #define mp_compare p_cmp
107: #define ALIGN _align(quadword)
108:
109: #ifdef VAXC
110: /*
111: * A VAX is a CISC machine. Unfortunately C is at to low a level to use
112: * many of the instruction set enhancements so we define some macros
113: * here that implement fast moves and fast zero fills with single
114: * instructions.
115: */
116: #pragma builtins
1.1.1.6 ! root 117: #define mp_move( dst, src) _MOVC3( global_precision*4, (char *) src, \
! 118: (char *) dst)
! 119: #define unitfill0( r, unitcount) _MOVC5( 0, (char *) 0, 0, unitcount*4, \
! 120: (char *) r)
1.1.1.5 root 121: #define mp_burn(r) _MOVC5(0, (char *) 0, 0, global_precision*4, (char *) r)
122: #define mp_init0(r) mp_burn(r) /* Just for documentation purposes */
123: #endif /* VAXC */
124:
125: #define PLATFORM_SPECIFIED
126: #endif /* VMS */
127:
128: #if defined(mips) || defined(__mips)
129: /*
130: * Needs r3kd.s and r3000.s (or r3000.c)
131: */
132: #define UNIT32
133: #define MUNIT32
134: #define SMITH
135: #define mp_dmul p_dmul
136: #define mp_setp p_setp
137: #define mp_addc p_addc
138: #define mp_subb p_subb
139: #define mp_rotate_left p_rotl
140: #define mp_smula p_smula
141: #define mp_quo_digit p_quo_digit
142: #define mp_set_recip p_setrecip
143: #define PLATFORM_SPECIFIED
144: #endif /* mips */
145:
146: #ifdef i386
147: /*
148: * Needs 80386.S
149: */
150: #define UNIT32
151: #define MUNIT32
152: #define SMITH
153: #define mp_setp P_SETP
154: #define mp_addc P_ADDC
155: #define mp_subb P_SUBB
156: #define mp_rotate_left P_ROTL
157: #define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit))
158: #define mp_smula P_SMULA
159: #define mp_quo_digit p_quo_digit
160: #define mp_set_recip p_setrecip
161: #define PLATFORM_SPECIFIED
162: #endif /* i386 */
163:
164: #ifdef sparc
165: /*
166: * Needs sparc.s
167: */
168: #define UNIT32
169: #define MERRITT
170: #define mp_setp P_SETP
171: #define mp_addc P_ADDC
172: #define mp_subb P_SUBB
173: #define mp_rotate_left P_ROTL
174: #define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit))
175: #define PLATFORM_SPECIFIED
176: #endif /* sparc */
177:
178: #if defined(mc68000) || defined(mc68020)
179: /*
180: * Needs mc68020.S
181: */
182: #define UNIT32
183: #define mp_setp P_SETP
184: #define mp_addc P_ADDC
185: #define mp_subb P_SUBB
186: #define mp_rotate_left P_ROTL
187: #define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit))
188: #if defined(sun3) || defined(mc68020)
189: # define UPTON
190: # define MUNIT32
191: # define mp_smul P_SMUL
192: /* # define mp_dmul P_DMUL */ /* mc68020.s has a bug in P_DMUL */
193: #else
194: # define SMITH
195: # define MUNIT16
196: #endif
197: #define PLATFORM_SPECIFIED
198: #endif /* mc68000 */
199:
200: /* Add additional platforms here ... */
201:
202: /**************** End of system specification ************************/
203:
204: #ifndef PLATFORM_SPECIFIED
205: /* No platform explicitly selected. Customization is controlled by
206: * PORTABLE and MPORTABLE.
207: */
208: #define mp_setp P_SETP
209: #define mp_addc P_ADDC
210: #define mp_subb P_SUBB
211: #define mp_rotate_left P_ROTL
212: #define UPTON
213: #define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit))
214: #ifndef MPORTABLE
215: #define mp_smul P_SMUL
216: #endif /* MPORTABLE */
217: #endif /* PLATFORM_SPECIFIED */
218: #endif /* PORTABLE */
219: #endif /* PLATFORM_H */
220:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.