home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 2 / RISC_DISC_2.iso / pd_share / utilities / cli / pgp2 / src / h / platform < prev    next >
Encoding:
Text File  |  1995-06-06  |  8.2 KB  |  270 lines

  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. #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.  
  98. #ifdef __DECC
  99. #define _VMS_DECC    /* Compiler is DECC */
  100. #ifdef __alpha
  101. #define _VMS_ALPHA    /* Platform alpha */
  102. #define _VMS_T_PLATFORM "DECC/Alpha"
  103. #endif
  104. #ifdef __vax
  105. #define _VMS_VAX    /* Platform VAX */
  106. #define _VMS_T_PLATFORM "DECC/VAX"
  107. #endif
  108. #else            /* #ifdef __DECC */
  109. #ifdef VAXC
  110. #define _VMS_VAX    /* Platform _must_ be VAX for VAXC w/o __DECC */
  111. #define _VMS_VAXC    /* Compiler _is_ VAXC */
  112. #define _VMS_T_PLATFORM "VAXC/VAX"
  113. #endif            /* #ifdef VAXC */
  114. #endif            /* #else (#ifdef __DECC) */
  115.  
  116. #define UNIT32         /* use 32-bit units */
  117. #define MUNIT16        /* not used in C code, only in assembler */
  118. #define UPTON
  119. #ifndef __ALPHA
  120. #define mp_setp        p_setp
  121. #define mp_addc        p_addc
  122. #define mp_subb        p_subb
  123. #define mp_rotate_left    p_rotl
  124. #define mp_smul    p_smul
  125. #define mp_dmul    p_dmul
  126. #define mp_compare    p_cmp
  127. #endif
  128. #define ALIGN _align(quadword)
  129.  
  130. #pragma builtins
  131. #ifdef __DECC
  132. #define mp_move( dst, src)  memcpy((char *) dst,(char *) src, global_precision*4)
  133. #define unitfill0( r, unitcount) memset( (char *) r, 0, unitcount*4)
  134. #define mp_burn(r) memset( (char *) r, 0, global_precision*4)
  135. #define mp_init0(r) mp_burn(r)    /* Just for documentation purposes */
  136. #else
  137. #define mp_move( dst, src)  _MOVC3( global_precision*4, (char *) src, (char *) dst)
  138. #define unitfill0( r, unitcount) _MOVC5( 0, (char *) 0, 0, unitcount*4, (char *) r)
  139. #define mp_burn(r) _MOVC5(0, (char *) 0, 0, global_precision*4, (char *) r)
  140. #define mp_init0(r) mp_burn(r)    /* Just for documentation purposes */
  141. #endif    /* __DECC */
  142.  
  143. #define PLATFORM_SPECIFIED
  144. #endif            /* #ifdef VMS */
  145.  
  146. #if defined(mips) || defined(__mips)
  147. /*
  148.  * Needs r3kd.s and r3000.s (or r3000.c)
  149.  */
  150. #define UNIT32
  151. #define MUNIT32
  152. #define SMITH
  153. #define mp_dmul        p_dmul
  154. #define mp_setp        p_setp
  155. #define mp_addc        p_addc
  156. #define mp_subb        p_subb
  157. #define mp_rotate_left    p_rotl
  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 /* mips */
  163.  
  164. #ifdef i386
  165. /*
  166.  * Needs 80386.S
  167.  */
  168. #define UNIT32
  169. #define MUNIT32
  170. #define SMITH
  171. #define mp_setp        P_SETP
  172. #define mp_addc        P_ADDC
  173. #define mp_subb        P_SUBB
  174. #define mp_rotate_left    P_ROTL
  175. #define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit))
  176. #define mp_smula    P_SMULA
  177. #define mp_quo_digit    p_quo_digit
  178. #define mp_set_recip    p_setrecip
  179. #define PLATFORM_SPECIFIED
  180. #endif /* i386 */
  181.  
  182. #ifdef sparc
  183. /*
  184.  * Needs sparc.s
  185.  */
  186. #define UNIT32
  187. #define MERRITT
  188. #define mp_setp        P_SETP
  189. #define mp_addc        P_ADDC
  190. #define mp_subb        P_SUBB
  191. #define mp_rotate_left    P_ROTL
  192. #define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit))
  193. #define PLATFORM_SPECIFIED
  194. #endif /* sparc */
  195.  
  196. #if defined(mc68000) || defined(mc68020)
  197. /*
  198.  * Needs mc68020.S
  199.  */
  200. #define UNIT32
  201. #define mp_setp        P_SETP
  202. #define mp_addc        P_ADDC
  203. #define mp_subb        P_SUBB
  204. #define mp_rotate_left    P_ROTL
  205. #define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit))
  206. #if defined(sun3) || defined(mc68020)
  207. # define UPTON
  208. # define MUNIT32
  209. # define mp_smul    P_SMUL
  210. /* # define mp_dmul    P_DMUL */ /* mc68020.s has a bug in P_DMUL */
  211. #else
  212. # define SMITH
  213. # define MUNIT16
  214. #endif
  215. #define PLATFORM_SPECIFIED
  216. #endif /* mc68000 */
  217.  
  218. #ifdef AMIGA
  219. #define UNIT32
  220. #define mp_addc         P_ADDC
  221. #define mp_subb         P_SUBB
  222. #define mp_rotate_left  P_ROTL
  223. #define mp_setp         P_SETP
  224. #ifdef _M68020
  225. #define mp_smul         P_SMUL
  226. #define UPTON
  227. #define MUNIT32                 /* 32-bit multiplies for >=68020 */
  228. #else /* _M68020 */
  229. #define SMITH
  230. #define MUNIT16
  231. #endif /* _M68020 */
  232. #define PLATFORM_SPECIFIED
  233. #endif /* AMIGA */
  234.  
  235. /* RISC OS added. -- GJM */
  236. #ifdef RISC_OS
  237. #define UNIT32
  238. #define MUNIT32    /* can't use Smith's algorithm */
  239. #define UPTON
  240. #define mp_addc _p_addc
  241. #define mp_subb _p_subb
  242. #define mp_rotate_left _p_rol
  243. #define mp_smul _p_smul
  244. #define mp_dmul _p_dmul
  245. #define unitfill0(r,ct) memset((void*)r,0,(ct)*sizeof(unit))
  246. #define PLATFORM_SPECIFIED
  247. #endif
  248.  
  249. /* Add additional platforms here ... */
  250.  
  251. /**************** End of system specification ************************/
  252.  
  253. #ifndef PLATFORM_SPECIFIED
  254. /* No platform explicitly selected.  Customization is controlled by
  255.  * PORTABLE and MPORTABLE.
  256.  */
  257. #define mp_setp        P_SETP
  258. #define mp_addc        P_ADDC
  259. #define mp_subb        P_SUBB
  260. #define mp_rotate_left    P_ROTL
  261. #define UPTON
  262. #define unitfill0(r,ct) memset((void*)r, 0, (ct)*sizeof(unit))
  263. #ifndef MPORTABLE
  264. #define mp_smul    P_SMUL
  265. #endif    /* MPORTABLE */
  266. #endif    /* PLATFORM_SPECIFIED */
  267. #endif    /* PORTABLE */
  268. #endif    /* PLATFORM_H */
  269.  
  270.