Mark unused arguments in many modules. Either with UNNEEDED (if the module already used ccan/compiler) or with (void) casting. The only other change is in ccan/list/test/run-CCAN_LIST_DEBUG.c, because the linenumbers change and thus it needs updating. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
mem: get clever with memeqzero(). Best of both worlds. Before: 1: 6ns 2: 7ns 4: 7ns 8: 7ns 16: 7ns 32: 8ns 64: 9ns 128: 13ns 256: 24ns 512: 47ns 1024: 92ns 2048: 185ns 4096: 376ns 8192: 739ns 16384: 1463ns 32768: 2914ns 65536: 5800ns 2: 7ns 3: 7ns 5: 7ns 9: 7ns 17: 7ns 33: 8ns 65: 9ns 129: 20ns 257: 31ns 513: 49ns 1025: 96ns 2049: 189ns 4097: 381ns 8193: 745ns 16385: 1477ns 32769: 2930ns 65537: 5824ns total = 599391004 After: 1: 3ns 2: 3ns 4: 4ns 8: 5ns 16: 12ns 32: 13ns 64: 15ns 128: 19ns 256: 25ns 512: 35ns 1024: 57ns 2048: 105ns 4096: 183ns 8192: 324ns 16384: 607ns 32768: 1317ns 65536: 2774ns 2: 3ns 3: 3ns 5: 4ns 9: 6ns 17: 11ns 33: 13ns 65: 14ns 129: 19ns 257: 24ns 513: 35ns 1025: 57ns 2049: 106ns 4097: 183ns 8193: 324ns 16385: 607ns 32769: 1315ns 65537: 2773ns total = 599391004 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
mem: optimize. Better for larger, worse for smaller compares. Before: 1: 3ns 2: 3ns 4: 5ns 8: 9ns 16: 11ns 32: 33ns 64: 45ns 128: 87ns 256: 157ns 512: 296ns 1024: 579ns 2048: 1139ns 4096: 2251ns 8192: 4505ns 16384: 9704ns 32768: 18482ns 65536: 36144ns 2: 4ns 3: 6ns 5: 8ns 9: 9ns 17: 12ns 33: 22ns 65: 45ns 129: 90ns 257: 175ns 513: 357ns 1025: 607ns 2049: 1204ns 4097: 2278ns 8193: 4552ns 16385: 9011ns 32769: 18405ns 65537: 36153ns total = 599391004 After: 1: 6ns 2: 7ns 4: 7ns 8: 7ns 16: 7ns 32: 8ns 64: 9ns 128: 13ns 256: 24ns 512: 47ns 1024: 92ns 2048: 185ns 4096: 376ns 8192: 739ns 16384: 1463ns 32768: 2914ns 65536: 5800ns 2: 7ns 3: 7ns 5: 7ns 9: 7ns 17: 7ns 33: 8ns 65: 9ns 129: 20ns 257: 31ns 513: 49ns 1025: 96ns 2049: 189ns 4097: 381ns 8193: 745ns 16385: 1477ns 32769: 2930ns 65537: 5824ns total = 599391004 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
mem: mark all functions as PURE This might allow compilers that support the anotation to make better choices when optimizing, and all these functions meet the requirements for being marked pure. Signed-off-by: Cody P Schafer <dev@codyps.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
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>
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>
mem: Rename memmem module to mem 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>