"Marco Bodrato" <[email protected]> writes: On Fri, August 21, 2015 10:36 pm, Marco Bodrato wrote: > Maybe changing the prototype of mpq_cmp_maybe_z to > int mpq_cmp_maybe_z (mpq_srcptr op1, const void *op2, int op2_is_mpz) ... no, void * is a nonsense ... Maybe the attached version is better, it uses the cast (mpz_srcptr) op2 when the numerator is needed, and a plain DEN(op2) to access the denominator if it is available. (Being busy, therefore slow to read code.)
An alternative to messing with void * would be an interface like this: static int cmp_helper (mpq_srcptr op1, mpz_srcptr op2num, mpz_srcptr op2den) ... Then have mpq_cmp simply split its op2 arg before dropping into the helper function, and mpz_cmp_z pass its 2nd arg as op2num, and then ether pass a global static op2den which is compile-time initialised to 1, or perhaps pass NULL. That'd allow tail calls for most machines, and should not need many pesky branches. -- Torbjörn Please encrypt, key id 0xC8601622 _______________________________________________ gmp-devel mailing list [email protected] https://gmplib.org/mailman/listinfo/gmp-devel
