commit a5079576ae9007fb1ca7ebcc911b5fb035cd2d06 parent 49d8fa1058aaf23c29e074b2314492ae40d2f557 Author: Laurent Bercot <ska-skaware@skarnet.org> Date: Wed, 22 Feb 2017 10:03:15 +0000 Types change: switch libdatastruct to uint32_t Still needs to be reviewed. Diffstat:
58 files changed, 204 insertions(+), 165 deletions(-)
diff --git a/package/deps.mak b/package/deps.mak @@ -98,7 +98,7 @@ src/libdatastruct/avlnode_insertnode.o src/libdatastruct/avlnode_insertnode.lo: src/libdatastruct/avlnode_iter.o src/libdatastruct/avlnode_iter.lo: src/libdatastruct/avlnode_iter.c src/include/skalibs/avlnode.h src/libdatastruct/avlnode_iter_withcancel.o src/libdatastruct/avlnode_iter_withcancel.lo: src/libdatastruct/avlnode_iter_withcancel.c src/include/skalibs/avlnode.h src/libdatastruct/avlnode_rotate.o src/libdatastruct/avlnode_rotate.lo: src/libdatastruct/avlnode_rotate.c src/libdatastruct/avlnode-internal.h src/include/skalibs/avlnode.h -src/libdatastruct/avlnode_search.o src/libdatastruct/avlnode_search.lo: src/libdatastruct/avlnode_search.c src/include/skalibs/avlnode.h +src/libdatastruct/avlnode_search.o src/libdatastruct/avlnode_search.lo: src/libdatastruct/avlnode_search.c src/include/skalibs/avlnode.h src/include/skalibs/functypes.h src/libdatastruct/avlnode_searchnode.o src/libdatastruct/avlnode_searchnode.lo: src/libdatastruct/avlnode_searchnode.c src/libdatastruct/avlnode-internal.h src/include/skalibs/avlnode.h src/include/skalibs/functypes.h src/libdatastruct/avlnode_zero.o src/libdatastruct/avlnode_zero.lo: src/libdatastruct/avlnode_zero.c src/include/skalibs/avlnode.h src/libdatastruct/avltree_delete.o src/libdatastruct/avltree_delete.lo: src/libdatastruct/avltree_delete.c src/include/skalibs/avlnode.h src/include/skalibs/avltree.h src/include/skalibs/gensetdyn.h diff --git a/src/include/skalibs/avlnode.h b/src/include/skalibs/avlnode.h @@ -3,44 +3,45 @@ #ifndef AVLNODE_H #define AVLNODE_H +#include <stdint.h> #include <skalibs/gccattributes.h> #include <skalibs/functypes.h> #define AVLNODE_MAXDEPTH 49 /* enough for 2^32 nodes in the worst case */ -typedef int avliterfunc_t (unsigned int, unsigned int, void *) ; +typedef int avliterfunc_t (uint32_t, unsigned int, void *) ; typedef avliterfunc_t *avliterfunc_t_ref ; typedef struct avlnode_s avlnode, *avlnode_ref ; struct avlnode_s { - unsigned int data ; - unsigned int child[2] ; + uint32_t data ; + uint32_t child[2] ; signed char balance : 2 ; } ; -#define AVLNODE_ZERO { .data = 0, .child = { (unsigned int)-1, (unsigned int)-1 }, .balance = 0 } +#define AVLNODE_ZERO { .data = 0, .child = { UINT32_MAX, UINT32_MAX }, .balance = 0 } extern avlnode const avlnode_zero ; -extern unsigned int avlnode_searchnode (avlnode const *, unsigned int, unsigned int, void const *, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; -extern int avlnode_search (avlnode const *, unsigned int, unsigned int, void const *, unsigned int *, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; -extern unsigned int avlnode_height (avlnode const *, unsigned int, unsigned int) gccattr_pure ; +extern uint32_t avlnode_searchnode (avlnode const *, uint32_t, uint32_t, void const *, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; +extern int avlnode_search (avlnode const *, uint32_t, uint32_t, void const *, uint32_t *, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; +extern unsigned int avlnode_height (avlnode const *, uint32_t, uint32_t) gccattr_pure ; -extern unsigned int avlnode_extremenode (avlnode const *, unsigned int, unsigned int, int) gccattr_pure ; +extern uint32_t avlnode_extremenode (avlnode const *, uint32_t, uint32_t, int) gccattr_pure ; #define avlnode_minnode(s, max, r) avlnode_extremenode(s, max, (r), 0) #define avlnode_maxnode(s, max, r) avlnode_extremenode(s, max, (r), 1) -extern int avlnode_extreme (avlnode const *, unsigned int, unsigned int, int, unsigned int *) ; +extern int avlnode_extreme (avlnode const *, uint32_t, uint32_t, int, uint32_t *) ; #define avlnode_min(s, max, r, data) avlnode_extreme(s, max, (r), 0, data) #define avlnode_max(s, max, r, data) avlnode_extreme(s, max, (r), 1, data) -extern unsigned int avlnode_insertnode (avlnode *, unsigned int, unsigned int, unsigned int, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; -extern unsigned int avlnode_delete (avlnode *, unsigned int, unsigned int *, void const *, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; +extern uint32_t avlnode_insertnode (avlnode *, uint32_t, uint32_t, uint32_t, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; +extern uint32_t avlnode_delete (avlnode *, uint32_t, uint32_t *, void const *, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; #define avlnode_deletenode(s, max, r, i, dtok, f, p) avlnode_delete(s, max, r, (*(dtok))((s)[i].data), dtok, f, p) -extern unsigned int avlnode_iter_nocancel (avlnode *, unsigned int, unsigned int, unsigned int, avliterfunc_t_ref, void *) ; +extern uint32_t avlnode_iter_nocancel (avlnode *, uint32_t, uint32_t, uint32_t, avliterfunc_t_ref, void *) ; #define avlnode_iter(tree, max, root, f, stuff) (avlnode_iter_nocancel(tree, max, max, root, f, stuff) == (max)) -extern int avlnode_iter_withcancel (avlnode *, unsigned int, unsigned int, avliterfunc_t_ref, avliterfunc_t_ref, void *) ; +extern int avlnode_iter_withcancel (avlnode *, uint32_t, uint32_t, avliterfunc_t_ref, avliterfunc_t_ref, void *) ; #endif diff --git a/src/include/skalibs/avltree.h b/src/include/skalibs/avltree.h @@ -3,6 +3,7 @@ #ifndef AVLTREE_H #define AVLTREE_H +#include <stdint.h> #include <skalibs/functypes.h> #include <skalibs/gensetdyn.h> #include <skalibs/avlnode.h> @@ -11,24 +12,24 @@ typedef struct avltree_s avltree, *avltree_ref ; struct avltree_s { gensetdyn x ; - unsigned int root ; + uint32_t root ; dtokfunc_t_ref dtok ; cmpfunc_t_ref kcmp ; void *external ; } ; -#define AVLTREE_ZERO { .x = GENSETDYN_ZERO, .root = (unsigned int)-1, .dtok = 0, .kcmp = 0, .external = 0 } +#define AVLTREE_ZERO { .x = GENSETDYN_ZERO, .root = UINT32_MAX, .dtok = 0, .kcmp = 0, .external = 0 } extern avltree const avltree_zero ; #define avltree_len(t) gensetdyn_n(&(t)->x) -#define avltree_totalsize(t) ((t)->x.storage.len) +#define avltree_totalsize(t) ((uint32_t)(t)->x.storage.len) #define avltree_nodes(t) ((avlnode *)(t)->x.storage.s) -#define avltree_data(t, i) (avltree_nodes(t)[i].data) +#define avltree_data(t, i) ((uint32_t)avltree_nodes(t)[i].data) #define avltree_root(t) ((t)->root) #define avltree_setroot(t, r) ((t)->root = (r)) extern void avltree_free (avltree *) ; -extern void avltree_init (avltree *, unsigned int, unsigned int, unsigned int, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; -#define AVLTREE_INIT(b, num, den, dtk, f, p) { .x = GENSETDYN_INIT(avlnode, (b), num, den), .root = (unsigned int)-1, .dtok = (dtk), .kcmp = (f), .external = (p) } +extern void avltree_init (avltree *, uint32_t, uint32_t, uint32_t, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; +#define AVLTREE_INIT(b, num, den, dtk, f, p) { .x = GENSETDYN_INIT(avlnode, (b), num, den), .root = UINT32_MAX, .dtok = (dtk), .kcmp = (f), .external = (p) } #define avltree_searchnode(t, k) avlnode_searchnode(avltree_nodes(t), avltree_totalsize(t), avltree_root(t), k, (t)->dtok, (t)->kcmp, (t)->external) #define avltree_search(t, k, data) avlnode_search(avltree_nodes(t), avltree_totalsize(t), avltree_root(t), k, (data), (t)->dtok, (t)->kcmp, (t)->external) @@ -43,9 +44,9 @@ extern void avltree_init (avltree *, unsigned int, unsigned int, unsigned int, d #define avltree_min(t, data) avltree_extreme((t), 0, data) #define avltree_max(t, data) avltree_extreme((t), 1, data) -extern int avltree_newnode (avltree *, unsigned int, unsigned int *) ; +extern int avltree_newnode (avltree *, uint32_t, uint32_t *) ; #define avltree_insertnode(t, i) avltree_setroot(t, avlnode_insertnode(avltree_nodes(t), avltree_totalsize(t), avltree_root(t), i, (t)->dtok, (t)->kcmp, (t)->external)) -extern int avltree_insert (avltree *, unsigned int) ; +extern int avltree_insert (avltree *, uint32_t) ; #define avltree_deletenode(t, i) avltree_delete(t, (*(t)->dtok)(avltree_data(t, i))) extern int avltree_delete (avltree *, void const *) ; diff --git a/src/include/skalibs/avltreen.h b/src/include/skalibs/avltreen.h @@ -3,6 +3,7 @@ #ifndef AVLTREEN_H #define AVLTREEN_H +#include <stdint.h> #include <skalibs/functypes.h> #include <skalibs/genset.h> #include <skalibs/avlnode.h> @@ -14,20 +15,20 @@ typedef struct avltreen_s avltreen, *avltreen_ref ; struct avltreen_s { genset x ; - unsigned int root ; + uint32_t root ; dtokfunc_t_ref dtok ; cmpfunc_t_ref kcmp ; void *external ; } ; -#define AVLTREEN_ZERO { .x = GENSET_ZERO, .root = (unsigned int)-1, .dtok = 0, .kcmp = 0, .external = 0 } +#define AVLTREEN_ZERO { .x = GENSET_ZERO, .root = UINT32_MAX, .dtok = 0, .kcmp = 0, .external = 0 } #define avltreen_totalsize(t) ((t)->x.max) #define avltreen_len(t) genset_n(&(t)->x) #define avltreen_nodes(t) ((avlnode *)(t)->x.storage) #define avltreen_data(t, i) (avltreen_nodes(t)[i].data) #define avltreen_root(t) ((t)->root) #define avltreen_setroot(t, r) ((t)->root = (r)) -extern void avltreen_init (avltreen *, avlnode *, unsigned int *, unsigned int, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; +extern void avltreen_init (avltreen *, avlnode *, uint32_t *, uint32_t, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; #define avltreen_searchnode(t, k) avlnode_searchnode(avltreen_nodes(t), avltreen_totalsize(t), avltreen_root(t), (k), (t)->dtok, (t)->kcmp, (t)->external) #define avltreen_search(t, k, data) avlnode_search(avltreen_nodes(t), avltreen_totalsize(t), avltreen_root(t), k, (data), (t)->dtok, (t)->kcmp, (t)->external) @@ -42,9 +43,9 @@ extern void avltreen_init (avltreen *, avlnode *, unsigned int *, unsigned int, #define avltreen_min(t, data) avltreen_extreme((t), 0, data) #define avltreen_max(t, data) avltreen_extreme((t), 1, data) -extern unsigned int avltreen_newnode (avltreen *, unsigned int) ; +extern uint32_t avltreen_newnode (avltreen *, uint32_t) ; #define avltreen_insertnode(t, i) avltreen_setroot(t, avlnode_insertnode(avltreen_nodes(t), avltreen_totalsize(t), avltreen_root(t), i, (t)->dtok, (t)->kcmp, (t)->external)) -extern int avltreen_insert (avltreen *, unsigned int) ; +extern int avltreen_insert (avltreen *, uint32_t) ; #define avltreen_deletenode(t, i) avltreen_delete(t, avltreen_data(t, i)) extern int avltreen_delete (avltreen *, void const *) ; @@ -56,7 +57,7 @@ extern int avltreen_delete (avltreen *, void const *) ; /* avltreeb: everything in one place. Stack or BSS, or heap if you insist */ -#define AVLTREEB_TYPE(size) struct { avlnode storage[size] ; unsigned int freelist[size] ; avltreen info ; } +#define AVLTREEB_TYPE(size) struct { avlnode storage[size] ; uint32_t freelist[size] ; avltreen info ; } #define avltreeb_init(t, size, dtk, f, p) avltreen_init(&(t)->info, (t)->storage, (t)->freelist, size, dtk, f, p) #define avltreeb_totalsize(t) avltreen_totalsize(&(t)->info) #define avltreeb_len(t) avltreen_len(&(t)->info) diff --git a/src/include/skalibs/functypes.h b/src/include/skalibs/functypes.h @@ -3,16 +3,19 @@ #ifndef FUNCTYPES_H #define FUNCTYPES_H -#include <sys/types.h> +#include <stdint.h> #include <sys/uio.h> typedef int uintcmpfunc_t (unsigned int, unsigned int, void *) ; typedef uintcmpfunc_t *uintcmpfunc_t_ref ; +typedef int uint32cmpfunc_t (uint32_t, uint32_t, void *) ; +typedef uint32cmpfunc_t *uint32cmpfunc_t_ref ; + typedef int cmpfunc_t (void const *, void const *, void *) ; typedef cmpfunc_t *cmpfunc_t_ref ; -typedef void *dtokfunc_t (unsigned int, void *) ; +typedef void *dtokfunc_t (uint32_t, void *) ; typedef dtokfunc_t *dtokfunc_t_ref ; typedef int iterfunc_t (char *, void *) ; diff --git a/src/include/skalibs/genset.h b/src/include/skalibs/genset.h @@ -3,31 +3,32 @@ #ifndef GENSET_H #define GENSET_H +#include <stdint.h> #include <skalibs/functypes.h> typedef struct genset_s genset, *genset_ref ; struct genset_s { char *storage ; - unsigned int *freelist ; - unsigned int esize ; - unsigned int max ; - unsigned int sp ; + uint32_t *freelist ; + uint32_t esize ; + uint32_t max ; + uint32_t sp ; } ; #define GENSET_ZERO { .storage = 0, .freelist = 0, .esize = 1, .max = 0, .sp = 0 } -extern void genset_init (genset *, void *, unsigned int *, unsigned int, unsigned int) ; +extern void genset_init (genset *, void *, uint32_t *, uint32_t, uint32_t) ; #define GENSET_init(g, type, storage, fl, size) genset_init(g, storage, fl, sizeof(type), size) #define genset_p(type, g, i) ((type *)((g)->storage + (i) * (g)->esize)) -extern unsigned int genset_new (genset *) ; -extern int genset_delete (genset *, unsigned int) ; +extern uint32_t genset_new (genset *) ; +extern int genset_delete (genset *, uint32_t) ; #define genset_n(g) ((g)->max - (g)->sp) -extern unsigned int genset_iter_nocancel (genset *, unsigned int, iterfunc_t_ref, void *) ; +extern uint32_t genset_iter_nocancel (genset *, uint32_t, iterfunc_t_ref, void *) ; #define genset_iter(g, f, stuff) genset_iter_nocancel(g, (g)->max, f, stuff) extern int genset_iter_withcancel (genset *, iterfunc_t_ref, iterfunc_t_ref, void *) ; -#define GENSETB_TYPE(type, size) struct { type storage[size] ; unsigned int freelist[size] ; genset info ; } +#define GENSETB_TYPE(type, size) struct { type storage[size] ; uint32_t freelist[size] ; genset info ; } #define GENSETB_init(type, g, size) GENSET_init(&(g)->info, type, (g)->storage, (g)->freelist, size) #define gensetb_p(type, g, i) genset_p(type, &(g)->info, i) #define gensetb_new(g) genset_new(&(g)->info) diff --git a/src/include/skalibs/gensetdyn.h b/src/include/skalibs/gensetdyn.h @@ -3,6 +3,7 @@ #ifndef GENSETDYN_H #define GENSETDYN_H +#include <stdint.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> #include <skalibs/functypes.h> @@ -11,31 +12,31 @@ typedef struct gensetdyn_s gensetdyn, *gensetdyn_ref ; struct gensetdyn_s { stralloc storage ; - genalloc freelist ; /* array of unsigned int */ - unsigned int esize ; - unsigned int base ; - unsigned int fracnum ; - unsigned int fracden ; + genalloc freelist ; /* array of uint32_t */ + uint32_t esize ; + uint32_t base ; + uint32_t fracnum ; + uint32_t fracden ; } ; #define GENSETDYN_ZERO { .storage = STRALLOC_ZERO, .freelist = GENALLOC_ZERO, .esize = 1, .base = 0, .fracnum = 0, .fracden = 1 } extern gensetdyn const gensetdyn_zero ; #define GENSETDYN_INIT(type, b, num, den) { .storage = STRALLOC_ZERO, .freelist = GENALLOC_ZERO, .esize = sizeof(type), .base = (b), .fracnum = (num), .fracden = (den) } -extern void gensetdyn_init (gensetdyn *, unsigned int, unsigned int, unsigned int, unsigned int) ; +extern void gensetdyn_init (gensetdyn *, uint32_t, uint32_t, uint32_t, uint32_t) ; -#define gensetdyn_n(g) ((g)->storage.len - genalloc_len(unsigned int, &(g)->freelist)) -extern int gensetdyn_ready (gensetdyn *, unsigned int) ; +#define gensetdyn_n(g) ((uint32_t)((g)->storage.len - genalloc_len(uint32_t, &(g)->freelist))) +extern int gensetdyn_ready (gensetdyn *, uint32_t) ; #define gensetdyn_readyplus(x, n) gensetdyn_ready(x, gensetdyn_n(x) + (n)) extern void gensetdyn_free (gensetdyn *) ; -extern int gensetdyn_new (gensetdyn *, unsigned int *) ; -extern int gensetdyn_delete (gensetdyn *, unsigned int) ; +extern int gensetdyn_new (gensetdyn *, uint32_t *) ; +extern int gensetdyn_delete (gensetdyn *, uint32_t) ; #define gensetdyn_p(g, i) ((g)->storage.s + (i) * (g)->esize) #define GENSETDYN_P(type, g, i) ((type *)gensetdyn_p(g, i)) -extern unsigned int gensetdyn_iter_nocancel (gensetdyn *, unsigned int, iterfunc_t_ref, void *) ; +extern uint32_t gensetdyn_iter_nocancel (gensetdyn *, uint32_t, iterfunc_t_ref, void *) ; #define gensetdyn_iter(g, f, stuff) gensetdyn_iter_nocancel(g, gensetdyn_n(g), f, stuff) extern int gensetdyn_iter_withcancel (gensetdyn *, iterfunc_t_ref, iterfunc_t_ref, void *) ; diff --git a/src/libdatastruct/avlnode-internal.h b/src/libdatastruct/avlnode-internal.h @@ -3,13 +3,14 @@ #ifndef AVLNODE_INTERNAL_H #define AVLNODE_INTERNAL_H +#include <stdint.h> #include <skalibs/avlnode.h> #define avlnode_ufroms(c) ((c) > 0) #define avlnode_sfromu(h) ((h) ? 1 : -1) -extern unsigned int avlnode_rotate (avlnode *, unsigned int, unsigned int, int) ; -extern unsigned int avlnode_doublerotate (avlnode *, unsigned int, unsigned int, int) ; +extern uint32_t avlnode_rotate (avlnode *, uint32_t, uint32_t, int) ; +extern uint32_t avlnode_doublerotate (avlnode *, uint32_t, uint32_t, int) ; #define avlnode_rotate_maydouble(s, max, r, h, isdouble) ((isdouble) ? avlnode_doublerotate(s, max, r, h) : avlnode_rotate(s, max, r, h)) #endif diff --git a/src/libdatastruct/avlnode_delete.c b/src/libdatastruct/avlnode_delete.c @@ -1,20 +1,21 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/functypes.h> #include <skalibs/avlnode.h> #include "avlnode-internal.h" -unsigned int avlnode_delete (avlnode *s, unsigned int max, unsigned int *root, void const *k, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) +uint32_t avlnode_delete (avlnode *s, uint32_t max, uint32_t *root, void const *k, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) { - unsigned int stack[AVLNODE_MAXDEPTH] ; + uint32_t stack[AVLNODE_MAXDEPTH] ; int spin[AVLNODE_MAXDEPTH] ; unsigned int sp = 0 ; - unsigned int r = *root ; - unsigned int itodel ; + uint32_t r = *root ; + uint32_t itodel ; for (; r < max ; sp++) { - register int c = (*f)(k, (*dtok)(s[r].data, p), p) ; + int c = (*f)(k, (*dtok)(s[r].data, p), p) ; if (!c) break ; spin[sp] = avlnode_ufroms(c) ; stack[sp] = r ; diff --git a/src/libdatastruct/avlnode_doublerotate.c b/src/libdatastruct/avlnode_doublerotate.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/avlnode.h> #include "avlnode-internal.h" -unsigned int avlnode_doublerotate (avlnode_ref s, unsigned int max, unsigned int i, int h) +uint32_t avlnode_doublerotate (avlnode_ref s, uint32_t max, uint32_t i, int h) { - register unsigned int j = s[i].child[!h] ; - register unsigned int k = s[j].child[h] ; + uint32_t j = s[i].child[!h] ; + uint32_t k = s[j].child[h] ; s[i].child[!h] = s[k].child[h] ; s[j].child[h] = s[k].child[!h] ; s[k].child[!h] = j ; diff --git a/src/libdatastruct/avlnode_extreme.c b/src/libdatastruct/avlnode_extreme.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <stdint.h> #include <errno.h> #include <skalibs/avlnode.h> -int avlnode_extreme (avlnode const *s, unsigned int max, unsigned int r, int h, unsigned int *k) +int avlnode_extreme (avlnode const *s, uint32_t max, uint32_t r, int h, uint32_t *k) { - register unsigned int i = avlnode_extremenode(s, max, r, h) ; + uint32_t i = avlnode_extremenode(s, max, r, h) ; if (i >= max) return (errno = ESRCH, 0) ; *k = s[i].data ; return 1 ; diff --git a/src/libdatastruct/avlnode_extremenode.c b/src/libdatastruct/avlnode_extremenode.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/avlnode.h> -unsigned int avlnode_extremenode (avlnode const *s, unsigned int max, unsigned int r, int h) +uint32_t avlnode_extremenode (avlnode const *s, uint32_t max, uint32_t r, int h) { - register unsigned int oldr = r ; + uint32_t oldr = r ; for (; r < max ; oldr = r, r = s[r].child[h]) ; return oldr ; } diff --git a/src/libdatastruct/avlnode_height.c b/src/libdatastruct/avlnode_height.c @@ -1,8 +1,9 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/avlnode.h> -unsigned int avlnode_height (avlnode const *s, unsigned int max, unsigned int r) +unsigned int avlnode_height (avlnode const *s, uint32_t max, uint32_t r) { if (r >= max) return 0 ; else if (s[r].balance) return 1 + avlnode_height(s, max, s[r].child[s[r].balance > 0]) ; diff --git a/src/libdatastruct/avlnode_insertnode.c b/src/libdatastruct/avlnode_insertnode.c @@ -1,17 +1,18 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/functypes.h> #include <skalibs/avlnode.h> #include "avlnode-internal.h" -unsigned int avlnode_insertnode (avlnode *s, unsigned int max, unsigned int r, unsigned int i, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) +uint32_t avlnode_insertnode (avlnode *s, uint32_t max, uint32_t r, uint32_t i, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) { - unsigned int stack[AVLNODE_MAXDEPTH] ; + uint32_t stack[AVLNODE_MAXDEPTH] ; int spin[AVLNODE_MAXDEPTH] ; unsigned int sp = 0 ; { - register void const *k = (*dtok)(s[i].data, p) ; + void const *k = (*dtok)(s[i].data, p) ; for (; r < max ; sp++) { spin[sp] = avlnode_ufroms((*f)(k, (*dtok)(s[r].data, p), p)) ; diff --git a/src/libdatastruct/avlnode_iter.c b/src/libdatastruct/avlnode_iter.c @@ -1,21 +1,22 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/avlnode.h> struct avlnode_iter_s { avlnode const *s ; - unsigned int max ; - unsigned int cut ; + uint32_t max ; + uint32_t cut ; avliterfunc_t_ref f ; void *p ; } ; -static unsigned int avlnode_iter_rec (struct avlnode_iter_s const *blah, unsigned int r, unsigned int h) +static uint32_t avlnode_iter_rec (struct avlnode_iter_s const *blah, uint32_t r, unsigned int h) { if (r >= blah->max) return blah->max ; { - unsigned int res = avlnode_iter_rec(blah, blah->s[r].child[0], h+1) ; + uint32_t res = avlnode_iter_rec(blah, blah->s[r].child[0], h+1) ; if (res != blah->max) return res ; } if (r == blah->cut) return blah->max ; @@ -23,7 +24,7 @@ static unsigned int avlnode_iter_rec (struct avlnode_iter_s const *blah, unsigne return avlnode_iter_rec(blah, blah->s[r].child[1], h+1) ; } -unsigned int avlnode_iter_nocancel (avlnode *s, unsigned int max, unsigned int cut, unsigned int r, avliterfunc_t_ref f, void *p) +uint32_t avlnode_iter_nocancel (avlnode *s, uint32_t max, uint32_t cut, uint32_t r, avliterfunc_t_ref f, void *p) { struct avlnode_iter_s blah = { .s = s, .max = max, .cut = cut, .f = f, .p = p } ; return avlnode_iter_rec(&blah, r, 0) ; diff --git a/src/libdatastruct/avlnode_iter_withcancel.c b/src/libdatastruct/avlnode_iter_withcancel.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <stdint.h> #include <errno.h> #include <skalibs/avlnode.h> -int avlnode_iter_withcancel (avlnode *tree, unsigned int max, unsigned int root, avliterfunc_t_ref f, avliterfunc_t_ref cancelf, void *stuff) +int avlnode_iter_withcancel (avlnode *tree, uint32_t max, uint32_t root, avliterfunc_t_ref f, avliterfunc_t_ref cancelf, void *stuff) { - unsigned int cut = avlnode_iter_nocancel(tree, max, max, root, f, stuff) ; + uint32_t cut = avlnode_iter_nocancel(tree, max, max, root, f, stuff) ; if (cut != max) { int e = errno ; diff --git a/src/libdatastruct/avlnode_rotate.c b/src/libdatastruct/avlnode_rotate.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/avlnode.h> #include "avlnode-internal.h" -unsigned int avlnode_rotate (avlnode *s, unsigned int max, unsigned int i, int h) +uint32_t avlnode_rotate (avlnode *s, uint32_t max, uint32_t i, int h) { - register unsigned int j = s[i].child[!h] ; + uint32_t j = s[i].child[!h] ; s[i].child[!h] = s[j].child[h] ; s[j].child[h] = i ; if (s[j].balance * avlnode_sfromu(h) < 0) s[i].balance = s[j].balance = 0 ; diff --git a/src/libdatastruct/avlnode_search.c b/src/libdatastruct/avlnode_search.c @@ -1,11 +1,13 @@ /* ISC license. */ +#include <stdint.h> #include <errno.h> +#include <skalibs/functypes.h> #include <skalibs/avlnode.h> -int avlnode_search (avlnode const *s, unsigned int max, unsigned int r, void const *k, unsigned int *data, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) +int avlnode_search (avlnode const *s, uint32_t max, uint32_t r, void const *k, uint32_t *data, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) { - register unsigned int i = avlnode_searchnode(s, max, r, k, dtok, f, p) ; + uint32_t i = avlnode_searchnode(s, max, r, k, dtok, f, p) ; if (i >= max) return (errno = ESRCH, 0) ; *data = s[i].data ; return 1 ; diff --git a/src/libdatastruct/avlnode_searchnode.c b/src/libdatastruct/avlnode_searchnode.c @@ -1,14 +1,15 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/functypes.h> #include <skalibs/avlnode.h> #include "avlnode-internal.h" -unsigned int avlnode_searchnode (avlnode const *s, unsigned int max, unsigned int r, void const *k, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) +uint32_t avlnode_searchnode (avlnode const *s, uint32_t max, uint32_t r, void const *k, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) { while (r < max) { - register int h = (*f)(k, (*dtok)(s[r].data, p), p) ; + int h = (*f)(k, (*dtok)(s[r].data, p), p) ; if (!h) break ; r = s[r].child[avlnode_ufroms(h)] ; } diff --git a/src/libdatastruct/avltree_delete.c b/src/libdatastruct/avltree_delete.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <stdint.h> #include <errno.h> #include <skalibs/gensetdyn.h> #include <skalibs/avlnode.h> @@ -7,8 +8,8 @@ int avltree_delete (avltree *t, void const *k) { - unsigned int r = avltree_root(t) ; - unsigned int i = avlnode_delete(avltree_nodes(t), avltree_totalsize(t), &r, k, t->dtok, t->kcmp, t->external) ; + uint32_t r = avltree_root(t) ; + uint32_t i = avlnode_delete(avltree_nodes(t), avltree_totalsize(t), &r, k, t->dtok, t->kcmp, t->external) ; if (i >= avltree_totalsize(t)) return (errno = ESRCH, 0) ; avltree_setroot(t, r) ; if (!gensetdyn_delete(&t->x, i)) return 0 ; diff --git a/src/libdatastruct/avltree_init.c b/src/libdatastruct/avltree_init.c @@ -1,15 +1,16 @@ /* ISC license. */ +#include <stdint.h> #include <errno.h> #include <skalibs/functypes.h> #include <skalibs/gensetdyn.h> #include <skalibs/avlnode.h> #include <skalibs/avltree.h> -void avltree_init (avltree *t, unsigned int base, unsigned int fracnum, unsigned int fracden, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) +void avltree_init (avltree *t, uint32_t base, uint32_t fracnum, uint32_t fracden, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) { gensetdyn_init(&t->x, sizeof(avlnode), base, fracnum, fracden) ; - t->root = (unsigned int)-1 ; + t->root = UINT32_MAX ; t->dtok = dtok ; t->kcmp = f ; t->external = p ; diff --git a/src/libdatastruct/avltree_insert.c b/src/libdatastruct/avltree_insert.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/avltree.h> -int avltree_insert (avltree_ref t, unsigned int d) +int avltree_insert (avltree *t, uint32_t d) { - unsigned int i ; + uint32_t i ; if (!avltree_newnode(t, d, &i)) return 0 ; avltree_insertnode(t, i) ; return 1 ; diff --git a/src/libdatastruct/avltree_newnode.c b/src/libdatastruct/avltree_newnode.c @@ -1,17 +1,18 @@ /* ISC license. */ +#include <stdint.h> #include <errno.h> #include <skalibs/gensetdyn.h> #include <skalibs/avlnode.h> #include <skalibs/avltree.h> -int avltree_newnode (avltree *t, unsigned int data, unsigned int *i) +int avltree_newnode (avltree *t, uint32_t data, uint32_t *i) { if (!gensetdyn_new(&t->x, i)) return 0 ; { - register avlnode *s = avltree_nodes(t) ; + avlnode *s = avltree_nodes(t) ; s[*i].data = data ; - s[*i].child[0] = s[*i].child[1] = (unsigned int)-1 ; + s[*i].child[0] = s[*i].child[1] = UINT32_MAX ; s[*i].balance = 0 ; } return 1 ; diff --git a/src/libdatastruct/avltreen_delete.c b/src/libdatastruct/avltreen_delete.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <stdint.h> #include <errno.h> #include <skalibs/genset.h> #include <skalibs/avlnode.h> @@ -7,8 +8,8 @@ int avltreen_delete (avltreen *t, void const *k) { - unsigned int r = avltreen_root(t) ; - unsigned int i = avlnode_delete(avltreen_nodes(t), avltreen_totalsize(t), &r, k, t->dtok, t->kcmp, t->external) ; + uint32_t r = avltreen_root(t) ; + uint32_t i = avlnode_delete(avltreen_nodes(t), avltreen_totalsize(t), &r, k, t->dtok, t->kcmp, t->external) ; if (i >= avltreen_totalsize(t)) return (errno = ESRCH, 0) ; avltreen_setroot(t, r) ; if (!genset_delete(&t->x, i)) return 0 ; diff --git a/src/libdatastruct/avltreen_init.c b/src/libdatastruct/avltreen_init.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/functypes.h> #include <skalibs/genset.h> #include <skalibs/avlnode.h> #include <skalibs/avltreen.h> -void avltreen_init (avltreen *t, avlnode_ref storage, unsigned int *freelist, unsigned int size, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) +void avltreen_init (avltreen *t, avlnode *storage, uint32_t *freelist, uint32_t size, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) { GENSET_init(&t->x, avlnode, storage, freelist, size) ; t->root = size ; diff --git a/src/libdatastruct/avltreen_insert.c b/src/libdatastruct/avltreen_insert.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/avltreen.h> -int avltreen_insert (avltreen *t, unsigned int d) +int avltreen_insert (avltreen *t, uint32_t d) { - unsigned int i = avltreen_newnode(t, d) ; + uint32_t i = avltreen_newnode(t, d) ; if (i >= avltreen_totalsize(t)) return 0 ; avltreen_insertnode(t, i) ; return 1 ; diff --git a/src/libdatastruct/avltreen_newnode.c b/src/libdatastruct/avltreen_newnode.c @@ -1,15 +1,16 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/genset.h> #include <skalibs/avlnode.h> #include <skalibs/avltreen.h> -unsigned int avltreen_newnode (avltreen *t, unsigned int d) +uint32_t avltreen_newnode (avltreen *t, uint32_t d) { - register unsigned int i = genset_new(&t->x) ; + uint32_t i = genset_new(&t->x) ; if (i < avltreen_totalsize(t)) { - register avlnode *s = avltreen_nodes(t) ; + avlnode *s = avltreen_nodes(t) ; s[i].data = d ; s[i].child[0] = s[i].child[1] = avltreen_totalsize(t) ; s[i].balance = 0 ; diff --git a/src/libdatastruct/genset.c b/src/libdatastruct/genset.c @@ -1,25 +1,26 @@ /* ISC license. */ +#include <stdint.h> #include <errno.h> #include <skalibs/genset.h> -void genset_init (genset *x, void *storage, unsigned int *freelist, unsigned int esize, unsigned int max) +void genset_init (genset *x, void *storage, uint32_t *freelist, uint32_t esize, uint32_t max) { - register unsigned int i = 0 ; + uint32_t i = max ; x->storage = (char *)storage ; x->freelist = freelist ; x->esize = esize ; x->max = max ; x->sp = max ; - for (; i < max ; i++) freelist[i] = max - 1 - i ; + while (i--) freelist[i] = max - 1 - i ; } -unsigned int genset_new (genset *x) +uint32_t genset_new (genset *x) { return x->sp ? x->freelist[--x->sp] : (errno = ENOSPC, x->max) ; } -int genset_delete (genset *x, unsigned int i) +int genset_delete (genset *x, uint32_t i) { if ((i >= x->max) || (x->sp >= x->max)) return (errno = EINVAL, 0) ; x->freelist[x->sp++] = i ; diff --git a/src/libdatastruct/genset_iter_nocancel.c b/src/libdatastruct/genset_iter_nocancel.c @@ -1,13 +1,14 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/bitarray.h> #include <skalibs/functypes.h> #include <skalibs/genset.h> -unsigned int genset_iter_nocancel (genset *g, unsigned int n, iterfunc_t_ref f, void *stuff) +uint32_t genset_iter_nocancel (genset *g, uint32_t n, iterfunc_t_ref f, void *stuff) { unsigned char bits[bitarray_div8(n)] ; - unsigned int i = 0, j = 0, m = genset_n(g) ; + uint32_t i = 0, j = 0, m = genset_n(g) ; bitarray_setn(bits, 0, n) ; for (; i < g->sp ; i++) if (g->freelist[i] < n) bitarray_clear(bits, g->freelist[i]) ; for (i = 0 ; (i < n) && (j < m) ; i++) if (bitarray_peek(bits, i)) diff --git a/src/libdatastruct/genset_iter_withcancel.c b/src/libdatastruct/genset_iter_withcancel.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include <stdint.h> #include <errno.h> #include <skalibs/functypes.h> #include <skalibs/genset.h> int genset_iter_withcancel (genset *g, iterfunc_t_ref f, iterfunc_t_ref cancelf, void *stuff) { - unsigned int n = genset_iter(g, f, stuff) ; + uint32_t n = genset_iter(g, f, stuff) ; if (n < g->max) { int e = errno ; diff --git a/src/libdatastruct/gensetdyn_delete.c b/src/libdatastruct/gensetdyn_delete.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <stdint.h> #include <errno.h> #include <skalibs/genalloc.h> #include <skalibs/gensetdyn.h> -int gensetdyn_delete (gensetdyn *g, unsigned int i) +int gensetdyn_delete (gensetdyn *g, uint32_t i) { return (i >= g->storage.len) ? (errno = EINVAL, 0) : - genalloc_catb(unsigned int, &g->freelist, &i, 1) ; + genalloc_catb(uint32_t, &g->freelist, &i, 1) ; } diff --git a/src/libdatastruct/gensetdyn_free.c b/src/libdatastruct/gensetdyn_free.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> #include <skalibs/gensetdyn.h> @@ -7,6 +8,6 @@ void gensetdyn_free (gensetdyn *g) { stralloc_free(&g->storage) ; - genalloc_free(unsigned int, &g->freelist) ; + genalloc_free(uint32_t, &g->freelist) ; *g = gensetdyn_zero ; } diff --git a/src/libdatastruct/gensetdyn_init.c b/src/libdatastruct/gensetdyn_init.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> #include <skalibs/gensetdyn.h> -void gensetdyn_init (gensetdyn *g, unsigned int esize, unsigned int base, unsigned int fracnum, unsigned int fracden) +void gensetdyn_init (gensetdyn *g, uint32_t esize, uint32_t base, uint32_t fracnum, uint32_t fracden) { g->storage = stralloc_zero ; g->freelist = genalloc_zero ; diff --git a/src/libdatastruct/gensetdyn_iter.c b/src/libdatastruct/gensetdyn_iter.c @@ -1,19 +1,22 @@ /* ISC license. */ +#include <sys/types.h> +#include <stdint.h> #include <skalibs/bitarray.h> #include <skalibs/functypes.h> #include <skalibs/gensetdyn.h> -unsigned int gensetdyn_iter_nocancel (gensetdyn *g, unsigned int n, iterfunc_t_ref f, void *stuff) +uint32_t gensetdyn_iter_nocancel (gensetdyn *g, uint32_t n, iterfunc_t_ref f, void *stuff) { /* XXX: we may be called by a freeing function, so we cannot alloc - XXX: so pray that the bitarray fits in the stack. */ - unsigned char bits[bitarray_div8(g->storage.len)] ; - unsigned int i = 0, j = 0 ; - register unsigned int *fl = genalloc_s(unsigned int, &g->freelist) ; - register unsigned int sp = genalloc_len(unsigned int, &g->freelist) ; + unsigned char bits[bitarray_div8(g->storage.len) ? bitarray_div8(g->storage.len) : 1] ; + size_t i = 0 ; + uint32_t j = 0 ; + uint32_t *fl = genalloc_s(uint32_t, &g->freelist) ; + size_t sp = genalloc_len(uint32_t, &g->freelist) ; bitarray_setn(bits, 0, g->storage.len) ; for (; i < sp ; i++) if (fl[i] < g->storage.len) bitarray_clear(bits, fl[i]) ; diff --git a/src/libdatastruct/gensetdyn_iter_withcancel.c b/src/libdatastruct/gensetdyn_iter_withcancel.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include <stdint.h> #include <errno.h> #include <skalibs/functypes.h> #include <skalibs/gensetdyn.h> int gensetdyn_iter_withcancel (gensetdyn *g, iterfunc_t_ref f, iterfunc_t_ref cancelf, void *stuff) { - unsigned int n = gensetdyn_iter_nocancel(g, gensetdyn_n(g), f, stuff) ; + uint32_t n = gensetdyn_iter_nocancel(g, gensetdyn_n(g), f, stuff) ; if (n < gensetdyn_n(g)) { int e = errno ; diff --git a/src/libdatastruct/gensetdyn_new.c b/src/libdatastruct/gensetdyn_new.c @@ -1,14 +1,16 @@ /* ISC license. */ +#include <sys/types.h> +#include <stdint.h> #include <skalibs/genalloc.h> #include <skalibs/gensetdyn.h> -int gensetdyn_new (gensetdyn *g, unsigned int *i) +int gensetdyn_new (gensetdyn *g, uint32_t *i) { - register unsigned int n ; - if (!genalloc_len(unsigned int, &g->freelist) && !gensetdyn_readyplus(g, 1)) return 0 ; - n = genalloc_len(unsigned int, &g->freelist) ; - *i = genalloc_s(unsigned int, &g->freelist)[n-1] ; - genalloc_setlen(unsigned int, &g->freelist, n-1) ; + size_t n ; + if (!genalloc_len(uint32_t, &g->freelist) && !gensetdyn_readyplus(g, 1)) return 0 ; + n = genalloc_len(uint32_t, &g->freelist) ; + *i = genalloc_s(uint32_t, &g->freelist)[n-1] ; + genalloc_setlen(uint32_t, &g->freelist, n-1) ; return 1 ; } diff --git a/src/libdatastruct/gensetdyn_ready.c b/src/libdatastruct/gensetdyn_ready.c @@ -1,25 +1,26 @@ /* ISC license. */ +#include <stdint.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> #include <skalibs/gensetdyn.h> -int gensetdyn_ready (gensetdyn *g, unsigned int n) +int gensetdyn_ready (gensetdyn *g, uint32_t n) { int wasnull = !g->storage.s ; - unsigned int i = g->storage.len ; + uint32_t i = g->storage.len ; if (n < i) return 1 ; n += g->base + (n * g->fracnum) / g->fracden ; if (!stralloc_ready_tuned(&g->storage, n * g->esize, 0, 0, 1)) return 0 ; - if (!genalloc_ready(unsigned int, &g->freelist, n)) + if (!genalloc_ready(uint32_t, &g->freelist, n)) { if (wasnull) stralloc_free(&g->storage) ; return 0 ; } for (; i < n ; i++) { - unsigned int j = n - 1 - i + g->storage.len ; - genalloc_catb(unsigned int, &g->freelist, &j, 1) ; + uint32_t j = n - 1 - i + g->storage.len ; + genalloc_catb(uint32_t, &g->freelist, &j, 1) ; } g->storage.len = n ; return 1 ; diff --git a/src/libstddjb/alloc.c b/src/libstddjb/alloc.c @@ -16,7 +16,7 @@ aligned_char *alloc (size_t n) { - register aligned_char *p = n ? (aligned_char *)malloc(n) : (aligned_char *)alloc_0 ; + aligned_char *p = n ? (aligned_char *)malloc(n) : (aligned_char *)alloc_0 ; #ifdef DEBUG_ALLOC static unsigned int counter = 0 ; PLM("alloc(%u): %p. Allocated: %u", n, p, ++counter) ; @@ -26,7 +26,7 @@ aligned_char *alloc (size_t n) void alloc_free (void *p) { - register int e = errno ; + int e = errno ; #ifdef DEBUG_ALLOC static unsigned int counter = 0 ; PLM("alloc_free(%p). Freed: %u", p, ++counter) ; diff --git a/src/libstddjb/allreadwrite.c b/src/libstddjb/allreadwrite.c @@ -10,7 +10,7 @@ size_t allreadwrite (iofunc_t_ref op, int fd, char *buf, size_t len) size_t written = 0 ; while (len) { - register ssize_t w = (*op)(fd, buf, len) ; + ssize_t w = (*op)(fd, buf, len) ; if (w <= 0) { if (!w) errno = 0 ; diff --git a/src/libstddjb/bitarray_and.c b/src/libstddjb/bitarray_and.c @@ -5,7 +5,6 @@ void bitarray_and (unsigned char *c, unsigned char const *a, unsigned char const *b, size_t n) { - size_t len = bitarray_div8(n) ; - register size_t i = 0 ; - for (; i < len ; i++) c[i] = a[i] & b[i] ; + size_t i = bitarray_div8(n) ; + while (i--) c[i] = a[i] & b[i] ; } diff --git a/src/libstddjb/bitarray_clearsetn.c b/src/libstddjb/bitarray_clearsetn.c @@ -3,19 +3,19 @@ #include <sys/types.h> #include <skalibs/bitarray.h> -void bitarray_clearsetn (register unsigned char *s, register size_t a, register size_t b, register int h) +void bitarray_clearsetn (unsigned char *s, size_t a, size_t b, int h) { if (!b) return ; b += a ; if ((a >> 3) == ((b-1) >> 3)) { - register unsigned char mask = (1 << (a & 7)) - 1 ^ (1 << 1 + (b-1 & 7)) - 1 ; + unsigned char mask = (1 << (a & 7)) - 1 ^ (1 << 1 + (b-1 & 7)) - 1 ; if (h) s[a>>3] |= mask ; else s[a>>3] &= ~mask ; } else { - register unsigned char mask = ~((1 << (a & 7)) - 1) ; - register size_t i = (a>>3) + 1 ; + unsigned char mask = ~((1 << (a & 7)) - 1) ; + size_t i = (a>>3) + 1 ; if (h) s[a>>3] |= mask ; else s[a>>3] &= ~mask ; mask = h ? 0xff : 0x00 ; for (; i < b>>3 ; i++) s[i] = mask ; diff --git a/src/libstddjb/bitarray_count.c b/src/libstddjb/bitarray_count.c @@ -14,7 +14,7 @@ uint64_t bitarray_countones (unsigned char const *c, size_t n) static unsigned char const table[256] = { B3(0) } ; size_t len = bitarray_div8(n) ; uint64_t total = 0 ; - register size_t i = 0 ; + size_t i = 0 ; if (n & 7) len-- ; for (; i < len ; i++) total += table[c[i]] ; if (n & 7) total += table[c[i] & ((1 << (n & 7)) - 1)] ; diff --git a/src/libstddjb/bitarray_firstclear.c b/src/libstddjb/bitarray_firstclear.c @@ -3,10 +3,10 @@ #include <sys/types.h> #include <skalibs/bitarray.h> -size_t bitarray_firstclear (register unsigned char const *s, size_t max) +size_t bitarray_firstclear (unsigned char const *s, size_t max) { size_t n = bitarray_div8(max) ; - register size_t i = 0 ; + size_t i = 0 ; for (; i < n ; i++) if (s[i] != 0xffU) break ; if (i == n) return max ; i <<= 3 ; diff --git a/src/libstddjb/bitarray_firstset.c b/src/libstddjb/bitarray_firstset.c @@ -3,10 +3,10 @@ #include <sys/types.h> #include <skalibs/bitarray.h> -size_t bitarray_firstset (register unsigned char const *s, size_t max) +size_t bitarray_firstset (unsigned char const *s, size_t max) { size_t n = bitarray_div8(max) ; - register size_t i = 0 ; + size_t i = 0 ; for (; i < n ; i++) if (s[i]) break ; if (i == n) return max ; i <<= 3 ; diff --git a/src/libstddjb/bitarray_not.c b/src/libstddjb/bitarray_not.c @@ -3,7 +3,7 @@ #include <sys/types.h> #include <skalibs/bitarray.h> -void bitarray_not (register unsigned char *s, register size_t a, register size_t b) +void bitarray_not (unsigned char *s, size_t a, size_t b) { if (!b) return ; b += a ; @@ -11,7 +11,7 @@ void bitarray_not (register unsigned char *s, register size_t a, register size_t s[a>>3] ^= ((1 << (a & 7)) - 1) ^ ((a << (b & 7)) - 1) ; else { - register size_t i = (a>>3) + 1 ; + size_t i = (a>>3) + 1 ; s[a>>3] ^= ~((1 << (a & 7)) - 1) ; for (; i < (b>>3) ; i++) s[i] = ~s[i] ; s[b>>3] ^= (1 << (b & 7)) - 1 ; diff --git a/src/libstddjb/bitarray_or.c b/src/libstddjb/bitarray_or.c @@ -5,7 +5,6 @@ void bitarray_or (unsigned char *c, unsigned char const *a, unsigned char const *b, size_t n) { - size_t len = bitarray_div8(n) ; - register size_t i = 0 ; - for (; i < len ; i++) c[i] = a[i] | b[i] ; + size_t i = bitarray_div8(n) ; + while (i--) c[i] = a[i] | b[i] ; } diff --git a/src/libstddjb/bitarray_testandpoke.c b/src/libstddjb/bitarray_testandpoke.c @@ -3,10 +3,10 @@ #include <sys/types.h> #include <skalibs/bitarray.h> -int bitarray_testandpoke (register unsigned char *s, register size_t n, register int h) +int bitarray_testandpoke (unsigned char *s, size_t n, int h) { - register unsigned char mask = 1 << (n & 7) ; - register unsigned char c = s[n>>3] ; + unsigned char mask = 1 << (n & 7) ; + unsigned char c = s[n>>3] ; s[n>>3] = h ? c | mask : c & ~mask ; return (c & mask) ? 1 : 0 ; } diff --git a/src/libstddjb/bitarray_xor.c b/src/libstddjb/bitarray_xor.c @@ -5,7 +5,6 @@ void bitarray_xor (unsigned char *c, unsigned char const *a, unsigned char const *b, size_t n) { - size_t len = bitarray_div8(n) ; - register size_t i = 0 ; - for (; i < len ; i++) c[i] = a[i] ^ b[i] ; + size_t i = bitarray_div8(n) ; + while (i--) c[i] = a[i] ^ b[i] ; } diff --git a/src/libstddjb/bufalloc_clean.c b/src/libstddjb/bufalloc_clean.c @@ -3,7 +3,7 @@ #include <string.h> #include <skalibs/bufalloc.h> -void bufalloc_clean (register bufalloc *ba) +void bufalloc_clean (bufalloc *ba) { if (ba->p) { diff --git a/src/libstddjb/buffer_get.c b/src/libstddjb/buffer_get.c @@ -7,7 +7,7 @@ ssize_t buffer_get (buffer *b, char *s, size_t len) { size_t w = 0 ; - register int r = buffer_getall(b, s, len, &w) ; + int r = buffer_getall(b, s, len, &w) ; return r == -1 ? errno == EPIPE ? (errno = 0, (ssize_t)w) : -1 : - !r ? (errno = EWOULDBLOCK, -1) : (ssize_t)w ; + !r ? (errno = EWOULDBLOCK, -1) : w ; } diff --git a/src/libstddjb/buffer_getvall.c b/src/libstddjb/buffer_getvall.c @@ -12,7 +12,7 @@ int buffer_getvall (buffer *b, struct iovec const *v, unsigned int n, size_t *wr struct iovec vv[n ? n : 1] ; if (*written > len) return (errno = EINVAL, -1) ; { - register unsigned int i = n ; + unsigned int i = n ; while (i--) vv[i] = v[i] ; } siovec_seek(vv, n, *written) ; diff --git a/src/libstddjb/byte_chr.c b/src/libstddjb/byte_chr.c @@ -6,6 +6,6 @@ size_t byte_chr (char const *s, size_t n, int c) { - register void *p = memchr(s, c, n) ; + void *p = memchr(s, c, n) ; return p ? (char *)p - s : n ; } diff --git a/src/libstddjb/case_str.c b/src/libstddjb/case_str.c @@ -10,7 +10,7 @@ size_t case_str (char const *haystack, char const *needle) { - register char *p = strcasestr(haystack, needle) ; + char *p = strcasestr(haystack, needle) ; return p ? p - haystack : strlen(haystack) ; } diff --git a/src/libstddjb/iobufferk_finish.c b/src/libstddjb/iobufferk_finish.c @@ -15,14 +15,14 @@ static void iobufferk_nop (iobufferk *k) static void iobufferk_finish_0 (iobufferk *k) { - register int e = errno ; + int e = errno ; fd_close(k->p[1]) ; errno = e ; } static void iobufferk_finish_3 (iobufferk *k) { - register int e = errno ; + int e = errno ; fd_close(k->p[1]) ; fd_close(k->p[0]) ; errno = e ; diff --git a/src/libstddjb/iobufferu_init.c b/src/libstddjb/iobufferu_init.c @@ -7,7 +7,7 @@ int iobufferu_init (iobufferu *b, int fdin, int fdout) { - register char *x = alloc(IOBUFFERU_SIZE) ; + char *x = alloc(IOBUFFERU_SIZE) ; if (!x) return 0 ; b->buf = x ; buffer_init(&b->b[0], &fd_readv, fdin, x, IOBUFFERU_SIZE) ; diff --git a/src/libstddjb/ip4_scanu32.c b/src/libstddjb/ip4_scanu32.c @@ -8,7 +8,7 @@ size_t ip4_scanu32 (char const *s, uint32_t *ip) { char pack[4] ; - register size_t r = ip4_scan(s, pack) ; + size_t r = ip4_scan(s, pack) ; if (r) uint32_unpack_big(pack, ip) ; return r ; } diff --git a/src/libstddjb/open3.c b/src/libstddjb/open3.c @@ -7,7 +7,7 @@ int open3 (char const *s, unsigned int flags, unsigned int mode) { - register int r ; + int r ; do r = open(s, flags, mode) ; while ((r == -1) && (errno == EINTR)) ; return r ; diff --git a/src/libstddjb/time_from_tai.c b/src/libstddjb/time_from_tai.c @@ -13,7 +13,7 @@ int time_from_tai (time_t *u, tai_t const *t) { - register uint64_t uu = t->x - TAI_MAGIC ; + uint64_t uu = t->x - TAI_MAGIC ; #if SKALIBS_SIZEOFTIME < 8 if ((uu >> 32) && (uu >> 32) != 0xffffffffUL) return (errno = EOVERFLOW, 0) ;