mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-12 13:55:57 +03:00
Haiku OS support; thanks to MrSunshine
This commit is contained in:
parent
2490631d5b
commit
233299e5c8
8 changed files with 39 additions and 6 deletions
|
@ -1704,7 +1704,18 @@ void floatToBuffer(OutBuffer *buf, Type *type, real_t value)
|
||||||
if (r == value) // if exact duplication
|
if (r == value) // if exact duplication
|
||||||
buf->writestring(buffer);
|
buf->writestring(buffer);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
#ifdef __HAIKU__ // broken printf workaround
|
||||||
|
char buffer2[25];
|
||||||
|
char *ptr = (char *)&value;
|
||||||
|
for(int i = 0; i < sizeof(value); i++)
|
||||||
|
snprintf(buffer2, sizeof(char), "%x", ptr[i]);
|
||||||
|
|
||||||
|
buf->writestring(buffer2);
|
||||||
|
#else
|
||||||
buf->printf("%La", value); // ensure exact duplication
|
buf->printf("%La", value); // ensure exact duplication
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (type)
|
if (type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
/* Lexical Analyzer */
|
/* Lexical Analyzer */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -147,6 +147,7 @@ enum OS
|
||||||
{
|
{
|
||||||
OSinvalid,
|
OSinvalid,
|
||||||
OSLinux,
|
OSLinux,
|
||||||
|
OSHaiku,
|
||||||
OSWindows,
|
OSWindows,
|
||||||
OSMacOSX,
|
OSMacOSX,
|
||||||
OSFreeBSD,
|
OSFreeBSD,
|
||||||
|
|
|
@ -315,7 +315,7 @@ char *Port::strupr(char *s)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if linux || __APPLE__ || __FreeBSD__ || __MINGW32__
|
#if linux || __APPLE__ || __FreeBSD__ || __MINGW32__ || __HAIKU__
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#if linux
|
#if linux
|
||||||
|
@ -368,7 +368,7 @@ PortInitializer::PortInitializer()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __MINGW32__
|
#if !defined __MINGW32__ && !defined __HAIKU__
|
||||||
#undef isnan
|
#undef isnan
|
||||||
#endif
|
#endif
|
||||||
int Port::isNan(double r)
|
int Port::isNan(double r)
|
||||||
|
@ -377,6 +377,8 @@ int Port::isNan(double r)
|
||||||
return __inline_isnan(r);
|
return __inline_isnan(r);
|
||||||
#elif defined __MINGW32__
|
#elif defined __MINGW32__
|
||||||
return isnan(r);
|
return isnan(r);
|
||||||
|
#elif defined __HAIKU__
|
||||||
|
return isnan(r);
|
||||||
#else
|
#else
|
||||||
return ::isnan(r);
|
return ::isnan(r);
|
||||||
#endif
|
#endif
|
||||||
|
@ -388,6 +390,8 @@ int Port::isNan(long double r)
|
||||||
return __inline_isnan(r);
|
return __inline_isnan(r);
|
||||||
#elif defined __MINGW32__
|
#elif defined __MINGW32__
|
||||||
return isnan(r);
|
return isnan(r);
|
||||||
|
#elif defined __HAIKU__
|
||||||
|
return isnan(r);
|
||||||
#else
|
#else
|
||||||
return ::isnan(r);
|
return ::isnan(r);
|
||||||
#endif
|
#endif
|
||||||
|
@ -415,7 +419,7 @@ int Port::isFinite(double r)
|
||||||
return ::finite(r);
|
return ::finite(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __MINGW32__
|
#if !defined __MINGW32__ && !defined __HAIKU__
|
||||||
#undef isinf
|
#undef isinf
|
||||||
#endif
|
#endif
|
||||||
int Port::isInfinity(double r)
|
int Port::isInfinity(double r)
|
||||||
|
@ -424,6 +428,8 @@ int Port::isInfinity(double r)
|
||||||
return fpclassify(r) == FP_INFINITE;
|
return fpclassify(r) == FP_INFINITE;
|
||||||
#elif defined __MINGW32__
|
#elif defined __MINGW32__
|
||||||
return isinf(r);
|
return isinf(r);
|
||||||
|
#elif defined __HAIKU__
|
||||||
|
return isinf(r);
|
||||||
#else
|
#else
|
||||||
return ::isinf(r);
|
return ::isinf(r);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,7 +40,7 @@ struct Port
|
||||||
static double dbl_min;
|
static double dbl_min;
|
||||||
static long double ldbl_max;
|
static long double ldbl_max;
|
||||||
|
|
||||||
#if __GNUC__
|
#if __GNUC__ && !defined __HAIKU__
|
||||||
// These conflict with macros in math.h, should rename them
|
// These conflict with macros in math.h, should rename them
|
||||||
#undef isnan
|
#undef isnan
|
||||||
#undef isfinite
|
#undef isfinite
|
||||||
|
|
|
@ -34,6 +34,10 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
#include <iostream>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if POSIX
|
#if POSIX
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
|
@ -172,7 +172,9 @@ int linkExecutable(const char* argv0)
|
||||||
args.push_back("-lpthread");
|
args.push_back("-lpthread");
|
||||||
args.push_back("-lm");
|
args.push_back("-lm");
|
||||||
break;
|
break;
|
||||||
|
case OSHaiku:
|
||||||
|
args.push_back("-lroot");
|
||||||
|
break;
|
||||||
case OSWindows:
|
case OSWindows:
|
||||||
// FIXME: I'd assume kernel32 etc
|
// FIXME: I'd assume kernel32 etc
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -589,6 +589,13 @@ LDC_TARGETS
|
||||||
VersionCondition::addPredefinedGlobalIdent("linux");
|
VersionCondition::addPredefinedGlobalIdent("linux");
|
||||||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||||
}
|
}
|
||||||
|
// haiku
|
||||||
|
else if (triple.find("haiku") != npos)
|
||||||
|
{
|
||||||
|
global.params.os = OSHaiku;
|
||||||
|
VersionCondition::addPredefinedGlobalIdent("Haiku");
|
||||||
|
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||||
|
}
|
||||||
// darwin
|
// darwin
|
||||||
else if (triple.find("-darwin") != npos)
|
else if (triple.find("-darwin") != npos)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue