Patch to allow compiling LDC with MinGW, by mp4 / [1]jaffa (slightly edited).

Closes #300.
This commit is contained in:
Frits van Bommel
2009-05-18 14:02:50 +02:00
parent 1ca2ee5d66
commit 81cf30688a
2 changed files with 16 additions and 2 deletions

View File

@@ -94,7 +94,7 @@ int REALALIGNSIZE = 2;
int Tsize_t = Tuns32;
int Tptrdiff_t = Tint32;
#if _WIN32
#if _WIN32 && !defined __MINGW32__
static double zero = 0;
double Port::nan = NAN;
double Port::infinity = 1/zero;

View File

@@ -315,7 +315,7 @@ char *Port::strupr(char *s)
#endif
#if linux || __APPLE__ || __FreeBSD__
#if linux || __APPLE__ || __FreeBSD__ || __MINGW32__
#include <math.h>
#if linux
@@ -363,11 +363,15 @@ PortInitializer::PortInitializer()
#endif
}
#ifndef __MINGW32__
#undef isnan
#endif
int Port::isNan(double r)
{
#if __APPLE__
return __inline_isnan(r);
#elif defined __MINGW32__
return isnan(r);
#else
return ::isnan(r);
#endif
@@ -377,6 +381,8 @@ int Port::isNan(long double r)
{
#if __APPLE__
return __inline_isnan(r);
#elif defined __MINGW32__
return isnan(r);
#else
return ::isnan(r);
#endif
@@ -404,11 +410,15 @@ int Port::isFinite(double r)
return ::finite(r);
}
#ifndef __MINGW32__
#undef isinf
#endif
int Port::isInfinity(double r)
{
#if __APPLE__
return fpclassify(r) == FP_INFINITE;
#elif defined __MINGW32__
return isinf(r);
#else
return ::isinf(r);
#endif
@@ -443,7 +453,11 @@ char *Port::ull_to_string(char *buffer, ulonglong ull)
wchar_t *Port::ull_to_string(wchar_t *buffer, ulonglong ull)
{
#ifndef __MINGW32__
swprintf(buffer, sizeof(ulonglong) * 3 + 1, L"%llu", ull);
#else
_snwprintf(buffer, sizeof(ulonglong) * 3 + 1, L"%llu", ull);
#endif
return buffer;
}