summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2015-08-19configurator: sometimes _GNU_SOURCE is already defined, in those cases avoid ↵Cody P Schafer
redefinition Config defines are disabled if a warning is emitted (we may want to reconsider that), and warnings are emitted for define redefinition. Signed-off-by: Cody P Schafer <dev@codyps.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-19configurator: hide type punningCody P Schafer
As for the type punning: gcc-5.1 with optimization (at least) warns about type punning in the previous example. The new usage should be exactly equivalent to the old, but just seperates the cast and deref into 2 statements. Frankly, I'm suprised gcc's type-punning analysis is so limited. Signed-off-by: Cody P Schafer <dev@codyps.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-18bytestring: Add rational comment to testcaseDavid Gibson
Reviewing the previous patch it took me some time to work out what the purpose of the compile_fail-BYTESTRING-2.c test. Add a comment to avoid that in future. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-08-18bytestring: avoid compile_fail failure due to uninitialized warningCody P Schafer
bytestring: Module tests compile (tests_compile): FAIL /home/x/g/ccc/ccan/ccan/bytestring/test/compile_fail-BYTESTRING-2.c:Compile gave warnings without -DFAIL: /home/x/g/ccc/ccan/ccan/bytestring/test/compile_fail-BYTESTRING-2.c: In function ‘main’: /home/x/g/ccc/ccan/ccan/bytestring/test/compile_fail-BYTESTRING-2.c:15:2: warning: ‘bs.len’ is used uninitialized in this function [-Wuninitialized] printf("%zd %s\n", bs.len, x); ^ Signed-off-by: Cody P Schafer <dev@codyps.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-08-17talloc: avoid a comparison mismatch & at the same time switch to non-legacy ↵Cody P Schafer
sysconf() Without this, gcc warns about a sign mismatch in the comparison. Signed-off-by: Cody P Schafer <dev@codyps.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-17configurator: avoid leaks that LeakSanitizer doesn't likeCody P Schafer
These leaks aren't really an issue since they are completely bounded, but if one is building with leak sanitizer enabled (as -fsanitize=address does in gcc-5.1), it kills the configurator, which isn't very useful for us. Add the few free() calls it's looking for. This is not an actual code issue, they just workaround some optional compiler peculiarities. Signed-off-by: Cody P Schafer <dev@codyps.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (split off leak change)
2015-08-15cpuid: update inline docsA. Samy
Signed-off-by: A. Samy <f.fallen45@gmail.com>
2015-08-15cpuid: use a hardcoded constant when comparing CPU namesA. Samy
Signed-off-by: A. Samy <f.fallen45@gmail.com>
2015-08-14cpuid: fix test.Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-12cpuid: namespacize some functions and define them as null if unsupportedA. Samy
2015-08-12cpuid: cpuid_write_info(): have outfile a file pointer insteadA. Samy
2015-08-12cpuid: rename ___cpuid to get_cpuidA. Samy
2015-08-12cpuid: minor clean upA. Samy
2015-08-12Makefile-ccan: add new modules.Rusty Russell
I really need to get rid of this... Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-08-02agar: Re-entrant Abstract Graph AlgorithmsDavid Gibson
New module Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-08-02aga: Add lazytrie testcaseDavid Gibson
This adds a more complex testcase to the aga module. This one is a trie (basically a radix tree for strings). It demonstrates different ways of constructing edge information from an internal representation than the existing testcases. Importantly, it also demonstrates aga's ability to cope with the edge function lazily constructing nodes on the fly. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-08-02aga: Testcase for attempt to run concurrent algorithmsDavid Gibson
The aga algorithms can't be run concurrently, because they store state information in the aga_node structures. However, they are supposed to detect an attempt to re-enter and safely report an error. This adds a testcase for this. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-08-02aga: Breadth first searchDavid Gibson
This implements breadth first search for the abstract graph algorithms module. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-08-02aga: Depth first searchDavid Gibson
This implements depth first search for the abstract graph algorithms module. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-08-02aga: Simple test graphsDavid Gibson
This adds code for a number of example graphs for use in tests of the aga module. They also demonstrate several different ways of constructing graphs using the aga callbacks. It adds one actual testcase, which just verifies that the example graph look like what they're supposed to. Specifically it computes a set of adjacency lists for the example graphs from the callback code, then compares that to a canned example of what it should be. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-08-02aga: Abstract Graph AlgorithmsDavid Gibson
New module. This patch just adds the module, with some generic helper routines, no actual algorithms are implemented yet. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-07-30daemonize: check setsid() return valueMaxim Zakharov
2015-07-30daemonize: exit parent without triggering atexit() processingMaxim Zakharov
2015-07-20short_types: Fix warning in testJoel Stanley
Our project builds the ccan tests with -Wextra, so we get warnings about the unused variables. Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-09tools/modfiles: include _info (unless requested not to)Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-09tools/create-ccan-tree: clean up modfiles binary after use.Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-09tools/create-ccan-tree: fix nested modules with -aRusty Russell
The cp -a would copy nested submodules, and worse, if that submodule was copied later it would end up duplicated in a subdir, eg. "ccan/tal/str/str/". Using modfiles handles this properly, and also uses git to filter out ignored files & other junk. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-09tools/modfiles: list files in a module.Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-09tools: include LICENSE file in manifest.Rusty Russell
It's generally a symlink, so the lstat & S_ISREG tests were eliminating it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-09tools: don't include submodules in manifest.Rusty Russell
They currently get classed as "other_files"; they should be entirely ignored. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-09crypto/sha256: add license file for intel code in benchmarks/Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-08Makefile-ccan: add order to MOD list.Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-08crypto/ripemd160: new module.Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-07-08crypto/sha256: fix up CCAN_CRYPTO_SHA256_USE_OPENSSL implementation.Rusty Russell
sha256_update_bytes is sha256_update since f989a43b55795c04a6225b392f3f58afd2cd6543. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-25crypto/sha256: include Intel ASM versions in benchmarks.Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-25crypto/sha256: add benchmark.Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-18avl: Use definitions from order moduleDavid Gibson
The AvlCompare type defined in the avl module is identical in signature to the compare function used by qsort() and bsearch(). That has a common definition in the new order module, so use that rather than defining its own. In addition use the standard comparison functions from order where possible for the avl test code. Cc: Joey Adams <joeyadams3.14159@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-06-18asort: Use order module definitionsDavid Gibson
The asort routine takes a user-supplied comparison function. Use the definitions from the new order module to slightly simplify the declaration and handling of this function. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-06-18order: Scalar comparison functionsDavid Gibson
Extend the order module to provide simple, standard, comparison callbacks for scalar types (i.e. integer and floating point types). In addition to the usual variants comparing a plain scalar, this also provides helper macros to construct a suitably typed callback and context pointer to order structures by a specified scalar field. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-06-18order: Module for comparison callbacksDavid Gibson
Many common algorithms take a callback for comparing items - effectively giving the items a user defined order. For example, the standard library qsort() and bsearch() routines take such a callback. The ccan/avl module takes an identical one. The ccan/asort and ccan/asearch modules use a different variant: their callback takes an additional context parameter, and is also typed via use of macros and typesafe_cb. This module provides helper types and macros for easily declaring any of the common variants on comparison functions: the 2-parameter untyped form (as used by qsort), the 3-parameter untyped form (used by the asort back end) and the 3-parameter typed form (used by the asort front end). It provides a wrapper macro for doing the typesafe_cb conversion from 3-parameter typed to 3-parameter untyped. It also provides a container struct to describe both a comparison callback and a context value as a single structure. This also comes in both untyped and typed variants. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-06-18ccanlint: handle circular test-depends.Rusty Russell
eg. asort depends on order, but order testdepends on asort. Probably not the greatest thing to do, but don't barf because of it. Reported-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-14lqueue: Allow a queueu to be initialized from an existing back elementDavid Gibson
There are occasional cases where you might construct a valid queue, and retain a direct pointer to the back element, but not the struct lqueue used to build it. This patch adds a new lqueue_init_from_back() macro to reconstruct a valid struct lqueue from the element pointer for cases like this. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-06-14lstack: Allow a stack to be initialized from an existing top elementDavid Gibson
There are occasional cases where you might construct a valid stack, and retain a direct pointer to the top element, but not the struct lstack used to build it. This patch adds a new lstack_init_from_top() macro to reconstruct a valid struct lstack from the element pointer for cases like this. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-06-04opt: add opt_usage_exit_fail.Rusty Russell
I've been using opt_usage_and_exit() but that exits status 0. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-02bitmap: Don't crash if allocation fails in bitmap_alloc0() & friendsKirill Smelkov
Currently, if allocation fails, inside bitmap_alloc0(), we'll continue to use bitmap=NULL pointer and pass it to bitmap_zero() which will SIGSEGV. Cc: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Kirill Smelkov <kirr@nexedi.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-06-01ntdb: don't overlap with test filenames.Rusty Russell
This may have been causing a travis failure. Let's see! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-01One line change to test Travis (now I've turned it on)Rusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-05-28tal: rename tal_dup to tal_dup_arr, make tal_dup simpler.Rusty Russell
It's a bit too powerful, if you just want to memdup one thing, it's hard to remember what the extra args are for. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-05-28Makefile: add ptrintRusty Russell
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-05-28asearch: Add context pointer to asearch comparison callbackDavid Gibson
asearch, like the standard library bsearch, takes a comparison callback. Like bsearch() that callback doesn't include a user supplied context pointer. As well as being generally limiting, that makes the comparison functions used by asearch gratuitously different from those used by the asort module. This patch alters this. Note that this is an incompatible change to the asearch interface. I think this is worth it to correct the oversight, but others might disagree. At present the only user within ccan is ntdb, which is corrected to match. This means actually supplying a binary search implementation, rather than relying on bsearch() from the standard library. We follow the lead of the asort module and steal^H^H^H^H^Hadapt the implementation from glibc. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>