Skip to content

Commit

Permalink
merge D2 pull 736
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Feb 19, 2012
1 parent bdde56f commit 80c4f89
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 143 deletions.
4 changes: 2 additions & 2 deletions src/root/dchar.h
Expand Up @@ -152,10 +152,10 @@ typedef char dchar;
struct Dchar
{
static dchar *inc(dchar *p) { return p + 1; }
static dchar *dec(dchar *pstart, dchar *p) { return p - 1; }
static dchar *dec(dchar *pstart, dchar *p) { (void)pstart; return p - 1; }
static int len(const dchar *p) { return strlen(p); }
static int get(dchar *p) { return *p & 0xFF; }
static int getprev(dchar *pstart, dchar *p) { return p[-1] & 0xFF; }
static int getprev(dchar *pstart, dchar *p) { (void)pstart; return p[-1] & 0xFF; }
static dchar *put(dchar *p, unsigned c) { *p = c; return p + 1; }
static int cmp(dchar *s1, dchar *s2) { return strcmp(s1, s2); }
static int memcmp(const dchar *s1, const dchar *s2, int nchars) { return ::memcmp(s1, s2, nchars); }
Expand Down
2 changes: 2 additions & 0 deletions src/root/lstring.h
Expand Up @@ -19,8 +19,10 @@ struct Lstring
{
unsigned length;

#ifndef IN_GCC
// Disable warning about nonstandard extension
#pragma warning (disable : 4200)
#endif
dchar string[];

static Lstring zero; // 0 length string
Expand Down
141 changes: 0 additions & 141 deletions src/root/port.c
Expand Up @@ -649,144 +649,3 @@ char *Port::strupr(char *s)

#endif

#if IN_GCC

#include <math.h>
#include <bits/nan.h>
#include <bits/mathdef.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

static double zero = 0;
double Port::nan = NAN;
double Port::infinity = 1 / zero;
double Port::dbl_max = 1.7976931348623157e308;
double Port::dbl_min = 5e-324;
long double Port::ldbl_max = LDBL_MAX;

#include "d-gcc-real.h"
extern "C" bool real_isnan (const real_t *);

struct PortInitializer
{
PortInitializer();
};

static PortInitializer portinitializer;

PortInitializer::PortInitializer()
{
Port::infinity = real_t::getinfinity();
Port::nan = real_t::getnan(real_t::LongDouble);
}

#undef isnan
int Port::isNan(double r)
{
#if __APPLE__
return __inline_isnan(r);
#else
return ::isnan(r);
#endif
}

int Port::isNan(long double r)
{
return real_isnan(&r);
}

int Port::isSignallingNan(double r)
{
/* A signalling NaN is a NaN with 0 as the most significant bit of
* its significand, which is bit 51 of 0..63 for 64 bit doubles.
*/
return isNan(r) && !((((unsigned char*)&r)[6]) & 8);
}

int Port::isSignallingNan(long double r)
{
/* A signalling NaN is a NaN with 0 as the most significant bit of
* its significand, which is bit 62 of 0..79 for 80 bit reals.
*/
return isNan(r) && !((((unsigned char*)&r)[7]) & 0x40);
}

#undef isfinite
int Port::isFinite(double r)
{
return ::finite(r);
}

#undef isinf
int Port::isInfinity(double r)
{
return ::isinf(r);
}

#undef signbit
int Port::Signbit(double r)
{
return (long)(((long *)&r)[1] & 0x80000000);
}

double Port::floor(double d)
{
return ::floor(d);
}

double Port::pow(double x, double y)
{
return ::pow(x, y);
}

unsigned long long Port::strtoull(const char *p, char **pend, int base)
{
return ::strtoull(p, pend, base);
}

char *Port::ull_to_string(char *buffer, ulonglong ull)
{
sprintf(buffer, "%llu", ull);
return buffer;
}

wchar_t *Port::ull_to_string(wchar_t *buffer, ulonglong ull)
{
swprintf(buffer, L"%llu", ull);
return buffer;
}

double Port::ull_to_double(ulonglong ull)
{
return (double) ull;
}

const char *Port::list_separator()
{
return ",";
}

const wchar_t *Port::wlist_separator()
{
return L",";
}

char *Port::strupr(char *s)
{
char *t = s;

while (*s)
{
*s = toupper(*s);
s++;
}

return t;
}

#endif

0 comments on commit 80c4f89

Please sign in to comment.