Bugzilla – Attachment 53970 Details for
Bug 97562
python miscompiled on ppc64
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
gcc testcase
mathmodule.c (text/plain), 1.65 KB, created by
Jan Matejek
on 2005-10-13 18:12:21 UTC
(
hide
)
Description:
gcc testcase
Filename:
MIME Type:
Creator:
Jan Matejek
Created:
2005-10-13 18:12:21 UTC
Size:
1.65 KB
patch
obsolete
>/* Math module -- standard C math library functions, pi and e */ > >#include "Python.h" >#include "longintrepr.h" > >/* A decent logarithm is easy to compute even for huge longs, but libm can't > do that by itself -- loghelper can. func is log or log10, and name is > "log" or "log10". Note that overflow isn't possible: a long can contain > no more than INT_MAX * SHIFT bits, so has value certainly less than > 2**(2**64 * 2**16) == 2**2**80, and log2 of that is 2**80, which is > small enough to fit in an IEEE single. log and log10 are even smaller. >*/ >static PyObject* >loghelper(PyObject* args, double (*func)(double), char *format, PyObject *arg) >{ > /* If it is long, do it ourselves. */ > if (PyLong_Check(arg)) { > double x; > int e; > x = _PyLong_AsScaledDouble(arg, &e); > x = func(x) + (e * (double)SHIFT) * func(2.0); > return PyFloat_FromDouble(x); > } > > /* Else let libm handle it by itself. */ > return PyFloat_FromDouble(2.302585); >} > >static PyObject * >math_log(PyObject *self, PyObject *args) >{ > PyObject *arg; > PyObject *base = NULL; > PyObject *num, *den; > PyObject *ans; > PyObject *newargs; > > PyArg_UnpackTuple(args, "log", 1, 2, &arg, &base); > > newargs = PyTuple_Pack(1, arg); > num = loghelper(newargs, log, "d:log", arg); > > > Py_DECREF(newargs); > newargs = PyTuple_Pack(1, base); > den = loghelper(newargs, log, "d:log", base); > > > Py_DECREF(newargs); > > ans = PyNumber_Divide(num, den); > Py_DECREF(num); > Py_DECREF(den); > return ans; >} > >static PyMethodDef math_methods[] = { > {"log", math_log, METH_VARARGS, NULL}, > {NULL, NULL} /* sentinel */ >}; > >PyMODINIT_FUNC >initmath(void) >{ > PyObject *m; > > m = Py_InitModule3("math", math_methods, NULL); > PyModule_GetDict(m); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
Attachments on
bug 97562
: 53970