Commit a16ef96d authored by Alexandre Julliard's avatar Alexandre Julliard

include/msvcrt: Add INFINITY and NAN definitions.

parent d535df42
......@@ -22,25 +22,6 @@
#include "wine/test.h"
#include "d3dx9.h"
#ifndef INFINITY
static inline float __port_infinity(void)
{
static const unsigned __inf_bytes = 0x7f800000;
return *(const float *)&__inf_bytes;
}
#define INFINITY __port_infinity()
#endif /* INFINITY */
#ifndef NAN
static float get_nan(void)
{
DWORD nan = 0x7fc00000;
return *(float *)&nan;
}
#define NAN get_nan()
#endif
/* helper functions */
static BOOL compare_float(FLOAT f, FLOAT g, UINT ulps)
{
......
......@@ -18,6 +18,7 @@
#include <fcntl.h>
#include <float.h>
#include <math.h>
#include <io.h>
#include <stdio.h>
#include <windef.h>
......@@ -180,20 +181,6 @@ typedef struct {
exception e;
} logic_error;
static inline float __port_infinity(void)
{
static const unsigned __inf_bytes = 0x7f800000;
return *(const float *)&__inf_bytes;
}
#define INFINITY __port_infinity()
static inline float __port_nan(void)
{
static const unsigned __nan_bytes = 0x7fc00000;
return *(const float *)&__nan_bytes;
}
#define NAN __port_nan()
#undef __thiscall
#ifdef __i386__
#define __thiscall __stdcall
......
......@@ -169,20 +169,6 @@ static void init_thiscall_thunk(void)
#define call_func7(func,_this,a,b,c,d,e,f) func(_this,a,b,c,d,e,f)
#endif /* __i386__ */
static inline float __port_infinity(void)
{
static const unsigned __inf_bytes = 0x7f800000;
return *(const float *)&__inf_bytes;
}
#define INFINITY __port_infinity()
static inline float __port_nan(void)
{
static const unsigned __nan_bytes = 0x7fc00000;
return *(const float *)&__nan_bytes;
}
#define NAN __port_nan()
typedef int MSVCRT_long;
typedef unsigned char MSVCP_bool;
......
......@@ -27,20 +27,6 @@
#include <winbase.h>
#include "wine/test.h"
static inline float __port_infinity(void)
{
static const unsigned __inf_bytes = 0x7f800000;
return *(const float *)&__inf_bytes;
}
#define INFINITY __port_infinity()
static inline float __port_nan(void)
{
static const unsigned __nan_bytes = 0x7fc00000;
return *(const float *)&__nan_bytes;
}
#define NAN __port_nan()
static inline float __port_ind(void)
{
static const unsigned __ind_bytes = 0xffc00000;
......
......@@ -22,6 +22,7 @@
#include <wchar.h>
#include <stdio.h>
#include <float.h>
#include <math.h>
#include <limits.h>
#include <wctype.h>
......@@ -114,30 +115,6 @@ typedef struct {
critical_section lock;
} _Condition_variable;
static inline float __port_infinity(void)
{
static const unsigned __inf_bytes = 0x7f800000;
return *(const float *)&__inf_bytes;
}
#define INFINITY __port_infinity()
static inline float __port_nan(void)
{
static const unsigned __nan_bytes = 0x7fc00000;
return *(const float *)&__nan_bytes;
}
#define NAN __port_nan()
static inline int isnormal(double d)
{
return _fpclass(d) & (_FPCLASS_PN | _FPCLASS_NN);
}
static inline int isinf(double d)
{
return _fpclass(d) & (_FPCLASS_PINF | _FPCLASS_NINF);
}
struct MSVCRT_lconv
{
char* decimal_point;
......
......@@ -25,20 +25,6 @@
#include "msvcrt.h"
#include <process.h>
static inline float __port_infinity(void)
{
static const unsigned __inf_bytes = 0x7f800000;
return *(const float *)&__inf_bytes;
}
#define INFINITY __port_infinity()
static inline float __port_nan(void)
{
static const unsigned __nan_bytes = 0x7fc00000;
return *(const float *)&__nan_bytes;
}
#define NAN __port_nan()
static inline BOOL almost_equal(double d1, double d2) {
if(d1-d2>-1e-30 && d1-d2<1e-30)
return TRUE;
......
......@@ -24,9 +24,10 @@
* the following macro is defined.
*/
#define _CRT_NON_CONFORMING_SWPRINTFS
#include <stdio.h>
#include <errno.h>
#include <math.h>
#include <locale.h>
#include "windef.h"
......@@ -35,20 +36,6 @@
#include "wine/test.h"
static inline float __port_infinity(void)
{
static const unsigned __inf_bytes = 0x7f800000;
return *(const float *)&__inf_bytes;
}
#define INFINITY __port_infinity()
static inline float __port_nan(void)
{
static const unsigned __nan_bytes = 0x7fc00000;
return *(const float *)&__nan_bytes;
}
#define NAN __port_nan()
static inline float __port_ind(void)
{
static const unsigned __ind_bytes = 0xffc00000;
......
......@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <wchar.h>
#include <stdio.h>
#include <math.h>
#include <float.h>
#include <io.h>
#include <sys/stat.h>
......@@ -57,20 +58,6 @@
expect_ ## func = called_ ## func = FALSE; \
}while(0)
static inline float __port_infinity(void)
{
static const unsigned __inf_bytes = 0x7f800000;
return *(const float *)&__inf_bytes;
}
#define INFINITY __port_infinity()
static inline float __port_nan(void)
{
static const unsigned __nan_bytes = 0x7fc00000;
return *(const float *)&__nan_bytes;
}
#define NAN __port_nan()
static inline double __port_min_pos_double(void)
{
static const UINT64 __min_pos_double = 0x10000000000000;
......
......@@ -23,6 +23,7 @@
#include <stdio.h>
#include <errno.h>
#include <math.h>
#include "windef.h"
#include "winbase.h"
......@@ -66,20 +67,6 @@ DEFINE_EXPECT(invalid_parameter_handler);
#define UCRTBASE_PRINTF_LEGACY_MSVCRT_COMPATIBILITY (0x0008)
#define UCRTBASE_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS (0x0010)
static inline float __port_infinity(void)
{
static const unsigned __inf_bytes = 0x7f800000;
return *(const float *)&__inf_bytes;
}
#define INFINITY __port_infinity()
static inline float __port_nan(void)
{
static const unsigned __nan_bytes = 0x7fc00000;
return *(const float *)&__nan_bytes;
}
#define NAN __port_nan()
static inline float __port_ind(void)
{
static const unsigned __ind_bytes = 0xffc00000;
......
......@@ -57,24 +57,6 @@ DEFINE_EXPECT(invalid_parameter_handler);
static _invalid_parameter_handler (__cdecl *p_set_invalid_parameter_handler)(_invalid_parameter_handler);
#ifndef INFINITY
static inline float __port_infinity(void)
{
static const unsigned __inf_bytes = 0x7f800000;
return *(const float *)&__inf_bytes;
}
#define INFINITY __port_infinity()
#endif
#ifndef NAN
static inline float __port_nan(void)
{
static const unsigned __nan_bytes = 0x7fc00000;
return *(const float *)&__nan_bytes;
}
#define NAN __port_nan()
#endif
static void __cdecl test_invalid_parameter_handler(const wchar_t *expression,
const wchar_t *function, const wchar_t *file,
unsigned line, uintptr_t arg)
......
......@@ -17,30 +17,12 @@
*/
#include <stdio.h>
#include <math.h>
#include "windows.h"
#include "rpc.h"
#include "webservices.h"
#include "wine/test.h"
#include <math.h>
#ifndef INFINITY
static inline float __port_infinity(void)
{
static const unsigned __inf_bytes = 0x7f800000;
return *(const float *)&__inf_bytes;
}
#define INFINITY __port_infinity()
#endif
#ifndef NAN
static inline float __port_nan(void)
{
static const unsigned __nan_bytes = 0x7fc00000;
return *(const float *)&__nan_bytes;
}
#define NAN __port_nan()
#endif
static HRESULT set_output( WS_XML_WRITER *writer )
{
WS_XML_WRITER_TEXT_ENCODING text = { {WS_XML_WRITER_ENCODING_TYPE_TEXT}, WS_CHARSET_UTF8 };
......
......@@ -205,6 +205,18 @@ static const union {
# endif
#endif
#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
# define INFINITY __builtin_inff()
# define NAN __builtin_nanf("")
#else
static const union {
unsigned int __i;
float __f;
} __inff = { 0x7f800000 }, __nanf = { 0x7fc00000 };
# define INFINITY (__inff.__f)
# define NAN (__nanf.__f)
#endif
#define FP_INFINITE 1
#define FP_NAN 2
#define FP_NORMAL -1
......
......@@ -46,6 +46,15 @@
#define INVALID_SET_FILE_POINTER (~0u)
#endif
#ifdef _MSC_VER
# ifndef INFINITY
# define INFINITY ((float)HUGE_VAL)
# endif
# ifndef NAN
# define NAN (INFINITY * 0.0f)
# endif
#endif
/* debug level */
extern int winetest_debug;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment