commit efd2b41c35d427c78c685b9a543578df3641135d
parent d6d44bb45053f0dbf866f355d1e5a4b0b3eeaf3d
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Sat, 16 May 2015 00:26:24 +0000
- add bitarray_count
- add openwritevnclose_at
- rc for 2.3.5.0
Diffstat:
8 files changed, 67 insertions(+), 3 deletions(-)
diff --git a/doc/index.html b/doc/index.html
@@ -60,7 +60,7 @@ with a standard C development environment </li>
<h3> Download </h3>
<ul>
- <li> The current released version of skalibs is <a href="skalibs-2.3.4.0.tar.gz">2.3.4.0</a>. </li>
+ <li> The current released version of skalibs is <a href="skalibs-2.3.5.0.tar.gz">2.3.5.0</a>. </li>
<li> Alternatively, you can checkout a copy of the skalibs git repository:
<pre> git clone git://git.skarnet.org/skalibs </pre> </li>
</ul>
diff --git a/doc/upgrade.html b/doc/upgrade.html
@@ -18,6 +18,12 @@
<h1> What has changed in skalibs </h1>
+<h2> in 2.3.5.0 </h2>
+
+<ul>
+ <li> New functions: bitarray_count(), openwritevnclose_at() </li>
+</ul>
+
<h2> in 2.3.4.0 </h2>
<ul>
diff --git a/package/deps.mak b/package/deps.mak
@@ -21,13 +21,16 @@ src/include/skalibs/djbtime.h: src/include/skalibs/config.h src/include/skalibs/
src/include/skalibs/djbunix.h: src/include/skalibs/env.h src/include/skalibs/envalloc.h src/include/skalibs/gccattributes.h src/include/skalibs/siovec.h src/include/skalibs/stralloc.h src/include/skalibs/uint64.h
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/error.h: src/include/skalibs/gccattributes.h
src/include/skalibs/fmtscan.h: src/include/skalibs/gccattributes.h src/include/skalibs/uint32.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
+src/include/skalibs/gidstuff.h: src/include/skalibs/uint32.h
src/include/skalibs/iobuffer.h: src/include/skalibs/buffer.h src/include/skalibs/djbunix.h
src/include/skalibs/iopause.h: src/include/skalibs/tai.h
+src/include/skalibs/ip46.h: src/include/skalibs/bytestr.h src/include/skalibs/fmtscan.h src/include/skalibs/socket.h src/include/skalibs/tai.h src/include/skalibs/uint16.h
src/include/skalibs/kolbak.h: src/include/skalibs/unixmessage.h
src/include/skalibs/lolstdio.h: src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/strerr2.h
src/include/skalibs/md5.h: src/include/skalibs/uint32.h
@@ -51,15 +54,20 @@ src/include/skalibs/strerr.h: src/include/skalibs/gccattributes.h
src/include/skalibs/strerr2.h: src/include/skalibs/strerr.h
src/include/skalibs/surf.h: src/include/skalibs/uint32.h
src/include/skalibs/tai.h: src/include/skalibs/gccattributes.h src/include/skalibs/uint32.h src/include/skalibs/uint64.h
+src/include/skalibs/uint.h: src/include/skalibs/uint32.h
+src/include/skalibs/uint16.h: src/include/skalibs/uint64.h
+src/include/skalibs/uint32.h: src/include/skalibs/uint64.h
+src/include/skalibs/ulong.h: src/include/skalibs/uint64.h
src/include/skalibs/unirandom.h: src/include/skalibs/buffer.h src/include/skalibs/surf.h
src/include/skalibs/unirandomdev.h: src/include/skalibs/unirandom.h
src/include/skalibs/unirandomegd.h: src/include/skalibs/unirandom.h
src/include/skalibs/unisurf.h: src/include/skalibs/unirandom.h
src/include/skalibs/unix-timed.h: src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/functypes.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h
-src/include/skalibs/unix-transactional.h: src/include/skalibs/stralloc.h src/include/skalibs/uint64.h
+src/include/skalibs/unix-transactional.h: src/include/skalibs/siovec.h src/include/skalibs/stralloc.h src/include/skalibs/uint64.h
src/include/skalibs/unixconnection.h: src/include/skalibs/unixmessage.h
src/include/skalibs/unixmessage.h: src/include/skalibs/buffer.h src/include/skalibs/cbuffer.h src/include/skalibs/gccattributes.h src/include/skalibs/genalloc.h src/include/skalibs/siovec.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h src/include/skalibs/uint16.h src/include/skalibs/uint32.h
src/include/skalibs/unixonacid.h: src/include/skalibs/kolbak.h src/include/skalibs/skaclient.h src/include/skalibs/unix-timed.h src/include/skalibs/unix-transactional.h src/include/skalibs/unixconnection.h src/include/skalibs/unixmessage.h
+src/include/skalibs/ushort.h: src/include/skalibs/uint16.h
src/include/skalibs/webipc.h: src/include/skalibs/djbunix.h src/include/skalibs/tai.h
src/libdatastruct/avlnode-internal.h: src/include/skalibs/avlnode.h
src/librandom/random-internal.h: src/include/skalibs/gccattributes.h src/include/skalibs/rrandom.h src/include/skalibs/surf.h src/include/skalibs/unirandom.h
@@ -209,6 +217,7 @@ src/libstddjb/baprintf.o src/libstddjb/baprintf.lo: src/libstddjb/baprintf.c src
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_firstclear.o src/libstddjb/bitarray_firstclear.lo: src/libstddjb/bitarray_firstclear.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
src/libstddjb/bitarray_not.o src/libstddjb/bitarray_not.lo: src/libstddjb/bitarray_not.c src/include/skalibs/bitarray.h
@@ -739,6 +748,7 @@ src/libunixonacid/openwritenclose_at.o src/libunixonacid/openwritenclose_at.lo:
src/libunixonacid/openwritenclose_devino.o src/libunixonacid/openwritenclose_devino.lo: src/libunixonacid/openwritenclose_devino.c src/include/skalibs/skamisc.h src/include/skalibs/uint64.h src/include/skalibs/unix-transactional.h
src/libunixonacid/openwritenclose_devino_tmp.o src/libunixonacid/openwritenclose_devino_tmp.lo: src/libunixonacid/openwritenclose_devino_tmp.c src/include/skalibs/djbunix.h src/include/skalibs/random.h src/include/skalibs/stralloc.h src/include/skalibs/uint64.h src/include/skalibs/unix-transactional.h
src/libunixonacid/openwritenclose_tmp.o src/libunixonacid/openwritenclose_tmp.lo: src/libunixonacid/openwritenclose_tmp.c src/include/skalibs/stralloc.h src/include/skalibs/uint64.h src/include/skalibs/unix-transactional.h
+src/libunixonacid/openwritevnclose_at.o src/libunixonacid/openwritevnclose_at.lo: src/libunixonacid/openwritevnclose_at.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/include/skalibs/siovec.h src/include/skalibs/unix-transactional.h
src/libunixonacid/skaclient_default_cb.o src/libunixonacid/skaclient_default_cb.lo: src/libunixonacid/skaclient_default_cb.c src/include/skalibs/error.h src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h
src/libunixonacid/skaclient_end.o src/libunixonacid/skaclient_end.lo: src/libunixonacid/skaclient_end.c src/include/skalibs/djbunix.h src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h
src/libunixonacid/skaclient_init.o src/libunixonacid/skaclient_init.lo: src/libunixonacid/skaclient_init.c src/include/skalibs/kolbak.h src/libunixonacid/skaclient-internal.h src/include/skalibs/skaclient.h src/include/skalibs/unixmessage.h
diff --git a/package/info b/package/info
@@ -1,4 +1,4 @@
package=skalibs
-version=2.3.4.0
+version=2.3.5.0
category=prog
package_macro_name=SKALIBS
diff --git a/src/include/skalibs/bitarray.h b/src/include/skalibs/bitarray.h
@@ -24,6 +24,7 @@ extern int bitarray_testandpoke (unsigned char *, unsigned int, int) ;
extern unsigned int bitarray_firstclear (unsigned char const *, unsigned int) gccattr_pure ;
extern unsigned int bitarray_firstset (unsigned char const *, unsigned int) gccattr_pure ;
#define bitarray_first(s, n, h) ((h) ? bitarray_firstset(s, n) : bitarray_firstclear(s, n))
+extern unsigned int bitarray_countones (unsigned char const *, unsigned int) 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) ;
diff --git a/src/include/skalibs/unix-transactional.h b/src/include/skalibs/unix-transactional.h
@@ -6,6 +6,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <skalibs/uint64.h>
+#include <skalibs/siovec.h>
#include <skalibs/stralloc.h>
/* Transactional/reliable filesystem operations */
@@ -36,6 +37,7 @@ extern int openwritenclose_devino (char const *, char const *, unsigned int, uin
extern int openwritenclose_tmp (char const *, char const *, unsigned int, stralloc *) ;
extern int openwritenclose_devino_tmp (char const *, char const *, unsigned int, uint64 *, uint64 *, stralloc *) ;
extern unsigned int openwritenclose_at (int, char const *, char const *, unsigned int) ;
+extern unsigned int openwritevnclose_at (int, char const *, siovec_t const *, unsigned int) ;
extern int mkdir_unique (stralloc *, char const *, unsigned int) ;
diff --git a/src/libstddjb/bitarray_count.c b/src/libstddjb/bitarray_count.c
@@ -0,0 +1,20 @@
+/* ISC license. */
+
+#include <skalibs/bitarray.h>
+
+#define B0(n) n, n+1, n+1, n+2
+#define B1(n) B0(n), B0(n+1), B0(n+1), B0(n+2)
+#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)
+{
+ static unsigned char const table[256] = { B3(0) } ;
+ unsigned int len = bitarray_div8(n) ;
+ unsigned int total = 0 ;
+ register unsigned int 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)] ;
+ return total ;
+}
diff --git a/src/libunixonacid/openwritevnclose_at.c b/src/libunixonacid/openwritevnclose_at.c
@@ -0,0 +1,25 @@
+/* ISC license. */
+
+#include <unistd.h>
+#include <errno.h>
+#include <skalibs/allreadwrite.h>
+#include <skalibs/siovec.h>
+#include <skalibs/djbunix.h>
+#include <skalibs/unix-transactional.h>
+
+unsigned int openwritevnclose_at (int dirfd, char const *file, siovec_t const *v, unsigned int n)
+{
+ register unsigned int r ;
+ int fd = open_truncatb(dirfd, file) ;
+ if (fd < 0) return 0 ;
+ r = allwritev(fd, v, n) ;
+ if (r < siovec_len(v, n) || fsync(fd) < 0)
+ {
+ register int e = errno ;
+ fd_close(fd) ;
+ errno = e ;
+ return r ;
+ }
+ fd_close(fd) ;
+ return r ;
+}