Jeremy Kerr [Thu, 24 May 2012 01:48:00 +0000 (09:48 +0800)]
tools/create-ccan-tree: Add --build-type=TYPE
Replace the --exclude-configurator argument with a
single --build-type=TYPE argument, allowing future expansion of build
system types (and allowing source-tree-only creation). We currently
support:
* 'make' (just the Makefile, equivalent to --exclude-configurator)
* 'make+config' (current default)
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
Jeremy Kerr [Thu, 24 May 2012 03:49:10 +0000 (11:49 +0800)]
tools/create-ccan-tree: replace --exclude-tests with --copy-all option
Rather than explicitly excluding the tests, just copy the source files
by default. Add an option (--copy-all) to include all of the non-source
stuff in each module.
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
Jeremy Kerr [Tue, 22 May 2012 09:19:24 +0000 (17:19 +0800)]
tools: ccan_depends requires a config.h
Commit a77cc282 causes tools/create-ccan-tree to fail, as it can't build
tools/ccan_depends (via `make tools/ccan_depends`) without a
configuration header present.
This change adds a dependency on config.h, so that the configurator
kicks-in prior to building ccan_depends.o.
Other tools don't need this dependency, as tools/ccan_depends is built
during the Makefile 'include' process.
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Jeremy Kerr [Wed, 16 May 2012 03:02:56 +0000 (11:02 +0800)]
tools: Add create-ccan-tree utility
Add a script to create a ccan source tree for inclusion into projects'
distributed code.
create-ccan-tree takes a list of ccan modules and copies them, plus any
dependent modules, into a target directory. Enough build infrastructure
is added to build libccan.a from the ccan modules.
Typical usage for my project that uses talloc and read-write-all:
Rusty Russell [Thu, 29 Mar 2012 04:28:33 +0000 (14:58 +1030)]
cast: make sure suncc sees a constant.
cast_const() et. al. are supposed to be a constant expression, so you can do things like:
static char *p = cast_const(char *, (const char *)"hello");
Unfortunately, a cast to intptr_t and arithmetic makes suncc reject it as
a constant expression. We need the cast, because (1) the expression could be
a void *, so we can't just add to it, and (2) gcc complains with -Wcast-qual
without it.
So instead of adding BUILD_BUG_OR_ZERO, we use a ? :, which keeps everyone happy.
Rusty Russell [Tue, 27 Mar 2012 05:01:27 +0000 (15:31 +1030)]
ccanlint: module_links test must link with module.
Gcc doesn't include unused inline functions, even without -O, but Solaris CC
does, so fails to link block_pool where one inline function refers to a
non-inline function.
Rusty Russell [Mon, 19 Mar 2012 05:14:13 +0000 (15:44 +1030)]
tools: determing ccan directory differently
Don't assume it's two levels above the module dir, instead look for
last "/ccan/" in path. This is an incremental step towards nested
module directories.
Rusty Russell [Thu, 8 Mar 2012 03:44:22 +0000 (14:14 +1030)]
failtest: don't assume FD_SETSIZE is maximum runtime fd.
This breaks when rlimit is less. Unfortunately, valgrind (32 bit x86,
3.7.0.SVN, Ubuntu) fails to set the file limit properly on the test:
reducing it to the obvious getrlimit/setrlimit/getrlimit works fine,
so leaving diagnostics for another day.
Rusty Russell [Tue, 14 Feb 2012 09:39:18 +0000 (20:09 +1030)]
tdb: delete from CCAN.
This was an early experiment in putting code into CCAN, but TDB is a public
library distributed as part of the Samba sources; there is no reason to
publish it here (especially now the unit tests are also in Samba).
Rusty Russell [Tue, 14 Feb 2012 09:34:00 +0000 (20:04 +1030)]
configurator: define HAVE_CCAN.
An interesting case came up with the tdb2 code in SAMBA recently. It's a
public library, and it doesn't want to be dependent on CCAN, but the header
uses cast and typesafe_cb for extra type safety.
A good solution to this is to put dummy versions under !HAVE_CCAN. Of course,
any CCAN config.h should define HAVE_CCAN.
Rusty Russell [Sat, 28 Jan 2012 04:14:43 +0000 (14:44 +1030)]
tdb2: tdb1: use same expansion factor logic when expanding for new recovery area.
If we're expanding because the current recovery area is too small, we
expand only the amount we need. This can quickly lead to exponential
growth when we have a slowly-expanding record (hence a
slowly-expanding transaction size).
Rusty Russell [Wed, 21 Dec 2011 05:44:51 +0000 (16:14 +1030)]
tdb2: be more careful on 4G files (tdb1).
I came across a tdb which had wrapped to 4G + 4K, and the contents had been
destroyed by processes which thought it only 4k long. Fix this by checking
on open, and making tdb_oob() check for wrap itself.
Rusty Russell [Tue, 20 Dec 2011 07:10:57 +0000 (17:40 +1030)]
tdb: don't free old recovery area when expanding if already at EOF.
We allocate a new recovery area by expanding the file. But if the
recovery area is already at the end of file (as shown in at least one
client case), we can simply expand the record, rather than freeing it
and creating a new one.
Rusty Russell [Tue, 20 Dec 2011 07:09:28 +0000 (17:39 +1030)]
tdb: use same expansion factor logic when expanding for new recovery area.
If we're expanding because the current recovery area is too small, we
expand only the amount we need. This can quickly lead to exponential
growth when we have a slowly-expanding record (hence a
slowly-expanding transaction size).
Rusty Russell [Mon, 12 Dec 2011 03:20:05 +0000 (13:50 +1030)]
container_of: add container_off_var macro
Based on patch by Andrey Smirnov <andrew.smirnov@gmail.com>:
There is are certain use-cases when it is necessary to know the offset
of the member in a structure's memory layout. One such use-case can be
seen in `ccan/list/list.h' in macros `list_for_each' and
`list_for_each_safe'. This commit implements said functionality with
`container_of_var_off' macro.
Renamed container_of_var_off -> container_off_var now we have container_off.
Andrey Smirnov [Mon, 12 Dec 2011 03:19:57 +0000 (13:49 +1030)]
Makefile, configurator: Add additional debug flags to CFLAGS
Just adding `-g' to list of CFLAGS doesn't make gcc to generate debug
information required for macro expansion during debugging. Replacing
it with `-g3 -ggdb' rectifies this.
Rusty Russell [Wed, 7 Dec 2011 02:57:14 +0000 (13:27 +1030)]
autodata: add example, clean up description a little.
Also add #include to AUTODATA_TYPE example, so ccanlint doesn't try to
put it inside a function (which works, for this, but gives a warning
about unused variables).
Rusty Russell [Thu, 1 Dec 2011 06:14:51 +0000 (16:44 +1030)]
opt: add OPT_EARLY and opt_early_parse.
Parsing options like --verbose and --debug can be a pain. You need to
have everything set up before invoking parse_args(), but that may be a
significant amount of work, for which you may want verbose or
debugging enabled.
Thus the concept of "early" args: you can nominate arguments to be
parse before anything else, using opt_early_parse().
Rusty Russell [Wed, 30 Nov 2011 01:39:18 +0000 (12:09 +1030)]
tdb2: add a capability list from the header.
This allows even more extensibility in future: in particular, the top
bits of each capability tell us what to do if we don't understand it:
fail the open, fail to open for write, or don't try to check the
format.
tdb_check needs to understand the capability list so it can know to
skip over it: each element in the list is prefixed with the type tag
and the length.