--- pgp/src/platform.h 2018/04/24 16:41:20 1.1.1.4 +++ pgp/src/platform.h 2018/04/24 16:45:49 1.1.1.7 @@ -35,7 +35,7 @@ * atomic multiply instruction. For a 16x16 bit multiply yielding a * 32-bit product, MUNIT16 should be set. * Define one (or more) of the following: - * PEASANT, MERRITT, UPTON, SMITH -algorithm used for modmult. All defined + * PEASANT, MERRITT, UPTON, SMITH -algorithm used for modmult.All defined * algorithms are compiled, but the first defined name listed will be * assigned to the generic entry point symbols. Multiple algorithms are * used primarily for testing. @@ -94,9 +94,29 @@ #endif /* MSDOS */ #ifdef VMS + +#ifdef __DECC +#define _VMS_DECC /* Compiler is DECC */ +#ifdef __alpha +#define _VMS_ALPHA /* Platform alpha */ +#define _VMS_T_PLATFORM "DECC/Alpha" +#endif +#ifdef __vax +#define _VMS_VAX /* Platform VAX */ +#define _VMS_T_PLATFORM "DECC/VAX" +#endif +#else /* #ifdef __DECC */ +#ifdef VAXC +#define _VMS_VAX /* Platform _must_ be VAX for VAXC w/o __DECC */ +#define _VMS_VAXC /* Compiler _is_ VAXC */ +#define _VMS_T_PLATFORM "VAXC/VAX" +#endif /* #ifdef VAXC */ +#endif /* #else (#ifdef __DECC) */ + #define UNIT32 /* use 32-bit units */ -#define MUNIT32 /* not used in C code, only in assembler */ +#define MUNIT16 /* not used in C code, only in assembler */ #define UPTON +#ifndef __ALPHA #define mp_setp p_setp #define mp_addc p_addc #define mp_subb p_subb @@ -104,24 +124,24 @@ #define mp_smul p_smul #define mp_dmul p_dmul #define mp_compare p_cmp +#endif #define ALIGN _align(quadword) -#ifdef VAXC -/* - * A VAX is a CISC machine. Unfortunately C is at to low a level to use - * many of the instruction set enhancements so we define some macros - * here that implement fast moves and fast zero fills with single - * instructions. - */ #pragma builtins -#define mp_move( dst, src) _MOVC3( global_precision*4, (char *) src, (char *) dst) +#ifdef __DECC +#define mp_move( dst, src) memcpy((char *) dst,(char *) src, global_precision*4) +#define unitfill0( r, unitcount) memset( (char *) r, 0, unitcount*4) +#define mp_burn(r) memset( (char *) r, 0, global_precision*4) +#define mp_init0(r) mp_burn(r) /* Just for documentation purposes */ +#else +#define mp_move( dst, src) _MOVC3( global_precision*4, (char *) src, (char *) dst) #define unitfill0( r, unitcount) _MOVC5( 0, (char *) 0, 0, unitcount*4, (char *) r) #define mp_burn(r) _MOVC5(0, (char *) 0, 0, global_precision*4, (char *) r) #define mp_init0(r) mp_burn(r) /* Just for documentation purposes */ -#endif /* VAXC */ +#endif /* __DECC */ #define PLATFORM_SPECIFIED -#endif /* VMS */ +#endif /* #ifdef VMS */ #if defined(mips) || defined(__mips) /* @@ -195,6 +215,96 @@ #define PLATFORM_SPECIFIED #endif /* mc68000 */ +#ifdef AMIGA +#define UNIT32 +#define mp_addc P_ADDC +#define mp_subb P_SUBB +#define mp_rotate_left P_ROTL +#define mp_setp P_SETP +#ifdef _M68020 +#define mp_smul P_SMUL +#define UPTON +#define MUNIT32 /* 32-bit multiplies for >=68020 */ +#else /* _M68020 */ +#define SMITH +#define MUNIT16 +#endif /* _M68020 */ +#define PLATFORM_SPECIFIED +#endif /* AMIGA */ + +/* + * Notes on the WIN32 port: (David Boreham davidb@daylight.demon.co.uk) + * + * The port is very lightweight, save for the assembler routines for MP arithmetic. + * In general, the old DOS code is used, except where it is broken for NT and Win95, + * for example we don't use short pathnames or fold filenames to lowercase. + * The MP arithmetic routines in PGP can work in a portable mode using the MERRITT + * code. This is very much slower than Thad Smith's code. Unfortunately, Thad's + * code assumes that sizeof(long) > sizeof (int), which is not the case in Win32. + * This means that his C code will not work. I have re-implemented his 8086 assembler + * in 386 code, optimised for the Pentium pipeline. This works fine and if you're + * building for one of the 386 compatible processors (386, 486, Pentium, clones etc.) + * define USE_WIN_ASSEMBLER in the project options and build that version. + * If you're building for another processor (PowerPC, MIPS, Alpha) then you need to + * either a) write assembler routines for those processors (and send the code back + * for inclusion in the distribution) or b) use the portable, slower, code by not + * defining USE_WIN32_ASSEMBLER. + * The assembler code needs the Microsoft compiler. The non-assembler version + * should work with any compiler. I've not tested any other compilers. + * I've done extensive profiling on this and other versions of PGP on NT. + * Some of the optimisations I've tried out are not in this code because they + * didn't give a significant performance improvement, but did make the code + * rather un-portable back to the other supported platforms (DOS, OS/2 etc). + * Lastly, if you're underwhelmed by the speed of this PGP compared to the + * old 16-bit DOS version, don't blame me: PGP uses the IDEA encryption + * system, which is inherently 16-bit. It also suffers from some rather + * poor I/O code design, which can soak up performance on a proper operating + * system. + */ +#ifdef WIN32 +#define UNIT32 +#ifdef USE_WIN32_ASSEMBLER +#define SMITH +#define MUNIT32 +#else +#define MERRITT +#endif +#define PLATFORM_SPECIFIED +#endif + +#ifdef MACTC5 +/* + * needs mp_macasm.c + */ +#define UNIT32 +#if defined(M68030) || defined(CODEWARRIOR) /* 680[234]0 capable */ +#define MUNIT32 +#else +#define MUNIT16 +#endif +#define mp_setp P_SETP +#define mp_addc P_ADDC +#define mp_subb P_SUBB +#define mp_smul P_SMUL +#define mp_rotate_left P_ROTL +#define UPTON +#define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit)) +#define PLATFORM_SPECIFIED +#endif /* MACTC5 */ + +#ifdef ATARI +#define UNIT32 +#define MUNIT16 +#define mp_setp P_SETP +#define mp_addc P_ADDC +#define mp_subb P_SUBB +#define mp_smul P_SMUL +#define mp_rotate_left P_ROTL +#define UPTON +#define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit)) +#define PLATFORM_SPECIFIED +#endif /* ATARI */ + /* Add additional platforms here ... */ /**************** End of system specification ************************/ @@ -215,4 +325,3 @@ #endif /* PLATFORM_SPECIFIED */ #endif /* PORTABLE */ #endif /* PLATFORM_H */ -