]> git.ozlabs.org Git - ccan/log
ccan
8 years agomem: add memeqzero.
Rusty Russell [Thu, 15 Oct 2015 03:29:43 +0000 (13:59 +1030)]
mem: add memeqzero.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoTravis: do make in parallel to test if that gives slight speedup.
Rusty Russell [Fri, 9 Oct 2015 02:05:28 +0000 (12:35 +1030)]
Travis: do make in parallel to test if that gives slight speedup.

Seems to.  Numbers are noisy, but before was 5 min 32 sec, after this
commit was 3 min 42 sec.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoTravis: upgrade, try using apt dependencies.
Rusty Russell [Fri, 9 Oct 2015 01:43:58 +0000 (12:13 +1030)]
Travis: upgrade, try using apt dependencies.

I've filed bugs to get those dev packages whitelisted:
  https://github.com/travis-ci/apt-package-whitelist/issues/1366
  https://github.com/travis-ci/apt-package-whitelist/issues/1367
  https://github.com/travis-ci/apt-package-whitelist/issues/1368
  https://github.com/travis-ci/apt-package-whitelist/issues/1369

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoccanlint: enhance and streamline "output" testing lines.
Rusty Russell [Mon, 28 Sep 2015 03:14:40 +0000 (12:44 +0930)]
ccanlint: enhance and streamline "output" testing lines.

1) Require "" around input
2) Make them optional around output: if not there, loose match whitespace
3) Handle \n in output.
4) Document that "Given xxx" is optional.
5) Reject any non-matching comment lines starting with "given" or "outputs"
6) Fix missed test in ccan/cast

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agopermutation: Generate permutations of arrays
David Gibson [Mon, 28 Sep 2015 14:59:17 +0000 (00:59 +1000)]
permutation: Generate permutations of arrays

New module.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agomem: add memcheck() for valgrind.
Rusty Russell [Thu, 24 Sep 2015 02:19:40 +0000 (11:49 +0930)]
mem: add memcheck() for valgrind.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoconfigurator: check for valgrind/memcheck.h
Rusty Russell [Thu, 24 Sep 2015 01:50:56 +0000 (11:20 +0930)]
configurator: check for valgrind/memcheck.h

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agostrgrp: Fix compile errors in example
David Gibson [Mon, 14 Sep 2015 11:06:11 +0000 (21:06 +1000)]
strgrp: Fix compile errors in example

Commit 63f13d6 "strgrp: Tidy up kerneldoc in _info" introduced some compile
errors into the example in strgrp/_info.  This fixes them.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agomem: Add memswap() function
David Gibson [Wed, 9 Sep 2015 11:27:32 +0000 (21:27 +1000)]
mem: Add memswap() function

Add a memswap() function to the mem module, which exchanges two (equal
sized, non-overlapping) memory regions.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agomem: Add function to check whether memory ranges overlap
David Gibson [Wed, 9 Sep 2015 08:04:33 +0000 (18:04 +1000)]
mem: Add function to check whether memory ranges overlap

The test is simple, but every time I do it by hand, I always spend ages
convincing myself it's actually correct.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agomem: Remove array_size dependency
David Gibson [Sat, 5 Sep 2015 04:32:24 +0000 (14:32 +1000)]
mem: Remove array_size dependency

The mem module declares array_size as a test dependency, and includes it in
test/api.c, but doesn't actually use it.  This removes the unneeded
dependency.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agostrgrp: Tidy up kerneldoc in _info
Andrew Jeffery [Fri, 11 Sep 2015 12:10:43 +0000 (21:40 +0930)]
strgrp: Tidy up kerneldoc in _info

The documentation as it stood rendered badly in HTML due to a lack of
knowledge of kerneldoc formatting.

8 years agostrgrp: Optionally include OpenMP pragma
Andrew Jeffery [Sat, 5 Sep 2015 14:33:05 +0000 (00:03 +0930)]
strgrp: Optionally include OpenMP pragma

8 years agoccanlint: Add cflags support to _info
Andrew Jeffery [Sat, 5 Sep 2015 13:00:43 +0000 (22:30 +0930)]
ccanlint: Add cflags support to _info

8 years agoconfigurator: Add OpenMP detection
Andrew Jeffery [Sat, 5 Sep 2015 14:09:59 +0000 (23:39 +0930)]
configurator: Add OpenMP detection

8 years agostrgrp: new module
Andrew Jeffery [Thu, 20 Aug 2015 06:16:31 +0000 (15:46 +0930)]
strgrp: new module

8 years agomem: add memends_str() helper for symmetry
Cody P Schafer [Sun, 6 Sep 2015 01:21:06 +0000 (21:21 -0400)]
mem: add memends_str() helper for symmetry

Signed-off-by: Cody P Schafer <dev@codyps.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agomem: mark all functions as PURE
Cody P Schafer [Sun, 6 Sep 2015 01:21:05 +0000 (21:21 -0400)]
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>
8 years agobytestring: use newly added mem helpers
Cody P Schafer [Sun, 6 Sep 2015 01:21:04 +0000 (21:21 -0400)]
bytestring: use newly added mem helpers

Reviwed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Cody P Schafer <dev@codyps.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agomem: add mem helper functions
Cody P Schafer [Sun, 6 Sep 2015 01:21:03 +0000 (21:21 -0400)]
mem: add mem helper functions

Signed-off-by: Cody P Schafer <dev@codyps.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agoarray_size: fix spurious test fail with gcc-5
Rusty Russell [Thu, 20 Aug 2015 01:39:44 +0000 (11:09 +0930)]
array_size: fix spurious test fail with gcc-5

It now warns about sizeof(function-param-not-really-an-array).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agopr_log: a new module that provides a simple run-time controlled logging interface
Cody P Schafer [Wed, 19 Aug 2015 02:29:54 +0000 (22:29 -0400)]
pr_log: a new module that provides a simple run-time controlled logging interface

A simple printf logging infra where levels are determined by the
value of the "DEBUG" environment variable.

This is loosely based on the interfaces & functionality of Linux's
printk() and pr_*() wrapper macros.

Note that the current implementation uses "<N>" prefixes (where N is a
syslog level in ascii), allowing other programs that parse log output
(like systemd's journald) to know what the priority level is.

Signed-off-by: Cody P Schafer <dev@codyps.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agolist: suppress unused argument warnings
Cody P Schafer [Sun, 16 Aug 2015 22:33:48 +0000 (18:33 -0400)]
list: suppress unused argument warnings

Signed-off-by: Cody P Schafer <dev@codyps.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoconfigurator: avoid potential unused parameter warnings hosing our config.h
Cody P Schafer [Sun, 16 Aug 2015 22:54:39 +0000 (18:54 -0400)]
configurator: avoid potential unused parameter warnings hosing our config.h

Signed-off-by: Cody P Schafer <dev@codyps.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoconfigurator: sometimes _GNU_SOURCE is already defined, in those cases avoid redefinition
Cody P Schafer [Sun, 16 Aug 2015 22:54:38 +0000 (18:54 -0400)]
configurator: sometimes _GNU_SOURCE is already defined, in those cases avoid 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>
8 years agoconfigurator: hide type punning
Cody P Schafer [Sun, 16 Aug 2015 22:54:37 +0000 (18:54 -0400)]
configurator: hide type punning

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>
8 years agobytestring: Add rational comment to testcase
David Gibson [Tue, 18 Aug 2015 23:17:02 +0000 (16:17 -0700)]
bytestring: Add rational comment to testcase

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>
8 years agobytestring: avoid compile_fail failure due to uninitialized warning
Cody P Schafer [Tue, 18 Aug 2015 00:33:31 +0000 (20:33 -0400)]
bytestring: avoid compile_fail failure due to uninitialized warning

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>
8 years agotalloc: avoid a comparison mismatch & at the same time switch to non-legacy sysconf()
Cody P Schafer [Sun, 16 Aug 2015 22:58:32 +0000 (18:58 -0400)]
talloc: avoid a comparison mismatch & at the same time switch to non-legacy 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>
8 years agoconfigurator: avoid leaks that LeakSanitizer doesn't like
Cody P Schafer [Sun, 16 Aug 2015 22:54:37 +0000 (18:54 -0400)]
configurator: avoid leaks that LeakSanitizer doesn't like

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)
8 years agocpuid: update inline docs
A. Samy [Sat, 15 Aug 2015 01:13:01 +0000 (01:13 +0000)]
cpuid: update inline docs

Signed-off-by: A. Samy <f.fallen45@gmail.com>
8 years agocpuid: use a hardcoded constant when comparing CPU names
A. Samy [Sat, 15 Aug 2015 01:06:12 +0000 (01:06 +0000)]
cpuid: use a hardcoded constant when comparing CPU names

Signed-off-by: A. Samy <f.fallen45@gmail.com>
8 years agocpuid: fix test.
Rusty Russell [Fri, 14 Aug 2015 00:24:40 +0000 (09:54 +0930)]
cpuid: fix test.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agocpuid: namespacize some functions and define them as null if unsupported
A. Samy [Tue, 11 Aug 2015 05:21:42 +0000 (05:21 +0000)]
cpuid: namespacize some functions and define them as null if unsupported

8 years agocpuid: cpuid_write_info(): have outfile a file pointer instead
A. Samy [Tue, 11 Aug 2015 05:14:57 +0000 (05:14 +0000)]
cpuid: cpuid_write_info(): have outfile a file pointer instead

8 years agocpuid: rename ___cpuid to get_cpuid
A. Samy [Tue, 11 Aug 2015 05:10:15 +0000 (05:10 +0000)]
cpuid: rename ___cpuid to get_cpuid

8 years agocpuid: minor clean up
A. Samy [Tue, 11 Aug 2015 05:09:32 +0000 (05:09 +0000)]
cpuid: minor clean up

8 years agoMakefile-ccan: add new modules.
Rusty Russell [Wed, 12 Aug 2015 02:33:01 +0000 (12:03 +0930)]
Makefile-ccan: add new modules.

I really need to get rid of this...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoagar: Re-entrant Abstract Graph Algorithms
David Gibson [Fri, 17 Jul 2015 14:54:44 +0000 (00:54 +1000)]
agar: Re-entrant Abstract Graph Algorithms

New module

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agoaga: Add lazytrie testcase
David Gibson [Mon, 11 May 2015 10:35:34 +0000 (22:35 +1200)]
aga: Add lazytrie testcase

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>
8 years agoaga: Testcase for attempt to run concurrent algorithms
David Gibson [Thu, 7 May 2015 11:29:19 +0000 (21:29 +1000)]
aga: Testcase for attempt to run concurrent algorithms

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>
8 years agoaga: Breadth first search
David Gibson [Sat, 13 Jun 2015 15:33:23 +0000 (01:33 +1000)]
aga: Breadth first search

This implements breadth first search for the abstract graph algorithms
module.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agoaga: Depth first search
David Gibson [Sat, 13 Jun 2015 15:34:40 +0000 (01:34 +1000)]
aga: Depth first search

This implements depth first search for the abstract graph algorithms
module.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agoaga: Simple test graphs
David Gibson [Thu, 21 May 2015 09:23:19 +0000 (21:23 +1200)]
aga: Simple test graphs

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>
8 years agoaga: Abstract Graph Algorithms
David Gibson [Tue, 21 Jul 2015 11:38:22 +0000 (21:38 +1000)]
aga: Abstract Graph Algorithms

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>
8 years agodaemonize: check setsid() return value
Maxim Zakharov [Thu, 30 Jul 2015 01:58:36 +0000 (11:58 +1000)]
daemonize: check setsid() return value

8 years agodaemonize: exit parent without triggering atexit() processing
Maxim Zakharov [Thu, 30 Jul 2015 01:49:20 +0000 (11:49 +1000)]
daemonize: exit parent without triggering atexit() processing

8 years agoshort_types: Fix warning in test
Joel Stanley [Mon, 20 Jul 2015 06:01:23 +0000 (15:31 +0930)]
short_types: Fix warning in test

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>
8 years agotools/modfiles: include _info (unless requested not to)
Rusty Russell [Thu, 9 Jul 2015 05:31:01 +0000 (15:01 +0930)]
tools/modfiles: include _info (unless requested not to)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agotools/create-ccan-tree: clean up modfiles binary after use.
Rusty Russell [Thu, 9 Jul 2015 05:28:50 +0000 (14:58 +0930)]
tools/create-ccan-tree: clean up modfiles binary after use.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agotools/create-ccan-tree: fix nested modules with -a
Rusty Russell [Thu, 9 Jul 2015 05:20:27 +0000 (14:50 +0930)]
tools/create-ccan-tree: fix nested modules with -a

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>
8 years agotools/modfiles: list files in a module.
Rusty Russell [Thu, 9 Jul 2015 05:04:56 +0000 (14:34 +0930)]
tools/modfiles: list files in a module.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agotools: include LICENSE file in manifest.
Rusty Russell [Thu, 9 Jul 2015 05:04:05 +0000 (14:34 +0930)]
tools: include LICENSE file in manifest.

It's generally a symlink, so the lstat & S_ISREG tests were eliminating it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agotools: don't include submodules in manifest.
Rusty Russell [Thu, 9 Jul 2015 02:56:48 +0000 (12:26 +0930)]
tools: don't include submodules in manifest.

They currently get classed as "other_files"; they should be entirely
ignored.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agocrypto/sha256: add license file for intel code in benchmarks/
Rusty Russell [Thu, 9 Jul 2015 01:05:10 +0000 (10:35 +0930)]
crypto/sha256: add license file for intel code in benchmarks/

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoMakefile-ccan: add order to MOD list.
Rusty Russell [Wed, 8 Jul 2015 06:37:11 +0000 (16:07 +0930)]
Makefile-ccan: add order to MOD list.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agocrypto/ripemd160: new module.
Rusty Russell [Wed, 8 Jul 2015 06:34:50 +0000 (16:04 +0930)]
crypto/ripemd160: new module.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agocrypto/sha256: fix up CCAN_CRYPTO_SHA256_USE_OPENSSL implementation.
Rusty Russell [Wed, 8 Jul 2015 06:33:29 +0000 (16:03 +0930)]
crypto/sha256: fix up CCAN_CRYPTO_SHA256_USE_OPENSSL implementation.

sha256_update_bytes is sha256_update since f989a43b55795c04a6225b392f3f58afd2cd6543.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agocrypto/sha256: include Intel ASM versions in benchmarks.
Rusty Russell [Thu, 25 Jun 2015 07:21:07 +0000 (16:51 +0930)]
crypto/sha256: include Intel ASM versions in benchmarks.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agocrypto/sha256: add benchmark.
Rusty Russell [Thu, 25 Jun 2015 05:58:52 +0000 (15:28 +0930)]
crypto/sha256: add benchmark.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoavl: Use definitions from order module
David Gibson [Thu, 18 Jun 2015 09:30:18 +0000 (19:30 +1000)]
avl: Use definitions from order module

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>
8 years agoasort: Use order module definitions
David Gibson [Thu, 18 Jun 2015 09:29:37 +0000 (19:29 +1000)]
asort: Use order module definitions

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>
8 years agoorder: Scalar comparison functions
David Gibson [Tue, 2 Jun 2015 07:30:58 +0000 (17:30 +1000)]
order: Scalar comparison functions

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>
8 years agoorder: Module for comparison callbacks
David Gibson [Tue, 2 Jun 2015 07:26:49 +0000 (17:26 +1000)]
order: Module for comparison callbacks

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>
8 years agoccanlint: handle circular test-depends.
Rusty Russell [Thu, 18 Jun 2015 03:30:01 +0000 (13:00 +0930)]
ccanlint: handle circular test-depends.

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>
8 years agolqueue: Allow a queueu to be initialized from an existing back element
David Gibson [Sat, 13 Jun 2015 14:24:57 +0000 (00:24 +1000)]
lqueue: Allow a queueu to be initialized from an existing back element

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>
8 years agolstack: Allow a stack to be initialized from an existing top element
David Gibson [Sat, 13 Jun 2015 14:23:39 +0000 (00:23 +1000)]
lstack: Allow a stack to be initialized from an existing top element

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>
8 years agoopt: add opt_usage_exit_fail.
Rusty Russell [Thu, 4 Jun 2015 03:18:18 +0000 (12:48 +0930)]
opt: add opt_usage_exit_fail.

I've been using opt_usage_and_exit() but that exits status 0.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agobitmap: Don't crash if allocation fails in bitmap_alloc0() & friends
Kirill Smelkov [Mon, 1 Jun 2015 15:10:00 +0000 (18:10 +0300)]
bitmap: Don't crash if allocation fails in bitmap_alloc0() & friends

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>
8 years agontdb: don't overlap with test filenames.
Rusty Russell [Mon, 1 Jun 2015 06:50:04 +0000 (16:20 +0930)]
ntdb: don't overlap with test filenames.

This may have been causing a travis failure.  Let's see!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoOne line change to test Travis (now I've turned it on)
Rusty Russell [Mon, 1 Jun 2015 06:38:26 +0000 (16:08 +0930)]
One line change to test Travis (now I've turned it on)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agotal: rename tal_dup to tal_dup_arr, make tal_dup simpler.
Rusty Russell [Thu, 28 May 2015 10:25:42 +0000 (19:55 +0930)]
tal: rename tal_dup to tal_dup_arr, make tal_dup simpler.

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>
8 years agoMakefile: add ptrint
Rusty Russell [Thu, 28 May 2015 03:48:12 +0000 (13:18 +0930)]
Makefile: add ptrint

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoasearch: Add context pointer to asearch comparison callback
David Gibson [Wed, 27 May 2015 14:17:35 +0000 (00:17 +1000)]
asearch: Add context pointer to asearch comparison callback

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>
8 years agoasearch: Correct license tag to LGPL 2.1+
David Gibson [Wed, 27 May 2015 14:17:34 +0000 (00:17 +1000)]
asearch: Correct license tag to LGPL 2.1+

The _info file for asearch currently gives the license as just "LGPL".
That gives a warning from ccanlint, because it interprets that as the
latest LGPL 3 whereas asearch.h and the license link indicate it's actually
LGPL 2.1+.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoptrint: Module for encoding integers into void * pointers
David Gibson [Tue, 26 May 2015 12:56:50 +0000 (22:56 +1000)]
ptrint: Module for encoding integers into void * pointers

For callbacks which need a void * context pointer in the general case,
there are often simpler cases where an integer would suffice.  These are
often handled by casting the integer into a pointer, rather than having
to allocate that integer somewhere.

This adds a module with some helpers for this.  It has some advantages over
direct casts:
  * It uses pointer arithmetic against NULL instead of casts which should
    make it more portable, even to weird platforms with odd representations
    for NULL.  I don't know the C standard well enough to know if it's
    totally portable though.
  * In particular it means that the truth value of the pointer
    representation matches that of the encoded integer.
  * The conversion functions are inlines providing more type safety than
    raw casts.
  * It uses a ptrint_t * type which can be used to mark such pointer
    encoded integers.  ptrint_t is a deliberately incomplete type so such
    pointers can never be dereferenced.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agoMakefile: fix upload target (really this time!)
Rusty Russell [Wed, 27 May 2015 04:26:31 +0000 (13:56 +0930)]
Makefile: fix upload target (really this time!)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoMakefile: more hacks for crypto/ and str/ subdirs.
Rusty Russell [Wed, 27 May 2015 04:22:10 +0000 (13:52 +0930)]
Makefile: more hacks for crypto/ and str/ subdirs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agocrypto/sha256: simplify interface.
Rusty Russell [Wed, 27 May 2015 04:19:20 +0000 (13:49 +0930)]
crypto/sha256: simplify interface.

I misused it by accident: the implied sizeof() is too tricky.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoMakefile: add missing modules.
Rusty Russell [Mon, 25 May 2015 06:31:22 +0000 (16:01 +0930)]
Makefile: add missing modules.

Otherwise their web pages don't get built.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoMakefile: update upload target.
Rusty Russell [Mon, 25 May 2015 06:30:47 +0000 (16:00 +0930)]
Makefile: update upload target.

For ccan core maintainers only, but useful.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agocrypto/shachain: examples and some documentation.
Rusty Russell [Mon, 25 May 2015 06:19:56 +0000 (15:49 +0930)]
crypto/shachain: examples and some documentation.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agocrypto/shachain: enforce that indexes have to be added incrementally.
Rusty Russell [Mon, 25 May 2015 05:51:08 +0000 (15:21 +0930)]
crypto/shachain: enforce that indexes have to be added incrementally.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agocrypto/shachain: detect if we're inserting a bogus hash.
Rusty Russell [Mon, 25 May 2015 05:41:56 +0000 (15:11 +0930)]
crypto/shachain: detect if we're inserting a bogus hash.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agocrypto/shachain: a bit more common code.
Rusty Russell [Mon, 25 May 2015 05:24:28 +0000 (14:54 +0930)]
crypto/shachain: a bit more common code.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agocrypto/shachain: add design document.
Rusty Russell [Mon, 25 May 2015 05:04:15 +0000 (14:34 +0930)]
crypto/shachain: add design document.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agocrypto/shachain: new module
Rusty Russell [Mon, 25 May 2015 04:19:41 +0000 (13:49 +0930)]
crypto/shachain: new module

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agocrypto/sha256: new module.
Rusty Russell [Mon, 25 May 2015 02:08:46 +0000 (11:38 +0930)]
crypto/sha256: new module.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agotools: add HAVE_UNALIGNED_ACCESS test.
Rusty Russell [Sun, 24 May 2015 10:03:05 +0000 (19:33 +0930)]
tools: add HAVE_UNALIGNED_ACCESS test.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agotimer: simple optimization for large number of timers.
Rusty Russell [Wed, 20 May 2015 07:54:22 +0000 (17:24 +0930)]
timer: simple optimization for large number of timers.

This is still pretty stupid, but greatly reduces my routing-sim time.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agotimer: brute force corruption fix.
Rusty Russell [Wed, 20 May 2015 01:21:31 +0000 (10:51 +0930)]
timer: brute force corruption fix.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agotimer: put level-0 optimization directly into find_first.
Rusty Russell [Tue, 19 May 2015 20:51:43 +0000 (06:21 +0930)]
timer: put level-0 optimization directly into find_first.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agotimer: fix two corruption bugs.
Rusty Russell [Tue, 19 May 2015 06:59:54 +0000 (16:29 +0930)]
timer: fix two corruption bugs.

We fill the upper buckets after we've moved on from the first bucket
in this layer.  This means two things:
1) If we have to look at an upper layer, we need to look at the next bucket,
   unless offset is 0.
2) We need to keep looking up layers in the corner case, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agotimer: better dump code.
Rusty Russell [Tue, 19 May 2015 04:52:13 +0000 (14:22 +0930)]
timer: better dump code.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agotimer: fix timer_check() to iterate all levels.
Rusty Russell [Tue, 19 May 2015 02:36:37 +0000 (12:06 +0930)]
timer: fix timer_check() to iterate all levels.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agostr/hex: to-from hexstring conversion routines.
Rusty Russell [Thu, 14 May 2015 06:55:52 +0000 (23:55 -0700)]
str/hex: to-from hexstring conversion routines.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agohtable: add pre-sized option.
Rusty Russell [Tue, 12 May 2015 22:22:29 +0000 (15:22 -0700)]
htable: add pre-sized option.

I thought this was slowing down my program; it turned out they were
all hashing to the same value.  But it might be useful.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoAdd Travis continuous integration
Joel Stanley [Tue, 5 May 2015 11:53:30 +0000 (21:23 +0930)]
Add Travis continuous integration

This enables building of the CCAN and running of all the tests on
https://travis-ci.org/

Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
8 years agodoc: english fixup.
Rusty Russell [Sat, 25 Apr 2015 06:41:55 +0000 (16:11 +0930)]
doc: english fixup.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years agoweb: remove unused db dir
Rusty Russell [Fri, 24 Apr 2015 06:20:54 +0000 (15:50 +0930)]
web: remove unused db dir

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>