Skip to content

Commit

Permalink
Merge pull request #3787 from yebblies/sqrtport
Browse files Browse the repository at this point in the history
[DDMD] Move sqrt into Port
  • Loading branch information
9rnsr committed Jul 20, 2014
2 parents e47d845 + 6bcbae1 commit 82b031c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/builtin.c
Expand Up @@ -69,7 +69,7 @@ Expression *eval_sqrt(Loc loc, FuncDeclaration *fd, Expressions *arguments)
{
Expression *arg0 = (*arguments)[0];
assert(arg0->op == TOKfloat64);
return new RealExp(loc, sqrtl(arg0->toReal()), arg0->type);
return new RealExp(loc, Port::sqrt(arg0->toReal()), arg0->type);
}

Expression *eval_fabs(Loc loc, FuncDeclaration *fd, Expressions *arguments)
Expand Down
25 changes: 25 additions & 0 deletions src/root/port.c
Expand Up @@ -77,6 +77,11 @@ int Port::isInfinity(double r)
return (::fpclassify(r) == FP_INFINITE);
}

longdouble Port::sqrt(longdouble x)
{
return ::sqrtl(x);
}

longdouble Port::fmodl(longdouble x, longdouble y)
{
return ::fmodl(x, y);
Expand Down Expand Up @@ -214,6 +219,11 @@ int Port::isInfinity(double r)
return (::_fpclass(r) & (_FPCLASS_NINF | _FPCLASS_PINF));
}

longdouble Port::sqrt(longdouble x)
{
return ::sqrtl(x);
}

longdouble Port::fmodl(longdouble x, longdouble y)
{
return ::fmodl(x, y);
Expand Down Expand Up @@ -352,6 +362,11 @@ int Port::isInfinity(double r)
return isinf(r);
}

longdouble Port::sqrt(longdouble x)
{
return ::sqrtl(x);
}

longdouble Port::fmodl(longdouble x, longdouble y)
{
return ::fmodl(x, y);
Expand Down Expand Up @@ -572,6 +587,11 @@ int Port::isInfinity(double r)
#endif
}

longdouble Port::sqrt(longdouble x)
{
return ::sqrtl(x);
}

longdouble Port::fmodl(longdouble x, longdouble y)
{
#if __FreeBSD__ && __FreeBSD_version < 800000 || __OpenBSD__
Expand Down Expand Up @@ -753,6 +773,11 @@ int Port::isInfinity(double r)
return isinf(r);
}

longdouble Port::sqrt(longdouble x)
{
return ::sqrtl(x);
}

longdouble Port::fmodl(longdouble x, longdouble y)
{
return ::fmodl(x, y);
Expand Down
1 change: 1 addition & 0 deletions src/root/port.h
Expand Up @@ -51,6 +51,7 @@ struct Port
static int isInfinity(double);

static longdouble fmodl(longdouble x, longdouble y);
static longdouble sqrt(longdouble x);
static int fequal(longdouble x, longdouble y);

static char *strupr(char *);
Expand Down

0 comments on commit 82b031c

Please sign in to comment.