|
|
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 ! 81: #define UNIT16 ! 82: #define MUNIT16 ! 83: #define mp_setp P_SETP ! 84: #define mp_addc P_ADDC ! 85: #define mp_subb P_SUBB ! 86: #define mp_rotate_left P_ROTL ! 87: #define mp_smula P_SMULA ! 88: #define mp_quo_digit P_QUO_DIGIT ! 89: #define mp_set_recip P_SETRECIP ! 90: #define SMITH ! 91: #define PLATFORM_SPECIFIED ! 92: #endif /* MSDOS */ ! 93: ! 94: #ifdef VMS ! 95: #define UNIT32 /* use 32-bit units */ ! 96: #define MUNIT32 /* not used in C code, only in assembler */ ! 97: #define UPTON ! 98: #define mp_setp p_setp ! 99: #define mp_addc p_addc ! 100: #define mp_subb p_subb ! 101: #define mp_rotate_left p_rotl ! 102: #define mp_smul p_smul ! 103: #define mp_dmul p_dmul ! 104: #define mp_compare p_cmp ! 105: #define ALIGN _align(quadword) ! 106: ! 107: #ifdef VAXC ! 108: /* ! 109: * A VAX is a CISC machine. Unfortunately C is at to low a level to use ! 110: * many of the instruction set enhancements so we define some macros ! 111: * here that implement fast moves and fast zero fills with single ! 112: * instructions. ! 113: */ ! 114: #pragma builtins ! 115: #define mp_move( dst, src) _MOVC3( global_precision*4, (char *) src, (char *) dst) ! 116: #define unitfill0( r, unitcount) _MOVC5( 0, (char *) 0, 0, unitcount*4, (char *) r) ! 117: #define mp_burn(r) _MOVC5(0, (char *) 0, 0, global_precision*4, (char *) r) ! 118: #define mp_init0(r) mp_burn(r) /* Just for documentation purposes */ ! 119: #endif /* VAXC */ ! 120: ! 121: #define PLATFORM_SPECIFIED ! 122: #endif /* VMS */ ! 123: ! 124: #ifdef mips ! 125: /* ! 126: * Needs r3kd.s and r3000.s (or r3000.c) ! 127: */ ! 128: #define UNIT32 ! 129: #define MUNIT32 ! 130: #define SMITH ! 131: #define mp_dmul p_dmul ! 132: #define mp_setp p_setp ! 133: #define mp_addc p_addc ! 134: #define mp_subb p_subb ! 135: #define mp_rotate_left p_rotl ! 136: #define mp_smula p_smula ! 137: #define mp_quo_digit p_quo_digit ! 138: #define mp_set_recip p_setrecip ! 139: #define PLATFORM_SPECIFIED ! 140: #endif /* mips */ ! 141: ! 142: #ifdef i386 ! 143: /* ! 144: * Needs 80386.S ! 145: */ ! 146: #define UNIT32 ! 147: #define MUNIT32 ! 148: #define SMITH ! 149: #define mp_setp P_SETP ! 150: #define mp_addc P_ADDC ! 151: #define mp_subb P_SUBB ! 152: #define mp_rotate_left P_ROTL ! 153: #define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit)) ! 154: #define mp_smula P_SMULA ! 155: #define mp_quo_digit p_quo_digit ! 156: #define mp_set_recip p_setrecip ! 157: #define PLATFORM_SPECIFIED ! 158: #endif /* i386 */ ! 159: ! 160: #ifdef sparc ! 161: /* ! 162: * Needs sparc.s ! 163: */ ! 164: #define UNIT32 ! 165: #define MERRITT ! 166: #define mp_setp P_SETP ! 167: #define mp_addc P_ADDC ! 168: #define mp_subb P_SUBB ! 169: #define mp_rotate_left P_ROTL ! 170: #define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit)) ! 171: #define PLATFORM_SPECIFIED ! 172: #endif /* sparc */ ! 173: ! 174: /* Add additional platforms here ... */ ! 175: ! 176: /**************** End of system specification ************************/ ! 177: ! 178: #ifndef PLATFORM_SPECIFIED ! 179: /* No platform explicitly selected. Customization is controlled by ! 180: * PORTABLE and MPORTABLE. ! 181: */ ! 182: #define mp_setp P_SETP ! 183: #define mp_addc P_ADDC ! 184: #define mp_subb P_SUBB ! 185: #define mp_rotate_left P_ROTL ! 186: #define UPTON ! 187: #define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit)) ! 188: #ifndef MPORTABLE ! 189: #define mp_smul P_SMUL ! 190: #endif /* MPORTABLE */ ! 191: #endif /* PLATFORM_SPECIFIED */ ! 192: #endif /* PORTABLE */ ! 193: #endif /* PLATFORM_H */ ! 194:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.