Skip to content

Commit

Permalink
put fmodl in Port
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed May 18, 2011
1 parent d6a98ae commit fc7e107
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/constfold.c
Expand Up @@ -36,10 +36,6 @@ extern "C" bool real_isnan (const real_t *);

static real_t zero; // work around DMC bug for now

#if __FreeBSD__ || __OpenBSD__
#define fmodl fmod // hack for now, fix later
#endif

#define LOG 0

Expression *expType(Type *type, Expression *e)
Expand Down Expand Up @@ -495,22 +491,22 @@ Expression *Mod(Type *type, Expression *e1, Expression *e2)
{ real_t r2 = e2->toReal();

#ifdef __DMC__
c = fmodl(e1->toReal(), r2) + fmodl(e1->toImaginary(), r2) * I;
c = Port::fmodl(e1->toReal(), r2) + Port::fmodl(e1->toImaginary(), r2) * I;
#elif defined(IN_GCC)
c = complex_t(e1->toReal() % r2, e1->toImaginary() % r2);
#else
c = complex_t(fmodl(e1->toReal(), r2), fmodl(e1->toImaginary(), r2));
c = complex_t(Port::fmodl(e1->toReal(), r2), Port::fmodl(e1->toImaginary(), r2));
#endif
}
else if (e2->type->isimaginary())
{ real_t i2 = e2->toImaginary();

#ifdef __DMC__
c = fmodl(e1->toReal(), i2) + fmodl(e1->toImaginary(), i2) * I;
c = Port::fmodl(e1->toReal(), i2) + Port::fmodl(e1->toImaginary(), i2) * I;
#elif defined(IN_GCC)
c = complex_t(e1->toReal() % i2, e1->toImaginary() % i2);
#else
c = complex_t(fmodl(e1->toReal(), i2), fmodl(e1->toImaginary(), i2));
c = complex_t(Port::fmodl(e1->toReal(), i2), Port::fmodl(e1->toImaginary(), i2));
#endif
}
else
Expand Down
19 changes: 19 additions & 0 deletions src/root/port.c
Expand Up @@ -70,6 +70,11 @@ double Port::pow(double x, double y)
return ::pow(x, y);
}

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

unsigned long long Port::strtoull(const char *p, char **pend, int base)
{
return ::strtoull(p, pend, base);
Expand Down Expand Up @@ -201,6 +206,11 @@ double Port::pow(double x, double y)
return ::pow(x, y);
}

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

unsigned _int64 Port::strtoull(const char *p, char **pend, int base)
{
unsigned _int64 number = 0;
Expand Down Expand Up @@ -442,6 +452,15 @@ double Port::pow(double x, double y)
return ::pow(x, y);
}

long double Port::fmodl(long double x, long double y)
{
#if __FreeBSD__ || __OpenBSD__
return ::fmod(x, y); // hack for now, fix later
#else
return ::fmodl(x, y);
#endif
}

unsigned long long Port::strtoull(const char *p, char **pend, int base)
{
return ::strtoull(p, pend, base);
Expand Down
2 changes: 2 additions & 0 deletions src/root/port.h
Expand Up @@ -61,6 +61,8 @@ struct Port
static double floor(double);
static double pow(double x, double y);

static long double fmodl(long double x, long double y);

static ulonglong strtoull(const char *p, char **pend, int base);

static char *ull_to_string(char *buffer, ulonglong ull);
Expand Down

0 comments on commit fc7e107

Please sign in to comment.