commit 48a89e0e110907a7a60ed8f5a0977e3b34661259
parent 64157e1d0e47a8b4e34817d77325fa09e1250b5f
Author: Mattias Andrée <maandree@kth.se>
Date: Sat, 5 Mar 2016 20:59:03 +0100
zinit is now an inline function
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat:
3 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/Makefile b/Makefile
@@ -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
@@ -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;
-}
diff --git a/zahl.h b/zahl.h
@@ -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. */