home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 1.ddi / DOC / WEITEK.DOC < prev   
Encoding:
Text File  |  1992-04-21  |  6.6 KB  |  188 lines

  1.        Copyright (C) 1992 MetaWare Incorporated; All Rights Reserved.
  2.  
  3.                           High C/C++ Version 3.0
  4.                        Globally Optimizing Compiler
  5.                 for Extended DOS 80386/486 and Windows 3.0
  6.                                 April 1992
  7.  
  8.                         +-------------------------+
  9.                         |  Weitek ABACUS Support  |
  10.                         +-------------------------+
  11.  
  12.  
  13. Table of Contents
  14. -----------------
  15.  
  16.  1.  Compiling
  17.  2.  Calling Convention
  18.  3.  386|DOS-Extender
  19.  4.  stdio.h
  20.  5.  Libraries
  21.  6.  Library Name Space
  22.  7.  Math Errors
  23.  
  24.  
  25. 1.  Compiling
  26. -------------
  27.  
  28. To generate Weitek code, compile your program with driver command-line option
  29. -f4167, -f3167 or -f1167.  This will:
  30.  
  31.    * Turn on toggle 4167, 3167, or 1167, respectively.
  32.  
  33.    * Link with library HCWP.LIB.
  34.  
  35.    * Define the macro __1167 to be 1 (this macro is used for conditional
  36.      preprocessing in stdio.h).
  37.  
  38.    * -f4167 also turns on additional 486 floating-point optimizations.
  39.  
  40. Read Programmer's Guide chapter "Floating-Point Support" for additional
  41. information.
  42.  
  43. Driver command-line options:
  44.  
  45.  -f4167     Enables Weitek 4167 floating-point-coprocessor instruction
  46.             generation and also enables 486-specific optimizations.
  47.             Links with the Weitek library hcwp and defines __1167.
  48.  
  49.  -f3167,    Enable Wietek 3167/1167 floating-point-coprocessor instruction
  50.  -f1167     generation, link with the Weitek library hcwp, and define __1167.
  51.  
  52.  
  53.  
  54. 2.  Calling Convention
  55. ----------------------
  56.  
  57. Specify calling-convention attribute _NO_1167 to allow allocation of variables
  58. to ABACUS scratch registers rather than to nonvolatile registers.  _NO_1167
  59. informs the compiler that a function (and any function that it calls) does not
  60. modify the ABACUS register set.
  61.  
  62. If a math function such as sin() calls no other functions, the compiler
  63. allocates variables to ABACUS scratch registers rather than to nonvolatile
  64. registers if possible, thereby avoiding the save/restore at entry to/exit from
  65. sin().  However, if sin() calls another function P(), the worst is assumed:
  66. that P() modifies the ABACUS scratch registers; and therefore variables are
  67. not so allocated.  The result is that sin() has to save and restore the
  68. nonvolatile registers.
  69.  
  70. However, if you use _NO_1167 to indicate that P() does not affect the ABACUS
  71. registers, the compiler can use ABACUS scratch registers.  Or, if P() is an
  72. error handler that never returns, the effect on sin() is the same: it can
  73. assume the scratch registers are saved across the call to P().
  74.  
  75. You can use this if a function calls a library error routine that reports or
  76. records an error, and either does not use the ABACUS or never returns.  For
  77. instance, sqrt() and asin() both call fprintf().  Informing the compiler that
  78. fprintf() does not touch the ABACUS improves execution speed.  For example,
  79. modifying stdio.h to surround the declaration of fprintf() with the following
  80. lines achieves this effect:
  81.  
  82.    pragma Calling_convention(_DEFAULT_CALLING_CONVENTION | _NO_1167);
  83.    ...
  84.    pragma Calling_convention();
  85.  
  86. See the Programmer's Guide for more information about calling conventions.
  87.  
  88.  
  89. 3.  386|DOS-Extender
  90. --------------------
  91.  
  92. To use the compiler with Phar Lap's 386|DOS-Extender, be sure you have a
  93. version of 386|DOS-Extender that detects Weitek coprocessors.  The MetaWare
  94. Run-Time Libraries automatically initialize the chip.  Phar Lap has
  95. implemented this since Version 1.1u (Fall 1987).
  96.  
  97.  
  98. 4.  stdio.h
  99. -----------
  100.  
  101. Header file stdio.h contains code conditioned on #ifdef __1167.  If you use
  102. driver command-line option -f4167, -f3167, or -f1167, __1167 is automatically
  103. defined.  If you do not use these options, you must provide a definition for
  104. __1167.  A modified version of stdio.h called wstdio.h is included for this
  105. purpose in the Weitek subdirectory.  This header file contains:
  106.  
  107.    #define __1167 1
  108.  
  109. and then:
  110.  
  111.    #include <stdio.h>
  112.  
  113. You can use wstdio.h, or just define __1167 and then include stdio.h.
  114.  
  115.  
  116. 5. Libraries
  117. -------------
  118.  
  119. The High C run-time math libraries for transcendentals are included in your
  120. distribution.  If you use header file math.h, you should include these
  121. libraries in your link before the standard High C libraries.  The libraries
  122. are provided for Phar Lap's environment.
  123.  
  124. These transcendentals were supplied to MetaWare by Weitek under license.  AS
  125. OF THIS WRITING, printf() and scanf() have not been modified to use the 1167;
  126. they are awaiting further work.
  127.  
  128.  
  129. 6. Library Name Space
  130. ---------------------
  131.  
  132. Weitek uses names in the transcendental library that are not in the ANSI C
  133. Standard.  Do not use these names if you want to avoid the transcendental
  134. routines.  The following names are in the transcendental library:
  135.  
  136.    _cabs       asin        fmod        rcosh       rsqrt_tb2
  137.    _ccos       atan        log         rcot        rsqrt
  138.    _cexp       atan2       log10       rem         rtan
  139.    _clog       carg_err    pow         rexp        rtanh
  140.    _csin       ceil        racos       rfmod       sin
  141.    _csqrt      cos         rarg1_err   rlog        sinh
  142.    _hypot      cosh        rarg1p_err  rlog10      sqrt_tb
  143.    _mwWTKCPR   cot         rarg2_err   rrem        sqrt_tb1
  144.    acos        cotan_      rarg2p_err  rsin        sqrt_tb2
  145.    arg1_err    dcotan_     rasin       rsincosh_tb sqrt_tb3
  146.    arg1p_err   exp         ratan       rsinh       sqrt
  147.    arg2_err    exp_tb      ratan2      rsqrt_tb    tan
  148.    arg2p_err   floor       rcos        rsqrt_tb1   tanh
  149.    math_err_control
  150.  
  151. The following functions should not be called directly; these are library
  152. functions that return a floating-point type:
  153.  
  154.    atof
  155.    difftime
  156.    strtod
  157.  
  158. There is a way around this.  In general, if you would ordinarily use a non-
  159. Weitek-supported library function F() as follows:
  160.  
  161.    extern double F();
  162.    ...
  163.    double answer = F();
  164.  
  165. instead, write:
  166.  
  167.    extern void F_();
  168.    ...
  169.    double answer;
  170.    F_(&answer);
  171.  
  172. where you compile separately, with the 4167/3167/1167 toggles Off, the
  173. following code:
  174.  
  175.    extern double F();
  176.    void F_(double *result) { *result = F(); }
  177.  
  178.  
  179. 7. Math Errors
  180. --------------
  181.  
  182. You can trap math errors in the Weitek library by modifying MATHERR.C.
  183. MATHERR.C in the ETC\SRC subdirectory contains a different specification of
  184. the exception data structure from \INC\MATH.H, and the two specifications are
  185. not compatible.  MATHERR.C is distributed by Weitek with the Weitek library.
  186. If you are using the Weitek library, you may have to substitute Weitek's
  187. definition of exceptions for the one contained in MATH.H.
  188.