- 30 Oct, 2014 11 commits
-
-
David Gibson authored
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 authored
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 authored
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 authored
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 authored
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 authored
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 authored
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 authored
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 authored
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 authored
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 authored
Add a bytestring_byte() function to get a single byte / character from a bytestring. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-
- 27 Oct, 2014 3 commits
-
-
David Gibson authored
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 authored
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>
-
David Gibson authored
Currently the 'memmem' module does nothing but provide an implementation of the memmem() function if it is missing from the standard C library. However there are other functions (e.g. memrchr()) also missing from some C library implementations, so rename the module to mem to allow future inclusion of other functions. This also updates the rfc822 module - the only existing user of the memmem module - to use the new name. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-
- 25 Oct, 2014 6 commits
-
-
Chris McCormick authored
Syntax highlighting for module example code using prettify. Note: prettify is introduced with an svn checkout into the web directoy.
-
Chris McCormick authored
-
Chris McCormick authored
New page layout, font, background image. Replaced table tags with headers and paragraph tags as appropriate. Redesigned logo. Added stylesheet to specify layout more easily. Meta tag for mobile device friendliness.
-
Chris McCormick authored
-
Chris McCormick authored
-
Chris McCormick authored
-
- 23 Oct, 2014 1 commit
-
-
Chris McCormick authored
Changed the look of the website. Added a new logo design (source SVG included). Fixed an issue with junkcode prefix not being set (broken links and images on current site). Removed /tmp/ccan in clean as it was preventing 'make webpages' running twice. Brought the HTML closer to standards compliance (doctype, encoding). Added meta tag for mobile device browsers to render nicely.
-
- 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 1 commit
-
-
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>
-