Chris McCormick [Sat, 25 Oct 2014 11:02:29 +0000 (19:02 +0800)]
Fix for broken links/images on website 'junkcode' pages.
Rasmus Villemoes [Tue, 7 Oct 2014 20:19:41 +0000 (22:19 +0200)]
configurator: Fix CTZ detection
The literal "1" in "1 << (sizeof(long{, long})*8 - 1)" should be 1L or
1LL, so that the expression has the right type. Otherwise, the shift
is only by 31 bits on x86 (other platforms may behave differently). To
avoid language lawyers shouting UB at me, and since
__builtin_ctz{,l,ll} formally takes unsigned parameters, use UL and
ULL suffixes.
Also, fix a typo (missing parenthesis) in the code for CTZLL causing
the detection of __builtin_ctzll to always fail for the wrong reason.
Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 13 Oct 2014 02:46:29 +0000 (13:16 +1030)]
Add eratosthenes to Makefile-ccan list.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Thu, 2 Oct 2014 14:15:01 +0000 (00:15 +1000)]
eratosthenes: Implementation of the Sieve of Eratosthenes
This adds a new "eratosthenes" module which implements the standard
Sieve of Eratosthenes algorithm for locating small prime numbers.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Thu, 2 Oct 2014 14:15:00 +0000 (00:15 +1000)]
bitmap: Implement bitmap_ffs()
This adds a bitmap_ffs() function to find the first (by the usual bitmap
bit ordering) 1 bit in a bitmap between two given bits.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Thu, 2 Oct 2014 14:14:59 +0000 (00:14 +1000)]
bitmap: Extend allocation functions
The bitmap module already has a simple allocation helper, which returns
an uninitialized, dynamically allocated bitmap of a given size.
This extends this with bitmap_alloc[01]() which allocate bitmaps and
initialize them to all zero or all one.
It also adds bitmap_realloc[01]() which reallocate an existing bitmap,
preserving existing bits, and setting any new bits to all zero or all one.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Thu, 2 Oct 2014 14:14:58 +0000 (00:14 +1000)]
bitmap: Add functions to set/clear ranges of bits
Add bitmap_zero_range() and bitmap_fill_range() functions which will set
a contiguous range of bits in the bitmap to 0 or 1.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Thu, 2 Oct 2014 14:14:57 +0000 (00:14 +1000)]
bitmap: Switch bit indices to unsigned long
Currently all bit indices used in the bitmap module are represented as
'int'. These conceptually should be unsigned. In additional limiting
these to ints potentially prevents use of very large bitmaps. So, change
these all to unsigned long.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Tue, 9 Sep 2014 14:22:54 +0000 (00:22 +1000)]
lstack: Linked list stack implementation
This new module provides a simple stack implementation as a singly
linked list.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Tue, 9 Sep 2014 14:22:53 +0000 (00:22 +1000)]
lqueue: Linked list queue implementation
This new module provides a simple queue implementation as a singly
linked (circular) list.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Tue, 9 Sep 2014 14:22:52 +0000 (00:22 +1000)]
container_of: Add container_of_or_null()
It's quite common to have a pointer which could be either a pointer to a
structure member, or NULL. This needs special casing with container_of(),
or it will convert NULL into something strange.
This patch adds container_of_or_null(), which will return NULL if passed
(an appropriately typed) NULL, or the containining structure as
container_of() otherwise.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Wed, 27 Aug 2014 06:57:37 +0000 (16:27 +0930)]
io: use normal linked lists.
There seems to be a bug with the overloaded single-linked list.
Rewrite.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Wed, 27 Aug 2014 06:27:24 +0000 (15:57 +0930)]
list_del_init/list_node_init: for multiple list_del() calls.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 18 Aug 2014 17:07:19 +0000 (02:37 +0930)]
tal/str: use tal/grab_file not grab_file in example.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 18 Aug 2014 17:03:03 +0000 (02:33 +0930)]
charset: make example use tal/grab_file instead of grab_file.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 18 Aug 2014 16:55:04 +0000 (02:25 +0930)]
ccan_tokenizer: remove warnings with gcc
/home/rusty/devel/cvs/ccan/ccan/ccan_tokenizer/test/run.c:898:66: warning: initialization discards ‘const’ qualifier from pointer target type [enabled by default]
#define T(txt, ...) {txt, sizeof(txt)-1, array_count_pair(struct token, __VA_ARGS__)}
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 18 Aug 2014 16:43:46 +0000 (02:13 +0930)]
ccan_tokenizer: switch example from grab_file to ccan/grab_file.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Joel Stanley [Thu, 14 Aug 2014 03:37:53 +0000 (13:37 +1000)]
endian: Wrap arguments in braces to silence warnings
When using the endian swapping marcos with multiple arguments that are
or'd together:
CPU_TO_BE64(THIS_THING | THAT_THING)
gcc will emit this warning:
warning: suggest parentheses around arithmetic in operand
of ‘|’ [-Wparentheses]
Wrap the arugments in braces to avoid this.
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Andy Grover [Tue, 12 Aug 2014 17:49:13 +0000 (10:49 -0700)]
darray: Add darray_remove()
It is useful to be able to remove elements from other than the end, even
if it is slow.
Signed-off-by: Andy Grover <agrover@redhat.com>
Rusty Russell [Fri, 8 Aug 2014 05:10:47 +0000 (14:40 +0930)]
io: always make fds O_NONBLOCK.
Debugging an issue where pettycoin would become unresponsive, I discovered
this:
poll([{fd=5, events=POLLIN}, {fd=19, events=POLLIN}, {fd=6, events=POLLIN}, {fd=15, events=POLLIN}, {fd=8, events=POLLIN}, {fd=-11}, {fd=7, events=POLL
OUT}], 7, -1) = 1 ([{fd=7, revents=POLLOUT}]) <0.000014>
write(7, "\224]\4\0\4\0\0\0\200\203\16\234\v\262\276\321h\357\217Y\0\204\21\31\253\304#U\0206}\20"..., 286100) = 159280 <98.894019>
Despite poll saying the (TCP socket) fd was ready, the write took 98 seconds!
The results were far more reasonable with O_NONBLOCK:
write(9, "%\247l0\337^\216\24\323\2705\203Y\340h\2767/bM\373?dM\254\22g\310\v\0\0\0"..., 206460) = 40544 <0.000052>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Fri, 8 Aug 2014 03:25:12 +0000 (12:55 +0930)]
io: don't do wakeup immediately.
ccan/io users don't expect to deal with callbacks inside each other; we should
just mark woken connections as if they were io_always.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 5 Aug 2014 11:07:44 +0000 (20:37 +0930)]
ccan/io: use shutdown() before close.
During a debugging session, I wondered why poll() wasn't exiting
when I killed a (local) peer.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 4 Aug 2014 08:17:21 +0000 (17:47 +0930)]
ccan/io: add io_out_wait() and io_out_always().
This specificity is required, for example, when doing:
return io_duplex(conn, io_read(...), io_always(...));
The workaround suggested doesn't work, because io_duplex_prepare()
asserts() if the plans aren't UNSET to start. And pettycoin needs this.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 4 Aug 2014 08:16:21 +0000 (17:46 +0930)]
ccan/io: io_halfclose.
Helper for a common case. Replace all but 1 in tests.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 4 Aug 2014 08:15:21 +0000 (17:45 +0930)]
ccan/io: keep more io_plan details internal.
To write a normal helper you only need access to the args, so only
expose that.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 4 Aug 2014 08:14:21 +0000 (17:44 +0930)]
ccan/io: implement debug.
Now a simple flag, with an external toggle (no compile time DEBUG
define required). But it's completely synchronous.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 4 Aug 2014 08:13:21 +0000 (17:43 +0930)]
ccan/io: implement timeouts.
We do this by the simplest method: return from io_loop() and let the caller
sort them out.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 4 Aug 2014 08:12:21 +0000 (17:42 +0930)]
ccan/io: duplex support.
This is actually pretty simple now.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 4 Aug 2014 08:11:21 +0000 (17:41 +0930)]
ccan/io: eliminate dir argument from io_wait and io_always.
We can use either empty slot for this, so figure it out internally.
This could cause problems if you want to use it with io_duplex, so
document that.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Sun, 3 Aug 2014 00:25:07 +0000 (09:55 +0930)]
ccan/io: rewrite.
I found it difficult to use myself, particularly io_duplex().
So this removes that, as well as timers and debug (for the moment).
API changes:
1) An io_plan is passed by pointer, rather than copied on the stack.
3) All io_plans are generated using the struct io_conn.
3) tal is the allocator.
4) A new connection must be set up with a callback, so this is now the
same as one generated from a listener.
5) io_read_partial and io_write_partial take an explicit length.
6) io_always() and io_wait() take an explit in/out arg.
7) io_break() does not return a plan.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Sun, 3 Aug 2014 00:25:01 +0000 (09:55 +0930)]
ccan/io: fix io_connect.
getsockopt(fd, SOL_SOCKET, SO_ERROR, &err, &len) gives err == ECONNREFUSED
when connection is refused. Handle this (and other error cases).
And we need F_SETFL not F_SETFD to restore blocking on the socket!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Fri, 1 Aug 2014 07:06:39 +0000 (16:36 +0930)]
tools/ccanlint: add global .valgrind_suppressions file.
Seems like my local Ubuntu install is giving bogus warnings. Allow
local valgrind overrides.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cody P Schafer [Mon, 28 Jul 2014 02:28:53 +0000 (22:28 -0400)]
configurator: add BUILTIN_CTZ*, BUILTIN_FFS, and ICCARM_INTRINSICS
Realistically, the ICCARM_INTRINSICS probably won't ever be generated
by configurator, but will show up in manually created or alternately
generated config.h's.
Signed-off-by: Cody P Schafer <dev@codyps.com>
Douglas Bagnall [Wed, 16 Jul 2014 10:19:11 +0000 (22:19 +1200)]
opt/helpers: fix out-of-range check in opt_set_floatval()
opt_set_floatval() uses opt_set_doubleval() to do initial conversion
and bounds checking before casting the result to float. Previously
the out of bounds check compared the original and float values for
equality and declared anything unequal to be out of bounds. While this
trick works well in the orderly integer world, it can backfire with
floating point. For example, 3.1 resolves to the double more precisely
known as 3.
100000000000000088817841970012523233890533447265625, while
3.1f resolves to 3.
099999904632568359375. These are not equal, though
3.1 is generally regarded as being in bounds for a float. There are
around 8 billion other doubles (i.e. 3.1 +/- a little bit) that map to
the same 3.1f value, of which only one is strictly equal to it.
Why wasn't this discovered by the tests? It turns out that neither
set_floatval nor set_doubleval were tested against non-integral
numbers. This is slightly improved here.
This patch uses the arguably more reasonable definition of bounds that
is found in opt_set_doubleval(): it excludes numbers that would get
rounded to zero or an infinity. One subtlety is that the double
version allows `--foo=INF` for an explicit infinity without overflow.
This is possibly useful, and there is some fiddling to allow this for
floats. Likewise an explicit zero is allowed, as you would expect.
It is perhaps worth noting that the `*f = d` cast/assignment at the
heart of it all can crash and core dump on overflow or underflow if
the floating point exception flags are in an unexpected state.
Signed-off-by: Douglas Bagnall <douglas@halo.gen.nz>
Rusty Russell [Wed, 23 Jul 2014 23:50:21 +0000 (09:20 +0930)]
net: use freeaddrinfo() in _info example.
In fact, almost everyone will want to do this, so include the required
headers in net.h. This makes usage simpler.
Reported-by: Jeremy Visser <jeremy@visser.name>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Thu, 17 Jul 2014 03:39:55 +0000 (13:09 +0930)]
io: fix io_connect().
How embarrassing: we weren't actually doing a non-blocking connect because
I was using F_SETFD instead of F_SETFL...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Wed, 25 Jun 2014 02:28:57 +0000 (11:58 +0930)]
structeq: new module.
World's most trivial module, but I want it for pettycoin.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 23 Jun 2014 06:36:19 +0000 (16:06 +0930)]
tal/str: fix error when strreg regex looks for literal slashes.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Sun, 22 Jun 2014 23:49:08 +0000 (09:19 +0930)]
time: update for new configurator.
HAVE_CLOCK_GETTIME_IN_LIBRT now implies HAVE_CLOCK_GETTIME.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Sat, 21 Jun 2014 04:44:56 +0000 (14:14 +0930)]
tools/configurator: set HAVE_CLOCK_GETTIME even if it's in -lrt.
This avoids conflicts with autoconf and other config.h sources.
Based on the work by Cody P Schafer <dev@codyps.com>.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Douglas Bagnall [Fri, 20 Jun 2014 04:38:33 +0000 (16:38 +1200)]
opt: Don't segfault if a string's default is NULL
Instead show '(nil)', like other people do. This is distinguishable
from a similar looking string value, because the latter is shown with
double quotes while NULL's nil has no quotes.
Signed-off-by: Douglas Bagnall <douglas@halo.gen.nz>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Douglas Bagnall [Fri, 20 Jun 2014 02:34:02 +0000 (14:34 +1200)]
opt: add an int decrementing helper function
opt_dec_intval decrements an int value, just as opt_inc_intval
increments.
There is not much more to say, other than it allows this
kind of thing, with balanced opposing options:
static int opt_verbosity = 0;
static struct opt_table options[] = {
OPT_WITHOUT_ARG("-q|--quiet", opt_dec_intval,
&opt_verbosity, "print less"),
OPT_WITHOUT_ARG("-v|--verbose", opt_inc_intval,
&opt_verbosity, "print more"),
OPT_ENDTABLE
};
which is an occasionally seen idiom. It allows, e.g., people who like
quiet to use `alias foo='foo -q'`, while letting them get back to
normal and verbose modes with various amounts of '-v's.
Signed-off-by: Douglas Bagnall <douglas@halo.gen.nz>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Douglas Bagnall [Fri, 20 Jun 2014 02:33:53 +0000 (14:33 +1200)]
opt: always initialise values in set_llong_with_suffix()
The helper API functions based on set_llong_with_suffix() left the
value uninitialised in the case of an empty string argument. This is
quite unlikely to have caused problem in practice, as most values will
have already been set to a default and the non-NULL error message
should have triggered an early exit or some other emergency action.
Nevertheless, it caused a compiler warning on some minor version of
GCC 4.8 which I no longer seem to have, and the complaint seemed
reasonable at the time.
If an empty string (or any other non-numeric value) is passed to
strtoll(), the result is zero. As far as I know, the strtoll() call is
only short-circuited here to form a more specific error message, not
because there is a good reason for the empty string to be a special
non-initialising case. So let's set it to zero.
Signed-off-by: Douglas Bagnall <douglas@halo.gen.nz>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Sun, 22 Jun 2014 08:28:04 +0000 (18:28 +1000)]
memmem, bytestring: Fix includes in _info
When I fixed up the includes in _info for nearly everything, I managed to
leave out a couple of my own modules. This fixes them up.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Cody P Schafer [Sat, 21 Jun 2014 00:46:02 +0000 (20:46 -0400)]
autodata: fix example, autodata_get()s second arg must be a (size_t *)
CC: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Cody P Schafer <dev@codyps.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cody P Schafer [Sat, 21 Jun 2014 00:46:01 +0000 (20:46 -0400)]
compiler: avoid barfing when config.h & the current -std= mode mismatch
Add a bunch of __ for all the attribute members.
Lets us keep working even if configurator is called with different
CFLAGS than the build of a file which includes compiler.h
Idealy, we (people using ccan) wouldn't let this happen, however I don't
see any reason /not/ to avoid build breakage in the above case.
Long term, it might make sense to plug some logic into configurator's
config.h (or a cc wrapper, so something else) to warn when the current
flags don't look the same as the ones used to generate config.h
CC: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Cody P Schafer <dev@codyps.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cody P Schafer [Sat, 21 Jun 2014 00:46:00 +0000 (20:46 -0400)]
compiler: Add PURE_FUNCTION
CC: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Cody P Schafer <dev@codyps.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Sun, 15 Jun 2014 09:12:11 +0000 (19:12 +1000)]
memmem: Remove void * arithmetic warning
haystack is a void *, so we can't do pointer arithmetic on it uncasted.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Sun, 15 Jun 2014 14:09:09 +0000 (00:09 +1000)]
ccan: Correct some poor conventions in _info includes
There are a couple of small problems with the includes used in most of
ccan's _info files.
* _info routinely uses printf(), and so should include <stdio.h>, but
only some of them do. We get away with it, because they do include
<string.h>, which apparently includes <stdio.h> indirectly, but we should
be explicit about it.
* Most _info files were including config.h after the system headers.
That _seems_ sensible, but actually causes problems. Because config.h
defines _GNU_SOURCE it can change the behaviour of the system headers.
More specifically it can make them behave differently to how the individual
module headers (which have included config.h) expects them to behave.
This patch adjusts all the existing _info files and, more importantly,
the template constructed by ccanlint.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Sat, 14 Jun 2014 16:11:26 +0000 (02:11 +1000)]
rfc822: Use the memmem module
This changes rfc822 to use the memmem module to supply a memmem() function
if the C library lacks it, instead of rolling our own locally.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Sat, 14 Jun 2014 16:11:25 +0000 (02:11 +1000)]
memmem: Trivial module to provide memmem() function
glibc includes a memmem() function which, by analogy with strstr()
searches for a byte sequence within a larger byte sequence. The function
isn't standard, however, so other C libraries may not include it.
This adds a trivial module providing the memmem() function, if the C
library doesn't already do so.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Wed, 4 Jun 2014 14:41:51 +0000 (00:41 +1000)]
jacobson_karels: Add missing inline keyword
Forgot the 'inline' in 'static inline' in the functions defined in the
header, which means that lots of warnings will be generated, if you include
the header but don't use the functions.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Rusty Russell [Fri, 13 Jun 2014 01:56:27 +0000 (11:26 +0930)]
ccan/htable: fix tools warning for 64-bit systems.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Thu, 12 Jun 2014 04:07:11 +0000 (13:37 +0930)]
time: fix example.
time_between()'s ordering matches time_sub, for better or worse.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 06:24:31 +0000 (15:54 +0930)]
strset: fix up tools for new ccan/time API.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 06:22:25 +0000 (15:52 +0930)]
lbalance: update tools for new time (and jmap!)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 06:02:30 +0000 (15:32 +0930)]
htable: update tools for time changes.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Wed, 4 Jun 2014 03:43:19 +0000 (13:13 +0930)]
time: time_mono() helpers.
From patch by David Gibson, rewritten on new ccan/time.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 3 Jun 2014 10:39:04 +0000 (20:09 +0930)]
io failtest timer tools: fallout from time changes.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 3 Jun 2014 03:56:13 +0000 (13:26 +0930)]
time: split absolute and relative times.
As suggested by David Gibson.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 05:09:34 +0000 (14:39 +0930)]
tal/talloc: include all ccan dependencies.
ccanlint now detects more missing dependencies.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 05:09:34 +0000 (14:39 +0930)]
tal/talloc: fix overflow on 64 bit systems
Arguably a bug in talloc_realloc_array, which uses an unsigned for
size, resulting in silent truncation and a memcpy into a too-small
buffer.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 05:09:34 +0000 (14:39 +0930)]
str_talloc: delete.
All the cool kids are using tal/str now...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 05:09:26 +0000 (14:39 +0930)]
grab_file: don't use str_talloc for tests.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 05:04:46 +0000 (14:34 +0930)]
htable: tools: use tal instead of talloc.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 03:36:16 +0000 (13:06 +0930)]
tools: use tal/grab_file
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 03:36:16 +0000 (13:06 +0930)]
strset: use tal instead of talloc in examples and tools.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 03:36:16 +0000 (13:06 +0930)]
strset: update tools for new ABI
Broken since commit
7c69053bd418bf0abd21f29e8cb11164684310ca
which normalized API.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 03:36:16 +0000 (13:06 +0930)]
strset: update ccan/time usage in tools
Broken since commit
2012d45e273c3016dbd09b2606efc9ffab07c57f
which switched to timespec.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 03:36:16 +0000 (13:06 +0930)]
crcsync: use tal/grab_file in _info example.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 03:36:12 +0000 (13:06 +0930)]
tal/grab_file: new module
tal variant of grab_file (which uses talloc).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 01:39:38 +0000 (11:09 +0930)]
talloc_link: remove it.
It's a prototype unused by anything else.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 01:38:56 +0000 (11:08 +0930)]
tal/link: remove incorrect references to talloc
Showing its origins in talloc_link.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 01:38:01 +0000 (11:08 +0930)]
tal: fix tal_check description
Cut & paste bug.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 10 Jun 2014 01:37:36 +0000 (11:07 +0930)]
idtree: use ccan/tal instead of talloc
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Sun, 1 Jun 2014 14:03:09 +0000 (00:03 +1000)]
jacobson_karels: New module
A straightforward implementation of the Jacobson/Karels algorithm for
estimating round-trip time on a network link.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Mon, 2 Jun 2014 12:37:28 +0000 (22:37 +1000)]
minmax: New module, safe min and max macros
Add a 'minmax' module with typesafe macros to compute minimum, maximum and
clamping. Inspired by the versions used in the Linux kernel, but using
a different implementation based on __builtin_types_compatible_p() and the
build_assert module.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 2 Jun 2014 23:50:52 +0000 (09:20 +0930)]
cpuid: fix LICENSE file to be symlink.
Somehow, it was a normal file.
Reported-by: Sam Watkins <sam@nipl.net>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 26 May 2014 03:40:02 +0000 (13:10 +0930)]
container_of: work with -Wcast-qual
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 26 May 2014 03:27:44 +0000 (12:57 +0930)]
tools/ccanlint: detect more unmentioned dependencies.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 27 May 2014 10:58:34 +0000 (20:28 +0930)]
antithread: correctly list ccan/typesafe_cb as dependency.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 27 May 2014 10:57:20 +0000 (20:27 +0930)]
io: correctly list ccan/typesafe_cb as dependency.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 26 May 2014 02:40:47 +0000 (12:10 +0930)]
tools/ccanlint: don't assert on relative directories for -d.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 26 May 2014 02:16:00 +0000 (11:46 +0930)]
test: add test to ensure we can use non-const lists via check.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 27 May 2014 03:47:29 +0000 (13:17 +0930)]
net: don't return still-connecting fd.
If one connect failed, we'd return the other one without
waiting for the connect to complete. This resulted in
read() returning 0, which was really weird.
The downside: the poll doesn't seem to time out when the
connect times out (Linux 3.13 x86-64).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
David Gibson [Mon, 19 May 2014 11:21:48 +0000 (21:21 +1000)]
bitmap: Use const qualifiers where possible
A number of functions in bitmap.h take parameters which they don't modify
but aren't currently marked as const. This patch fixes that.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson [Wed, 14 May 2014 05:13:26 +0000 (15:13 +1000)]
ccan/bitmap: const for bitmap_test_bit.
No reason for it not to be.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Cody P Schafer [Sun, 26 Jan 2014 02:23:13 +0000 (18:23 -0800)]
net: fix ipv4 immediate connect
Rusty Russell [Sun, 13 Apr 2014 11:55:37 +0000 (21:25 +0930)]
io: don't close if already closing in io_close_other.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Thu, 10 Apr 2014 11:48:36 +0000 (21:18 +0930)]
io: change io_idle() to io_wait()
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 8 Apr 2014 09:33:52 +0000 (19:03 +0930)]
io: io_never for events that should never happen.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Emilio G. Cota [Mon, 10 Mar 2014 15:04:50 +0000 (11:04 -0400)]
bitmap: use unsigned int for iterating over bitmap words
Bitmap words (e.g. resulting from BITMAP_{N,HEAD}WORDS) are of
unsigned type.
Use "unsigned int" to iterate over bitmap words to avoid comparisons
between signed and unsigned expressions. GCC otherwise warns about
these when -Wsign-compare is enabled.
Signed-off-by: Emilio G. Cota <cota@braap.org>
Rusty Russell [Sun, 2 Mar 2014 06:05:10 +0000 (16:35 +1030)]
io: call finish function after fd is actually closed.
This turns out to be the right sequence for pettycoin, which
wants to reap the child in the finish routine. From that sample
size of 1, this is clearly the Right Thing!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Fri, 28 Feb 2014 01:42:11 +0000 (12:12 +1030)]
Enhance CCAN_LIST_DEBUG to report original caller
Simpler reimplementation of SS's patch; just plumb file and line through
inline functions in header. We add a new check, which actually tests
these, and fix _info which missed ccan/check_type as a dependency.
Based-on-the-true-story-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 24 Feb 2014 03:26:32 +0000 (13:56 +1030)]
opt: add float/double helpers.
bfgminer/cgminer/sgminer want these. Con implemented some,
but these are independently written (with tests!)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Mon, 24 Feb 2014 02:55:19 +0000 (13:25 +1030)]
opt: relicense to GPLv2+ (from GPLv3+)
Acked by contributors:
Luke-Jr <luke@dashjr.org>:
I don't have any objections
Douglas Bagnall <douglas@halo.gen.nz>:
Fine by me.
Joel Stanley <joel@jms.id.au>:
Fine with me.
Brad Hards <bradh@frogmouth.net>:
Ack.
No response from Joey (trivial warning patch) or Andreas Schlick (one
trivial patch, but he also wrote opt_free() (which was a 2 line function).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 11 Feb 2014 03:32:17 +0000 (14:02 +1030)]
opt: don't wordwrap when description line starts with whitespace.
This was suggested by Luke, though his version insisted on using tab.
This one is a bit more complex, but allows either tab or space.
Suggested-by: Luke Dashjr <luke-jr+git@utopios.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 11 Feb 2014 02:47:44 +0000 (13:17 +1030)]
opt: test the new embedded-\n-in-usage behaviour.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Luke Dashjr [Fri, 7 Feb 2014 16:41:03 +0000 (16:41 +0000)]
opt: accept newline in help strings
This correctly continues on the next line indented.
Signed-off-by: Luke Dashjr <luke-jr+git@utopios.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell [Tue, 11 Feb 2014 02:36:24 +0000 (13:06 +1030)]
ccan: add test for line-wrapping usage message.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>