David Gibson [Thu, 18 Jun 2015 09:30:18 +0000 (19:30 +1000)]
avl: Use definitions from order module
The AvlCompare type defined in the avl module is identical in signature to
the compare function used by qsort() and bsearch(). That has a common
definition in the new order module, so use that rather than defining its
own.
In addition use the standard comparison functions from order where possible
for the avl test code.
Cc: Joey Adams <joeyadams3.14159@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Thu, 18 Jun 2015 09:29:37 +0000 (19:29 +1000)]
asort: Use order module definitions
The asort routine takes a user-supplied comparison function. Use the
definitions from the new order module to slightly simplify the declaration
and handling of this function.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Tue, 2 Jun 2015 07:30:58 +0000 (17:30 +1000)]
order: Scalar comparison functions
Extend the order module to provide simple, standard, comparison
callbacks for scalar types (i.e. integer and floating point types).
In addition to the usual variants comparing a plain scalar, this also
provides helper macros to construct a suitably typed callback and context
pointer to order structures by a specified scalar field.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Tue, 2 Jun 2015 07:26:49 +0000 (17:26 +1000)]
order: Module for comparison callbacks
Many common algorithms take a callback for comparing items - effectively
giving the items a user defined order.
For example, the standard library qsort() and bsearch() routines take such
a callback. The ccan/avl module takes an identical one. The ccan/asort
and ccan/asearch modules use a different variant: their callback takes an
additional context parameter, and is also typed via use of macros and
typesafe_cb.
This module provides helper types and macros for easily declaring any of
the common variants on comparison functions: the 2-parameter untyped form
(as used by qsort), the 3-parameter untyped form (used by the asort back
end) and the 3-parameter typed form (used by the asort front end). It
provides a wrapper macro for doing the typesafe_cb conversion from
3-parameter typed to 3-parameter untyped.
It also provides a container struct to describe both a comparison callback
and a context value as a single structure. This also comes in both
untyped and typed variants.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Rusty Russell [Thu, 18 Jun 2015 03:30:01 +0000 (13:00 +0930)]
ccanlint: handle circular test-depends.
eg. asort depends on order, but order testdepends on asort.
Probably not the greatest thing to do, but don't barf because of it.
Reported-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Sat, 13 Jun 2015 14:24:57 +0000 (00:24 +1000)]
lqueue: Allow a queueu to be initialized from an existing back element
There are occasional cases where you might construct a valid queue, and
retain a direct pointer to the back element, but not the struct lqueue
used to build it.
This patch adds a new lqueue_init_from_back() macro to reconstruct a valid
struct lqueue from the element pointer for cases like this.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Sat, 13 Jun 2015 14:23:39 +0000 (00:23 +1000)]
lstack: Allow a stack to be initialized from an existing top element
There are occasional cases where you might construct a valid stack, and
retain a direct pointer to the top element, but not the struct lstack
used to build it.
This patch adds a new lstack_init_from_top() macro to reconstruct a valid
struct lstack from the element pointer for cases like this.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Rusty Russell [Thu, 4 Jun 2015 03:18:18 +0000 (12:48 +0930)]
opt: add opt_usage_exit_fail.
I've been using opt_usage_and_exit() but that exits status 0.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Kirill Smelkov [Mon, 1 Jun 2015 15:10:00 +0000 (18:10 +0300)]
bitmap: Don't crash if allocation fails in bitmap_alloc0() & friends
Currently, if allocation fails, inside bitmap_alloc0(), we'll continue
to use bitmap=NULL pointer and pass it to bitmap_zero() which will
SIGSEGV.
Cc: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Kirill Smelkov <kirr@nexedi.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Rusty Russell [Mon, 1 Jun 2015 06:50:04 +0000 (16:20 +0930)]
ntdb: don't overlap with test filenames.
This may have been causing a travis failure. Let's see!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 1 Jun 2015 06:38:26 +0000 (16:08 +0930)]
One line change to test Travis (now I've turned it on)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Thu, 28 May 2015 10:25:42 +0000 (19:55 +0930)]
tal: rename tal_dup to tal_dup_arr, make tal_dup simpler.
It's a bit too powerful, if you just want to memdup one thing, it's
hard to remember what the extra args are for.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Thu, 28 May 2015 03:48:12 +0000 (13:18 +0930)]
Makefile: add ptrint
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Wed, 27 May 2015 14:17:35 +0000 (00:17 +1000)]
asearch: Add context pointer to asearch comparison callback
asearch, like the standard library bsearch, takes a comparison callback.
Like bsearch() that callback doesn't include a user supplied context
pointer. As well as being generally limiting, that makes the comparison
functions used by asearch gratuitously different from those used by the
asort module.
This patch alters this. Note that this is an incompatible change to the
asearch interface. I think this is worth it to correct the oversight, but
others might disagree. At present the only user within ccan is ntdb, which
is corrected to match.
This means actually supplying a binary search implementation, rather than
relying on bsearch() from the standard library. We follow the lead of the
asort module and steal^H^H^H^H^Hadapt the implementation from glibc.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Wed, 27 May 2015 14:17:34 +0000 (00:17 +1000)]
asearch: Correct license tag to LGPL 2.1+
The _info file for asearch currently gives the license as just "LGPL".
That gives a warning from ccanlint, because it interprets that as the
latest LGPL 3 whereas asearch.h and the license link indicate it's actually
LGPL 2.1+.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Tue, 26 May 2015 12:56:50 +0000 (22:56 +1000)]
ptrint: Module for encoding integers into void * pointers
For callbacks which need a void * context pointer in the general case,
there are often simpler cases where an integer would suffice. These are
often handled by casting the integer into a pointer, rather than having
to allocate that integer somewhere.
This adds a module with some helpers for this. It has some advantages over
direct casts:
* It uses pointer arithmetic against NULL instead of casts which should
make it more portable, even to weird platforms with odd representations
for NULL. I don't know the C standard well enough to know if it's
totally portable though.
* In particular it means that the truth value of the pointer
representation matches that of the encoded integer.
* The conversion functions are inlines providing more type safety than
raw casts.
* It uses a ptrint_t * type which can be used to mark such pointer
encoded integers. ptrint_t is a deliberately incomplete type so such
pointers can never be dereferenced.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Rusty Russell [Wed, 27 May 2015 04:26:31 +0000 (13:56 +0930)]
Makefile: fix upload target (really this time!)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Wed, 27 May 2015 04:22:10 +0000 (13:52 +0930)]
Makefile: more hacks for crypto/ and str/ subdirs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Wed, 27 May 2015 04:19:20 +0000 (13:49 +0930)]
crypto/sha256: simplify interface.
I misused it by accident: the implied sizeof() is too tricky.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 25 May 2015 06:31:22 +0000 (16:01 +0930)]
Makefile: add missing modules.
Otherwise their web pages don't get built.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 25 May 2015 06:30:47 +0000 (16:00 +0930)]
Makefile: update upload target.
For ccan core maintainers only, but useful.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 25 May 2015 06:19:56 +0000 (15:49 +0930)]
crypto/shachain: examples and some documentation.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 25 May 2015 05:51:08 +0000 (15:21 +0930)]
crypto/shachain: enforce that indexes have to be added incrementally.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 25 May 2015 05:41:56 +0000 (15:11 +0930)]
crypto/shachain: detect if we're inserting a bogus hash.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 25 May 2015 05:24:28 +0000 (14:54 +0930)]
crypto/shachain: a bit more common code.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 25 May 2015 05:04:15 +0000 (14:34 +0930)]
crypto/shachain: add design document.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 25 May 2015 04:19:41 +0000 (13:49 +0930)]
crypto/shachain: new module
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 25 May 2015 02:08:46 +0000 (11:38 +0930)]
crypto/sha256: new module.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Sun, 24 May 2015 10:03:05 +0000 (19:33 +0930)]
tools: add HAVE_UNALIGNED_ACCESS test.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Wed, 20 May 2015 07:54:22 +0000 (17:24 +0930)]
timer: simple optimization for large number of timers.
This is still pretty stupid, but greatly reduces my routing-sim time.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Wed, 20 May 2015 01:21:31 +0000 (10:51 +0930)]
timer: brute force corruption fix.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 19 May 2015 20:51:43 +0000 (06:21 +0930)]
timer: put level-0 optimization directly into find_first.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 19 May 2015 06:59:54 +0000 (16:29 +0930)]
timer: fix two corruption bugs.
We fill the upper buckets after we've moved on from the first bucket
in this layer. This means two things:
1) If we have to look at an upper layer, we need to look at the next bucket,
unless offset is 0.
2) We need to keep looking up layers in the corner case, too.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 19 May 2015 04:52:13 +0000 (14:22 +0930)]
timer: better dump code.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 19 May 2015 02:36:37 +0000 (12:06 +0930)]
timer: fix timer_check() to iterate all levels.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Thu, 14 May 2015 06:55:52 +0000 (23:55 -0700)]
str/hex: to-from hexstring conversion routines.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 12 May 2015 22:22:29 +0000 (15:22 -0700)]
htable: add pre-sized option.
I thought this was slowing down my program; it turned out they were
all hashing to the same value. But it might be useful.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Joel Stanley [Tue, 5 May 2015 11:53:30 +0000 (21:23 +0930)]
Add Travis continuous integration
This enables building of the CCAN and running of all the tests on
https://travis-ci.org/
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Rusty Russell [Sat, 25 Apr 2015 06:41:55 +0000 (16:11 +0930)]
doc: english fixup.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Fri, 24 Apr 2015 06:20:54 +0000 (15:50 +0930)]
web: remove unused db dir
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Fri, 24 Apr 2015 06:16:21 +0000 (15:46 +0930)]
web: remove unused directory.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Fri, 24 Apr 2015 05:42:43 +0000 (15:12 +0930)]
Delete unused file.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Fri, 24 Apr 2015 05:30:54 +0000 (15:00 +0930)]
web: Create webpages-unchecked target for running on server.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Delio Brignoli [Sun, 12 Apr 2015 13:27:25 +0000 (15:27 +0200)]
tal_stack
Hi Rusty,
Thanks for reviewing the patch. V2 is attached, see my comments below.
> On 31 Mar 2015, at 02:36, Rusty Russell <rusty@rustcorp.com.au> wrote:
>
> Delio Brignoli <brignoli.delio@gmail.com> writes:
>> Hi All,
>>
>> tal_stack implements a (trivial) stack of tal contexts. Would this be a worthy addition to CCAN? (not necessarily in its current form).
[…]
> This is cute; I’ve seen similar used in Samba. It's
Indeed, it was inspired by talloc_stack.h ;-)
[…]
> You are missing a _info file: I would create that, and put your example
> in an Example: section there.
I moved the module and tests under can/tal/stack and added a LICENSE and _info.
> Other random advice:
> 1) You should also document the tal_newframe function (particularly note
> that you're expected to tal_free the result, and that it will free
> any future unfreed frames). And note that it’s not threadsafe.
Done.
> 2) You probably want tal_newframe to be a macro, and hand file and line
> thought to the tal_alloc_ call. That makes debugging nicer when
> you iterate the tree.
Done. The macro is calling a tal_newframe_() function because I’d rather not make the module’s stack variable ‘public’.
> 3) Consider whether you want to declare a dummy type 'struct tal_stack'.
> Probably pretty unnecessary since it’s quite clear.
Skipped this one. We can declare it later if we change our minds.
Thanks
—
Delio
From
c2ceb9258d97b0dcb72e7b6986cfd2bd394b254e Mon Sep 17 00:00:00 2001
From: Delio Brignoli <dbrignoli@audioscience.com>
Date: Sun, 15 Mar 2015 13:26:40 +0100
Subject: [PATCH] tal_stack: new module - V2
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Peter Barker [Fri, 10 Apr 2015 01:26:23 +0000 (11:26 +1000)]
ccanlint: avoid segfault when module_builds' linking fails
In the case that the objects built but linking failed, module_builds.c
called score_file_error with a NULL ccan_file object and 0 for line
number.
score_file_error assumed that the ccan_file object it is passed was
not-NULL when appending file errors to the score's aggregate error
string. It attempted to dereference it to get "fullname".
score_error was factored out from score_file_error. It takes a
"source" parameter, which is the file's full name (and possibly line
number) in the score_file_error case, and the ccan module name in the
case of link failure.
Peter Barker [Mon, 9 Mar 2015 04:59:48 +0000 (15:59 +1100)]
base64: implements rfc4648, the base64 encoding
Encode buffers into base64 according to rfc4648.
Decode base64-encoded buffers according to the same standard.
Signed-off-by: <pb-ccan@barker.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 30 Mar 2015 06:27:38 +0000 (16:57 +1030)]
tools/ccanlint: slight neatening of license logic.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Peter Barker [Wed, 25 Feb 2015 03:34:14 +0000 (14:34 +1100)]
ccanlint - avoid e.g. GPL vs LGPL mismatch in license checking
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Eric Wong [Fri, 24 Oct 2014 22:02:32 +0000 (22:02 +0000)]
list: add list_for_each_rev_safe{,_off} macros
Deleting while iterating backwards will be needed in the
Ruby st_foreach_reverse_check implementation if we decide
to port Ruby's st.c to use ccan/list.
ref: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/65408
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Eric Wong [Fri, 24 Oct 2014 22:02:31 +0000 (22:02 +0000)]
list: add list_for_each_rev_off macro
And re-implement list_for_each_rev in terms of list_for_each_rev_off
to avoid duplicating iteration logic.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Eric Wong [Fri, 24 Oct 2014 22:02:30 +0000 (22:02 +0000)]
list: new list_for_each{, _safe}_off_dir_ macros
These internal iteration macros will make implementing reverse
iteration simpler. For now, reimplement existing list_for_each_off
and list_for_each_safe_off macros on top of these macros to
prove they pass existing tests.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Eric Wong [Fri, 24 Oct 2014 22:02:29 +0000 (22:02 +0000)]
list: list_swap to exchange elements
This allows deleting and re-inserting an element in place
of the deleted element without branching.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Eric Wong [Fri, 24 Oct 2014 22:02:28 +0000 (22:02 +0000)]
list: list_add_after and list_add_before functions
These make it easy to add a new element before or after an
existing element in the middle of the list.
The existing list_add and list_add_tail functions are trivially
reimplemented on top of these new functions.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 30 Mar 2015 05:23:45 +0000 (15:53 +1030)]
stringbuilder: fix ccan/str test dependency.
It's a test dependency, not a core one, so it belongs under "testdepends".
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Jeremy Kerr [Mon, 18 Aug 2014 10:45:39 +0000 (18:45 +0800)]
endian: Fix cpu_to_be64 on big-endian
Commit
9e2c88b5 added an extra return (with an unconditional byteswap)
in cpu_to_be64. This breaks on big-endian, where we shouldn't be
byteswapping.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Stuart Longland [Fri, 22 Aug 2014 23:25:09 +0000 (09:25 +1000)]
stringbuilder: Functions for joining strings.
This is a small couple of functions for joining lists of strings
together. The lists can either be varadic arguments or arrays, and
delimiters are optional.
This patch incorporates some advice from David Gibson on the original
module.
Rusty Russell [Mon, 30 Mar 2015 06:46:08 +0000 (17:16 +1030)]
Makefile: add ntdb.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Fri, 20 Mar 2015 01:06:52 +0000 (11:36 +1030)]
ntdb: fix up tests.
Mainly include path fixes.
Also Samba's unit tests were enhanced to detect the prefixes
helpapi and helprun to indicate an object was to be linked against
only api/run tests. We hack around that by #including the helper
code instead.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Fri, 20 Mar 2015 01:06:28 +0000 (11:36 +1030)]
ntdb: assume HAVE_CCAN in header.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Wed, 18 Mar 2015 03:39:33 +0000 (14:09 +1030)]
ntdb: fix up _info.
It was missing dependency information, and a description of ntdb.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Wed, 18 Mar 2015 03:38:50 +0000 (14:08 +1030)]
ntdb: move python bindings to subdir.
The other option would be to require Python.h, which seems overkill.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Wed, 18 Mar 2015 03:37:48 +0000 (14:07 +1030)]
ntdb: remove config.h
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 17 Mar 2015 01:55:21 +0000 (12:25 +1030)]
Merge branch 'ntdb' of https://github.com/ddiss/ccan into ddiss-ntdb
Rusty Russell [Mon, 16 Mar 2015 21:46:28 +0000 (08:16 +1030)]
invbloom: singleton callback for when destroying a singleton, too.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Disseldorp [Mon, 16 Mar 2015 14:15:31 +0000 (15:15 +0100)]
ntdb: add _info file
The Authors entries were added based on source file copyright
statements. Full details can be found via the upstream Samba Git
repository.
Signed-off-by: David Disseldorp <ddiss@suse.de>
David Disseldorp [Mon, 16 Mar 2015 13:08:57 +0000 (14:08 +0100)]
ntdb: link to common LGPL-3 license
Signed-off-by: David Disseldorp <ddiss@suse.de>
David Disseldorp [Mon, 16 Mar 2015 11:58:33 +0000 (12:58 +0100)]
ntdb: build core components via static Makefile
As part of Samba, ntdb was built using the Waf build system. As part of
ccan, convert this to a simple Makefile, and add a static config.h.
The Makefile only builds core ntdb components for now - libntdb and
tools.
Signed-off-by: David Disseldorp <ddiss@suse.de>
David Disseldorp [Fri, 13 Mar 2015 16:45:16 +0000 (17:45 +0100)]
ntdb: next-generation trivial key-value database
ntdb is a partial rewrite of Samba's Trivial Database, providing > 4GB
database scalability and an improved API.
Obtained from the Samba repository at git://git.samba.org/samba.git, as
of
bd13405e8570e9a5942165a8c52a2bc3fdc9d96e.
See Samba's Git changelog for authorship details.
Signed-off-by: David Disseldorp <ddiss@suse.de>
Rusty Russell [Sun, 15 Mar 2015 05:37:26 +0000 (16:07 +1030)]
invbloom: reduce hash count to 3.
Kalle shows the superiority of 3 (as does the paper for > 50 buckets).
https://github.com/kallerosenbaum/bitcoin-iblt/wiki/Diff-count-VS-failure-probability
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Sun, 15 Mar 2015 05:36:59 +0000 (16:06 +1030)]
invbloom: add callback for when an element becomes a singleton.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Sun, 15 Mar 2015 02:53:36 +0000 (13:23 +1030)]
invbloom: remove unused structure field.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Fri, 14 Nov 2014 02:45:18 +0000 (13:15 +1030)]
cdump: ignore __attribute__ (gcc extension).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Fri, 14 Nov 2014 02:28:58 +0000 (12:58 +1030)]
cdump: handle multi-line preprocessor directives.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Fri, 14 Nov 2014 00:21:29 +0000 (10:51 +1030)]
cdump: add CDUMP() support.
This lets you annotate your headers with notes for cdump.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Fri, 14 Nov 2014 00:20:01 +0000 (10:50 +1030)]
cdump: handle array sizes and comments better.
We can now parse array sizes properly: comments and extra [] pairs
will no longer confuse us.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 11 Nov 2014 05:40:21 +0000 (16:10 +1030)]
io: fix example in io_plan.h which didn't compile.
This was found because ccanlint now looks for examples here too.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 11 Nov 2014 05:25:54 +0000 (15:55 +1030)]
cdump: add useful tool to generate enum name string table.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 11 Nov 2014 05:25:54 +0000 (15:55 +1030)]
cdump: handle , at end of enums.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 11 Nov 2014 05:25:48 +0000 (15:55 +1030)]
cdump: new module.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 11 Nov 2014 05:23:27 +0000 (15:53 +1030)]
pushpull: new module.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 10 Nov 2014 04:30:26 +0000 (15:00 +1030)]
ccanlint: offer to insert license comments where they're missing.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 10 Nov 2014 04:30:06 +0000 (15:00 +1030)]
ccanlint: check all headers for examples.
pushpull module doesn't have examples in pushpull.h.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Fri, 7 Nov 2014 04:38:03 +0000 (15:08 +1030)]
invbloom: new module for IBLTs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Thu, 30 Oct 2014 22:53:26 +0000 (09:23 +1030)]
Makefile-ccan: bytestring now has source.
Reported-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Wed, 29 Oct 2014 05:59:56 +0000 (16:29 +1030)]
io: update for new timer API.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Wed, 29 Oct 2014 05:40:21 +0000 (16:10 +1030)]
timer: make timer_del() idempotent, add timer_init().
This catches duplicate timer_add() calls, as well as meaning we don't
need to track if the timer is active before calling timer_del().
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Wed, 29 Oct 2014 05:32:46 +0000 (16:02 +1030)]
timer: change timers_expire() to return a single timer.
The linked list method was problematic, especially if timers delete
other expired timers (eg. the next one in the expired list: the timer_del
will delete it from expired, but that's a bit unexpected).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Sat, 11 Oct 2014 16:46:57 +0000 (18:46 +0200)]
bytestring: Add initializer macro
The BYTESTRING macro is constant, since it's designed to take a string
literal, but it doesn't count as constant since it involves an (inlined)
function call. That means it can't be used in a static storage duration
initializer.
Unfortunately, I can't see a portable way to make something which can be
used as an initializer, but which can also be used in other contexts where
BYTESTRING() can be used, so this patch introduces BYTESTRING_INIT() which
is similar to BYTESTRING() but produces an initializer.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Sat, 11 Oct 2014 16:47:28 +0000 (18:47 +0200)]
bytestring: Use CONST_FUNCTION
The bytestring() constructor function satisfies the constraints of
CONST_FUNCTION, so mark it as such.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Mon, 28 Jul 2014 09:33:33 +0000 (19:33 +1000)]
bytestring: Split bytestrings by a string delimiter
This introduces the functions bytestring_splitstr_first() and
bytestring_splitstr_next() which can be used to iterate through substrings
of a bytestring separated by a specified substring.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Mon, 28 Jul 2014 09:31:36 +0000 (19:31 +1000)]
bytestring: Split bytestrings by a set of character delimiters
This introduces the functions bytestring_splitchrs_first() and
bytestring_splitchrs_next() which can be used to iterate through substrings
of a bytestring separated by any of a given set of delimiter characters.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Mon, 28 Jul 2014 09:31:11 +0000 (19:31 +1000)]
bytestring: Split bytestrings by a character delimiter
This introduces the functions bytestring_splitchr_first() and
bytestring_splitchr_next() which can be used to iterate through substrings
of a bytestring separated by a single, specified delimiter character.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Wed, 22 Oct 2014 13:37:22 +0000 (15:37 +0200)]
bytestring: Implement bytestring_spn() and bytestring_cspn()
Add bytestring_spn() and bytestring_cspn() functions which, in analogy to
strspn() and strcspn() return the lengths of initial sub-bytestrings which
either contain only a given set of bytes, or anything except a given set
of bytes.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Sat, 26 Jul 2014 12:51:22 +0000 (22:51 +1000)]
bytestring: Implement bytestring_bytestring()
Add a bytestring_bytestring() function which, in analogy with strstr() and
memmem() finds one bytestring within another.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Wed, 22 Oct 2014 13:35:26 +0000 (15:35 +0200)]
bytestring: Add bytestring_index and bytestring_rindex() functions
Add bytestring equivalents of the index() and rindex() standard functions
which search for characters/bytes within a bytestring.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Sun, 19 Oct 2014 10:26:29 +0000 (12:26 +0200)]
bytestring: bytestring_starts() and bytestring_ends() functions
This implements bytestring_starts() and bytestring_ends() which
will test if a given bytestring starts or ends with another given
bytestring.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Sun, 19 Oct 2014 10:22:49 +0000 (12:22 +0200)]
bytestring: Add bytestring_slice function
Add a bytestring_slice() function to take a sub(byte)string of a
bytestring.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Sun, 19 Oct 2014 10:20:14 +0000 (12:20 +0200)]
bytestring: Add bytestring_byte() function
Add a bytestring_byte() function to get a single byte / character
from a bytestring.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Wed, 22 Oct 2014 11:56:53 +0000 (13:56 +0200)]
mem: Implement memrchr()
The memrchr() function, which works like memchr(), but searches from the
back of the region to the front is implemented in the GNU C library, but
isn't standard.
This patch adds an implementation of the function to the mem module, when
it's not available in the system C library.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Wed, 22 Oct 2014 11:56:52 +0000 (13:56 +0200)]
mem: Correct testcases
Currently the 'mem' module testcases use test/run.c even though they don't
rely on access to the module internals. They're also missing an include
of mem.c, which has the effect that on systems with a C library memmem()
implementaiton, only that is tested, not the (re-)implementation in the
mem module itself. This corrects that by moving run.c to api.c/
Additionally, the memmem() testcases don't cover the case where the
"needle" appears multiple times in the "haystack". This patch also adds
such a test.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>