commit a896ca2a8c617e5e00ffd5fc9e69331ad754e5b3 parent 00c9cb1b22cc17c4db573e0e613a5f116ff0092e Author: Laurent Bercot <ska-skaware@skarnet.org> Date: Wed, 15 Feb 2017 17:40:40 +0000 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. Diffstat:
83 files changed, 322 insertions(+), 374 deletions(-)
diff --git a/configure b/configure @@ -512,6 +512,7 @@ EOF choose cl futimens FUTIMENS 'futimens()' choose cl futimes FUTIMES 'futimes()' choose cl arc4random ARC4RANDOM 'arc4random()' + choose cl arc4random_addrandom ARC4RANDOM_ADDRANDOM 'arc4random_addrandom()' choose cl getrandom GETRANDOM 'getrandom()' choose cl itimer ITIMER 'setitimer()' diff --git a/package/deps.mak b/package/deps.mak @@ -9,10 +9,10 @@ src/include/skalibs/avlnode.h: src/include/skalibs/functypes.h src/include/skali src/include/skalibs/avltree.h: src/include/skalibs/avlnode.h src/include/skalibs/functypes.h src/include/skalibs/gensetdyn.h src/include/skalibs/avltreen.h: src/include/skalibs/avlnode.h src/include/skalibs/functypes.h src/include/skalibs/genset.h src/include/skalibs/biguint.h: src/include/skalibs/gccattributes.h -src/include/skalibs/bitarray.h: src/include/skalibs/gccattributes.h +src/include/skalibs/bitarray.h: src/include/skalibs/gccattributes.h src/include/skalibs/uint64.h src/include/skalibs/bufalloc.h: src/include/skalibs/gccattributes.h src/include/skalibs/stralloc.h src/include/skalibs/buffer.h: src/include/skalibs/allreadwrite.h src/include/skalibs/bytestr.h src/include/skalibs/cbuffer.h src/include/skalibs/functypes.h src/include/skalibs/gccattributes.h src/include/skalibs/siovec.h -src/include/skalibs/bytestr.h: src/include/skalibs/config.h src/include/skalibs/gccattributes.h src/include/skalibs/sysdeps.h +src/include/skalibs/bytestr.h: src/include/skalibs/config.h src/include/skalibs/gccattributes.h src/include/skalibs/sysdeps.h src/include/skalibs/uint64.h src/include/skalibs/cbuffer.h: src/include/skalibs/bytestr.h src/include/skalibs/diuint.h src/include/skalibs/gccattributes.h src/include/skalibs/siovec.h src/include/skalibs/cdb.h: src/include/skalibs/gccattributes.h src/include/skalibs/uint32.h src/include/skalibs/cdb_make.h: src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/diuint32.h src/include/skalibs/genalloc.h src/include/skalibs/uint32.h @@ -23,7 +23,6 @@ src/include/skalibs/djbunix.h: src/include/skalibs/env.h src/include/skalibs/env src/include/skalibs/env.h: src/include/skalibs/gccattributes.h src/include/skalibs/stralloc.h src/include/skalibs/envalloc.h: src/include/skalibs/genalloc.h src/include/skalibs/fmtscan.h: src/include/skalibs/gccattributes.h -src/include/skalibs/functypes.h: src/include/skalibs/siovec.h src/include/skalibs/genalloc.h: src/include/skalibs/functypes.h src/include/skalibs/stralloc.h src/include/skalibs/genset.h: src/include/skalibs/functypes.h src/include/skalibs/gensetdyn.h: src/include/skalibs/functypes.h src/include/skalibs/genalloc.h src/include/skalibs/stralloc.h @@ -43,7 +42,6 @@ src/include/skalibs/skamisc.h: src/include/skalibs/buffer.h src/include/skalibs/ src/include/skalibs/socket.h: src/include/skalibs/djbunix.h src/include/skalibs/gccattributes.h src/include/skalibs/tai.h src/include/skalibs/uint16.h src/include/skalibs/uint32.h src/include/skalibs/webipc.h src/include/skalibs/stdcrypto.h: src/include/skalibs/md5.h src/include/skalibs/rc4.h src/include/skalibs/sha1.h src/include/skalibs/sha256.h src/include/skalibs/sha512.h src/include/skalibs/stddjb.h: src/include/skalibs/alarm.h src/include/skalibs/alloc.h src/include/skalibs/allreadwrite.h src/include/skalibs/bitarray.h src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/bytestr.h src/include/skalibs/cbuffer.h src/include/skalibs/cdb.h src/include/skalibs/cdb_make.h src/include/skalibs/config.h src/include/skalibs/direntry.h src/include/skalibs/diuint.h src/include/skalibs/diuint32.h src/include/skalibs/djbtime.h src/include/skalibs/djbunix.h src/include/skalibs/env.h src/include/skalibs/envalloc.h src/include/skalibs/environ.h src/include/skalibs/error.h src/include/skalibs/fmtscan.h src/include/skalibs/functypes.h src/include/skalibs/gccattributes.h src/include/skalibs/genalloc.h src/include/skalibs/genwrite.h src/include/skalibs/getpeereid.h src/include/skalibs/iobuffer.h src/include/skalibs/iopause.h src/include/skalibs/ip46.h src/include/skalibs/lolstdio.h src/include/skalibs/mininetstring.h src/include/skalibs/netstring.h src/include/skalibs/nsig.h src/include/skalibs/segfault.h src/include/skalibs/selfpipe.h src/include/skalibs/setgroups.h src/include/skalibs/sgetopt.h src/include/skalibs/sig.h src/include/skalibs/siovec.h src/include/skalibs/skamisc.h src/include/skalibs/socket.h src/include/skalibs/stralloc.h src/include/skalibs/strerr.h src/include/skalibs/strerr2.h src/include/skalibs/tai.h src/include/skalibs/types.h src/include/skalibs/uint16.h src/include/skalibs/uint32.h src/include/skalibs/uint64.h src/include/skalibs/webipc.h -src/include/skalibs/stralloc.h: src/include/skalibs/bytestr.h src/include/skalibs/siovec.h src/include/skalibs/strerr.h: src/include/skalibs/gccattributes.h src/include/skalibs/strerr2.h: src/include/skalibs/strerr.h src/include/skalibs/tai.h: src/include/skalibs/gccattributes.h src/include/skalibs/uint32.h src/include/skalibs/uint64.h @@ -165,16 +163,16 @@ src/libstddjb/alarm_timeout.o src/libstddjb/alarm_timeout.lo: src/libstddjb/alar src/libstddjb/alloc.o src/libstddjb/alloc.lo: src/libstddjb/alloc.c src/libstddjb/alloc-internal.h src/include/skalibs/alloc.h src/include/skalibs/sysdeps.h src/libstddjb/alloc_0.o src/libstddjb/alloc_0.lo: src/libstddjb/alloc_0.c src/libstddjb/alloc-internal.h src/include/skalibs/alloc.h src/include/skalibs/sysdeps.h src/libstddjb/allread.o src/libstddjb/allread.lo: src/libstddjb/allread.c src/include/skalibs/allreadwrite.h -src/libstddjb/allreadv.o src/libstddjb/allreadv.lo: src/libstddjb/allreadv.c src/include/skalibs/allreadwrite.h src/include/skalibs/siovec.h -src/libstddjb/allreadwrite.o src/libstddjb/allreadwrite.lo: src/libstddjb/allreadwrite.c src/include/skalibs/allreadwrite.h -src/libstddjb/allreadwritev.o src/libstddjb/allreadwritev.lo: src/libstddjb/allreadwritev.c src/include/skalibs/allreadwrite.h src/include/skalibs/siovec.h +src/libstddjb/allreadv.o src/libstddjb/allreadv.lo: src/libstddjb/allreadv.c src/include/skalibs/allreadwrite.h +src/libstddjb/allreadwrite.o src/libstddjb/allreadwrite.lo: src/libstddjb/allreadwrite.c src/include/skalibs/allreadwrite.h src/include/skalibs/functypes.h +src/libstddjb/allreadwritev.o src/libstddjb/allreadwritev.lo: src/libstddjb/allreadwritev.c src/include/skalibs/allreadwrite.h src/include/skalibs/functypes.h src/include/skalibs/siovec.h src/libstddjb/allwrite.o src/libstddjb/allwrite.lo: src/libstddjb/allwrite.c src/include/skalibs/allreadwrite.h -src/libstddjb/allwritev.o src/libstddjb/allwritev.lo: src/libstddjb/allwritev.c src/include/skalibs/allreadwrite.h src/include/skalibs/siovec.h +src/libstddjb/allwritev.o src/libstddjb/allwritev.lo: src/libstddjb/allwritev.c src/include/skalibs/allreadwrite.h src/libstddjb/baprintf.o src/libstddjb/baprintf.lo: src/libstddjb/baprintf.c src/include/skalibs/bufalloc.h src/include/skalibs/lolstdio.h src/libstddjb/basename.o src/libstddjb/basename.lo: src/libstddjb/basename.c src/include/skalibs/bytestr.h src/include/skalibs/djbunix.h src/include/skalibs/stralloc.h src/libstddjb/bitarray_and.o src/libstddjb/bitarray_and.lo: src/libstddjb/bitarray_and.c src/include/skalibs/bitarray.h src/libstddjb/bitarray_clearsetn.o src/libstddjb/bitarray_clearsetn.lo: src/libstddjb/bitarray_clearsetn.c src/include/skalibs/bitarray.h -src/libstddjb/bitarray_count.o src/libstddjb/bitarray_count.lo: src/libstddjb/bitarray_count.c src/include/skalibs/bitarray.h +src/libstddjb/bitarray_count.o src/libstddjb/bitarray_count.lo: src/libstddjb/bitarray_count.c src/include/skalibs/bitarray.h src/include/skalibs/uint64.h src/libstddjb/bitarray_firstclear.o src/libstddjb/bitarray_firstclear.lo: src/libstddjb/bitarray_firstclear.c src/include/skalibs/bitarray.h src/libstddjb/bitarray_firstclear_skip.o src/libstddjb/bitarray_firstclear_skip.lo: src/libstddjb/bitarray_firstclear_skip.c src/include/skalibs/bitarray.h src/libstddjb/bitarray_firstset.o src/libstddjb/bitarray_firstset.lo: src/libstddjb/bitarray_firstset.c src/include/skalibs/bitarray.h @@ -186,8 +184,8 @@ src/libstddjb/bitarray_xor.o src/libstddjb/bitarray_xor.lo: src/libstddjb/bitarr src/libstddjb/bprintf.o src/libstddjb/bprintf.lo: src/libstddjb/bprintf.c src/include/skalibs/buffer.h src/include/skalibs/lolstdio.h src/libstddjb/bufalloc_1.o src/libstddjb/bufalloc_1.lo: src/libstddjb/bufalloc_1.c src/include/skalibs/allreadwrite.h src/include/skalibs/bufalloc.h src/libstddjb/bufalloc_2.o src/libstddjb/bufalloc_2.lo: src/libstddjb/bufalloc_2.c src/include/skalibs/allreadwrite.h src/include/skalibs/bufalloc.h -src/libstddjb/bufalloc_clean.o src/libstddjb/bufalloc_clean.lo: src/libstddjb/bufalloc_clean.c src/include/skalibs/bufalloc.h src/include/skalibs/bytestr.h -src/libstddjb/bufalloc_flush.o src/libstddjb/bufalloc_flush.lo: src/libstddjb/bufalloc_flush.c src/include/skalibs/allreadwrite.h src/include/skalibs/bufalloc.h +src/libstddjb/bufalloc_clean.o src/libstddjb/bufalloc_clean.lo: src/libstddjb/bufalloc_clean.c src/include/skalibs/bufalloc.h +src/libstddjb/bufalloc_flush.o src/libstddjb/bufalloc_flush.lo: src/libstddjb/bufalloc_flush.c src/include/skalibs/allreadwrite.h src/include/skalibs/bufalloc.h src/include/skalibs/functypes.h src/libstddjb/bufalloc_getfd.o src/libstddjb/bufalloc_getfd.lo: src/libstddjb/bufalloc_getfd.c src/include/skalibs/bufalloc.h src/libstddjb/bufalloc_getlen.o src/libstddjb/bufalloc_getlen.lo: src/libstddjb/bufalloc_getlen.c src/include/skalibs/bufalloc.h src/libstddjb/bufalloc_init.o src/libstddjb/bufalloc_init.lo: src/libstddjb/bufalloc_init.c src/include/skalibs/bufalloc.h src/include/skalibs/stralloc.h @@ -199,7 +197,7 @@ src/libstddjb/buffer_1small.o src/libstddjb/buffer_1small.lo: src/libstddjb/buff src/libstddjb/buffer_2.o src/libstddjb/buffer_2.lo: src/libstddjb/buffer_2.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/libstddjb/buffer_fill.o src/libstddjb/buffer_fill.lo: src/libstddjb/buffer_fill.c src/include/skalibs/buffer.h src/libstddjb/buffer_flush.o src/libstddjb/buffer_flush.lo: src/libstddjb/buffer_flush.c src/include/skalibs/buffer.h src/include/skalibs/cbuffer.h src/include/skalibs/siovec.h -src/libstddjb/buffer_flush1read.o src/libstddjb/buffer_flush1read.lo: src/libstddjb/buffer_flush1read.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/siovec.h +src/libstddjb/buffer_flush1read.o src/libstddjb/buffer_flush1read.lo: src/libstddjb/buffer_flush1read.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/libstddjb/buffer_get.o src/libstddjb/buffer_get.lo: src/libstddjb/buffer_get.c src/include/skalibs/buffer.h src/libstddjb/buffer_getall.o src/libstddjb/buffer_getall.lo: src/libstddjb/buffer_getall.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/libstddjb/buffer_getallnf.o src/libstddjb/buffer_getallnf.lo: src/libstddjb/buffer_getallnf.c src/include/skalibs/buffer.h @@ -223,7 +221,7 @@ src/libstddjb/buffer_putv.o src/libstddjb/buffer_putv.lo: src/libstddjb/buffer_p src/libstddjb/buffer_putvall.o src/libstddjb/buffer_putvall.lo: src/libstddjb/buffer_putvall.c src/include/skalibs/buffer.h src/include/skalibs/siovec.h src/libstddjb/buffer_putvallnf.o src/libstddjb/buffer_putvallnf.lo: src/libstddjb/buffer_putvallnf.c src/include/skalibs/buffer.h src/libstddjb/buffer_putvflush.o src/libstddjb/buffer_putvflush.lo: src/libstddjb/buffer_putvflush.c src/include/skalibs/buffer.h src/include/skalibs/siovec.h -src/libstddjb/byte_chr.o src/libstddjb/byte_chr.lo: src/libstddjb/byte_chr.c src/include/skalibs/bytestr.h src/include/skalibs/config.h +src/libstddjb/byte_chr.o src/libstddjb/byte_chr.lo: src/libstddjb/byte_chr.c src/include/skalibs/bytestr.h src/libstddjb/byte_copy.o src/libstddjb/byte_copy.lo: src/libstddjb/byte_copy.c src/include/skalibs/bytestr.h src/include/skalibs/config.h src/libstddjb/byte_count.o src/libstddjb/byte_count.lo: src/libstddjb/byte_count.c src/include/skalibs/bytestr.h src/libstddjb/byte_cr.o src/libstddjb/byte_cr.lo: src/libstddjb/byte_cr.c src/include/skalibs/bytestr.h src/include/skalibs/config.h @@ -236,7 +234,7 @@ src/libstddjb/case_diffs.o src/libstddjb/case_diffs.lo: src/libstddjb/case_diffs src/libstddjb/case_lowerb.o src/libstddjb/case_lowerb.lo: src/libstddjb/case_lowerb.c src/include/skalibs/bytestr.h src/libstddjb/case_lowers.o src/libstddjb/case_lowers.lo: src/libstddjb/case_lowers.c src/include/skalibs/bytestr.h src/libstddjb/case_startb.o src/libstddjb/case_startb.lo: src/libstddjb/case_startb.c src/include/skalibs/bytestr.h -src/libstddjb/case_str.o src/libstddjb/case_str.lo: src/libstddjb/case_str.c src/include/skalibs/bytestr.h src/include/skalibs/config.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h +src/libstddjb/case_str.o src/libstddjb/case_str.lo: src/libstddjb/case_str.c src/include/skalibs/bytestr.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/libstddjb/case_upperb.o src/libstddjb/case_upperb.lo: src/libstddjb/case_upperb.c src/include/skalibs/bytestr.h src/libstddjb/case_uppers.o src/libstddjb/case_uppers.lo: src/libstddjb/case_uppers.c src/include/skalibs/bytestr.h src/libstddjb/cbuffer_get.o src/libstddjb/cbuffer_get.lo: src/libstddjb/cbuffer_get.c src/include/skalibs/cbuffer.h src/include/skalibs/siovec.h @@ -298,13 +296,11 @@ src/libstddjb/fd_ensure_open.o src/libstddjb/fd_ensure_open.lo: src/libstddjb/fd src/libstddjb/fd_move.o src/libstddjb/fd_move.lo: src/libstddjb/fd_move.c src/include/skalibs/djbunix.h src/libstddjb/fd_move2.o src/libstddjb/fd_move2.lo: src/libstddjb/fd_move2.c src/include/skalibs/djbunix.h src/libstddjb/fd_read.o src/libstddjb/fd_read.lo: src/libstddjb/fd_read.c src/include/skalibs/allreadwrite.h -src/libstddjb/fd_readsv.o src/libstddjb/fd_readsv.lo: src/libstddjb/fd_readsv.c src/include/skalibs/allreadwrite.h src/include/skalibs/siovec.h src/libstddjb/fd_readv.o src/libstddjb/fd_readv.lo: src/libstddjb/fd_readv.c src/include/skalibs/allreadwrite.h src/libstddjb/fd_recv.o src/libstddjb/fd_recv.lo: src/libstddjb/fd_recv.c src/include/skalibs/allreadwrite.h src/libstddjb/fd_send.o src/libstddjb/fd_send.lo: src/libstddjb/fd_send.c src/include/skalibs/allreadwrite.h src/libstddjb/fd_sync.o src/libstddjb/fd_sync.lo: src/libstddjb/fd_sync.c src/include/skalibs/djbunix.h src/libstddjb/fd_write.o src/libstddjb/fd_write.lo: src/libstddjb/fd_write.c src/include/skalibs/allreadwrite.h -src/libstddjb/fd_writesv.o src/libstddjb/fd_writesv.lo: src/libstddjb/fd_writesv.c src/include/skalibs/allreadwrite.h src/include/skalibs/siovec.h src/libstddjb/fd_writev.o src/libstddjb/fd_writev.lo: src/libstddjb/fd_writev.c src/include/skalibs/allreadwrite.h src/libstddjb/filecopy_suffix.o src/libstddjb/filecopy_suffix.lo: src/libstddjb/filecopy_suffix.c src/include/skalibs/bytestr.h src/include/skalibs/djbunix.h src/libstddjb/filecopy_unsafe.o src/libstddjb/filecopy_unsafe.lo: src/libstddjb/filecopy_unsafe.c src/include/skalibs/djbunix.h @@ -544,24 +540,24 @@ src/libstddjb/socket_udp6.o src/libstddjb/socket_udp6.lo: src/libstddjb/socket_u src/libstddjb/socket_waitconn.o src/libstddjb/socket_waitconn.lo: src/libstddjb/socket_waitconn.c src/include/skalibs/allreadwrite.h src/include/skalibs/iopause.h src/include/skalibs/socket.h src/include/skalibs/tai.h src/libstddjb/socketpair_internal.o src/libstddjb/socketpair_internal.lo: src/libstddjb/socketpair_internal.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/libstddjb/stamp.o src/libstddjb/stamp.lo: src/libstddjb/stamp.c src/include/skalibs/tai.h -src/libstddjb/str_chr.o src/libstddjb/str_chr.lo: src/libstddjb/str_chr.c src/include/skalibs/bytestr.h src/include/skalibs/config.h +src/libstddjb/str_chr.o src/libstddjb/str_chr.lo: src/libstddjb/str_chr.c src/include/skalibs/bytestr.h src/libstddjb/str_cpy.o src/libstddjb/str_cpy.lo: src/libstddjb/str_cpy.c src/include/skalibs/bytestr.h src/include/skalibs/config.h src/libstddjb/str_diff.o src/libstddjb/str_diff.lo: src/libstddjb/str_diff.c src/include/skalibs/bytestr.h src/include/skalibs/config.h src/libstddjb/str_diffn.o src/libstddjb/str_diffn.lo: src/libstddjb/str_diffn.c src/include/skalibs/bytestr.h src/include/skalibs/config.h src/libstddjb/str_fmt.o src/libstddjb/str_fmt.lo: src/libstddjb/str_fmt.c src/include/skalibs/fmtscan.h src/libstddjb/str_len.o src/libstddjb/str_len.lo: src/libstddjb/str_len.c src/include/skalibs/bytestr.h src/include/skalibs/config.h -src/libstddjb/str_rchr.o src/libstddjb/str_rchr.lo: src/libstddjb/str_rchr.c src/include/skalibs/bytestr.h src/include/skalibs/config.h +src/libstddjb/str_rchr.o src/libstddjb/str_rchr.lo: src/libstddjb/str_rchr.c src/include/skalibs/bytestr.h src/libstddjb/str_start.o src/libstddjb/str_start.lo: src/libstddjb/str_start.c src/include/skalibs/bytestr.h -src/libstddjb/str_strn.o src/libstddjb/str_strn.lo: src/libstddjb/str_strn.c src/include/skalibs/bytestr.h src/include/skalibs/config.h +src/libstddjb/str_strn.o src/libstddjb/str_strn.lo: src/libstddjb/str_strn.c src/include/skalibs/bytestr.h src/libstddjb/stralloc_append.o src/libstddjb/stralloc_append.lo: src/libstddjb/stralloc_append.c src/include/skalibs/stralloc.h -src/libstddjb/stralloc_catb.o src/libstddjb/stralloc_catb.lo: src/libstddjb/stralloc_catb.c src/include/skalibs/bytestr.h src/include/skalibs/stralloc.h -src/libstddjb/stralloc_catv.o src/libstddjb/stralloc_catv.lo: src/libstddjb/stralloc_catv.c src/include/skalibs/bytestr.h src/include/skalibs/siovec.h src/include/skalibs/stralloc.h -src/libstddjb/stralloc_copyb.o src/libstddjb/stralloc_copyb.lo: src/libstddjb/stralloc_copyb.c src/include/skalibs/bytestr.h src/include/skalibs/stralloc.h +src/libstddjb/stralloc_catb.o src/libstddjb/stralloc_catb.lo: src/libstddjb/stralloc_catb.c src/include/skalibs/stralloc.h +src/libstddjb/stralloc_catv.o src/libstddjb/stralloc_catv.lo: src/libstddjb/stralloc_catv.c src/include/skalibs/stralloc.h +src/libstddjb/stralloc_copyb.o src/libstddjb/stralloc_copyb.lo: src/libstddjb/stralloc_copyb.c src/include/skalibs/stralloc.h src/libstddjb/stralloc_free.o src/libstddjb/stralloc_free.lo: src/libstddjb/stralloc_free.c src/include/skalibs/alloc.h src/include/skalibs/stralloc.h -src/libstddjb/stralloc_insertb.o src/libstddjb/stralloc_insertb.lo: src/libstddjb/stralloc_insertb.c src/include/skalibs/bytestr.h src/include/skalibs/stralloc.h +src/libstddjb/stralloc_insertb.o src/libstddjb/stralloc_insertb.lo: src/libstddjb/stralloc_insertb.c src/include/skalibs/stralloc.h src/libstddjb/stralloc_ready_tuned.o src/libstddjb/stralloc_ready_tuned.lo: src/libstddjb/stralloc_ready_tuned.c src/include/skalibs/alloc.h src/include/skalibs/stralloc.h -src/libstddjb/stralloc_reverse.o src/libstddjb/stralloc_reverse.lo: src/libstddjb/stralloc_reverse.c src/include/skalibs/bytestr.h src/include/skalibs/stralloc.h -src/libstddjb/stralloc_reverse_blocks.o src/libstddjb/stralloc_reverse_blocks.lo: src/libstddjb/stralloc_reverse_blocks.c src/include/skalibs/bytestr.h src/include/skalibs/stralloc.h +src/libstddjb/stralloc_reverse.o src/libstddjb/stralloc_reverse.lo: src/libstddjb/stralloc_reverse.c src/include/skalibs/stralloc.h +src/libstddjb/stralloc_reverse_blocks.o src/libstddjb/stralloc_reverse_blocks.lo: src/libstddjb/stralloc_reverse_blocks.c src/include/skalibs/stralloc.h src/libstddjb/stralloc_shrink.o src/libstddjb/stralloc_shrink.lo: src/libstddjb/stralloc_shrink.c src/include/skalibs/alloc.h src/include/skalibs/stralloc.h src/libstddjb/stralloc_zero.o src/libstddjb/stralloc_zero.lo: src/libstddjb/stralloc_zero.c src/include/skalibs/stralloc.h src/libstddjb/strerr.o src/libstddjb/strerr.lo: src/libstddjb/strerr.c src/include/skalibs/buffer.h src/include/skalibs/strerr.h diff --git a/src/include/skalibs/alloc.h b/src/include/skalibs/alloc.h @@ -3,14 +3,15 @@ #ifndef ALLOC_H #define ALLOC_H +#include <sys/types.h> #include <skalibs/gccattributes.h> 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 @@ -8,26 +8,24 @@ #include <skalibs/functypes.h> #include <skalibs/siovec.h> -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 @@ -3,11 +3,13 @@ #ifndef BITARRAY_H #define BITARRAY_H +#include <sys/types.h> #include <skalibs/gccattributes.h> +#include <skalibs/uint64.h> #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 @@ -3,6 +3,7 @@ #ifndef BUFALLOC_H #define BUFALLOC_H +#include <sys/types.h> #include <skalibs/gccattributes.h> #include <skalibs/stralloc.h> @@ -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 @@ -9,12 +9,11 @@ /* for Alphas and other archs where char != 8bit */ #define T8(x) ((x) & 0xffU) -#ifndef SKALIBS_FLAG_REPLACE_LIBC - #include <skalibs/sysdeps.h> #include <sys/types.h> #include <string.h> #include <strings.h> +#include <skalibs/uint64.h> #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 @@ -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 @@ -3,7 +3,8 @@ #ifndef FUNCTYPES_H #define FUNCTYPES_H -#include <skalibs/siovec.h> +#include <sys/types.h> +#include <sys/uio.h> 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 @@ -3,6 +3,7 @@ #ifndef GENALLOC_H #define GENALLOC_H +#include <sys/types.h> #include <skalibs/stralloc.h> #include <skalibs/functypes.h> @@ -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 @@ -3,7 +3,9 @@ #ifndef GENWRITE_H #define GENWRITE_H -typedef int genwrite_put_func_t (void *, char const *, unsigned int) ; +#include <sys/types.h> + +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 @@ -3,38 +3,39 @@ #ifndef STRALLOC_H #define STRALLOC_H -#include <skalibs/bytestr.h> -#include <skalibs/siovec.h> +#include <sys/types.h> +#include <string.h> +#include <sys/uio.h> 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 diff --git a/src/librandom/random_init.c b/src/librandom/random_init.c @@ -10,9 +10,11 @@ int random_init () { +#ifdef SKALIBS_HASARC4RANDOM_ADDRANDOM char seed[160] ; random_makeseed(seed) ; arc4random_addrandom((unsigned char *)seed, 160) ; +#endif return 1 ; } diff --git a/src/libstddjb/absolutepath_tmp.c b/src/libstddjb/absolutepath_tmp.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <unistd.h> #include <errno.h> #include <skalibs/bytestr.h> @@ -8,8 +9,8 @@ int sarealpath_tmp (stralloc *sa, char const *path, stralloc *tmp) { - unsigned int tmpbase = tmp->len ; - unsigned int base = sa->len ; + size_t tmpbase = tmp->len ; + size_t base = sa->len ; unsigned int loop = 48 ; int fdhere ; int wasnull = !sa->s ; diff --git a/src/libstddjb/alloc.c b/src/libstddjb/alloc.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <stdlib.h> #include <skalibs/sysdeps.h> @@ -13,7 +14,7 @@ # define PLM(...) (bprintf(buffer_2, "%s: debug_alloc: ", PROG), bprintf(buffer_2, __VA_ARGS__), buffer_putflush(buffer_2, "\n", 1)) #endif -aligned_char *alloc (unsigned int n) +aligned_char *alloc (size_t n) { register aligned_char *p = n ? (aligned_char *)malloc(n) : (aligned_char *)alloc_0 ; #ifdef DEBUG_ALLOC @@ -37,7 +38,7 @@ void alloc_free (void *p) errno = e ; } -int alloc_realloc (aligned_char **x, unsigned int n) +int alloc_realloc (aligned_char **x, size_t n) { aligned_char *y = n ? (aligned_char *)realloc(*x, n) : (free(*x), alloc_0) ; #ifdef DEBUG_ALLOC diff --git a/src/libstddjb/allread.c b/src/libstddjb/allread.c @@ -1,8 +1,9 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/allreadwrite.h> -unsigned int allread (int fd, char *buf, unsigned int len) +size_t allread (int fd, char *buf, size_t len) { - return allreadwrite(&fd_read, fd, buf, len) ; + return allreadwrite(&fd_readv, fd, buf, len) ; } diff --git a/src/libstddjb/allreadv.c b/src/libstddjb/allreadv.c @@ -1,9 +1,10 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/allreadwrite.h> -#include <skalibs/siovec.h> -unsigned int allreadv (int fd, siovec_t const *v, unsigned int vlen) +size_t allreadv (int fd, struct iovec const *v, unsigned int vlen) { - return allreadwritev(&fd_readsv, fd, v, vlen) ; + return allreadwritev(&fd_readv, fd, v, vlen) ; } diff --git a/src/libstddjb/allreadwrite.c b/src/libstddjb/allreadwrite.c @@ -1,14 +1,16 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> +#include <skalibs/functypes.h> #include <skalibs/allreadwrite.h> -unsigned int allreadwrite (iofunc_t_ref op, int fd, register char *buf, register unsigned int len) +size_t allreadwrite (iofunc_t_ref op, int fd, char *buf, size_t len) { - register unsigned int written = 0 ; + size_t written = 0 ; while (len) { - register int w = (*op)(fd, buf, len) ; + register ssize_t w = (*op)(fd, buf, len) ; if (w <= 0) { if (!w) errno = 0 ; diff --git a/src/libstddjb/allreadwritev.c b/src/libstddjb/allreadwritev.c @@ -1,18 +1,20 @@ /* ISC license. */ -#include <errno.h> +#include <sys/types.h> +#include <sys/uio.h> +#include <skalibs/functypes.h> #include <skalibs/allreadwrite.h> #include <skalibs/siovec.h> -unsigned int allreadwritev (iovfunc_t_ref op, int fd, siovec_t const *v, unsigned int vlen) +size_t allreadwritev (iovfunc_t_ref op, int fd, struct iovec const *v, unsigned int vlen) { - register unsigned int written = 0 ; - siovec_t vv[vlen] ; - for (; written < vlen ; written++) vv[written] = v[written] ; - written = 0 ; + size_t written = 0 ; + struct iovec vv[vlen] ; + unsigned int i = 0 ; + for (; i < vlen ; i++) vv[i] = v[i] ; while (siovec_len(vv, vlen)) { - register int w = (*op)(fd, vv, vlen) ; + register ssize_t w = (*op)(fd, vv, vlen) ; if (w <= 0) break ; w = siovec_seek(vv, vlen, w) ; written += w ; diff --git a/src/libstddjb/allwrite.c b/src/libstddjb/allwrite.c @@ -2,7 +2,7 @@ #include <skalibs/allreadwrite.h> -unsigned int allwrite (int fd, char const *buf, unsigned int len) +size_t allwrite (int fd, char const *buf, size_t len) { return allreadwrite((iofunc_t_ref)&fd_write, fd, (char *)buf, len) ; } diff --git a/src/libstddjb/allwritev.c b/src/libstddjb/allwritev.c @@ -1,9 +1,10 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/allreadwrite.h> -#include <skalibs/siovec.h> -unsigned int allwritev (int fd, siovec_t const *v, unsigned int vlen) +size_t allwritev (int fd, struct iovec const *v, unsigned int vlen) { - return allreadwritev(&fd_writesv, fd, v, vlen) ; + return allreadwritev(&fd_writev, fd, v, vlen) ; } diff --git a/src/libstddjb/bitarray_and.c b/src/libstddjb/bitarray_and.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bitarray.h> -void bitarray_and (unsigned char *c, unsigned char const *a, unsigned char const *b, unsigned int n) +void bitarray_and (unsigned char *c, unsigned char const *a, unsigned char const *b, size_t n) { - unsigned int len = bitarray_div8(n) ; - register unsigned int i = 0 ; + size_t len = bitarray_div8(n) ; + register size_t i = 0 ; for (; i < len ; i++) c[i] = a[i] & b[i] ; } diff --git a/src/libstddjb/bitarray_clearsetn.c b/src/libstddjb/bitarray_clearsetn.c @@ -1,8 +1,9 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bitarray.h> -void bitarray_clearsetn (register unsigned char *s, register unsigned int a, register unsigned int b, register int h) +void bitarray_clearsetn (register unsigned char *s, register size_t a, register size_t b, register int h) { if (!b) return ; b += a ; @@ -14,7 +15,7 @@ void bitarray_clearsetn (register unsigned char *s, register unsigned int a, reg else { register unsigned char mask = ~((1 << (a & 7)) - 1) ; - register unsigned int i = (a>>3) + 1 ; + register 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 @@ -1,5 +1,7 @@ /* ISC license. */ +#include <sys/types.h> +#include <skalibs/uint64.h> #include <skalibs/bitarray.h> #define B0(n) n, n+1, n+1, n+2 @@ -7,12 +9,12 @@ #define B2(n) B1(n), B1(n+1), B1(n+1), B1(n+2) #define B3(n) B2(n), B2(n+1), B2(n+1), B2(n+2) -unsigned int bitarray_countones (unsigned char const *c, unsigned int n) +uint64_t bitarray_countones (unsigned char const *c, size_t n) { static unsigned char const table[256] = { B3(0) } ; - unsigned int len = bitarray_div8(n) ; - unsigned int total = 0 ; - register unsigned int i = 0 ; + size_t len = bitarray_div8(n) ; + uint64_t total = 0 ; + register 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 @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bitarray.h> -unsigned int bitarray_firstclear (register unsigned char const *s, unsigned int max) +size_t bitarray_firstclear (register unsigned char const *s, size_t max) { - unsigned int n = bitarray_div8(max) ; - register unsigned int i = 0 ; + size_t n = bitarray_div8(max) ; + register 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_firstclear_skip.c b/src/libstddjb/bitarray_firstclear_skip.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bitarray.h> -unsigned int bitarray_firstclear_skip (register unsigned char const *s, unsigned int max, unsigned int skip) +size_t bitarray_firstclear_skip (register unsigned char const *s, size_t max, size_t skip) { - register unsigned int i = bitarray_div8(skip) ; - register unsigned int j = i << 3 > max ? max : i << 3 ; + register size_t i = bitarray_div8(skip) ; + register size_t j = i << 3 > max ? max : i << 3 ; if (i && s[i-1] != 0xffU) { while ((skip < j) && bitarray_peek(s, skip)) skip++ ; diff --git a/src/libstddjb/bitarray_firstset.c b/src/libstddjb/bitarray_firstset.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bitarray.h> -unsigned int bitarray_firstset (register unsigned char const *s, unsigned int max) +size_t bitarray_firstset (register unsigned char const *s, size_t max) { - unsigned int n = bitarray_div8(max) ; - register unsigned int i = 0 ; + size_t n = bitarray_div8(max) ; + register 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_firstset_skip.c b/src/libstddjb/bitarray_firstset_skip.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bitarray.h> -unsigned int bitarray_firstset_skip (register unsigned char const *s, unsigned int max, unsigned int skip) +size_t bitarray_firstset_skip (register unsigned char const *s, size_t max, size_t skip) { - register unsigned int i = bitarray_div8(skip) ; - register unsigned int j = i << 3 > max ? max : i << 3 ; + register size_t i = bitarray_div8(skip) ; + register size_t j = i << 3 > max ? max : i << 3 ; if (i && s[i-1]) { while ((skip < j) && !bitarray_peek(s, skip)) skip++ ; diff --git a/src/libstddjb/bitarray_not.c b/src/libstddjb/bitarray_not.c @@ -1,8 +1,9 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bitarray.h> -void bitarray_not (register unsigned char *s, register unsigned int a, register unsigned int b) +void bitarray_not (register unsigned char *s, register size_t a, register size_t b) { if (!b) return ; b += a ; @@ -10,7 +11,7 @@ void bitarray_not (register unsigned char *s, register unsigned int a, register s[a>>3] ^= ((1 << (a & 7)) - 1) ^ ((a << (b & 7)) - 1) ; else { - register unsigned int i = (a>>3) + 1 ; + register 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 @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bitarray.h> -void bitarray_or (unsigned char *c, unsigned char const *a, unsigned char const *b, unsigned int n) +void bitarray_or (unsigned char *c, unsigned char const *a, unsigned char const *b, size_t n) { - unsigned int len = bitarray_div8(n) ; - register unsigned int i = 0 ; + size_t len = bitarray_div8(n) ; + register size_t i = 0 ; for (; i < len ; i++) c[i] = a[i] | b[i] ; } diff --git a/src/libstddjb/bitarray_testandpoke.c b/src/libstddjb/bitarray_testandpoke.c @@ -1,8 +1,9 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bitarray.h> -int bitarray_testandpoke (register unsigned char *s, register unsigned int n, register int h) +int bitarray_testandpoke (register unsigned char *s, register size_t n, register int h) { register unsigned char mask = 1 << (n & 7) ; register unsigned char c = s[n>>3] ; diff --git a/src/libstddjb/bitarray_xor.c b/src/libstddjb/bitarray_xor.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bitarray.h> -void bitarray_xor (unsigned char *c, unsigned char const *a, unsigned char const *b, unsigned int n) +void bitarray_xor (unsigned char *c, unsigned char const *a, unsigned char const *b, size_t n) { - unsigned int len = bitarray_div8(n) ; - register unsigned int i = 0 ; + size_t len = bitarray_div8(n) ; + register size_t i = 0 ; for (; i < len ; i++) c[i] = a[i] ^ b[i] ; } diff --git a/src/libstddjb/bufalloc_clean.c b/src/libstddjb/bufalloc_clean.c @@ -1,13 +1,13 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/bufalloc.h> void bufalloc_clean (register bufalloc *ba) { if (ba->p) { - byte_copy(ba->x.s, ba->x.len - ba->p, ba->x.s + ba->p) ; + memmove(ba->x.s, ba->x.s + ba->p, ba->x.len - ba->p) ; ba->x.len -= ba->p ; ba->p = 0 ; } diff --git a/src/libstddjb/bufalloc_flush.c b/src/libstddjb/bufalloc_flush.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <skalibs/functypes.h> #include <skalibs/allreadwrite.h> #include <skalibs/bufalloc.h> diff --git a/src/libstddjb/bufalloc_getlen.c b/src/libstddjb/bufalloc_getlen.c @@ -1,8 +1,9 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bufalloc.h> -unsigned int bufalloc_getlen (bufalloc const *ba) +size_t bufalloc_getlen (bufalloc const *ba) { return bufalloc_len(ba) ; } diff --git a/src/libstddjb/bufalloc_init.c b/src/libstddjb/bufalloc_init.c @@ -1,9 +1,10 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/stralloc.h> #include <skalibs/bufalloc.h> -void bufalloc_init (bufalloc *ba, int (*op)(int, char const *, unsigned int), int fd) +void bufalloc_init (bufalloc *ba, int (*op)(int, char const *, size_t), int fd) { ba->x = stralloc_zero ; ba->op = op ; diff --git a/src/libstddjb/buffer_0.c b/src/libstddjb/buffer_0.c @@ -6,4 +6,4 @@ #include <skalibs/buffer.h> static char buf[BUFFER_INSIZE] ; -buffer buffer_0_ = BUFFER_INIT(&fd_readsv, 0, buf, BUFFER_INSIZE) ; +buffer buffer_0_ = BUFFER_INIT(&fd_readv, 0, buf, BUFFER_INSIZE) ; diff --git a/src/libstddjb/buffer_0small.c b/src/libstddjb/buffer_0small.c @@ -6,4 +6,4 @@ #include <skalibs/buffer.h> static char buf[BUFFER_INSIZE_SMALL] ; -buffer buffer_0small_ = BUFFER_INIT(&fd_readsv, 0, buf, BUFFER_INSIZE_SMALL) ; +buffer buffer_0small_ = BUFFER_INIT(&fd_readv, 0, buf, BUFFER_INSIZE_SMALL) ; diff --git a/src/libstddjb/buffer_1.c b/src/libstddjb/buffer_1.c @@ -6,4 +6,4 @@ #include <skalibs/buffer.h> static char buf[BUFFER_OUTSIZE] ; -buffer buffer_1_ = BUFFER_INIT(&fd_writesv, 1, buf, BUFFER_OUTSIZE) ; +buffer buffer_1_ = BUFFER_INIT(&fd_writev, 1, buf, BUFFER_OUTSIZE) ; diff --git a/src/libstddjb/buffer_1small.c b/src/libstddjb/buffer_1small.c @@ -6,4 +6,4 @@ #include <skalibs/buffer.h> static char buf[BUFFER_OUTSIZE_SMALL] ; -buffer buffer_1small_ = BUFFER_INIT(&fd_writesv, 1, buf, BUFFER_OUTSIZE_SMALL) ; +buffer buffer_1small_ = BUFFER_INIT(&fd_writev, 1, buf, BUFFER_OUTSIZE_SMALL) ; diff --git a/src/libstddjb/buffer_2.c b/src/libstddjb/buffer_2.c @@ -6,4 +6,4 @@ #include <skalibs/buffer.h> static char buf[BUFFER_ERRSIZE] ; -buffer buffer_2_ = BUFFER_INIT(&fd_writesv, 2, buf, BUFFER_ERRSIZE) ; +buffer buffer_2_ = BUFFER_INIT(&fd_writev, 2, buf, BUFFER_ERRSIZE) ; diff --git a/src/libstddjb/buffer_flush1read.c b/src/libstddjb/buffer_flush1read.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> -#include <skalibs/siovec.h> -int buffer_flush1read (int fd, siovec_t const *v, unsigned int n) +ssize_t buffer_flush1read (int fd, struct iovec const *v, unsigned int n) { if (!buffer_flush(buffer_1)) return -1 ; - return fd_readsv(fd, v, n) ; + return fd_readv(fd, v, n) ; } diff --git a/src/libstddjb/byte_chr.c b/src/libstddjb/byte_chr.c @@ -1,26 +1,11 @@ /* ISC license. */ -#include <skalibs/config.h> -#include <skalibs/bytestr.h> - -#ifndef SKALIBS_FLAG_REPLACE_LIBC - +#include <sys/types.h> #include <string.h> +#include <skalibs/bytestr.h> -unsigned int byte_chr (char const *s, unsigned int n, int c) +size_t byte_chr (char const *s, size_t n, int c) { register void *p = memchr(s, c, n) ; - return p ? (unsigned int)((char *)p - s) : n ; + return p ? (char *)p - s : n ; } - -#else - -unsigned int byte_chr (char const *s, unsigned int n, int c) -{ - register unsigned int i = 0 ; - register char ch = c ; - for (; i < n && *s++ != ch ; i++) ; - return i ; -} - -#endif diff --git a/src/libstddjb/byte_count.c b/src/libstddjb/byte_count.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bytestr.h> -unsigned int byte_count (register char const *s, register unsigned int len, register char b) +size_t byte_count (char const *s, size_t len, char b) { - register unsigned int n = 0 ; + size_t n = 0 ; while (len--) if (*s++ == b) n++ ; return n ; } diff --git a/src/libstddjb/byte_in.c b/src/libstddjb/byte_in.c @@ -1,8 +1,9 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bytestr.h> -unsigned int byte_in (char const *s, register unsigned int n, register char const *sep, register unsigned int len) +size_t byte_in (char const *s, size_t n, char const *sep, size_t len) { register char const *t = s ; while (n--) diff --git a/src/libstddjb/byte_rchr.c b/src/libstddjb/byte_rchr.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bytestr.h> -unsigned int byte_rchr (register char const *s, unsigned int n, int c) +size_t byte_rchr (char const *s, size_t n, int c) { - register unsigned int i = n ; - register char ch = c ; + size_t i = n ; + char ch = c ; s += n ; while (i--) if (*--s == ch) return i ; return n ; diff --git a/src/libstddjb/case_lowerb.c b/src/libstddjb/case_lowerb.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bytestr.h> -void case_lowerb (register char *s, unsigned int len) +void case_lowerb (register char *s, size_t len) { - register unsigned char const d = 'a' - 'A' ; + unsigned char const d = 'a' - 'A' ; while (len--) { if (('A' <= *s) && (*s <= 'Z')) *s += d ; diff --git a/src/libstddjb/case_startb.c b/src/libstddjb/case_startb.c @@ -1,9 +1,11 @@ /* ISC license. */ +#include <sys/types.h> +#include <string.h> #include <skalibs/bytestr.h> -int case_startb (register char const *s, unsigned int slen, register char const *t) +int case_startb (register char const *s, size_t slen, register char const *t) { - register unsigned int tlen = str_len(t) ; + size_t tlen = strlen(t) ; return slen < tlen ? 0 : !case_diffb(s, tlen, t) ; } diff --git a/src/libstddjb/case_str.c b/src/libstddjb/case_str.c @@ -1,32 +1,33 @@ /* ISC license. */ -#include <skalibs/config.h> #include <skalibs/sysdeps.h> -#if defined(SKALIBS_HASSTRCASESTR) && !defined(SKALIBS_FLAG_REPLACE_LIBC) +#ifdef SKALIBS_HASSTRCASESTR #include <skalibs/nonposix.h> #include <string.h> #include <skalibs/bytestr.h> -unsigned int case_str (char const *haystack, char const *needle) +size_t case_str (char const *haystack, char const *needle) { register char *p = strcasestr(haystack, needle) ; - return p ? p - haystack : str_len(haystack) ; + return p ? p - haystack : strlen(haystack) ; } #else +#include <sys/types.h> +#include <string.h> #include <skalibs/bytestr.h> -unsigned int case_str (char const *haystack, char const *needle) +size_t case_str (char const *haystack, char const *needle) { - unsigned int nlen = str_len(needle) ; - register char const *p = haystack ; + size_t nlen = strlen(needle) ; + char const *p = haystack ; if (!nlen) return 0 ; for (; *p ; p++) if (!case_diffb(p, nlen, needle)) return p - haystack ; - return str_len(haystack) ; + return strlen(haystack) ; } #endif diff --git a/src/libstddjb/case_upperb.c b/src/libstddjb/case_upperb.c @@ -2,9 +2,9 @@ #include <skalibs/bytestr.h> -void case_upperb (register char *s, unsigned int len) +void case_upperb (char *s, size_t len) { - register unsigned char const d = 'a' - 'A' ; + unsigned char const d = 'a' - 'A' ; while (len--) { if (('a' <= *s) && (*s <= 'z')) *s -= d ; diff --git a/src/libstddjb/cdb_make.c b/src/libstddjb/cdb_make.c @@ -15,7 +15,7 @@ int cdb_make_start (struct cdb_make *c, int fd) { c->hplist = genalloc_zero ; c->pos = 2048 ; - buffer_init(&c->b, &fd_writesv, fd, c->buf, BUFFER_OUTSIZE) ; + buffer_init(&c->b, &fd_writev, fd, c->buf, BUFFER_OUTSIZE) ; return (int)lseek(fd, c->pos, SEEK_SET) ; } diff --git a/src/libstddjb/fd_cat.c b/src/libstddjb/fd_cat.c @@ -1,16 +1,17 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/iobuffer.h> #include <skalibs/djbunix.h> int fd_cat (int from, int to) { iobuffer b ; - unsigned int n = 0 ; + size_t n = 0 ; if (!iobuffer_init(&b, from, to)) return -1 ; for (;;) { - register int r = iobuffer_fill(&b) ; + register ssize_t r = iobuffer_fill(&b) ; if (r < 0) goto err ; else if (!r) break ; if (!iobuffer_flush(&b)) goto err ; diff --git a/src/libstddjb/fd_catn.c b/src/libstddjb/fd_catn.c @@ -1,20 +1,21 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/allreadwrite.h> #include <skalibs/iobuffer.h> #include <skalibs/djbunix.h> -unsigned int fd_catn (int from, int to, unsigned int n) +size_t fd_catn (int from, int to, size_t n) { - unsigned int w = 0 ; + size_t w = 0 ; if (n >= IOBUFFER_SIZE) { iobuffer b ; if (!iobuffer_init(&b, from, to)) return 0 ; while (n >= IOBUFFER_SIZE) { - register int r = iobuffer_fill(&b) ; + register ssize_t r = iobuffer_fill(&b) ; if (r <= 0) { iobuffer_finish(&b) ; @@ -33,8 +34,8 @@ unsigned int fd_catn (int from, int to, unsigned int n) { char buf[n] ; - unsigned int r = allread(from, buf, n) ; - unsigned int v = 0 ; + size_t r = allread(from, buf, n) ; + size_t v = 0 ; if (r) v = allwrite(to, buf, r) ; w += v ; } diff --git a/src/libstddjb/fd_chown.c b/src/libstddjb/fd_chown.c @@ -5,11 +5,11 @@ #include <errno.h> #include <skalibs/djbunix.h> -int fd_chown (int fd, unsigned int uid, unsigned int gid) +int fd_chown (int fd, uid_t uid, gid_t gid) { register int r ; do - r = fchown(fd, (uid_t)uid, (gid_t)gid) ; + r = fchown(fd, uid, gid) ; while ((r == -1) && (errno == EINTR)) ; return r ; } diff --git a/src/libstddjb/fd_copy2.c b/src/libstddjb/fd_copy2.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include <unistd.h> #include <errno.h> #include <skalibs/djbunix.h> diff --git a/src/libstddjb/fd_read.c b/src/libstddjb/fd_read.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include <sys/types.h> #include <unistd.h> #include <errno.h> #include <skalibs/allreadwrite.h> -int fd_read (int fd, char *buf, unsigned int len) +ssize_t fd_read (int fd, char *buf, size_t len) { - register int r ; + register ssize_t r ; do r = read(fd, buf, len) ; while ((r == -1) && (errno == EINTR)) ; return r ; diff --git a/src/libstddjb/fd_readsv.c b/src/libstddjb/fd_readsv.c @@ -1,13 +0,0 @@ -/* ISC license. */ - -#include <sys/types.h> -#include <sys/uio.h> -#include <skalibs/allreadwrite.h> -#include <skalibs/siovec.h> - -int fd_readsv (int fd, siovec_t const *v, unsigned int vlen) -{ - struct iovec vv[vlen] ; - iovec_from_siovec(vv, v, vlen) ; - return fd_readv(fd, vv, vlen) ; -} diff --git a/src/libstddjb/fd_readv.c b/src/libstddjb/fd_readv.c @@ -5,9 +5,9 @@ #include <errno.h> #include <skalibs/allreadwrite.h> -int fd_readv (int fd, struct iovec const *v, unsigned int vlen) +ssize_t fd_readv (int fd, struct iovec const *v, unsigned int vlen) { - register int r ; + ssize_t r ; do r = readv(fd, v, vlen) ; while ((r == -1) && (errno == EINTR)) ; return r ; diff --git a/src/libstddjb/fd_recv.c b/src/libstddjb/fd_recv.c @@ -5,9 +5,9 @@ #include <errno.h> #include <skalibs/allreadwrite.h> -int fd_recv (int fd, char *buf, unsigned int len, unsigned int flags) +ssize_t fd_recv (int fd, char *buf, size_t len, unsigned int flags) { - register int r ; + register ssize_t r ; do r = recv(fd, buf, len, (int)flags) ; while ((r == -1) && (errno == EINTR)) ; return r ; diff --git a/src/libstddjb/fd_send.c b/src/libstddjb/fd_send.c @@ -5,9 +5,9 @@ #include <errno.h> #include <skalibs/allreadwrite.h> -int fd_send (int fd, char const *buf, unsigned int len, unsigned int flags) +ssize_t fd_send (int fd, char const *buf, size_t len, unsigned int flags) { - register int r ; + register ssize_t r ; do r = send(fd, buf, len, (int)flags) ; while ((r == -1) && (errno == EINTR)) ; return r ; diff --git a/src/libstddjb/fd_write.c b/src/libstddjb/fd_write.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include <sys/types.h> #include <unistd.h> #include <errno.h> #include <skalibs/allreadwrite.h> -int fd_write (int fd, char const *buf, unsigned int len) +ssize_t fd_write (int fd, char const *buf, size_t len) { - register int r ; + register ssize_t r ; do r = write(fd, buf, len) ; while ((r == -1) && (errno == EINTR)) ; return r ; diff --git a/src/libstddjb/fd_writesv.c b/src/libstddjb/fd_writesv.c @@ -1,13 +0,0 @@ -/* ISC license. */ - -#include <sys/types.h> -#include <sys/uio.h> -#include <skalibs/allreadwrite.h> -#include <skalibs/siovec.h> - -int fd_writesv (int fd, siovec_t const *v, unsigned int vlen) -{ - struct iovec vv[vlen] ; - iovec_from_siovec(vv, v, vlen) ; - return fd_writev(fd, vv, vlen) ; -} diff --git a/src/libstddjb/fd_writev.c b/src/libstddjb/fd_writev.c @@ -5,9 +5,9 @@ #include <errno.h> #include <skalibs/allreadwrite.h> -int fd_writev (int fd, struct iovec const *v, unsigned int vlen) +ssize_t fd_writev (int fd, struct iovec const *v, unsigned int vlen) { - register int r ; + register ssize_t r ; do r = writev(fd, v, vlen) ; while ((r == -1) && (errno == EINTR)) ; return r ; diff --git a/src/libstddjb/genalloc_deepfree.c b/src/libstddjb/genalloc_deepfree.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> -void genalloc_deepfree_size (genalloc *g, freefunc_t_ref f, unsigned int size) +void genalloc_deepfree_size (genalloc *g, freefunc_t_ref f, size_t size) { - unsigned int len = g->len / size ; - register unsigned int i = 0 ; + size_t len = g->len / size ; + register size_t i = 0 ; for (; i < len ; i++) (*f)(g->s + i * size) ; stralloc_free(g) ; } diff --git a/src/libstddjb/genwrite_put_bufalloc.c b/src/libstddjb/genwrite_put_bufalloc.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bufalloc.h> #include <skalibs/genwrite.h> -int genwrite_put_bufalloc (void *target, char const *s, unsigned int len) +ssize_t genwrite_put_bufalloc (void *target, char const *s, size_t len) { register bufalloc *ba = target ; - return bufalloc_put(ba, s, len) ? (int)len : -1 ; + return bufalloc_put(ba, s, len) ? (ssize_t)len : -1 ; } diff --git a/src/libstddjb/genwrite_put_buffer.c b/src/libstddjb/genwrite_put_buffer.c @@ -1,9 +1,10 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/buffer.h> #include <skalibs/genwrite.h> -int genwrite_put_buffer (void *target, char const *s, unsigned int len) +ssize_t genwrite_put_buffer (void *target, char const *s, size_t len) { register buffer *b = target ; return buffer_put(b, s, len) ; diff --git a/src/libstddjb/genwrite_put_stralloc.c b/src/libstddjb/genwrite_put_stralloc.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/stralloc.h> #include <skalibs/genwrite.h> -int genwrite_put_stralloc (void *target, char const *s, unsigned int len) +ssize_t genwrite_put_stralloc (void *target, char const *s, size_t len) { register stralloc *sa = target ; - return stralloc_catb(sa, s, len) ? (int)len : -1 ; + return stralloc_catb(sa, s, len) ? (ssize_t)len : -1 ; } diff --git a/src/libstddjb/iobufferu_init.c b/src/libstddjb/iobufferu_init.c @@ -10,7 +10,7 @@ int iobufferu_init (iobufferu *b, int fdin, int fdout) register char *x = alloc(IOBUFFERU_SIZE) ; if (!x) return 0 ; b->buf = x ; - buffer_init(&b->b[0], &fd_readsv, fdin, x, IOBUFFERU_SIZE) ; - buffer_init(&b->b[1], &fd_writesv, fdout, x, IOBUFFERU_SIZE) ; + buffer_init(&b->b[0], &fd_readv, fdin, x, IOBUFFERU_SIZE) ; + buffer_init(&b->b[1], &fd_writev, fdout, x, IOBUFFERU_SIZE) ; return 1 ; } diff --git a/src/libstddjb/sanitize_read.c b/src/libstddjb/sanitize_read.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/allreadwrite.h> #include <skalibs/error.h> -int sanitize_read (int r) +ssize_t sanitize_read (ssize_t r) { return r == -1 ? error_isagain(errno) ? (errno = 0, 0) : -1 : !r ? (errno = EPIPE, -1) : r ; diff --git a/src/libstddjb/str_chr.c b/src/libstddjb/str_chr.c @@ -1,33 +1,11 @@ /* ISC license. */ -#include <skalibs/config.h> -#include <skalibs/bytestr.h> - -#ifndef SKALIBS_FLAG_REPLACE_LIBC - +#include <sys/types.h> #include <string.h> +#include <skalibs/bytestr.h> -unsigned int str_chr (register char const *s, int c) -{ - register char *p = strchr(s, c) ; - return p ? (unsigned int)(p - s) : strlen(s) ; -} - -#else - -unsigned int str_chr (register char const *s, int c) +size_t str_chr (char const *s, int c) { - register char ch = c ; - register char const *t = s ; - - for (;;) - { - if (!*t) break; if (*t == ch) break; ++t; - if (!*t) break; if (*t == ch) break; ++t; - if (!*t) break; if (*t == ch) break; ++t; - if (!*t) break; if (*t == ch) break; ++t; - } - return t - s ; + char *p = strchr(s, c) ; + return p ? p - s : strlen(s) ; } - -#endif diff --git a/src/libstddjb/str_rchr.c b/src/libstddjb/str_rchr.c @@ -1,28 +1,12 @@ /* ISC license. */ -#include <skalibs/config.h> -#include <skalibs/bytestr.h> - -#ifndef SKALIBS_FLAG_REPLACE_LIBC - +#include <sys/types.h> #include <string.h> +#include <skalibs/bytestr.h> -unsigned int str_rchr (register char const *s, int c) +size_t str_rchr (register char const *s, int c) { register char *p = strrchr(s, c) ; - return p ? (unsigned int)(p - s) : (unsigned int)strlen(s) ; -} - -#else - -unsigned int str_rchr (register char const *s, int c) -{ - register char ch = c ; - register char const *t = s ; - register char const *u = 0 ; - for ( ; *t ; t++) if (*t == ch) u = t ; - if (!u) u = t ; - return u - s ; + return p ? p - s : strlen(s) ; } -#endif diff --git a/src/libstddjb/str_strn.c b/src/libstddjb/str_strn.c @@ -1,36 +1,16 @@ /* ISC license. */ -#include <skalibs/config.h> -#include <skalibs/bytestr.h> - -#ifdef SKALIBS_FLAG_REPLACE_LIBC - -/* Very naive implementation, but it's small. */ - -unsigned int str_strn (char const *haystack, unsigned int hlen, char const *needle, unsigned int nlen) -{ - register unsigned int i = 0 ; - if (!nlen) return 0 ; - if (hlen < nlen) return hlen ; - hlen -= nlen ; - for (; i <= hlen ; i++) - if (!byte_diff(haystack+i, nlen, needle)) return i ; - return hlen+nlen ; -} - -#else - +#include <sys/types.h> #include <string.h> +#include <skalibs/bytestr.h> -unsigned int str_strn (char const *haystack, unsigned int hlen, char const *needle, unsigned int nlen) +size_t str_strn (char const *haystack, size_t hlen, char const *needle, size_t nlen) { char haystack2[hlen+1] ; char needle2[nlen+1] ; - register char *p ; + char *p ; byte_copy(haystack2, hlen, haystack) ; haystack2[hlen] = 0 ; byte_copy(needle2, nlen, needle) ; needle2[nlen] = 0 ; p = strstr(haystack2, needle2) ; return p ? p - haystack2 : hlen ; } - -#endif diff --git a/src/libstddjb/stralloc_catb.c b/src/libstddjb/stralloc_catb.c @@ -1,12 +1,13 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <sys/types.h> +#include <string.h> #include <skalibs/stralloc.h> -int stralloc_catb (stralloc *sa, char const *s, unsigned int n) +int stralloc_catb (stralloc *sa, char const *s, size_t n) { if (!stralloc_readyplus(sa, n)) return 0 ; - byte_copy(sa->s + sa->len, n, s) ; + memmove(sa->s + sa->len, s, n) ; sa->len += n ; return 1 ; } diff --git a/src/libstddjb/stralloc_catv.c b/src/libstddjb/stralloc_catv.c @@ -1,21 +1,22 @@ /* ISC license. */ -#include <skalibs/bytestr.h> -#include <skalibs/siovec.h> +#include <sys/types.h> +#include <string.h> +#include <sys/uio.h> #include <skalibs/stralloc.h> -int stralloc_catv (stralloc *sa, siovec_t const *v, unsigned int n) +int stralloc_catv (stralloc *sa, struct iovec const *v, unsigned int n) { register unsigned int i = 0 ; { - unsigned int total = 0 ; - for (; i < n ; i++) total += v[i].len ; + size_t total = 0 ; + for (; i < n ; i++) total += v[i].iov_len ; if (!stralloc_readyplus(sa, total)) return 0 ; } for (i = 0 ; i < n ; i++) { - byte_copy(sa->s + sa->len, v[i].len, v[i].s) ; - sa->len += v[i].len ; + memmove(sa->s + sa->len, v[i].iov_base, v[i].iov_len) ; + sa->len += v[i].iov_len ; } return 1 ; } diff --git a/src/libstddjb/stralloc_copyb.c b/src/libstddjb/stralloc_copyb.c @@ -1,12 +1,13 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <sys/types.h> +#include <string.h> #include <skalibs/stralloc.h> -int stralloc_copyb (stralloc *sa, char const *s, unsigned int n) +int stralloc_copyb (stralloc *sa, char const *s, size_t n) { if (!stralloc_ready(sa, n)) return 0 ; - byte_copy(sa->s, n, s) ; + memmove(sa->s, s, n) ; sa->len = n ; return 1 ; } diff --git a/src/libstddjb/stralloc_insertb.c b/src/libstddjb/stralloc_insertb.c @@ -1,15 +1,15 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> -#include <skalibs/bytestr.h> #include <skalibs/stralloc.h> -int stralloc_insertb (stralloc *sa, unsigned int offset, char const *s, unsigned int n) +int stralloc_insertb (stralloc *sa, size_t offset, char const *s, size_t n) { if (offset > sa->len) return (errno = EINVAL, 0) ; if (!stralloc_readyplus(sa, n)) return 0 ; - byte_copyr(sa->s + offset + n, sa->len - offset, sa->s + offset) ; + memmove(sa->s + offset + n, sa->s + offset, sa->len - offset) ; sa->len += n ; - byte_copyr(sa->s + offset, n, s) ; + memmove(sa->s + offset, s, n) ; return 1 ; } diff --git a/src/libstddjb/stralloc_ready_tuned.c b/src/libstddjb/stralloc_ready_tuned.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/alloc.h> #include <skalibs/stralloc.h> -int stralloc_ready_tuned (stralloc *sa, unsigned int n, unsigned int base, unsigned int a, unsigned int b) +int stralloc_ready_tuned (stralloc *sa, size_t n, size_t base, size_t a, size_t b) { - register unsigned int t ; + register size_t t ; if (!b) return (errno = EINVAL, 0) ; t = n + base + a * n / b ; if (t < n) return (errno = ERANGE, 0) ; diff --git a/src/libstddjb/stralloc_reverse.c b/src/libstddjb/stralloc_reverse.c @@ -1,11 +1,11 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <sys/types.h> #include <skalibs/stralloc.h> void stralloc_reverse (stralloc *sa) { - register unsigned int i = 0 ; + register size_t i = 0 ; for (; i < sa->len >> 1 ; i++) { char tmp = sa->s[i] ; diff --git a/src/libstddjb/stralloc_reverse_blocks.c b/src/libstddjb/stralloc_reverse_blocks.c @@ -1,17 +1,18 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <sys/types.h> +#include <string.h> #include <skalibs/stralloc.h> -void stralloc_reverse_blocks (stralloc *sa, unsigned int size) +void stralloc_reverse_blocks (stralloc *sa, size_t size) { - register unsigned int n = sa->len / (size << 1) ; - register unsigned int i = 0 ; + register size_t n = sa->len / (size << 1) ; + register size_t i = 0 ; char tmp[size] ; for (; i < n ; i++) { - byte_copy(tmp, size, sa->s + i * size) ; - byte_copy(sa->s + i * size, size, sa->s + (2*n - 1 - i) * size) ; - byte_copy(sa->s + (2*n - 1 - i) * size, size, tmp) ; + memcpy(tmp, sa->s + i * size, size) ; + memcpy(sa->s + i * size, sa->s + (2*n - 1 - i) * size, size) ; + memcpy(sa->s + (2*n - 1 - i) * size, tmp, size) ; } } diff --git a/src/libstddjb/unsanitize_read.c b/src/libstddjb/unsanitize_read.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/allreadwrite.h> #include <skalibs/error.h> -int unsanitize_read (int r) +ssize_t unsanitize_read (ssize_t r) { return r == -1 ? errno == EPIPE ? (errno = 0, 0) : -1 : !r ? (errno = EWOULDBLOCK, -1) : r ; diff --git a/src/libunixonacid/opengetlnclose.c b/src/libunixonacid/opengetlnclose.c @@ -16,7 +16,7 @@ int opengetlnclose (char const *fn, stralloc *sa, int sep) register int e ; int fd = open_readb(fn) ; if (fd < 0) return -1 ; - buffer_init(&b, &fd_readsv, fd, buf, BUFFER_INSIZE) ; + buffer_init(&b, &fd_readv, fd, buf, BUFFER_INSIZE) ; r = skagetln(&b, sa, sep) ; e = errno ; fd_close(fd) ; diff --git a/src/libunixonacid/opengetlnclose_at.c b/src/libunixonacid/opengetlnclose_at.c @@ -16,7 +16,7 @@ int opengetlnclose_at (int dirfd, char const *fn, stralloc *sa, int sep) register int e ; int fd = open_readatb(dirfd, fn) ; if (fd < 0) return -1 ; - buffer_init(&b, &fd_readsv, fd, buf, BUFFER_INSIZE) ; + buffer_init(&b, &fd_readv, fd, buf, BUFFER_INSIZE) ; r = skagetln(&b, sa, sep) ; e = errno ; fd_close(fd) ; diff --git a/src/sysdeps/tryarc4random_addrandom.c b/src/sysdeps/tryarc4random_addrandom.c @@ -0,0 +1,12 @@ +/* ISC license. */ + +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE + +#include <stdlib.h> + +int main (void) +{ + arc4random_addrandom("", 1) ; + return 0 ; +}