/*1* Copyright (C) 2017 - This file is part of libecc project2*3* Authors:4* Ryad BENADJILA <[email protected]>5* Arnaud EBALARD <[email protected]>6* Jean-Pierre FLORI <[email protected]>7*8* Contributors:9* Nicolas VIVET <[email protected]>10* Karim KHALFALLAH <[email protected]>11*12* This software is licensed under a dual BSD and GPL v2 license.13* See LICENSE file at the root folder of the project.14*/15#ifndef __NN_DIV_H__16#define __NN_DIV_H__17#include <libecc/nn/nn.h>18#include <libecc/nn/nn_div_public.h>1920/* Compute quotient q and remainder r for given a and b such that a = q*b + r */21/* ATTRIBUTE_WARN_UNUSED_RET int nn_divrem(nn_t q, nn_t r, nn_src_t a, nn_src_t b); (declared in public header) */22ATTRIBUTE_WARN_UNUSED_RET int nn_divrem_notrim(nn_t q, nn_t r, nn_src_t a, nn_src_t b);23ATTRIBUTE_WARN_UNUSED_RET int nn_divrem_unshifted(nn_t q, nn_t r, nn_src_t a, nn_src_t b, word_t v,24bitcnt_t cnt);25ATTRIBUTE_WARN_UNUSED_RET int nn_divrem_normalized(nn_t q, nn_t r, nn_src_t a, nn_src_t b, word_t v);2627/* Compute r = a mod b */28/* ATTRIBUTE_WARN_UNUSED_RET int nn_mod(nn_t r, nn_src_t a, nn_src_t b); (declared in public header) */29ATTRIBUTE_WARN_UNUSED_RET int nn_mod_notrim(nn_t r, nn_src_t a, nn_src_t b);30ATTRIBUTE_WARN_UNUSED_RET int nn_mod_unshifted(nn_t r, nn_src_t a, nn_src_t b, word_t v, bitcnt_t cnt);31ATTRIBUTE_WARN_UNUSED_RET int nn_mod_normalized(nn_t r, nn_src_t a, nn_src_t b, word_t v);3233/* Compute floor(B^3/(d+1)) - B. */34ATTRIBUTE_WARN_UNUSED_RET int wreciprocal(word_t dh, word_t dl, word_t *reciprocal);35ATTRIBUTE_WARN_UNUSED_RET int nn_compute_div_coefs(nn_t p_normalized, word_t *p_shift,36word_t *p_reciprocal, nn_src_t p_in);3738/* Compute gcd of a and b */39/* ATTRIBUTE_WARN_UNUSED_RET int nn_gcd(nn_t d, nn_src_t a, nn_src_t b, int *sign); (declared in public header) */40/* ATTRIBUTE_WARN_UNUSED_RET int nn_xgcd(nn_t g, nn_t u, nn_t v, nn_src_t a, nn_src_t b, int *sign); (declared in public header) */4142#endif /* __NN_DIV_H__ */434445