From a896ca2a8c617e5e00ffd5fc9e69331ad754e5b3 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 15 Feb 2017 17:40:40 +0000 Subject: add arc4random_addrandom sysdep; next batch of types changes. The library isn't supposed to be functional yet: there are still a lot of type mismatches. --- src/include/skalibs/alloc.h | 5 +++-- src/include/skalibs/allreadwrite.h | 30 +++++++++++++------------- src/include/skalibs/bitarray.h | 24 +++++++++++---------- src/include/skalibs/bufalloc.h | 7 ++++--- src/include/skalibs/bytestr.h | 43 ++++++++++++-------------------------- src/include/skalibs/djbunix.h | 2 +- src/include/skalibs/functypes.h | 11 +++++----- src/include/skalibs/genalloc.h | 3 ++- src/include/skalibs/genwrite.h | 4 +++- src/include/skalibs/stralloc.h | 27 ++++++++++++------------ 10 files changed, 73 insertions(+), 83 deletions(-) (limited to 'src/include') diff --git a/src/include/skalibs/alloc.h b/src/include/skalibs/alloc.h index 0df0f9d..85f02f2 100644 --- a/src/include/skalibs/alloc.h +++ b/src/include/skalibs/alloc.h @@ -3,14 +3,15 @@ #ifndef ALLOC_H #define ALLOC_H +#include #include typedef char aligned_char gccattr_aligned ; typedef aligned_char *aligned_char_ref, **aligned_char_ref_ref ; -extern aligned_char *alloc (unsigned int) ; +extern aligned_char *alloc (size_t) ; extern void alloc_free (void *) ; #define alloc_re(p, old, new) alloc_realloc(p, new) -extern int alloc_realloc (aligned_char **, unsigned int) ; +extern int alloc_realloc (aligned_char **, size_t) ; #endif diff --git a/src/include/skalibs/allreadwrite.h b/src/include/skalibs/allreadwrite.h index d2e6bf7..9e42c1c 100644 --- a/src/include/skalibs/allreadwrite.h +++ b/src/include/skalibs/allreadwrite.h @@ -8,26 +8,24 @@ #include #include -extern int sanitize_read (int) ; -extern int unsanitize_read (int) ; +extern ssize_t sanitize_read (ssize_t) ; +extern ssize_t unsanitize_read (ssize_t) ; -extern unsigned int allreadwrite (iofunc_t_ref, int, char *, unsigned int) ; -extern unsigned int allreadwritev (iovfunc_t_ref, int, siovec_t const *, unsigned int) ; +extern size_t allreadwrite (iofunc_t_ref, int, char *, size_t) ; +extern size_t allreadwritev (iovfunc_t_ref, int, struct iovec const *, unsigned int) ; -extern int fd_read (int, char *, unsigned int) ; -extern int fd_write (int, char const *, unsigned int) ; +extern ssize_t fd_read (int, char *, size_t) ; +extern ssize_t fd_write (int, char const *, size_t) ; -extern int fd_recv (int, char *, unsigned int, unsigned int) ; -extern int fd_send (int, char const *, unsigned int, unsigned int) ; +extern ssize_t fd_recv (int, char *, size_t, unsigned int) ; +extern ssize_t fd_send (int, char const *, size_t, unsigned int) ; -extern unsigned int allread (int, char *, unsigned int) ; -extern unsigned int allwrite (int, char const *, unsigned int) ; -extern unsigned int allreadv (int, siovec_t const *, unsigned int) ; -extern unsigned int allwritev (int, siovec_t const *, unsigned int) ; +extern size_t allread (int, char *, size_t) ; +extern size_t allwrite (int, char const *, size_t) ; +extern size_t allreadv (int, struct iovec const *, unsigned int) ; +extern size_t allwritev (int, struct iovec const *, unsigned int) ; -extern int fd_readv (int, struct iovec const *, unsigned int) ; -extern int fd_readsv (int, siovec_t const *, unsigned int) ; -extern int fd_writev (int, struct iovec const *, unsigned int) ; -extern int fd_writesv (int, siovec_t const *, unsigned int) ; +extern ssize_t fd_readv (int, struct iovec const *, unsigned int) ; +extern ssize_t fd_writev (int, struct iovec const *, unsigned int) ; #endif diff --git a/src/include/skalibs/bitarray.h b/src/include/skalibs/bitarray.h index fc9b16d..7344492 100644 --- a/src/include/skalibs/bitarray.h +++ b/src/include/skalibs/bitarray.h @@ -3,11 +3,13 @@ #ifndef BITARRAY_H #define BITARRAY_H +#include #include +#include #define bitarray_div8(n) ((n) ? 1U + (((n) - 1) >> 3) : 0U) -extern void bitarray_clearsetn (unsigned char *, unsigned int, unsigned int, int) ; +extern void bitarray_clearsetn (unsigned char *, size_t, size_t, int) ; #define bitarray_clearn(s, start, len) bitarray_clearsetn(s, start, (len), 0) #define bitarray_setn(s, start, len) bitarray_clearsetn(s, start, (len), 1) @@ -17,23 +19,23 @@ extern void bitarray_clearsetn (unsigned char *, unsigned int, unsigned int, int #define bitarray_set(s, n) ((s)[(n)>>3] |= 1U << ((n) & 7)) #define bitarray_poke(s, n, h) ((h) ? bitarray_set(s, n) : bitarray_clear(s, n)) -extern int bitarray_testandpoke (unsigned char *, unsigned int, int) ; +extern int bitarray_testandpoke (unsigned char *, size_t, int) ; #define bitarray_testandclear(b, n) bitarray_testandpoke(b, n, 0) #define bitarray_testandset(b, n) bitarray_testandpoke(b, n, 1) -extern unsigned int bitarray_firstclear (unsigned char const *, unsigned int) gccattr_pure ; -extern unsigned int bitarray_firstset (unsigned char const *, unsigned int) gccattr_pure ; +extern size_t bitarray_firstclear (unsigned char const *, size_t) gccattr_pure ; +extern size_t bitarray_firstset (unsigned char const *, size_t) gccattr_pure ; #define bitarray_first(s, n, h) ((h) ? bitarray_firstset(s, n) : bitarray_firstclear(s, n)) -extern unsigned int bitarray_firstclear_skip (unsigned char const *, unsigned int, unsigned int) gccattr_pure ; -extern unsigned int bitarray_firstset_skip (unsigned char const *, unsigned int, unsigned int) gccattr_pure ; +extern size_t bitarray_firstclear_skip (unsigned char const *, size_t, size_t) gccattr_pure ; +extern size_t bitarray_firstset_skip (unsigned char const *, size_t, size_t) gccattr_pure ; #define bitarray_first_skip(s, n, k, h) ((h) ? bitarray_firstset_skip(s, n, k) : bitarray_firstclear_skip(s, n, k)) -extern unsigned int bitarray_countones (unsigned char const *, unsigned int) gccattr_pure ; +extern uint64_t bitarray_countones (unsigned char const *, size_t) gccattr_pure ; -extern void bitarray_not (unsigned char *, unsigned int, unsigned int) ; -extern void bitarray_and (unsigned char *, unsigned char const *, unsigned char const *, unsigned int) ; -extern void bitarray_or (unsigned char *, unsigned char const *, unsigned char const *, unsigned int) ; -extern void bitarray_xor (unsigned char *, unsigned char const *, unsigned char const *, unsigned int) ; +extern void bitarray_not (unsigned char *, size_t, size_t) ; +extern void bitarray_and (unsigned char *, unsigned char const *, unsigned char const *, size_t) ; +extern void bitarray_or (unsigned char *, unsigned char const *, unsigned char const *, size_t) ; +extern void bitarray_xor (unsigned char *, unsigned char const *, unsigned char const *, size_t) ; #endif diff --git a/src/include/skalibs/bufalloc.h b/src/include/skalibs/bufalloc.h index 2941311..838ab02 100644 --- a/src/include/skalibs/bufalloc.h +++ b/src/include/skalibs/bufalloc.h @@ -3,6 +3,7 @@ #ifndef BUFALLOC_H #define BUFALLOC_H +#include #include #include @@ -10,14 +11,14 @@ typedef struct bufalloc bufalloc, *bufalloc_ref ; struct bufalloc { stralloc x ; - unsigned int p ; + size_t p ; int fd ; int (*op) (int, char const *, unsigned int) ; } ; #define BUFALLOC_ZERO { .x = STRALLOC_ZERO, .p = 0, .fd = -1, .op = 0 } #define BUFALLOC_INIT(f, d) { .x = STRALLOC_ZERO, .p = 0, .fd = (d), .op = (f) } -extern void bufalloc_init (bufalloc *, int (*)(int, char const *, unsigned int), int) ; +extern void bufalloc_init (bufalloc *, int (*)(int, char const *, size_t), int) ; #define bufalloc_shrink(ba) stralloc_shrink(&(ba)->x) #define bufalloc_free(ba) stralloc_free(&(ba)->x) #define bufalloc_put(ba, s, n) stralloc_catb(&(ba)->x, s, n) @@ -28,7 +29,7 @@ extern int bufalloc_getfd (bufalloc const *) gccattr_pure ; extern int bufalloc_flush (bufalloc *) ; extern void bufalloc_clean (bufalloc *) ; #define bufalloc_len(ba) ((ba)->x.len - (ba)->p) -extern unsigned int bufalloc_getlen (bufalloc const *) gccattr_pure ; +extern size_t bufalloc_getlen (bufalloc const *) gccattr_pure ; #define bufalloc_isempty(ba) ((ba)->x.len == (ba)->p) extern bufalloc bufalloc_1_ ; diff --git a/src/include/skalibs/bytestr.h b/src/include/skalibs/bytestr.h index 2340a2f..79768a8 100644 --- a/src/include/skalibs/bytestr.h +++ b/src/include/skalibs/bytestr.h @@ -9,12 +9,11 @@ /* for Alphas and other archs where char != 8bit */ #define T8(x) ((x) & 0xffU) -#ifndef SKALIBS_FLAG_REPLACE_LIBC - #include #include #include #include +#include #define byte_copy(to, n, from) memmove(to, (from), n) #define byte_copyr(to, n, from) memmove(to, (from), n) @@ -34,44 +33,28 @@ #define case_diffs strcasecmp #define case_diffn strncasecmp -#else - -extern void byte_copy (char *, unsigned int, char const *) ; -extern void byte_copyr (char *, unsigned int, char const *) ; -extern int byte_diff (char const *, unsigned int, char const *) gccattr_pure ; -extern void byte_zero (void *, unsigned int) ; -extern unsigned int str_len (char const *) gccattr_pure ; -#define str_nlen(s, max) byte_chr(s, (max), 0) -extern int str_diff (char const *, char const *) gccattr_pure ; -extern int str_diffn (char const *, char const *, unsigned int) gccattr_pure ; -extern unsigned int str_copy (char *, char const *) ; -extern int case_diffs (char const *, char const *) gccattr_pure ; -extern int case_diffn (char const *, char const *, unsigned int) gccattr_pure ; - -#endif - -extern unsigned int byte_chr (char const *, unsigned int, int) gccattr_pure ; -extern unsigned int byte_rchr (char const *, unsigned int, int) gccattr_pure ; -extern unsigned int byte_in (char const *, unsigned int, char const *, unsigned int) gccattr_pure ; +extern size_t byte_chr (char const *, size_t, int) gccattr_pure ; +extern size_t byte_rchr (char const *, size_t, int) gccattr_pure ; +extern size_t byte_in (char const *, size_t, char const *, size_t) gccattr_pure ; #define byte_equal(s, n, t) (!byte_diff((s), (n), (t))) -extern unsigned int byte_count (char const *, unsigned int, char) gccattr_pure ; +extern uint64_t byte_count (char const *, size_t, char) gccattr_pure ; #define str_diffb(a, n, b) str_diffn(a, (b), n) -extern unsigned int str_chr (char const *, int) gccattr_pure ; -extern unsigned int str_rchr (char const *, int) gccattr_pure ; +extern size_t str_chr (char const *, int) gccattr_pure ; +extern size_t str_rchr (char const *, int) gccattr_pure ; extern int str_start (char const *, char const *) gccattr_pure ; #define str_equal(s, t) (!str_diff(s, t)) -extern unsigned int str_strn (char const *, unsigned int, char const *, unsigned int) gccattr_pure ; +extern size_t str_strn (char const *, size_t, char const *, size_t) gccattr_pure ; extern void case_lowers (char *) ; -extern void case_lowerb (char *, unsigned int) ; +extern void case_lowerb (char *, size_t) ; extern void case_uppers (char *) ; -extern void case_upperb (char *, unsigned int) ; +extern void case_upperb (char *, size_t) ; #define case_diffb(a, n, b) case_diffn(a, (b), n) #define case_equals(a, b) (!case_diffs(a, b)) #define case_equalb(a, n, b) (!case_diffb(a, n, b)) -#define case_starts(s, t) case_startb(s, str_len(s), t) -extern int case_startb (char const *, unsigned int, char const *) gccattr_pure ; -extern unsigned int case_str (char const *, char const *) gccattr_pure ; +#define case_starts(s, t) case_startb(s, strlen(s), t) +extern int case_startb (char const *, size_t, char const *) gccattr_pure ; +extern size_t case_str (char const *, char const *) gccattr_pure ; #endif diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h index 354ca57..a0d65a0 100644 --- a/src/include/skalibs/djbunix.h +++ b/src/include/skalibs/djbunix.h @@ -35,7 +35,7 @@ extern int fd_chmod (int, unsigned int) ; extern int fd_chown (int, unsigned int, unsigned int) ; extern int fd_sync (int) ; extern int fd_cat (int, int) ; -extern unsigned int fd_catn (int, int, unsigned int) ; +extern size_t fd_catn (int, int, size_t) ; extern int fd_ensure_open (int, int) ; #define fd_sanitize() (fd_ensure_open(0, 0) && fd_ensure_open(1, 1) && fd_ensure_open(2, 1)) extern int lock_ex (int) ; diff --git a/src/include/skalibs/functypes.h b/src/include/skalibs/functypes.h index d7094fc..a443c2a 100644 --- a/src/include/skalibs/functypes.h +++ b/src/include/skalibs/functypes.h @@ -3,7 +3,8 @@ #ifndef FUNCTYPES_H #define FUNCTYPES_H -#include +#include +#include typedef int uintcmpfunc_t (unsigned int, unsigned int, void *) ; typedef uintcmpfunc_t *uintcmpfunc_t_ref ; @@ -26,16 +27,16 @@ typedef initfunc_t *initfunc_t_ref ; typedef unsigned int uinitfunc_t (void *) ; typedef uinitfunc_t *uinitfunc_t_ref ; -typedef int iofunc_t (int, char *, unsigned int) ; +typedef ssize_t iofunc_t (int, char *, size_t) ; typedef iofunc_t *iofunc_t_ref ; -typedef int iovfunc_t (int, siovec_t const *, unsigned int) ; +typedef ssize_t iovfunc_t (int, struct iovec const *, unsigned int) ; typedef iovfunc_t *iovfunc_t_ref ; -typedef unsigned int alliofunc_t (int, char *, unsigned int) ; +typedef size_t alliofunc_t (int, char *, size_t) ; typedef alliofunc_t *alliofunc_t_ref ; -typedef unsigned int alliovfunc_t (int, siovec_t const *, unsigned int) ; +typedef size_t alliovfunc_t (int, struct iovec const *, unsigned int) ; typedef alliovfunc_t *alliovfunc_t_ref ; #endif diff --git a/src/include/skalibs/genalloc.h b/src/include/skalibs/genalloc.h index 1aa0613..9c81acd 100644 --- a/src/include/skalibs/genalloc.h +++ b/src/include/skalibs/genalloc.h @@ -3,6 +3,7 @@ #ifndef GENALLOC_H #define GENALLOC_H +#include #include #include @@ -30,6 +31,6 @@ typedef stralloc genalloc, *genalloc_ref ; #define genalloc_insert(type, g1, offset, g2) stralloc_insert((g1), (offset)*sizeof(type), (g2)) #define genalloc_deepfree(type, g, f) genalloc_deepfree_size(g, (freefunc_t_ref)(f), sizeof(type)) -extern void genalloc_deepfree_size (genalloc *, freefunc_t_ref, unsigned int) ; +extern void genalloc_deepfree_size (genalloc *, freefunc_t_ref, size_t) ; #endif diff --git a/src/include/skalibs/genwrite.h b/src/include/skalibs/genwrite.h index 9ae0fb9..0b3af87 100644 --- a/src/include/skalibs/genwrite.h +++ b/src/include/skalibs/genwrite.h @@ -3,7 +3,9 @@ #ifndef GENWRITE_H #define GENWRITE_H -typedef int genwrite_put_func_t (void *, char const *, unsigned int) ; +#include + +typedef ssize_t genwrite_put_func_t (void *, char const *, size_t) ; typedef genwrite_put_func_t *genwrite_put_func_t_ref ; typedef int genwrite_flush_func_t (void *) ; diff --git a/src/include/skalibs/stralloc.h b/src/include/skalibs/stralloc.h index 2d762d4..2ec4c23 100644 --- a/src/include/skalibs/stralloc.h +++ b/src/include/skalibs/stralloc.h @@ -3,38 +3,39 @@ #ifndef STRALLOC_H #define STRALLOC_H -#include -#include +#include +#include +#include typedef struct stralloc_s stralloc, *stralloc_ref ; struct stralloc_s { char *s ; - unsigned int len ; - unsigned int a ; + size_t len ; + size_t a ; } ; #define STRALLOC_ZERO { .s = 0, .len = 0, .a = 0 } extern stralloc const stralloc_zero ; -extern int stralloc_ready_tuned (stralloc *, unsigned int, unsigned int, unsigned int, unsigned int) ; +extern int stralloc_ready_tuned (stralloc *, size_t, size_t, size_t, size_t) ; #define stralloc_ready(sa, n) stralloc_ready_tuned(sa, (n), 8, 1, 8) #define stralloc_readyplus(sa, n) stralloc_ready(sa, (sa)->len + (n)) extern void stralloc_free (stralloc *) ; extern int stralloc_shrink (stralloc *) ; -extern int stralloc_copyb (stralloc *, char const *, unsigned int) ; -extern int stralloc_catb (stralloc *, char const *, unsigned int) ; -extern int stralloc_catv (stralloc *, siovec_t const *, unsigned int) ; -#define stralloc_copys(sa, s) stralloc_copyb(sa, (s), str_len(s)) -#define stralloc_cats(sa, s) stralloc_catb(sa, (s), str_len(s)) +extern int stralloc_copyb (stralloc *, char const *, size_t) ; +extern int stralloc_catb (stralloc *, char const *, size_t) ; +extern int stralloc_catv (stralloc *, struct iovec const *, unsigned int) ; +#define stralloc_copys(sa, s) stralloc_copyb(sa, (s), strlen(s)) +#define stralloc_cats(sa, s) stralloc_catb(sa, (s), strlen(s)) #define stralloc_copy(sa1, sa2) stralloc_copyb(sa1, (sa2)->s, (sa2)->len) #define stralloc_cat(sa1, sa2) stralloc_catb(sa1, (sa2)->s, (sa2)->len) extern int stralloc_append (stralloc *, char) ; extern void stralloc_reverse (stralloc *) ; -extern void stralloc_reverse_blocks (stralloc *, unsigned int) ; +extern void stralloc_reverse_blocks (stralloc *, size_t) ; #define stralloc_0(sa) stralloc_catb(sa, "", 1) -extern int stralloc_insertb (stralloc *, unsigned int, char const *, unsigned int) ; -#define stralloc_inserts(sa, offset, s) stralloc_insertb(sa, offset, (s), str_len(s)) +extern int stralloc_insertb (stralloc *, size_t, char const *, size_t) ; +#define stralloc_inserts(sa, offset, s) stralloc_insertb(sa, offset, (s), strlen(s)) #define stralloc_insert(sa1, offset, sa2) stralloc_insertb(sa1, offset, (sa2)->s, (sa2)->len) #endif -- cgit v1.2.3