libzahl

big integer library
git clone git://git.suckless.org/libzahl
Log | Files | Refs | README | LICENSE

commit 4e659044778dfd05a5f5d2b41611e7737a0eb825
parent b0e210a02b8576828ac64e8b97bd565fd28c8748
Author: Mattias Andrée <maandree@kth.se>
Date:   Fri,  6 May 2016 19:00:44 +0200

Make zdiv and zmod (calls zdivmod) inline

Signed-off-by: Mattias Andrée <maandree@kth.se>

Diffstat:
MMakefile | 4++--
Dsrc/zdiv.c | 9---------
Dsrc/zmod.c | 9---------
Mzahl.h | 4++--
Mzahl/inlines.h | 14++++++++++++++
Mzahl/internals.h | 4++++
6 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/Makefile b/Makefile @@ -11,14 +11,12 @@ FUN =\ zadd\ zand\ zbset\ - zdiv\ zdivmod\ zerror\ zfree\ zgcd\ zload\ zlsh\ - zmod\ zmodmul\ zmodpow\ zmodpowu\ @@ -50,10 +48,12 @@ INLINE_FUN =\ zcmpi\ zcmpmag\ zcmpu\ + zdiv\ zeven\ zeven_nonzero\ zinit\ zlsb\ + zmod\ zneg\ zodd\ zodd_nonzero\ diff --git a/src/zdiv.c b/src/zdiv.c @@ -1,9 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include "internals.h" - - -void -zdiv(z_t a, z_t b, z_t c) -{ - zdivmod(a, libzahl_tmp_div, b, c); -} diff --git a/src/zmod.c b/src/zmod.c @@ -1,9 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include "internals.h" - - -void -zmod(z_t a, z_t b, z_t c) -{ - zdivmod(libzahl_tmp_mod, a, b, c); -} diff --git a/zahl.h b/zahl.h @@ -93,9 +93,9 @@ void zadd(z_t, z_t, z_t); /* a := b + c */ void zsub(z_t, z_t, z_t); /* a := b - c */ ZAHL_INLINE void zmul(z_t, z_t, z_t); /* a := b * c */ void zmodmul(z_t, z_t, z_t, z_t); /* a := (b * c) % d */ -void zdiv(z_t, z_t, z_t); /* a := b / c */ +ZAHL_INLINE void zdiv(z_t, z_t, z_t); /* a := b / c */ void zdivmod(z_t, z_t, z_t, z_t); /* a := c / d, b = c % d */ -void zmod(z_t, z_t, z_t); /* a := b % c */ +ZAHL_INLINE void zmod(z_t, z_t, z_t); /* a := b % c */ ZAHL_INLINE void zsqr(z_t, z_t); /* a := b² */ void zmodsqr(z_t, z_t, z_t); /* a := b² % c */ void zpow(z_t, z_t, z_t); /* a := b ↑ c */ diff --git a/zahl/inlines.h b/zahl/inlines.h @@ -291,3 +291,17 @@ zsqr(z_t a, z_t b) ZAHL_SET_SIGNUM(a, 1); } } + + +ZAHL_INLINE void +zdiv(z_t a, z_t b, z_t c) +{ + zdivmod(a, libzahl_tmp_div, b, c); +} + + +ZAHL_INLINE void +zmod(z_t a, z_t b, z_t c) +{ + zdivmod(libzahl_tmp_mod, a, b, c); +} diff --git a/zahl/internals.h b/zahl/internals.h @@ -107,6 +107,10 @@ struct zahl { }; +extern struct zahl libzahl_tmp_div[1]; +extern struct zahl libzahl_tmp_mod[1]; + + void libzahl_realloc(struct zahl *, size_t); ZAHL_INLINE void