[pypy-svn] r75874 - in pypy/branch/fast-forward/pypy/rpython: . lltypesystem/module
benjamin at codespeak.net
benjamin at codespeak.net
Tue Jul 6 03:07:01 CEST 2010
Author: benjamin
Date: Tue Jul 6 03:06:59 2010
New Revision: 75874
Modified:
pypy/branch/fast-forward/pypy/rpython/extfuncregistry.py
pypy/branch/fast-forward/pypy/rpython/lltypesystem/module/ll_math.py
Log:
add ll implementations of isinf and isnan
Modified: pypy/branch/fast-forward/pypy/rpython/extfuncregistry.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/extfuncregistry.py (original)
+++ pypy/branch/fast-forward/pypy/rpython/extfuncregistry.py Tue Jul 6 03:06:59 2010
@@ -10,6 +10,7 @@
from pypy.rpython.ootypesystem.module import ll_math as oo_math
from pypy.rpython.module import ll_os
from pypy.rpython.module import ll_time
+from pypy.rlib import rarithmetic
try:
import termios
except ImportError:
@@ -21,10 +22,18 @@
# and are part of math.h
for name in ll_math.unary_math_functions:
llimpl = getattr(ll_math, 'll_math_%s' % name, None)
- register_external(getattr(math, name), [float], float,
+ f = getattr(math, name)
+ register_external(f, [float], float,
export_name="ll_math.ll_math_%s" % name,
sandboxsafe=True, llimpl=llimpl)
+register_external(rarithmetic.isinf, [float], bool,
+ export_name="ll_math.ll_math_isinf", sandboxsafe=True,
+ llimpl=ll_math.ll_math_isinf)
+register_external(rarithmetic.isnan, [float], bool,
+ export_name="ll_math.ll_math_isnan", sandboxsafe=True,
+ llimpl=ll_math.ll_math_isnan)
+
complex_math_functions = [
('frexp', [float], (float, int)),
('ldexp', [float, int], float),
Modified: pypy/branch/fast-forward/pypy/rpython/lltypesystem/module/ll_math.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/lltypesystem/module/ll_math.py (original)
+++ pypy/branch/fast-forward/pypy/rpython/lltypesystem/module/ll_math.py Tue Jul 6 03:06:59 2010
@@ -36,6 +36,8 @@
math_fmod = llexternal('fmod', [rffi.DOUBLE, rffi.DOUBLE], rffi.DOUBLE)
math_hypot = llexternal(underscore + 'hypot',
[rffi.DOUBLE, rffi.DOUBLE], rffi.DOUBLE)
+math_isinf = llexternal('isinf', [rffi.DOUBLE], rffi.INT)
+math_isnan = llexternal('isnan', [rffi.DOUBLE], rffi.INT)
# ____________________________________________________________
#
@@ -69,6 +71,14 @@
# Custom implementations
+def ll_math_isnan(y):
+ return bool(math_isnan(y))
+
+
+def ll_math_isinf(y):
+ return bool(math_isinf(y))
+
+
def ll_math_atan2(y, x):
"""wrapper for atan2 that deals directly with special cases before
delegating to the platform libm for the remaining cases. This
More information about the Pypy-commit
mailing list