home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c220 / 3.ddi / WEITEK / WEITEK.DOC < prev    next >
Encoding:
Text File  |  1990-12-16  |  7.5 KB  |  233 lines

  1.        Copyright (C) 1990 MetaWare Incorporated.  All Rights Reserved.
  2.  
  3.                           High C Version 1.7
  4.                         Weitek ABACUS Support
  5.                             December 1990
  6.  
  7. Table of Contents
  8. -----------------
  9.  
  10.  1.  Included Files
  11.  2.  Compiling
  12.  3.  Calling Convention
  13.  4.  386|DOS-Extender
  14.  5.  Linking
  15.  6.  stdio.h
  16.  7.  Libraries
  17.  8.  Library Name Space
  18.  9.  Math Errors
  19.  10. Problems
  20.  
  21.  
  22. 1.  Included Files
  23. ------------------
  24.  
  25.    fbench.c     -- Benchmark example program.
  26.    wstdio.h     -- Modified to assume extern functions do not touch the 1167.
  27.    weitek.doc   -- This document.
  28.    hcwp.lib     -- Weitek transcendental library for Phar Lap.
  29.    weitek.pro   -- A sample profile for enabling pragma 1167 or pragma 3167.
  30.    matherr.c    -- Exception-handling function.
  31.  
  32.  
  33. 2.  Compiling
  34. -------------
  35.  
  36. To generate Weitek code, compile your program with driver command-line option
  37. -f3167 or -f1167.  This will:
  38.  
  39.    * Turn on toggle 3167 or 1167, respectively.
  40.    * Link with library HCWP.LIB.
  41.    * Define the macro __1167 to be 1 (this macro is used
  42.      for conditional preprocessing in stdio.h).
  43.  
  44. If you do not use the driver, instead do the following:
  45.  
  46.    * Turn on toggle 3167 or 1167.
  47.    * Link as described below.
  48.    * Either:
  49.         include wstdio.h (found in the Weitek subdirectory of your High C
  50.         distribution) instead of stdio.h
  51.      or:
  52.         #define __1167 1 in your program and include stdio.h.
  53.  
  54. Please read the Programmer's Guide chapter "Floating-Point Support" for
  55. additional information.
  56.  
  57.  
  58. 3.  Calling Convention
  59. ----------------------
  60.  
  61. Specify calling-convention attribute _NO_1167 to allow allocation of
  62. variables to ABACUS scratch registers rather than to nonvolatile registers.
  63. _NO_1167 informs the compiler that a function (and any functions that it
  64. calls) does not modify the ABACUS register set.
  65.  
  66. If a math function such as sin calls no other functions, the compiler
  67. allocates variables to ABACUS scratch registers rather than to nonvolatile
  68. registers if possible, thereby avoiding the save/restore at entry to/exit
  69. from sin.  However, if sin calls another function P, the worst is assumed:
  70. that P modifies the ABACUS scratch registers; and therefore variables are
  71. not so allocated.  The result is that sin has to save and restore the
  72. nonvolatile registers.
  73.  
  74. However, if you use _NO_1167 to indicate that P does not affect the ABACUS
  75. registers, the compiler can use ABACUS scratch registers.  Or, if P is an
  76. error handler that never returns, the effect on sin is the same: it can
  77. assume the scratch registers are saved across the call to P.
  78.  
  79. You can use this if a function calls a library error routine that reports
  80. or records an error, and either does not use the ABACUS or never returns.
  81. For instance, sqrt and asin both call fprintf.  Informing the compiler that
  82. fprintf does not touch the ABACUS improves execution speed.  For example,
  83. modifying stdio.h to surround the declaration of fprintf with the following
  84. lines achieves this effect:
  85.  
  86.    pragma Calling_convention(_DEFAULT_CALLING_CONVENTION | _NO_1167);
  87.    ...
  88.    pragma Calling_convention();
  89.  
  90. See the Programmer's Guide chapter Interfacing to Other Languages for more
  91. information about calling conventions.
  92.  
  93.  
  94. 4.  386|DOS-Extender
  95. --------------------
  96.  
  97. To use the compiler with Phar Lap's 386|DOS-Extender, be sure you have a
  98. version of 386|DOS-Extender that detects the 1167.  The MetaWare Run-Time
  99. Libraries automatically intialize the chip.  Phar Lap has implemented this
  100. since Version 1.1u (Fall 1987).
  101.  
  102.  
  103. 5.  Linking
  104. -----------
  105.  
  106. If you do not use the driver to invoke the compiler, you must link your High C
  107. programs with all of the following:
  108.  
  109.    - the Weitek-supplied run-time library (hcwp.lib)
  110.    - the standard High C run-time emulator library (hce.lib)
  111.    - the non-ANSI functions library (na.lib).
  112.  
  113. For example:
  114.  
  115.    386link fbench -lib hcwp hce na
  116.  
  117.  
  118. 6.  stdio.h
  119. -----------
  120.  
  121. Header file stdio.h contains code conditioned on #ifdef __1167.  If you
  122. use driver command-line option -f3167 or -f1167, __1167 is automatically
  123. defined.  If you do not use these options, you must provide a definition
  124. for __1167  A modified version of stdio.h called wstdio.h is included for
  125. this purpose in the Weitek subdirectory of the High C distribution.  This
  126. header file contains:
  127.  
  128.    #define __1167 1
  129.  
  130. and then:
  131.  
  132.    #include <stdio.h>
  133.  
  134. You can use wstdio.h, or just define __1167 and then include stdio.h.
  135.  
  136.  
  137. 7. Libraries
  138. -------------
  139.  
  140. The High C run-time math libraries for transcendentals are included in your
  141. High C distribution.  If you use header file math.h, you should include these
  142. libraries in your link before the standard High C libraries.  The libraries
  143. are provided for Phar Lap's environment.
  144.  
  145. These transcendentals were supplied to MetaWare by Weitek under license.  AS
  146. OF THIS WRITING, printf and scanf have not been modified to use the 1167; they
  147. are awaiting further work.
  148.  
  149.  
  150. 8. Library Name Space
  151. -----------------------------
  152.  
  153. Weitek uses names in the transcendental library that are not in the ANSI C
  154. Standard.  Do not use these names if you want to avoid the transcendental
  155. routines:
  156.  
  157.    _cabs       asin        fmod        rcosh       rsqrt_tb2
  158.    _ccos       atan        log         rcot        rsqrt
  159.    _cexp       atan2       log10       rem         rtan
  160.    _clog       carg_err    pow         rexp        rtanh
  161.    _csin       ceil        racos       rfmod       sin
  162.    _csqrt      cos         rarg1_err   rlog        sinh
  163.    _hypot      cosh        rarg1p_err  rlog10      sqrt_tb
  164.    _mwWTKCPR   cot         rarg2_err   rrem        sqrt_tb1
  165.    acos        cotan_      rarg2p_err  rsin        sqrt_tb2
  166.    arg1_err    dcotan_     rasin       rsincosh_tb sqrt_tb3
  167.    arg1p_err   exp         ratan       rsinh       sqrt
  168.    arg2_err    exp_tb      ratan2      rsqrt_tb    tan
  169.    arg2p_err   floor       rcos        rsqrt_tb1   tanh
  170.    math_err_control
  171.  
  172. The following functions should not be called directly; these are library
  173. functions that return a floating-point type:
  174.  
  175.    atof
  176.    difftime
  177.    strtod
  178.  
  179. There is a way around this.  In general, if you would ordinarily use a non-
  180. Weitek-supported library function F as follows:
  181.  
  182.    extern double F();
  183.    ...
  184.    double answer = F();
  185.  
  186. instead, write:
  187.  
  188.    extern void F_();
  189.    ...
  190.    double answer;
  191.    F_(&answer);
  192.  
  193. where you compile separately, with the 3167/1167 toggles Off, the following
  194. code:
  195.  
  196.    extern double F();
  197.    void F_(double *result) { *result = F(); }
  198.  
  199.  
  200. 9. Math Errors
  201. ---------------
  202.  
  203. You can trap math errors in the Weitek library by modifying matherr.c; source
  204. is included.  matherr.c is in the Weitek libraries; if you provide your own,
  205. you override the library version.
  206.  
  207.  
  208. 10. Problems
  209. ------------
  210.  
  211. If you think you have discovered a Weitek support problem, send a problem
  212. report to MetaWare Customer Service.  If possible, please send a test case
  213. that demonstrates the problem.
  214.  
  215. All problem reports must include your serial number and specify which version
  216. of the compiler you are using.  If your sample code exceeds 15 lines, please
  217. send it by diskette to the address below, or by E-mail to:
  218.  
  219.    uunet!acad!metaware!tech
  220.              -or-
  221.    Internet tech@metaware.com
  222.              -or-
  223.    INTERNET:tech@metaware.com
  224.  
  225. MetaWare Customer Service can be reached at (408) 429-6111, 8:00 am to 4:30 pm
  226. Monday through Friday.
  227.  
  228.  
  229. MetaWare Incorporated
  230. 2161 Delaware Avenue
  231. Santa Cruz, CA 95060-5706
  232. (408)429-6382  FAX:(408)429-9273
  233.