|
|
1.1 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:
38: * PEASANT, MERRITT, UPTON, SMITH -algorithm used for modmult. All defined
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
1.1.1.2 root 81: #ifndef i386 /* gcc */
1.1 root 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
1.1.1.2 root 93: #endif /* i386 */
1.1 root 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
117: #define mp_move( dst, src) _MOVC3( global_precision*4, (char *) src, (char *) dst)
118: #define unitfill0( r, unitcount) _MOVC5( 0, (char *) 0, 0, unitcount*4, (char *) r)
119: #define mp_burn(r) _MOVC5(0, (char *) 0, 0, global_precision*4, (char *) r)
120: #define mp_init0(r) mp_burn(r) /* Just for documentation purposes */
121: #endif /* VAXC */
122:
123: #define PLATFORM_SPECIFIED
124: #endif /* VMS */
125:
126: #ifdef mips
127: /*
128: * Needs r3kd.s and r3000.s (or r3000.c)
129: */
130: #define UNIT32
131: #define MUNIT32
132: #define SMITH
133: #define mp_dmul p_dmul
134: #define mp_setp p_setp
135: #define mp_addc p_addc
136: #define mp_subb p_subb
137: #define mp_rotate_left p_rotl
138: #define mp_smula p_smula
139: #define mp_quo_digit p_quo_digit
140: #define mp_set_recip p_setrecip
141: #define PLATFORM_SPECIFIED
142: #endif /* mips */
143:
144: #ifdef i386
145: /*
146: * Needs 80386.S
147: */
148: #define UNIT32
149: #define MUNIT32
150: #define SMITH
151: #define mp_setp P_SETP
152: #define mp_addc P_ADDC
153: #define mp_subb P_SUBB
154: #define mp_rotate_left P_ROTL
155: #define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit))
156: #define mp_smula P_SMULA
157: #define mp_quo_digit p_quo_digit
158: #define mp_set_recip p_setrecip
159: #define PLATFORM_SPECIFIED
160: #endif /* i386 */
161:
162: #ifdef sparc
163: /*
164: * Needs sparc.s
165: */
166: #define UNIT32
167: #define MERRITT
168: #define mp_setp P_SETP
169: #define mp_addc P_ADDC
170: #define mp_subb P_SUBB
171: #define mp_rotate_left P_ROTL
172: #define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit))
173: #define PLATFORM_SPECIFIED
174: #endif /* sparc */
175:
1.1.1.2 root 176: #if defined(mc68000) || defined(mc68020)
177: /*
178: * Needs mc68020.S
179: */
180: #define UNIT32
181: #define mp_setp P_SETP
182: #define mp_addc P_ADDC
183: #define mp_subb P_SUBB
184: #define mp_rotate_left P_ROTL
185: #define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit))
186: #if defined(sun3) || defined(mc68020)
187: # define UPTON
188: # define MUNIT32
189: # define mp_smul P_SMUL
1.1.1.3 ! root 190: /* # define mp_dmul P_DMUL */ /* mc68020.s has a bug in P_DMUL */
1.1.1.2 root 191: #else
192: # define SMITH
193: # define MUNIT16
194: #endif
195: #define PLATFORM_SPECIFIED
196: #endif /* mc68000 */
197:
1.1 root 198: /* Add additional platforms here ... */
199:
200: /**************** End of system specification ************************/
201:
202: #ifndef PLATFORM_SPECIFIED
203: /* No platform explicitly selected. Customization is controlled by
204: * PORTABLE and MPORTABLE.
205: */
206: #define mp_setp P_SETP
207: #define mp_addc P_ADDC
208: #define mp_subb P_SUBB
209: #define mp_rotate_left P_ROTL
210: #define UPTON
211: #define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit))
212: #ifndef MPORTABLE
213: #define mp_smul P_SMUL
214: #endif /* MPORTABLE */
215: #endif /* PLATFORM_SPECIFIED */
216: #endif /* PORTABLE */
217: #endif /* PLATFORM_H */
218:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.