Applyed Haiku patch by MrSunshine

This commit is contained in:
Alexey Prokhin
2010-10-08 10:19:46 +04:00
parent 9f26583e52
commit 5be6206eb8
6 changed files with 29 additions and 3 deletions

View File

@@ -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)
{

View File

@@ -12,6 +12,8 @@
#include <cmath>
#endif
#include <sstream>
/* Lexical Analyzer */
#include <stdio.h>

View File

@@ -153,6 +153,7 @@ enum OS
{
OSinvalid,
OSLinux,
OSHaiku,
OSWindows,
OSMacOSX,
OSFreeBSD,

View File

@@ -315,7 +315,7 @@ char *Port::strupr(char *s)
#endif
#if linux || __APPLE__ || __FreeBSD__
#if linux || __APPLE__ || __FreeBSD__ || __HAIKU__
#include <math.h>
#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

View File

@@ -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

View File

@@ -34,6 +34,10 @@
#include <errno.h>
#endif
#ifdef __HAIKU__
#include <iostream>
#endif
#if POSIX
#include <sys/types.h>
#include <sys/stat.h>