diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-03-05 20:59:03 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-03-05 20:59:03 +0100 |
| commit | 48a89e0e110907a7a60ed8f5a0977e3b34661259 (patch) | |
| tree | 26b328e070d60f3e3f484d5b92fd01e8239e33d9 | |
| parent | Improve zsub, only copy to temp when necessary (diff) | |
| download | libzahl-48a89e0e110907a7a60ed8f5a0977e3b34661259.tar.gz libzahl-48a89e0e110907a7a60ed8f5a0977e3b34661259.tar.bz2 libzahl-48a89e0e110907a7a60ed8f5a0977e3b34661259.tar.xz | |
zinit is now an inline function
Signed-off-by: Mattias Andrée <maandree@kth.se>
| -rw-r--r-- | Makefile | 12 | ||||
| -rw-r--r-- | src/zinit.c | 10 | ||||
| -rw-r--r-- | zahl.h | 4 |
3 files changed, 12 insertions, 14 deletions
@@ -20,7 +20,6 @@ FUN =\ zerror\ zfree\ zgcd\ - zinit\ zload\ zlsb\ zlsh\ @@ -55,8 +54,17 @@ FUN =\ zunsetup\ zxor +INLINE_FUN =\ + zinit\ + zeven\ + zodd\ + zeven_nonzero\ + zodd_nonzero\ + zzero\ + zsignum + OBJ = $(FUN:=.o) -MAN = $(foreach F,$(FUN),man/$(F).3) man/libzahl.7 +MAN = $(foreach F,$(FUN) $(INLINE_FUN),man/$(F).3) man/libzahl.7 all: libzahl.a diff --git a/src/zinit.c b/src/zinit.c deleted file mode 100644 index fc6d9fc..0000000 --- a/src/zinit.c +++ /dev/null @@ -1,10 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include "internals.h" - - -void -zinit(z_t a) -{ - a->alloced = 0; - a->chars = 0; -} @@ -42,7 +42,6 @@ void zunsetup(void); /* Free resources used by libzahl */ /* Memory functions. */ -void zinit(z_t); /* Prepare a for use. */ void zfree(z_t); /* Free resources in a. */ void zswap(z_t, z_t); /* (a, b) := (b, a) */ size_t zsave(z_t, void *); /* Store a into b (if !!b), and return number of written bytes. */ @@ -140,9 +139,10 @@ void zperror(const char *); /* Identical to perror(3p) except it supp /* Inline functions. */ +static inline void zinit(z_t a) { a->alloced = 0; a->chars = 0; } /* Prepare a for use. */ static inline int zeven(z_t a) { return !a->sign || !(a->chars[0] & 1); } /* Is a even? */ static inline int zodd(z_t a) { return a->sign && (a->chars[0] & 1); } /* Is a odd? */ static inline int zeven_nonzero(z_t a) { return !(a->chars[0] & 1); } /* Is a even? Assumes a ≠ 0. */ static inline int zodd_nonzero(z_t a) { return (a->chars[0] & 1); } /* Is a odd? Assumes a ≠ 0. */ static inline int zzero(z_t a) { return !a->sign; } /* Is a zero? */ -static inline int zsignum(z_t a) { return a->sign; } /* a/|a|, 0 if a is zero */ +static inline int zsignum(z_t a) { return a->sign; } /* a/|a|, 0 if a is zero. */ |
