home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / fltintrn.h < prev    next >
C/C++ Source or Header  |  1998-06-17  |  5KB  |  205 lines

  1. /***
  2. *fltintrn.h - contains declarations of internal floating point types,
  3. *             routines and variables
  4. *
  5. *       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
  6. *
  7. *Purpose:
  8. *       Declares floating point types, routines and variables used
  9. *       internally by the C run-time.
  10. *
  11. *       [Internal]
  12. *
  13. ****/
  14.  
  15. #if _MSC_VER > 1000
  16. #pragma once
  17. #endif  /* _MSC_VER > 1000 */
  18.  
  19. #ifndef _INC_FLTINTRN
  20. #define _INC_FLTINTRN
  21.  
  22. #ifndef _CRTBLD
  23. /*
  24.  * This is an internal C runtime header file. It is used when building
  25.  * the C runtimes only. It is not to be used as a public header file.
  26.  */
  27. #error ERROR: Use of C runtime library internal header file.
  28. #endif  /* _CRTBLD */
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif  /* __cplusplus */
  33.  
  34. #include <cruntime.h>
  35.  
  36.  
  37. /* Define _CRTIMP */
  38.  
  39. #ifndef _CRTIMP
  40. #ifdef CRTDLL
  41. #define _CRTIMP __declspec(dllexport)
  42. #else  /* CRTDLL */
  43. #ifdef _DLL
  44. #define _CRTIMP __declspec(dllimport)
  45. #else  /* _DLL */
  46. #define _CRTIMP
  47. #endif  /* _DLL */
  48. #endif  /* CRTDLL */
  49. #endif  /* _CRTIMP */
  50.  
  51.  
  52. /* Define __cdecl for non-Microsoft compilers */
  53.  
  54. #if (!defined (_MSC_VER) && !defined (__cdecl))
  55. #define __cdecl
  56. #endif  /* (!defined (_MSC_VER) && !defined (__cdecl)) */
  57.  
  58. /*
  59.  * For MS C for the x86 family, disable the annoying "long double is the
  60.  * same precision as double" warning
  61.  */
  62.  
  63. #ifdef _M_IX86
  64. #pragma warning(disable:4069)
  65. #endif  /* _M_IX86 */
  66.  
  67. /*
  68.  * structs used to fool the compiler into not generating floating point
  69.  * instructions when copying and pushing [long] double values
  70.  */
  71.  
  72. #ifndef DOUBLE
  73.  
  74. typedef struct {
  75.         double x;
  76. } DOUBLE;
  77.  
  78. #endif  /* DOUBLE */
  79.  
  80. #ifndef LONGDOUBLE
  81.  
  82. typedef struct {
  83. #if defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) || defined (_M_MPPC)
  84.         /*
  85.          * No long double type for MIPS, ALPHA, PPC. or PowerMac
  86.          */
  87.         double x;
  88. #else  /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) || defined (_M_MPPC) */
  89.         /*
  90.          * Assume there is a long double type
  91.          */
  92.         long double x;
  93. #endif  /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) || defined (_M_MPPC) */
  94. } LONGDOUBLE;
  95.  
  96. #endif  /* LONGDOUBLE */
  97.  
  98. /*
  99.  * typedef for _fltout
  100.  */
  101.  
  102. typedef struct _strflt
  103. {
  104.         int sign;             /* zero if positive otherwise negative */
  105.         int decpt;            /* exponent of floating point number */
  106.         int flag;             /* zero if okay otherwise IEEE overflow */
  107.         char *mantissa;       /* pointer to mantissa in string form */
  108. }
  109.         *STRFLT;
  110.  
  111.  
  112. /*
  113.  * typedef for _fltin
  114.  */
  115.  
  116. typedef struct _flt
  117. {
  118.         int flags;
  119.         int nbytes;          /* number of characters read */
  120.         long lval;
  121.         double dval;         /* the returned floating point number */
  122. }
  123.         *FLT;
  124.  
  125.  
  126. #ifdef _MAC
  127. /*
  128.  * typedef for _fltinl
  129.  */
  130.  
  131. typedef struct _fltl
  132. {
  133.         int flags;
  134.         int nbytes;          /* number of characters read */
  135.         long lval;
  136.         long double ldval;           /* the returned floating point number */
  137. }
  138.         *FLTL;
  139. #endif  /* _MAC */
  140.  
  141. /* floating point conversion routines, keep in sync with mrt32\include\convert.h */
  142.  
  143. char *_cftoe(double *, char *, int, int);
  144. char *_cftof(double *, char *, int);
  145. void __cdecl _fptostr(char *, int, STRFLT);
  146.  
  147. #ifdef _MT
  148.  
  149. STRFLT  __cdecl _fltout2( double, STRFLT, char * );
  150. FLT     __cdecl _fltin2( FLT , const char *, int, int, int );
  151.  
  152. #else  /* _MT */
  153.  
  154. STRFLT  __cdecl _fltout( double );
  155. FLT     __cdecl _fltin( const char *, int, int, int );
  156. #ifdef _MAC
  157. FLTL    __cdecl _fltinl( const char *, int, int, int );
  158. #endif  /* _MAC */
  159.  
  160. #endif  /* _MT */
  161.  
  162.  
  163. /*
  164.  * table of pointers to floating point helper routines
  165.  *
  166.  * We can't specify the prototypes for the entries of the table accurately,
  167.  * since different functions in the table have different arglists.
  168.  * So we declare the functions to take and return void (which is the
  169.  * correct prototype for _fptrap(), which is what the entries are all
  170.  * initialized to if no floating point is loaded) and cast appropriately
  171.  * on every usage.
  172.  */
  173.  
  174. typedef void (* PFV)(void);
  175. extern PFV _cfltcvt_tab[6];
  176.  
  177. typedef void (* PF0)(DOUBLE*, char*, int, int, int);
  178. #define _cfltcvt(a,b,c,d,e) (*((PF0)_cfltcvt_tab[0]))(a,b,c,d,e)
  179.  
  180. typedef void (* PF1)(char*);
  181. #define _cropzeros(a)       (*((PF1)_cfltcvt_tab[1]))(a)
  182.  
  183. typedef void (* PF2)(int, char*, char*);
  184. #define _fassign(a,b,c)     (*((PF2)_cfltcvt_tab[2]))(a,b,c)
  185.  
  186. typedef void (* PF3)(char*);
  187. #define _forcdecpt(a)       (*((PF3)_cfltcvt_tab[3]))(a)
  188.  
  189. typedef int (* PF4)(DOUBLE*);
  190. #define _positive(a)        (*((PF4)_cfltcvt_tab[4]))(a)
  191.  
  192. typedef void (* PF5)(LONGDOUBLE*, char*, int, int, int);
  193. #define _cldcvt(a,b,c,d,e)  (*((PF5)_cfltcvt_tab[5]))(a,b,c,d,e)
  194.  
  195.  
  196. #ifdef _M_IX86
  197. #pragma warning(default:4069)
  198. #endif  /* _M_IX86 */
  199.  
  200. #ifdef __cplusplus
  201. }
  202. #endif  /* __cplusplus */
  203.  
  204. #endif  /* _INC_FLTINTRN */
  205.