- 25 Oct, 2014 1 commit
-
-
Chris McCormick authored
-
- 13 Oct, 2014 7 commits
-
-
Rasmus Villemoes authored
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 authored
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-
David Gibson authored
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 authored
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 authored
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 authored
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 authored
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>
-
- 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 3 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>
-