home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / programacao / cwin / c.exe / $INSTDIR / include / float.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-12-15  |  5.0 KB  |  169 lines

  1. /* 
  2.  * float.h
  3.  *
  4.  * Constants related to floating point arithmetic.
  5.  *
  6.  * Also included here are some non-ANSI bits for accessing the floating
  7.  * point controller.
  8.  *
  9.  * NOTE: GCC provides float.h, but it doesn't include the non-standard
  10.  *       stuff for accessing the fp controller. We include_next the
  11.  *       GCC-supplied header and just define the MS-specific extensions
  12.  *       here.     
  13.  *
  14.  * This file is part of the Mingw32 package.
  15.  *
  16.  * Contributors:
  17.  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  18.  *
  19.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  20.  *
  21.  *  This source code is offered for use in the public domain. You may
  22.  *  use, modify or distribute it freely.
  23.  *
  24.  *  This code is distributed in the hope that it will be useful but
  25.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  26.  *  DISCLAIMED. This includes but is not limited to warranties of
  27.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  28.  *
  29.  * $Revision: 1.9 $
  30.  * $Author: earnie $
  31.  * $Date: 2002/08/12 13:06:35 $
  32.  *
  33.  */
  34.  
  35. #include_next<float.h>
  36.  
  37. #ifndef _MINGW_FLOAT_H_
  38. #define _MINGW_FLOAT_H_
  39.  
  40. /* All the headers include this file. */
  41. #include <_mingw.h>
  42.  
  43. /*
  44.  * Functions and definitions for controlling the FPU.
  45.  */
  46. #ifndef    __STRICT_ANSI__
  47.  
  48. /* TODO: These constants are only valid for x86 machines */
  49.  
  50. /* Control word masks for unMask */
  51. #define    _MCW_EM        0x0008001F    /* Error masks */
  52. #define    _MCW_IC        0x00040000    /* Infinity */
  53. #define    _MCW_RC        0x00000300    /* Rounding */
  54. #define    _MCW_PC        0x00030000    /* Precision */
  55.  
  56. /* Control word values for unNew (use with related unMask above) */
  57. #define    _EM_INVALID    0x00000010
  58. #define    _EM_DENORMAL    0x00080000
  59. #define    _EM_ZERODIVIDE    0x00000008
  60. #define    _EM_OVERFLOW    0x00000004
  61. #define    _EM_UNDERFLOW    0x00000002
  62. #define    _EM_INEXACT    0x00000001
  63. #define    _IC_AFFINE    0x00040000
  64. #define    _IC_PROJECTIVE    0x00000000
  65. #define    _RC_CHOP    0x00000300
  66. #define    _RC_UP        0x00000200
  67. #define    _RC_DOWN    0x00000100
  68. #define    _RC_NEAR    0x00000000
  69. #define    _PC_24        0x00020000
  70. #define    _PC_53        0x00010000
  71. #define    _PC_64        0x00000000
  72.  
  73. /* These are also defined in Mingw math.h, needed to work around
  74.    GCC build issues.  */
  75. /* Return values for fpclass. */
  76. #ifndef __MINGW_FPCLASS_DEFINED
  77. #define __MINGW_FPCLASS_DEFINED 1
  78. #define    _FPCLASS_SNAN    0x0001    /* Signaling "Not a Number" */
  79. #define    _FPCLASS_QNAN    0x0002    /* Quiet "Not a Number" */
  80. #define    _FPCLASS_NINF    0x0004    /* Negative Infinity */
  81. #define    _FPCLASS_NN    0x0008    /* Negative Normal */
  82. #define    _FPCLASS_ND    0x0010    /* Negative Denormal */
  83. #define    _FPCLASS_NZ    0x0020    /* Negative Zero */
  84. #define    _FPCLASS_PZ    0x0040    /* Positive Zero */
  85. #define    _FPCLASS_PD    0x0080    /* Positive Denormal */
  86. #define    _FPCLASS_PN    0x0100    /* Positive Normal */
  87. #define    _FPCLASS_PINF    0x0200    /* Positive Infinity */
  88. #endif /* __MINGW_FPCLASS_DEFINED */
  89.  
  90. /* invalid subconditions (_SW_INVALID also set) */
  91. #define _SW_UNEMULATED        0x0040  /* unemulated instruction */
  92. #define _SW_SQRTNEG        0x0080  /* square root of a neg number */
  93. #define _SW_STACKOVERFLOW    0x0200  /* FP stack overflow */
  94. #define _SW_STACKUNDERFLOW    0x0400  /* FP stack underflow */
  95.  
  96. /*  Floating point error signals and return codes */
  97. #define _FPE_INVALID        0x81
  98. #define _FPE_DENORMAL        0x82
  99. #define _FPE_ZERODIVIDE        0x83
  100. #define _FPE_OVERFLOW        0x84
  101. #define _FPE_UNDERFLOW        0x85
  102. #define _FPE_INEXACT        0x86
  103. #define _FPE_UNEMULATED        0x87
  104. #define _FPE_SQRTNEG        0x88
  105. #define _FPE_STACKOVERFLOW    0x8a
  106. #define _FPE_STACKUNDERFLOW    0x8b
  107. #define _FPE_EXPLICITGEN    0x8c    /* raise( SIGFPE ); */
  108.  
  109. #ifndef RC_INVOKED
  110.  
  111. #ifdef    __cplusplus
  112. extern "C" {
  113. #endif
  114.  
  115. /* Set the FPU control word as cw = (cw & ~unMask) | (unNew & unMask),
  116.  * i.e. change the bits in unMask to have the values they have in unNew,
  117.  * leaving other bits unchanged. */
  118. unsigned int    _controlfp (unsigned int unNew, unsigned int unMask);
  119. unsigned int    _control87 (unsigned int unNew, unsigned int unMask);
  120.  
  121.  
  122. unsigned int    _clearfp (void);    /* Clear the FPU status word */
  123. unsigned int    _statusfp (void);    /* Report the FPU status word */
  124. #define        _clear87    _clearfp
  125. #define        _status87    _statusfp
  126.  
  127.  
  128. /*
  129.    MSVCRT.dll _fpreset initializes the control register to 0x27f,
  130.    the status register to zero and the tag word to 0FFFFh.
  131.    This differs from asm instruction finit/fninit which set control
  132.    word to 0x37f (64 bit mantissa precison rather than 53 bit).
  133.    By default, the mingw version of _fpreset sets fp control as
  134.    per fninit. To use the MSVCRT.dll _fpreset, include CRT_fp8.o when
  135.    building your application.     
  136. */
  137. void        _fpreset (void);
  138. void        fpreset (void);
  139.  
  140. /* Global 'variable' for the current floating point error code. */
  141. int *    __fpecode(void);
  142. #define    _fpecode    (*(__fpecode()))
  143.  
  144. /*
  145.  * IEEE recommended functions.  MS puts them in float.h
  146.  * but they really belong in math.h.
  147.  */
  148.  
  149. double    _chgsign    (double);
  150. double    _copysign    (double, double);
  151. double    _logb        (double);
  152. double    _nextafter    (double, double);
  153. double    _scalb        (double, long);
  154.  
  155. int    _finite        (double);
  156. int    _fpclass    (double);
  157. int    _isnan        (double);
  158.  
  159. #ifdef    __cplusplus
  160. }
  161. #endif
  162.  
  163. #endif    /* Not RC_INVOKED */
  164.  
  165. #endif    /* Not __STRICT_ANSI__ */
  166.  
  167. #endif /* _FLOAT_H_ */
  168.  
  169.