diff --git a/dmd2/expression.c b/dmd2/expression.c index 35c24208..3a866751 100644 --- a/dmd2/expression.c +++ b/dmd2/expression.c @@ -1881,7 +1881,18 @@ void floatToBuffer(OutBuffer *buf, Type *type, real_t value) if (r == value) // if exact duplication buf->writestring(buffer); else - buf->printf("%La", value); // ensure exact duplication + { +#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) { diff --git a/dmd2/lexer.c b/dmd2/lexer.c index e6da85a5..3f41618e 100644 --- a/dmd2/lexer.c +++ b/dmd2/lexer.c @@ -12,6 +12,8 @@ #include #endif +#include + /* Lexical Analyzer */ #include diff --git a/dmd2/mars.h b/dmd2/mars.h index c98ebfed..61ae0390 100644 --- a/dmd2/mars.h +++ b/dmd2/mars.h @@ -153,6 +153,7 @@ enum OS { OSinvalid, OSLinux, + OSHaiku, OSWindows, OSMacOSX, OSFreeBSD, diff --git a/dmd2/root/port.c b/dmd2/root/port.c index 49794cc8..d4b20696 100644 --- a/dmd2/root/port.c +++ b/dmd2/root/port.c @@ -315,7 +315,7 @@ char *Port::strupr(char *s) #endif -#if linux || __APPLE__ || __FreeBSD__ +#if linux || __APPLE__ || __FreeBSD__ || __HAIKU__ #include #if linux @@ -368,11 +368,15 @@ PortInitializer::PortInitializer() #endif } +#ifndef __HAIKU__ #undef isnan +#endif int Port::isNan(double r) { #if __APPLE__ return __inline_isnan(r); +#elif defined __HAIKU__ + return isnan(r); #else return ::isnan(r); #endif @@ -382,6 +386,8 @@ int Port::isNan(long double r) { #if __APPLE__ return __inline_isnan(r); +#elif defined __HAIKU__ + return isnan(r); #else return ::isnan(r); #endif @@ -414,6 +420,8 @@ int Port::isInfinity(double r) { #if __APPLE__ return fpclassify(r) == FP_INFINITE; +#elif defined __HAIKU__ + return isinf(r); #else return ::isinf(r); #endif diff --git a/dmd2/root/port.h b/dmd2/root/port.h index d773c128..b4e7fbb7 100644 --- a/dmd2/root/port.h +++ b/dmd2/root/port.h @@ -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 diff --git a/dmd2/root/root.c b/dmd2/root/root.c index 0ff5a461..6cd0ea64 100644 --- a/dmd2/root/root.c +++ b/dmd2/root/root.c @@ -34,6 +34,10 @@ #include #endif +#ifdef __HAIKU__ +#include +#endif + #if POSIX #include #include