#endif /* def MPZ_GET_STR_BUG */
static PyObject *
-mpz_format(objp, base, withname)
- PyObject *objp;
- int base;
- unsigned char withname;
+mpz_format(PyObject *objp, int base, unsigned char withname)
{
mpzobject *mpzp = (mpzobject *)objp;
PyStringObject *strobjp;
/* MPZ methods */
static void
-mpz_dealloc(mpzp)
- mpzobject *mpzp;
+mpz_dealloc(mpzobject *mpzp)
{
#ifdef MPZ_DEBUG
fputs( "mpz_dealloc() called...\n", stderr );
static mpzobject *mpz_value_zero, *mpz_value_one, *mpz_value_mone;
static int
-mpz_compare(a, b)
- mpzobject *a, *b;
+mpz_compare(mpzobject *a, mpzobject *b)
{
int cmpres;
} /* mpz_compare() */
static PyObject *
-mpz_addition(a, b)
- mpzobject *a;
- mpzobject *b;
+mpz_addition(mpzobject *a, mpzobject *b)
{
mpzobject *z;
} /* mpz_addition() */
static PyObject *
-mpz_substract(a, b)
- mpzobject *a;
- mpzobject *b;
+mpz_substract(mpzobject *a, mpzobject *b)
{
mpzobject *z;
} /* mpz_substract() */
static PyObject *
-mpz_multiply(a, b)
- mpzobject *a;
- mpzobject *b;
+mpz_multiply(mpzobject *a, mpzobject *b)
{
#ifdef MPZ_SPARE_MALLOC
int cmpres;
} /* mpz_multiply() */
static PyObject *
-mpz_divide(a, b)
- mpzobject *a;
- mpzobject *b;
+mpz_divide(mpzobject *a, mpzobject *b)
{
#ifdef MPZ_SPARE_MALLOC
int cmpres;
} /* mpz_divide() */
static PyObject *
-mpz_remainder(a, b)
- mpzobject *a;
- mpzobject *b;
+mpz_remainder(mpzobject *a, mpzobject *b)
{
#ifdef MPZ_SPARE_MALLOC
int cmpres;
} /* mpz_remainder() */
static PyObject *
-mpz_div_and_mod(a, b)
- mpzobject *a;
- mpzobject *b;
+mpz_div_and_mod(mpzobject *a, mpzobject *b)
{
PyObject *z = NULL;
mpzobject *x = NULL, *y = NULL;
} /* mpz_div_and_mod() */
static PyObject *
-mpz_power(a, b, m)
- mpzobject *a;
- mpzobject *b;
- mpzobject *m;
+mpz_power(mpzobject *a, mpzobject *b, mpzobject *m)
{
mpzobject *z;
int cmpres;
static PyObject *
-mpz_negative(v)
- mpzobject *v;
+mpz_negative(mpzobject *v)
{
mpzobject *z;
static PyObject *
-mpz_positive(v)
- mpzobject *v;
+mpz_positive(mpzobject *v)
{
Py_INCREF(v);
return (PyObject *)v;
static PyObject *
-mpz_absolute(v)
- mpzobject *v;
+mpz_absolute(mpzobject *v)
{
mpzobject *z;
} /* mpz_absolute() */
static int
-mpz_nonzero(v)
- mpzobject *v;
+mpz_nonzero(mpzobject *v)
{
return mpz_cmp_ui(&v->mpz, (unsigned long int)0) != 0;
} /* mpz_nonzero() */
static PyObject *
-py_mpz_invert(v)
- mpzobject *v;
+py_mpz_invert(mpzobject *v)
{
mpzobject *z;
} /* py_mpz_invert() */
static PyObject *
-mpz_lshift(a, b)
- mpzobject *a;
- mpzobject *b;
+mpz_lshift(mpzobject *a, mpzobject *b)
{
int cmpres;
mpzobject *z;
} /* mpz_lshift() */
static PyObject *
-mpz_rshift(a, b)
- mpzobject *a;
- mpzobject *b;
+mpz_rshift(mpzobject *a, mpzobject *b)
{
int cmpres;
mpzobject *z;
} /* mpz_rshift() */
static PyObject *
-mpz_andfunc(a, b)
- mpzobject *a;
- mpzobject *b;
+mpz_andfunc(mpzobject *a, mpzobject *b)
{
mpzobject *z;
/* hack Hack HAck HACk HACK, XXX this code is dead slow */
void
-mpz_xor(res, op1, op2)
- MP_INT *res;
- const MP_INT *op1;
- const MP_INT *op2;
+mpz_xor(MP_INT *res, const MP_INT *op1, const MP_INT *op2)
{
MP_INT tmpmpz;
} /* mpz_xor() HACK */
static PyObject *
-mpz_xorfunc(a, b)
- mpzobject *a;
- mpzobject *b;
+mpz_xorfunc(mpzobject *a, mpzobject *b)
{
mpzobject *z;
} /* mpz_xorfunc() */
static PyObject *
-mpz_orfunc(a, b)
- mpzobject *a;
- mpzobject *b;
+mpz_orfunc(mpzobject *a, mpzobject *b)
{
mpzobject *z;
#include "longintrepr.h"
static PyObject *
-MPZ_mpz(self, args)
- PyObject *self;
- PyObject *args;
+MPZ_mpz(PyObject *self, PyObject *args)
{
mpzobject *mpzp;
PyObject *objp;
} /* MPZ_mpz() */
static mpzobject *
-mpz_mpzcoerce(z)
- PyObject *z;
+mpz_mpzcoerce(PyObject *z)
{
/* shortcut: 9 out of 10 times the type is already ok */
if (is_mpzobject(z)) {
const MP_INT *den, const MP_INT *mod);
static PyObject *
-MPZ_powm(self, args)
- PyObject *self;
- PyObject *args;
+MPZ_powm(PyObject *self, PyObject *args)
{
PyObject *base, *exp, *mod;
mpzobject *mpzbase = NULL, *mpzexp = NULL, *mpzmod = NULL;
static PyObject *
-MPZ_gcd(self, args)
- PyObject *self;
- PyObject *args;
+MPZ_gcd(PyObject *self, PyObject *args)
{
PyObject *op1, *op2;
mpzobject *mpzop1 = NULL, *mpzop2 = NULL;
static PyObject *
-MPZ_gcdext(self, args)
- PyObject *self;
- PyObject *args;
+MPZ_gcdext(PyObject *self, PyObject *args)
{
PyObject *op1, *op2, *z = NULL;
mpzobject *mpzop1 = NULL, *mpzop2 = NULL;
static PyObject *
-MPZ_sqrt(self, args)
- PyObject *self;
- PyObject *args;
+MPZ_sqrt(PyObject *self, PyObject *args)
{
PyObject *op;
mpzobject *mpzop = NULL;
static PyObject *
-MPZ_sqrtrem(self, args)
- PyObject *self;
- PyObject *args;
+MPZ_sqrtrem(PyObject *self, PyObject *args)
{
PyObject *op, *z = NULL;
mpzobject *mpzop = NULL;
static void
-#if __STDC__
mpz_divm(MP_INT *res, const MP_INT *num, const MP_INT *den, const MP_INT *mod)
-#else
-mpz_divm(res, num, den, mod)
- MP_INT *res;
- const MP_INT *num;
- const MP_INT *den;
- const MP_INT *mod;
-#endif
{
MP_INT s0, s1, q, r, x, d0, d1;
static PyObject *
-MPZ_divm(self, args)
- PyObject *self;
- PyObject *args;
+MPZ_divm(PyObject *self, PyObject *args)
{
PyObject *num, *den, *mod;
mpzobject *mpznum, *mpzden, *mpzmod = NULL;
/* MPZ methods-as-attributes */
#ifdef MPZ_CONVERSIONS_AS_METHODS
static PyObject *
-mpz_int(self, args)
- mpzobject *self;
- PyObject *args;
+mpz_int(mpzobject *self, PyObject *args)
#else /* def MPZ_CONVERSIONS_AS_METHODS */
static PyObject *
-mpz_int(self)
- mpzobject *self;
+mpz_int(mpzobject *self)
#endif /* def MPZ_CONVERSIONS_AS_METHODS else */
{
long sli;
static PyObject *
#ifdef MPZ_CONVERSIONS_AS_METHODS
-mpz_long(self, args)
- mpzobject *self;
- PyObject *args;
+mpz_long(mpzobject *self, PyObject *args)
#else /* def MPZ_CONVERSIONS_AS_METHODS */
-mpz_long(self)
- mpzobject *self;
+mpz_long(mpzobject *self)
#endif /* def MPZ_CONVERSIONS_AS_METHODS else */
{
int i, isnegative;
#ifdef MPZ_CONVERSIONS_AS_METHODS
static PyObject *
-mpz_float(self, args)
- mpzobject *self;
- PyObject *args;
+mpz_float(mpzobject *self, PyObject *args)
#else /* def MPZ_CONVERSIONS_AS_METHODS */
static PyObject *
-mpz_float(self)
- mpzobject *self;
+mpz_float(mpzobject *self)
#endif /* def MPZ_CONVERSIONS_AS_METHODS else */
{
int i, isnegative;
#ifdef MPZ_CONVERSIONS_AS_METHODS
static PyObject *
-mpz_hex(self, args)
- mpzobject *self;
- PyObject *args;
+mpz_hex(mpzobject *self, PyObject *args)
#else /* def MPZ_CONVERSIONS_AS_METHODS */
static PyObject *
-mpz_hex(self)
- mpzobject *self;
+mpz_hex(mpzobject *self)
#endif /* def MPZ_CONVERSIONS_AS_METHODS else */
{
#ifdef MPZ_CONVERSIONS_AS_METHODS
return NULL;
#endif /* def MPZ_CONVERSIONS_AS_METHODS */
- return mpz_format(self, 16, (unsigned char)1);
+ return mpz_format((PyObject *)self, 16, (unsigned char)1);
} /* mpz_hex() */
#ifdef MPZ_CONVERSIONS_AS_METHODS
static PyObject *
-mpz_oct(self, args)
- mpzobject *self;
- PyObject *args;
+mpz_oct(mpzobject *self, PyObject *args)
#else /* def MPZ_CONVERSIONS_AS_METHODS */
static PyObject *
-mpz_oct(self)
- mpzobject *self;
+mpz_oct(mpzobject *self)
#endif /* def MPZ_CONVERSIONS_AS_METHODS else */
{
#ifdef MPZ_CONVERSIONS_AS_METHODS
return NULL;
#endif /* def MPZ_CONVERSIONS_AS_METHODS */
- return mpz_format(self, 8, (unsigned char)1);
+ return mpz_format((PyObject *)self, 8, (unsigned char)1);
} /* mpz_oct() */
static PyObject *
-mpz_binary(self, args)
- mpzobject *self;
- PyObject *args;
+mpz_binary(mpzobject *self, PyObject *args)
{
int size;
PyStringObject *strobjp;
};
static PyObject *
-mpz_getattr(self, name)
- mpzobject *self;
- char *name;
+mpz_getattr(mpzobject *self, char *name)
{
return Py_FindMethod(mpz_methods, (PyObject *)self, name);
} /* mpz_getattr() */
static int
-mpz_coerce(pv, pw)
- PyObject **pv;
- PyObject **pw;
+mpz_coerce(PyObject **pv, PyObject **pw)
{
PyObject *z;
*pw = z;
}
else {
- if ((z = mpz_float(*pv, NULL)) == NULL)
+#ifdef MPZ_CONVERSIONS_AS_METHODS
+ if ((z = mpz_float((mpzobject *)(*pv), NULL)) == NULL)
+ return -1;
+#else /* def MPZ_CONVERSIONS_AS_METHODS */
+ if ((z = mpz_float((mpzobject *)(*pv))) == NULL)
return -1;
+#endif /* def MPZ_CONVERSIONS_AS_METHODS else */
Py_INCREF(*pw);
*pv = z;
static PyObject *
-mpz_repr(v)
- PyObject *v;
+mpz_repr(PyObject *v)
{
return mpz_format(v, 10, (unsigned char)1);
} /* mpz_repr() */
#define MP_DO_TEST(basep,size)
#endif /* def MP_TEST_ALLOC else */
-void *mp_allocate( alloc_size )
- size_t alloc_size;
+void *mp_allocate(size_t alloc_size)
{
void *res;
} /* mp_allocate() */
-void *mp_reallocate( ptr, old_size, new_size )
- void *ptr;
- size_t old_size;
- size_t new_size;
+void *mp_reallocate(void *ptr, size_t old_size, size_t new_size)
{
void *res;
} /* mp_reallocate() */
-void mp_free( ptr, size )
- void *ptr;
- size_t size;
+void mp_free(void *ptr, size_t size)
{
#ifdef MPZ_DEBUG