mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-12 05:47:11 +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
|
||||
buf->writestring(buffer);
|
||||
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
|
||||
#endif
|
||||
}
|
||||
|
||||
if (type)
|
||||
{
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include <cmath>
|
||||
#endif
|
||||
|
||||
#include <sstream>
|
||||
|
||||
/* Lexical Analyzer */
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -147,6 +147,7 @@ enum OS
|
|||
{
|
||||
OSinvalid,
|
||||
OSLinux,
|
||||
OSHaiku,
|
||||
OSWindows,
|
||||
OSMacOSX,
|
||||
OSFreeBSD,
|
||||
|
|
|
@ -315,7 +315,7 @@ char *Port::strupr(char *s)
|
|||
|
||||
#endif
|
||||
|
||||
#if linux || __APPLE__ || __FreeBSD__ || __MINGW32__
|
||||
#if linux || __APPLE__ || __FreeBSD__ || __MINGW32__ || __HAIKU__
|
||||
|
||||
#include <math.h>
|
||||
#if linux
|
||||
|
@ -368,7 +368,7 @@ PortInitializer::PortInitializer()
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifndef __MINGW32__
|
||||
#if !defined __MINGW32__ && !defined __HAIKU__
|
||||
#undef isnan
|
||||
#endif
|
||||
int Port::isNan(double r)
|
||||
|
@ -377,6 +377,8 @@ int Port::isNan(double r)
|
|||
return __inline_isnan(r);
|
||||
#elif defined __MINGW32__
|
||||
return isnan(r);
|
||||
#elif defined __HAIKU__
|
||||
return isnan(r);
|
||||
#else
|
||||
return ::isnan(r);
|
||||
#endif
|
||||
|
@ -388,6 +390,8 @@ int Port::isNan(long double r)
|
|||
return __inline_isnan(r);
|
||||
#elif defined __MINGW32__
|
||||
return isnan(r);
|
||||
#elif defined __HAIKU__
|
||||
return isnan(r);
|
||||
#else
|
||||
return ::isnan(r);
|
||||
#endif
|
||||
|
@ -415,7 +419,7 @@ int Port::isFinite(double r)
|
|||
return ::finite(r);
|
||||
}
|
||||
|
||||
#ifndef __MINGW32__
|
||||
#if !defined __MINGW32__ && !defined __HAIKU__
|
||||
#undef isinf
|
||||
#endif
|
||||
int Port::isInfinity(double r)
|
||||
|
@ -424,6 +428,8 @@ int Port::isInfinity(double r)
|
|||
return fpclassify(r) == FP_INFINITE;
|
||||
#elif defined __MINGW32__
|
||||
return isinf(r);
|
||||
#elif defined __HAIKU__
|
||||
return isinf(r);
|
||||
#else
|
||||
return ::isinf(r);
|
||||
#endif
|
||||
|
|
|
@ -40,7 +40,7 @@ struct Port
|
|||
static double dbl_min;
|
||||
static long double ldbl_max;
|
||||
|
||||
#if __GNUC__
|
||||
#if __GNUC__ && !defined __HAIKU__
|
||||
// These conflict with macros in math.h, should rename them
|
||||
#undef isnan
|
||||
#undef isfinite
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#ifdef __HAIKU__
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#if POSIX
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
|
@ -172,7 +172,9 @@ int linkExecutable(const char* argv0)
|
|||
args.push_back("-lpthread");
|
||||
args.push_back("-lm");
|
||||
break;
|
||||
|
||||
case OSHaiku:
|
||||
args.push_back("-lroot");
|
||||
break;
|
||||
case OSWindows:
|
||||
// FIXME: I'd assume kernel32 etc
|
||||
break;
|
||||
|
|
|
@ -589,6 +589,13 @@ LDC_TARGETS
|
|||
VersionCondition::addPredefinedGlobalIdent("linux");
|
||||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||
}
|
||||
// haiku
|
||||
else if (triple.find("haiku") != npos)
|
||||
{
|
||||
global.params.os = OSHaiku;
|
||||
VersionCondition::addPredefinedGlobalIdent("Haiku");
|
||||
VersionCondition::addPredefinedGlobalIdent("Posix");
|
||||
}
|
||||
// darwin
|
||||
else if (triple.find("-darwin") != npos)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue