- 13 Sep, 2014 3 commits
-
-
David Gibson authored
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 authored
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 authored
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>
-
- 27 Aug, 2014 2 commits
-
-
Rusty Russell authored
There seems to be a bug with the overloaded single-linked list. Rewrite. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-
- 18 Aug, 2014 4 commits
-
-
Rusty Russell authored
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
/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 authored
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-
- 15 Aug, 2014 1 commit
-
-
Joel Stanley authored
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>
-
- 12 Aug, 2014 1 commit
-
-
Andy Grover authored
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>
-
- 08 Aug, 2014 2 commits
-
-
Rusty Russell authored
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 authored
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>
-
- 05 Aug, 2014 1 commit
-
-
Rusty Russell authored
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>
-
- 04 Aug, 2014 7 commits
-
-
Rusty Russell authored
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 authored
Helper for a common case. Replace all but 1 in tests. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
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 authored
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 authored
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 authored
This is actually pretty simple now. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
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>
-
- 03 Aug, 2014 2 commits
-
-
Rusty Russell authored
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 authored
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>
-
- 01 Aug, 2014 1 commit
-
-
Rusty Russell authored
Seems like my local Ubuntu install is giving bogus warnings. Allow local valgrind overrides. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-
- 29 Jul, 2014 2 commits
-
-
Cody P Schafer authored
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 authored
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>
-
- 25 Jul, 2014 1 commit
-
-
Rusty Russell authored
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>
-
- 17 Jul, 2014 1 commit
-
-
Rusty Russell authored
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>
-
- 25 Jun, 2014 1 commit
-
-
Rusty Russell authored
World's most trivial module, but I want it for pettycoin. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-
- 23 Jun, 2014 6 commits
-
-
Rusty Russell authored
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
HAVE_CLOCK_GETTIME_IN_LIBRT now implies HAVE_CLOCK_GETTIME. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-
Rusty Russell authored
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 authored
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 authored
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 authored
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>
-
- 22 Jun, 2014 1 commit
-
-
David Gibson authored
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>
-
- 21 Jun, 2014 3 commits
-
-
Cody P Schafer authored
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 authored
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 authored
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>
-
- 16 Jun, 2014 1 commit
-
-
David Gibson authored
haystack is a void *, so we can't do pointer arithmetic on it uncasted. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-