/* asm-ppc64.h -- (C) 2006 Mark Rodenkirch.

   PPC assember mulmod, powmod routines.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
*/

#if defined(NEED_mulmod64) && !defined(HAVE_mulmod64)
#define HAVE_mulmod64
#define HAVE_powmod64

extern uint64_t  pMagic;
extern uint64_t  pShift;

extern void getMagic(uint64_t d);
extern uint64_t expmod(uint64_t a, uint64_t b, uint64_t p, uint64_t magic,
                       uint64_t shift);
extern uint64_t mulmod(uint64_t a, uint64_t b, uint64_t p, uint64_t magic,
                       uint64_t shift);

#define powmod64(b, e, p) expmod(b, e, p, pMagic, pShift)
#define mulmod64(a, b, p) mulmod(a, b, p, pMagic, pShift)
#define pre2_mulmod64(a, b, p) mulmod(a, b, p, pMagic, pShift)

#define MOD64_GREATEST_PRIME UINT64_C(4503599627370449)
#define MOD64_SIEVE_LIMIT "2^52"

static inline void mod64_init(uint64_t p) { }
static inline void mod64_fini(void) { }
static inline void pre2_mulmod64_init(uint64_t b) { }
static inline void pre2_mulmod64_fini(void) { }

#endif
