skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

commit e450f6efc39e55e32264d2daded6c757af0f7527
parent 04905aaeffba2bc77866a4056dc3f2020a86bb26
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Mon, 13 Mar 2017 10:31:14 +0000

 Cleanups - mostly removing superfluous includes in headers

Diffstat:
Mconfigure | 2++
Mdoc/libstddjb/bitarray.html | 6++++++
Mpackage/deps.mak | 8++++----
Msrc/include/skalibs/allreadwrite.h | 2--
Msrc/include/skalibs/bitarray.h | 5++---
Msrc/include/skalibs/buffer.h | 2--
Msrc/include/skalibs/bytestr.h | 12+++++-------
Msrc/include/skalibs/cbuffer.h | 1-
Msrc/include/skalibs/djbunix.h | 2--
Msrc/include/skalibs/genalloc.h | 1-
Msrc/include/skalibs/iopause.h | 1-
Msrc/include/skalibs/netstring.h | 1-
Msrc/include/skalibs/nonposix.h | 2+-
Msrc/include/skalibs/selfpipe.h | 2--
Msrc/include/skalibs/siovec.h | 1-
Msrc/include/skalibs/tai.h | 1-
Msrc/include/skalibs/unix-transactional.h | 4++--
Msrc/include/skalibs/unixmessage.h | 1-
Msrc/libstddjb/bitarray_count.c | 5++---
Msrc/libstddjb/buffer_get.c | 2+-
Msrc/libstddjb/selfpipe_read.c | 4++--
21 files changed, 27 insertions(+), 38 deletions(-)

diff --git a/configure b/configure @@ -382,6 +382,8 @@ tryflag CPPFLAGS_AUTO -Werror=implicit-function-declaration tryflag CPPFLAGS_AUTO -Werror=implicit-int tryflag CPPFLAGS_AUTO -Werror=pointer-sign tryflag CPPFLAGS_AUTO -Werror=pointer-arith +tryflag CPPFLAGS_AUTO -Wno-unused-value +tryflag CPPFLAGS_AUTO -Wno-parentheses tryflag CFLAGS_AUTO -ffunction-sections tryflag CFLAGS_AUTO -fdata-sections diff --git a/doc/libstddjb/bitarray.html b/doc/libstddjb/bitarray.html @@ -142,5 +142,11 @@ ignored: the function cannot return less than <em>skip</em>. It is a programming error if <em>skip</em> &gt; <em>len</em>. </p> +<p> +<code> size_t bitarray_countones (unsigned char const *c, size_t len) </code> <br /> +Returns the number of set bits in <em>s</em>, <em>len</em> being the +total number of bits being tested. +</p> + </body> </html> diff --git a/package/deps.mak b/package/deps.mak @@ -4,15 +4,15 @@ src/include/skalibs/alarm.h: src/include/skalibs/tai.h src/include/skalibs/alloc.h: src/include/skalibs/gccattributes.h -src/include/skalibs/allreadwrite.h: src/include/skalibs/functypes.h src/include/skalibs/siovec.h +src/include/skalibs/allreadwrite.h: src/include/skalibs/functypes.h src/include/skalibs/avlnode.h: src/include/skalibs/functypes.h src/include/skalibs/gccattributes.h 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/uint64.h +src/include/skalibs/bitarray.h: src/include/skalibs/gccattributes.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/cbuffer.h src/include/skalibs/functypes.h src/include/skalibs/gccattributes.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/bytestr.h: src/include/skalibs/config.h src/include/skalibs/gccattributes.h src/include/skalibs/sysdeps.h src/include/skalibs/cbuffer.h: src/include/skalibs/gccattributes.h src/include/skalibs/cdb.h: src/include/skalibs/gccattributes.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 @@ -170,7 +170,7 @@ src/libstddjb/allwritev.o src/libstddjb/allwritev.lo: src/libstddjb/allwritev.c src/libstddjb/baprintf.o src/libstddjb/baprintf.lo: src/libstddjb/baprintf.c src/include/skalibs/bufalloc.h src/include/skalibs/lolstdio.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/include/skalibs/uint64.h +src/libstddjb/bitarray_count.o src/libstddjb/bitarray_count.lo: src/libstddjb/bitarray_count.c src/include/skalibs/bitarray.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 diff --git a/src/include/skalibs/allreadwrite.h b/src/include/skalibs/allreadwrite.h @@ -3,10 +3,8 @@ #ifndef ALLREADWRITE_H #define ALLREADWRITE_H -#include <sys/types.h> #include <sys/uio.h> #include <skalibs/functypes.h> -#include <skalibs/siovec.h> extern ssize_t sanitize_read (ssize_t) ; extern ssize_t unsanitize_read (ssize_t) ; diff --git a/src/include/skalibs/bitarray.h b/src/include/skalibs/bitarray.h @@ -3,9 +3,8 @@ #ifndef BITARRAY_H #define BITARRAY_H -#include <sys/types.h> +#include <string.h> #include <skalibs/gccattributes.h> -#include <skalibs/uint64.h> #define bitarray_div8(n) ((n) ? 1U + (((n) - 1) >> 3) : 0U) @@ -31,7 +30,7 @@ extern size_t bitarray_firstclear_skip (unsigned char const *, size_t, size_t) g 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 uint64_t bitarray_countones (unsigned char const *, size_t) gccattr_pure ; +extern size_t bitarray_countones (unsigned char const *, size_t) gccattr_pure ; extern void bitarray_not (unsigned char *, size_t, size_t) ; extern void bitarray_and (unsigned char *, unsigned char const *, unsigned char const *, size_t) ; diff --git a/src/include/skalibs/buffer.h b/src/include/skalibs/buffer.h @@ -3,9 +3,7 @@ #ifndef BUFFER_H #define BUFFER_H -#include <sys/types.h> #include <sys/uio.h> -#include <string.h> #include <skalibs/gccattributes.h> #include <skalibs/allreadwrite.h> #include <skalibs/cbuffer.h> diff --git a/src/include/skalibs/bytestr.h b/src/include/skalibs/bytestr.h @@ -10,10 +10,8 @@ #define T8(x) ((x) & 0xffU) #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) @@ -36,14 +34,14 @@ 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))) +#define byte_equal(s, n, t) (!memcmp(s, (t), n)) extern size_t byte_count (char const *, size_t, char) gccattr_pure ; -#define str_diffb(a, n, b) str_diffn(a, (b), n) +#define str_diffb(a, n, b) strncmp(a, (b), n) 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)) +#define str_equal(s, t) (!strcmp(s, t)) extern size_t str_strn (char const *, size_t, char const *, size_t) gccattr_pure ; extern void case_lowers (char *) ; @@ -51,8 +49,8 @@ extern void case_lowerb (char *, size_t) ; extern void case_uppers (char *) ; 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_equals(a, b) (!strcasecmp(a, b)) +#define case_equalb(a, n, b) (!strcasecmp(a, (b), n)) #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 ; diff --git a/src/include/skalibs/cbuffer.h b/src/include/skalibs/cbuffer.h @@ -3,7 +3,6 @@ #ifndef CBUFFER_H #define CBUFFER_H -#include <sys/types.h> #include <sys/uio.h> #include <string.h> #include <skalibs/gccattributes.h> diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h @@ -6,8 +6,6 @@ #include <sys/types.h> #include <sys/uio.h> #include <sys/wait.h> -#include <sys/stat.h> -#include <unistd.h> #include <skalibs/gccattributes.h> #include <skalibs/stralloc.h> #include <skalibs/envalloc.h> diff --git a/src/include/skalibs/genalloc.h b/src/include/skalibs/genalloc.h @@ -3,7 +3,6 @@ #ifndef GENALLOC_H #define GENALLOC_H -#include <sys/types.h> #include <skalibs/stralloc.h> #include <skalibs/functypes.h> diff --git a/src/include/skalibs/iopause.h b/src/include/skalibs/iopause.h @@ -3,7 +3,6 @@ #ifndef IOPAUSE_H #define IOPAUSE_H -#include <sys/types.h> #include <poll.h> #include <skalibs/tai.h> diff --git a/src/include/skalibs/netstring.h b/src/include/skalibs/netstring.h @@ -3,7 +3,6 @@ #ifndef NETSTRING_H #define NETSTRING_H -#include <sys/types.h> #include <sys/uio.h> #include <string.h> #include <skalibs/buffer.h> diff --git a/src/include/skalibs/nonposix.h b/src/include/skalibs/nonposix.h @@ -51,7 +51,7 @@ /* old versions of BSD: system headers are not self-contained, - starting with sys/types.h is the usual workaround */ + starting with sys/types.h normally always works. */ #include <sys/types.h> diff --git a/src/include/skalibs/selfpipe.h b/src/include/skalibs/selfpipe.h @@ -1,7 +1,5 @@ /* ISC license. */ -/* MT-unsafe */ - #ifndef SELFPIPE_H #define SELFPIPE_H diff --git a/src/include/skalibs/siovec.h b/src/include/skalibs/siovec.h @@ -3,7 +3,6 @@ #ifndef SIOVEC_H #define SIOVEC_H -#include <sys/types.h> #include <sys/uio.h> #include <skalibs/gccattributes.h> diff --git a/src/include/skalibs/tai.h b/src/include/skalibs/tai.h @@ -3,7 +3,6 @@ #ifndef TAI_H #define TAI_H -#include <sys/types.h> #include <stdint.h> #include <time.h> #include <sys/time.h> diff --git a/src/include/skalibs/unix-transactional.h b/src/include/skalibs/unix-transactional.h @@ -4,8 +4,8 @@ #define UNIX_TRANSACTIONAL_H #include <sys/types.h> -#include <sys/uio.h> #include <sys/stat.h> +#include <sys/uio.h> #include <skalibs/uint64.h> #include <skalibs/stralloc.h> @@ -59,7 +59,7 @@ extern int dd_open_write (dirdescriptor_t *, char const *, unsigned int) ; extern int dd_close (dirdescriptor_t *) ; /* after dd_open_read */ extern void dd_cancel (dirdescriptor_t *) ; /* after dd_open_write */ extern int dd_commit (dirdescriptor_t *) ; /* after dd_open_write */ -extern int dd_commit_devino (dirdescriptor_t *, uint64 *, uint64 *) ; /* after dd_open_write */ +extern int dd_commit_devino (dirdescriptor_t *, dev_t *, ino_t *) ; /* after dd_open_write */ #define dd_openreadnclose(blah, file, s, len) openreadnclose_at((blah)->fd, file, s, len) #define dd_openslurpclose(blah, file, sa) openslurpclose_at((blah)->fd, file, sa) diff --git a/src/include/skalibs/unixmessage.h b/src/include/skalibs/unixmessage.h @@ -3,7 +3,6 @@ #ifndef UNIXMESSAGE_H #define UNIXMESSAGE_H -#include <sys/types.h> #include <sys/uio.h> #include <stdint.h> #include <skalibs/gccattributes.h> diff --git a/src/libstddjb/bitarray_count.c b/src/libstddjb/bitarray_count.c @@ -1,7 +1,6 @@ /* ISC license. */ #include <sys/types.h> -#include <skalibs/uint64.h> #include <skalibs/bitarray.h> #define B0(n) n, n+1, n+1, n+2 @@ -9,11 +8,11 @@ #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) -uint64_t bitarray_countones (unsigned char const *c, size_t n) +size_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 ; + size_t total = 0 ; size_t i = 0 ; if (n & 7) len-- ; for (; i < len ; i++) total += table[c[i]] ; diff --git a/src/libstddjb/buffer_get.c b/src/libstddjb/buffer_get.c @@ -8,6 +8,6 @@ ssize_t buffer_get (buffer *b, char *s, size_t len) { size_t w = 0 ; int r = buffer_getall(b, s, len, &w) ; - return r == -1 ? errno == EPIPE ? (errno = 0, (ssize_t)w) : -1 : + return r == -1 ? errno == EPIPE ? (errno = 0, w) : -1 : !r ? (errno = EWOULDBLOCK, -1) : w ; } diff --git a/src/libstddjb/selfpipe_read.c b/src/libstddjb/selfpipe_read.c @@ -16,7 +16,7 @@ int selfpipe_read (void) { struct signalfd_siginfo buf ; ssize_t r = sanitize_read(fd_read(selfpipe_fd, (char *)&buf, sizeof(struct signalfd_siginfo))) ; - return (r <= 0) ? r : (int)buf.ssi_signo ; + return (r <= 0) ? r : buf.ssi_signo ; } #else @@ -25,7 +25,7 @@ int selfpipe_read (void) { char c ; ssize_t r = sanitize_read((fd_read(selfpipe_fd, &c, 1))) ; - return (r <= 0) ? r : (int)c ; + return (r <= 0) ? r : c ; } #endif