lib: Remove ccan
authorVolker Lendecke <vl@samba.org>
Thu, 12 Mar 2015 15:07:54 +0000 (15:07 +0000)
committerMichael Adam <obnox@samba.org>
Tue, 17 Mar 2015 13:06:15 +0000 (14:06 +0100)
The only component, that really used more than tiny bits of ccan was ntdb. Now
that ntdb is gone, ccan is not required anymore either.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Tue Mar 17 14:06:15 CET 2015 on sn-devel-104

210 files changed:
lib/ccan/README [deleted file]
lib/ccan/array_size/_info [deleted file]
lib/ccan/array_size/array_size.h [deleted file]
lib/ccan/array_size/test/compile_fail-function-param.c [deleted file]
lib/ccan/array_size/test/compile_fail.c [deleted file]
lib/ccan/array_size/test/run.c [deleted file]
lib/ccan/asearch/LICENSE [deleted file]
lib/ccan/asearch/_info [deleted file]
lib/ccan/asearch/asearch.h [deleted file]
lib/ccan/asearch/test/compile_fail-return-value-const.c [deleted file]
lib/ccan/asearch/test/compile_fail-return-value.c [deleted file]
lib/ccan/asearch/test/run-strings.c [deleted file]
lib/ccan/asearch/test/run.c [deleted file]
lib/ccan/build_assert/LICENSE [deleted file]
lib/ccan/build_assert/_info [deleted file]
lib/ccan/build_assert/build_assert.h [deleted file]
lib/ccan/build_assert/test/compile_fail-expr.c [deleted file]
lib/ccan/build_assert/test/compile_fail.c [deleted file]
lib/ccan/build_assert/test/compile_ok.c [deleted file]
lib/ccan/build_assert/test/run-BUILD_ASSERT_OR_ZERO.c [deleted file]
lib/ccan/build_assert/test/run-EXPR_BUILD_ASSERT.c [deleted file]
lib/ccan/cast/LICENSE [deleted file]
lib/ccan/cast/_info [deleted file]
lib/ccan/cast/cast.h [deleted file]
lib/ccan/cast/test/compile_fail-cast_const.c [deleted file]
lib/ccan/cast/test/compile_fail-cast_const2.c [deleted file]
lib/ccan/cast/test/compile_fail-cast_const3.c [deleted file]
lib/ccan/cast/test/compile_fail-cast_signed-const.c [deleted file]
lib/ccan/cast/test/compile_fail-cast_signed-sizesame.c [deleted file]
lib/ccan/cast/test/compile_fail-cast_signed.c [deleted file]
lib/ccan/cast/test/compile_fail-cast_static-2.c [deleted file]
lib/ccan/cast/test/compile_fail-cast_static-3.c [deleted file]
lib/ccan/cast/test/compile_fail-cast_static.c [deleted file]
lib/ccan/cast/test/compile_ok-cast_void.c [deleted file]
lib/ccan/cast/test/compile_ok-static.c [deleted file]
lib/ccan/check_type/_info [deleted file]
lib/ccan/check_type/check_type.h [deleted file]
lib/ccan/check_type/test/compile_fail-check_type.c [deleted file]
lib/ccan/check_type/test/compile_fail-check_type_unsigned.c [deleted file]
lib/ccan/check_type/test/compile_fail-check_types_match.c [deleted file]
lib/ccan/check_type/test/run.c [deleted file]
lib/ccan/compiler/LICENSE [deleted file]
lib/ccan/compiler/_info [deleted file]
lib/ccan/compiler/compiler.h [deleted file]
lib/ccan/compiler/test/compile_fail-printf.c [deleted file]
lib/ccan/compiler/test/run-is_compile_constant.c [deleted file]
lib/ccan/container_of/_info [deleted file]
lib/ccan/container_of/container_of.h [deleted file]
lib/ccan/container_of/test/compile_fail-bad-type.c [deleted file]
lib/ccan/container_of/test/compile_fail-types.c [deleted file]
lib/ccan/container_of/test/compile_fail-var-types.c [deleted file]
lib/ccan/container_of/test/run.c [deleted file]
lib/ccan/endian/LICENSE [deleted file]
lib/ccan/endian/_info [deleted file]
lib/ccan/endian/endian.h [deleted file]
lib/ccan/endian/test/run.c [deleted file]
lib/ccan/err/.depends [deleted file]
lib/ccan/err/_info [deleted file]
lib/ccan/err/err.c [deleted file]
lib/ccan/err/err.h [deleted file]
lib/ccan/err/test/run.c [deleted file]
lib/ccan/failtest/LICENSE [deleted file]
lib/ccan/failtest/_info [deleted file]
lib/ccan/failtest/failtest.c [deleted file]
lib/ccan/failtest/failtest.d [deleted file]
lib/ccan/failtest/failtest.h [deleted file]
lib/ccan/failtest/failtest_override.h [deleted file]
lib/ccan/failtest/failtest_proto.h [deleted file]
lib/ccan/failtest/failtest_undo.h [deleted file]
lib/ccan/failtest/test/run-failpath.c [deleted file]
lib/ccan/failtest/test/run-history.c [deleted file]
lib/ccan/failtest/test/run-locking.c [deleted file]
lib/ccan/failtest/test/run-malloc.c [deleted file]
lib/ccan/failtest/test/run-open.c [deleted file]
lib/ccan/failtest/test/run-with-fdlimit.c [deleted file]
lib/ccan/failtest/test/run-write.c [deleted file]
lib/ccan/hash/_info [deleted file]
lib/ccan/hash/hash.c [deleted file]
lib/ccan/hash/hash.h [deleted file]
lib/ccan/hash/test/api-hash_stable.c [deleted file]
lib/ccan/hash/test/run.c [deleted file]
lib/ccan/htable/LICENSE [deleted file]
lib/ccan/htable/_info [deleted file]
lib/ccan/htable/htable.c [deleted file]
lib/ccan/htable/htable.h [deleted file]
lib/ccan/htable/htable_type.h [deleted file]
lib/ccan/htable/test/run-size.c [deleted file]
lib/ccan/htable/test/run-type.c [deleted file]
lib/ccan/htable/test/run.c [deleted file]
lib/ccan/htable/tools/Makefile [deleted file]
lib/ccan/htable/tools/hsearchspeed.c [deleted file]
lib/ccan/htable/tools/speed.c [deleted file]
lib/ccan/htable/tools/stringspeed.c [deleted file]
lib/ccan/ilog/LICENSE [deleted file]
lib/ccan/ilog/_info [deleted file]
lib/ccan/ilog/ilog.c [deleted file]
lib/ccan/ilog/ilog.h [deleted file]
lib/ccan/ilog/test/run-out-of-line.c [deleted file]
lib/ccan/ilog/test/run.c [deleted file]
lib/ccan/likely/LICENSE [deleted file]
lib/ccan/likely/_info [deleted file]
lib/ccan/likely/likely.c [deleted file]
lib/ccan/likely/likely.h [deleted file]
lib/ccan/likely/test/run-debug.c [deleted file]
lib/ccan/likely/test/run.c [deleted file]
lib/ccan/list/.namespacize [deleted file]
lib/ccan/list/LICENSE [deleted file]
lib/ccan/list/_info [deleted file]
lib/ccan/list/list.c [deleted file]
lib/ccan/list/list.d [deleted file]
lib/ccan/list/list.h [deleted file]
lib/ccan/list/test/compile_ok-constant.c [deleted file]
lib/ccan/list/test/helper.c [deleted file]
lib/ccan/list/test/helper.h [deleted file]
lib/ccan/list/test/run-check-corrupt.c [deleted file]
lib/ccan/list/test/run-list_del_from-assert.c [deleted file]
lib/ccan/list/test/run-single-eval.c [deleted file]
lib/ccan/list/test/run-with-debug.c [deleted file]
lib/ccan/list/test/run.c [deleted file]
lib/ccan/read_write_all/LICENSE [deleted file]
lib/ccan/read_write_all/_info [deleted file]
lib/ccan/read_write_all/read_write_all.c [deleted file]
lib/ccan/read_write_all/read_write_all.d [deleted file]
lib/ccan/read_write_all/read_write_all.h [deleted file]
lib/ccan/read_write_all/test/run-read_all.c [deleted file]
lib/ccan/read_write_all/test/run-write_all.c [deleted file]
lib/ccan/str/_info [deleted file]
lib/ccan/str/debug.c [deleted file]
lib/ccan/str/str.c [deleted file]
lib/ccan/str/str.h [deleted file]
lib/ccan/str/str_debug.h [deleted file]
lib/ccan/str/test/compile_fail-isalnum.c [deleted file]
lib/ccan/str/test/compile_fail-isalpha.c [deleted file]
lib/ccan/str/test/compile_fail-isascii.c [deleted file]
lib/ccan/str/test/compile_fail-isblank.c [deleted file]
lib/ccan/str/test/compile_fail-iscntrl.c [deleted file]
lib/ccan/str/test/compile_fail-isdigit.c [deleted file]
lib/ccan/str/test/compile_fail-islower.c [deleted file]
lib/ccan/str/test/compile_fail-isprint.c [deleted file]
lib/ccan/str/test/compile_fail-ispunct.c [deleted file]
lib/ccan/str/test/compile_fail-isspace.c [deleted file]
lib/ccan/str/test/compile_fail-isupper.c [deleted file]
lib/ccan/str/test/compile_fail-isxdigit.c [deleted file]
lib/ccan/str/test/compile_fail-strchr.c [deleted file]
lib/ccan/str/test/compile_fail-strrchr.c [deleted file]
lib/ccan/str/test/compile_fail-strstr.c [deleted file]
lib/ccan/str/test/debug.c [deleted file]
lib/ccan/str/test/run.c [deleted file]
lib/ccan/strset/tools/Makefile [deleted file]
lib/ccan/strset/tools/cbspeed.c [deleted file]
lib/ccan/strset/tools/speed.c [deleted file]
lib/ccan/tally/LICENSE [deleted file]
lib/ccan/tally/_info [deleted file]
lib/ccan/tally/tally.c [deleted file]
lib/ccan/tally/tally.h [deleted file]
lib/ccan/tally/test/run-bucket_of.c [deleted file]
lib/ccan/tally/test/run-divlu64.c [deleted file]
lib/ccan/tally/test/run-histogram.c [deleted file]
lib/ccan/tally/test/run-mean.c [deleted file]
lib/ccan/tally/test/run-median.c [deleted file]
lib/ccan/tally/test/run-min-max.c [deleted file]
lib/ccan/tally/test/run-mode.c [deleted file]
lib/ccan/tally/test/run-renormalize.c [deleted file]
lib/ccan/tally/test/run-total.c [deleted file]
lib/ccan/tcon/_info [deleted file]
lib/ccan/tcon/tcon.h [deleted file]
lib/ccan/tcon/test/compile_fail-tcon_cast.c [deleted file]
lib/ccan/tcon/test/compile_fail.c [deleted file]
lib/ccan/tcon/test/compile_ok-void.c [deleted file]
lib/ccan/tcon/test/compile_ok.c [deleted file]
lib/ccan/time/LICENSE [deleted file]
lib/ccan/time/_info [deleted file]
lib/ccan/time/test/run.c [deleted file]
lib/ccan/time/time.c [deleted file]
lib/ccan/time/time.d [deleted file]
lib/ccan/time/time.h [deleted file]
lib/ccan/tlist/LICENSE [deleted file]
lib/ccan/tlist/_info [deleted file]
lib/ccan/tlist/test/compile_fail-tlist_add.c [deleted file]
lib/ccan/tlist/test/compile_fail-tlist_add_tail.c [deleted file]
lib/ccan/tlist/test/compile_fail-tlist_del_from.c [deleted file]
lib/ccan/tlist/test/compile_fail-tlist_for_each.c [deleted file]
lib/ccan/tlist/test/compile_fail-tlist_for_each_safe.c [deleted file]
lib/ccan/tlist/test/compile_fail-tlist_tail.c [deleted file]
lib/ccan/tlist/test/compile_fail-tlist_top.c [deleted file]
lib/ccan/tlist/test/run.c [deleted file]
lib/ccan/tlist/tlist.h [deleted file]
lib/ccan/typesafe_cb/LICENSE [deleted file]
lib/ccan/typesafe_cb/_info [deleted file]
lib/ccan/typesafe_cb/test/compile_fail-cast_if_any.c [deleted file]
lib/ccan/typesafe_cb/test/compile_fail-cast_if_type-promotable.c [deleted file]
lib/ccan/typesafe_cb/test/compile_fail-cast_if_type.c [deleted file]
lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb-int.c [deleted file]
lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb.c [deleted file]
lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_cast-multi.c [deleted file]
lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_cast.c [deleted file]
lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_exact.c [deleted file]
lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_postargs.c [deleted file]
lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_preargs.c [deleted file]
lib/ccan/typesafe_cb/test/compile_ok-cast_if_any.c [deleted file]
lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c [deleted file]
lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb-const.c [deleted file]
lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb-undefined.c [deleted file]
lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb-vars.c [deleted file]
lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb-volatile.c [deleted file]
lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb_cast.c [deleted file]
lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb_def-const.c [deleted file]
lib/ccan/typesafe_cb/test/run.c [deleted file]
lib/ccan/typesafe_cb/typesafe_cb.h [deleted file]
lib/ccan/wscript [deleted file]

diff --git a/lib/ccan/README b/lib/ccan/README
deleted file mode 100644 (file)
index 5ba0a32..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-These files are from the CCAN project (http://ccan.ozlabs.org); the
-_info and LICENSE files in each directory indicate their (separate)
-licenses.
-
-I'm trying to keep them in sync with the upstream versions as much as
-possible, so please be careful!
-
-Thanks!
-Rusty Russell <rusty@rustcorp.com.au>
diff --git a/lib/ccan/array_size/_info b/lib/ccan/array_size/_info
deleted file mode 100644 (file)
index 0ecb45d..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * array_size - routine for safely deriving the size of a visible array.
- *
- * This provides a simple ARRAY_SIZE() macro, which (given a good compiler)
- * will also break compile if you try to use it on a pointer.
- *
- * This can ensure your code is robust to changes, without needing a gratuitous
- * macro or constant.
- *
- * Example:
- *     // Outputs "Initialized 32 values"
- *     #include <ccan/array_size/array_size.h>
- *     #include <stdlib.h>
- *     #include <stdio.h>
- *
- *     // We currently use 32 random values.
- *     static unsigned int vals[32];
- *
- *     int main(void)
- *     {
- *             unsigned int i;
- *             for (i = 0; i < ARRAY_SIZE(vals); i++)
- *                     vals[i] = random();
- *             printf("Initialized %u values\n", i);
- *             return 0;
- *     }
- *
- * License: Public domain
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               printf("ccan/build_assert\n");
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/array_size/array_size.h b/lib/ccan/array_size/array_size.h
deleted file mode 100644 (file)
index 0876945..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef CCAN_ARRAY_SIZE_H
-#define CCAN_ARRAY_SIZE_H
-#include "config.h"
-#include <ccan/build_assert/build_assert.h>
-
-/**
- * ARRAY_SIZE - get the number of elements in a visible array
- * @arr: the array whose size you want.
- *
- * This does not work on pointers, or arrays declared as [], or
- * function parameters.  With correct compiler support, such usage
- * will cause a build error (see build_assert).
- */
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + _array_size_chk(arr))
-
-#if HAVE_BUILTIN_TYPES_COMPATIBLE_P && HAVE_TYPEOF
-/* Two gcc extensions.
- * &a[0] degrades to a pointer: a different type from an array */
-#define _array_size_chk(arr)                                           \
-       BUILD_ASSERT_OR_ZERO(!__builtin_types_compatible_p(typeof(arr), \
-                                                       typeof(&(arr)[0])))
-#else
-#define _array_size_chk(arr) 0
-#endif
-#endif /* CCAN_ALIGNOF_H */
diff --git a/lib/ccan/array_size/test/compile_fail-function-param.c b/lib/ccan/array_size/test/compile_fail-function-param.c
deleted file mode 100644 (file)
index cb64d98..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <ccan/array_size/array_size.h>
-#include <stdlib.h>
-
-struct foo {
-       unsigned int a, b;
-};
-
-int check_parameter(const struct foo array[4]);
-int check_parameter(const struct foo array[4])
-{
-#ifdef FAIL
-       return (ARRAY_SIZE(array) == 4);
-#if !HAVE_TYPEOF || !HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if _array_size_chk is a noop."
-#endif
-#else
-       return sizeof(array) == 4 * sizeof(struct foo);
-#endif
-}
-
-int main(int argc, char *argv[])
-{
-       return check_parameter(NULL);
-}
diff --git a/lib/ccan/array_size/test/compile_fail.c b/lib/ccan/array_size/test/compile_fail.c
deleted file mode 100644 (file)
index 37d315f..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <ccan/array_size/array_size.h>
-
-int main(int argc, char *argv[8])
-{
-       char array[100];
-#ifdef FAIL
-       return ARRAY_SIZE(argv) + ARRAY_SIZE(array);
-#if !HAVE_TYPEOF || !HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if _array_size_chk is a noop."
-#endif
-#else
-       return ARRAY_SIZE(array);
-#endif
-}
diff --git a/lib/ccan/array_size/test/run.c b/lib/ccan/array_size/test/run.c
deleted file mode 100644 (file)
index 37b4200..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <ccan/array_size/array_size.h>
-#include <ccan/tap/tap.h>
-
-static char array1[1];
-static int array2[2];
-static unsigned long array3[3][5];
-struct foo {
-       unsigned int a, b;
-       char string[100];
-};
-static struct foo array4[4];
-
-/* Make sure they can be used in initializers. */
-static int array1_size = ARRAY_SIZE(array1);
-static int array2_size = ARRAY_SIZE(array2);
-static int array3_size = ARRAY_SIZE(array3);
-static int array4_size = ARRAY_SIZE(array4);
-
-int main(int argc, char *argv[])
-{
-       plan_tests(8);
-       ok1(array1_size == 1);
-       ok1(array2_size == 2);
-       ok1(array3_size == 3);
-       ok1(array4_size == 4);
-
-       ok1(ARRAY_SIZE(array1) == 1);
-       ok1(ARRAY_SIZE(array2) == 2);
-       ok1(ARRAY_SIZE(array3) == 3);
-       ok1(ARRAY_SIZE(array4) == 4);
-
-       return exit_status();
-}
diff --git a/lib/ccan/asearch/LICENSE b/lib/ccan/asearch/LICENSE
deleted file mode 100644 (file)
index 5522aa5..0000000
+++ /dev/null
@@ -1,508 +0,0 @@
-
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
-       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL.  It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
-                            Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations
-below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-\f
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it
-becomes a de-facto standard.  To achieve this, non-free programs must
-be allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-\f
-                  GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control
-compilation and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-\f
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at least
-    three years, to give the same user the materials specified in
-    Subsection 6a, above, for a charge no more than the cost of
-    performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-\f
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply, and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License
-may add an explicit geographical distribution limitation excluding those
-countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-                            NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-                     END OF TERMS AND CONDITIONS
-\f
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms
-of the ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.
-It is safest to attach them to the start of each source file to most
-effectively convey the exclusion of warranty; and each file should
-have at least the "copyright" line and a pointer to where the full
-notice is found.
-
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or
-your school, if any, to sign a "copyright disclaimer" for the library,
-if necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James
-  Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/lib/ccan/asearch/_info b/lib/ccan/asearch/_info
deleted file mode 100644 (file)
index 4bfe40a..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * asearch - typesafe binary search (bsearch)
- *
- * An ordered array of objects can be efficiently searched using a binary
- * search algorithm; the time taken is around log(number of elements).
- *
- * This version uses macros to be typesafe on platforms which support it.
- *
- * License: LGPL
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- *
- * Example:
- *     #include <ccan/asearch/asearch.h>
- *     #include <stdio.h>
- *     #include <string.h>
- *
- *     static int cmp(const char *key, char *const *elem)
- *     {
- *             return strcmp(key, *elem);
- *     }
- *
- *     int main(int argc, char *argv[])
- *     {
- *             char **p;
- *
- *             if (argc < 2) {
- *                     fprintf(stderr, "Usage: %s <key> <list>...\n"
- *                             "Print position of key in (sorted) list\n",
- *                             argv[0]);
- *                     exit(1);
- *             }
- *
- *             p = asearch(argv[1], &argv[2], argc-2, cmp);
- *             if (!p) {
- *                     printf("Not found!\n");
- *                     return 1;
- *             }
- *             printf("%u\n", (int)(p - &argv[2]));
- *             return 0;
- *     }
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               printf("ccan/typesafe_cb\n");
-               printf("ccan/array_size\n");
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/asearch/asearch.h b/lib/ccan/asearch/asearch.h
deleted file mode 100644 (file)
index aae6eed..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Licensed under LGPLv2.1+ - see LICENSE file for details */
-#ifndef CCAN_ASEARCH_H
-#define CCAN_ASEARCH_H
-#include <stdlib.h>
-#include <ccan/typesafe_cb/typesafe_cb.h>
-
-/**
- * asearch - search an array of elements
- * @key: pointer to item being searched for
- * @base: pointer to data to sort
- * @num: number of elements
- * @cmp: pointer to comparison function
- *
- * This function does a binary search on the given array.  The
- * contents of the array should already be in ascending sorted order
- * under the provided comparison function.
- *
- * Note that the key need not have the same type as the elements in
- * the array, e.g. key could be a string and the comparison function
- * could compare the string with the struct's name field.  However, if
- * the key and elements in the array are of the same type, you can use
- * the same comparison function for both sort() and asearch().
- */
-#if HAVE_TYPEOF
-#define asearch(key, base, num, cmp)                                   \
-       ((__typeof__(*(base))*)(bsearch((key), (base), (num), sizeof(*(base)), \
-               typesafe_cb_cast(int (*)(const void *, const void *),   \
-                                int (*)(const __typeof__(*(key)) *,    \
-                                        const __typeof__(*(base)) *),  \
-                                (cmp)))))
-
-#else
-#define asearch(key, base, num, cmp)                           \
-       (bsearch((key), (base), (num), sizeof(*(base)),         \
-                (int (*)(const void *, const void *))(cmp)))
-#endif
-
-#endif /* CCAN_ASEARCH_H */
diff --git a/lib/ccan/asearch/test/compile_fail-return-value-const.c b/lib/ccan/asearch/test/compile_fail-return-value-const.c
deleted file mode 100644 (file)
index 2edee93..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <ccan/asearch/asearch.h>
-#include <ccan/array_size/array_size.h>
-#include <string.h>
-
-static int cmp(const char *key, const char *const *elem)
-{
-       return strcmp(key, *elem);
-}
-
-int main(void)
-{
-       const char key[] = "key";
-       const char *elems[] = { "a", "big", "list", "of", "things" };
-
-#ifdef FAIL
-       char **p;
-#if !HAVE_TYPEOF
-#error "Unfortunately we don't fail if no typeof."
-#endif
-#else
-       const char **p;
-#endif
-       p = asearch(key, elems, ARRAY_SIZE(elems), cmp);
-       return p ? 0 : 1;
-}
diff --git a/lib/ccan/asearch/test/compile_fail-return-value.c b/lib/ccan/asearch/test/compile_fail-return-value.c
deleted file mode 100644 (file)
index 4aef532..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <ccan/asearch/asearch.h>
-
-static int cmp(const char *key, char *const *elem)
-{
-       return 0;
-}
-
-int main(int argc, char **argv)
-{
-       const char key[] = "key";
-
-#ifdef FAIL
-       int **p;
-#if !HAVE_TYPEOF
-#error "Unfortunately we don't fail if no typeof."
-#endif
-#else
-       char **p;
-#endif
-       p = asearch(key, argv+1, argc-1, cmp);
-       return p ? 0 : 1;
-}
diff --git a/lib/ccan/asearch/test/run-strings.c b/lib/ccan/asearch/test/run-strings.c
deleted file mode 100644 (file)
index 3ec4538..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <ccan/asearch/asearch.h>
-#include <ccan/array_size/array_size.h>
-#include <ccan/tap/tap.h>
-#include <stdlib.h>
-
-static int cmp(const int *key, const char *const *elem)
-{
-       return *key - atoi(*elem);
-}
-
-int main(void)
-{
-       const char *args[] = { "1", "4", "7", "9" };
-       int key = 7;
-       const char **p;
-
-       plan_tests(1);
-       p = asearch(&key, args, ARRAY_SIZE(args), cmp);
-       ok1(p == &args[2]);
-
-       return exit_status();
-}
diff --git a/lib/ccan/asearch/test/run.c b/lib/ccan/asearch/test/run.c
deleted file mode 100644 (file)
index 2a896fc..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <ccan/asearch/asearch.h>
-#include <ccan/array_size/array_size.h>
-#include <ccan/tap/tap.h>
-#include <limits.h>
-
-static int test_cmp(const int *key, const int *elt)
-{
-       if (*key < *elt)
-               return -1;
-       else if (*key > *elt)
-               return 1;
-       return 0;
-}
-
-int main(void)
-{
-       const int arr[] = { INT_MIN, 0, 1, 2, 3, 4, 5, 6, INT_MAX };
-       unsigned int start, num, i, total = 0;
-       int key;
-
-       plan_tests(285);
-
-       for (start = 0; start < ARRAY_SIZE(arr); start++) {
-               for (num = 0; num < ARRAY_SIZE(arr) - start; num++) {
-                       key = 7;
-                       ok1(asearch(&key, &arr[start], num, test_cmp) == NULL);
-                       total++;
-                       for (i = start; i < start+num; i++) {
-                               const int *ret;
-                               key = arr[i];
-                               ret = asearch(&key, &arr[start], num, test_cmp);
-                               ok1(ret);
-                               ok1(ret && *ret == key);
-                               total++;
-                       }
-               }
-       }
-       diag("Tested %u searches\n", total);
-       return exit_status();
-}
diff --git a/lib/ccan/build_assert/LICENSE b/lib/ccan/build_assert/LICENSE
deleted file mode 100644 (file)
index 5522aa5..0000000
+++ /dev/null
@@ -1,508 +0,0 @@
-
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
-       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL.  It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
-                            Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations
-below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-\f
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it
-becomes a de-facto standard.  To achieve this, non-free programs must
-be allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-\f
-                  GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control
-compilation and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-\f
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at least
-    three years, to give the same user the materials specified in
-    Subsection 6a, above, for a charge no more than the cost of
-    performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-\f
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply, and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License
-may add an explicit geographical distribution limitation excluding those
-countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-                            NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-                     END OF TERMS AND CONDITIONS
-\f
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms
-of the ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.
-It is safest to attach them to the start of each source file to most
-effectively convey the exclusion of warranty; and each file should
-have at least the "copyright" line and a pointer to where the full
-notice is found.
-
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or
-your school, if any, to sign a "copyright disclaimer" for the library,
-if necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James
-  Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/lib/ccan/build_assert/_info b/lib/ccan/build_assert/_info
deleted file mode 100644 (file)
index 284c6cf..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * build_assert - routines for build-time assertions
- *
- * This code provides routines which will cause compilation to fail should some
- * assertion be untrue: such failures are preferable to run-time assertions,
- * but much more limited since they can only depends on compile-time constants.
- *
- * These assertions are most useful when two parts of the code must be kept in
- * sync: it is better to avoid such cases if possible, but seconds best is to
- * detect invalid changes at build time.
- *
- * For example, a tricky piece of code might rely on a certain element being at
- * the start of the structure.  To ensure that future changes don't break it,
- * you would catch such changes in your code like so:
- *
- * Example:
- *     #include <stddef.h>
- *     #include <ccan/build_assert/build_assert.h>
- *
- *     struct foo {
- *             char string[5];
- *             int x;
- *     };
- *
- *     static char *foo_string(struct foo *foo)
- *     {
- *             // This trick requires that the string be first in the structure
- *             BUILD_ASSERT(offsetof(struct foo, string) == 0);
- *             return (char *)foo;
- *     }
- *
- * License: Public domain
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0)
-               /* Nothing. */
-               return 0;
-
-       return 1;
-}
diff --git a/lib/ccan/build_assert/build_assert.h b/lib/ccan/build_assert/build_assert.h
deleted file mode 100644 (file)
index 24e59c4..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef CCAN_BUILD_ASSERT_H
-#define CCAN_BUILD_ASSERT_H
-
-/**
- * BUILD_ASSERT - assert a build-time dependency.
- * @cond: the compile-time condition which must be true.
- *
- * Your compile will fail if the condition isn't true, or can't be evaluated
- * by the compiler.  This can only be used within a function.
- *
- * Example:
- *     #include <stddef.h>
- *     ...
- *     static char *foo_to_char(struct foo *foo)
- *     {
- *             // This code needs string to be at start of foo.
- *             BUILD_ASSERT(offsetof(struct foo, string) == 0);
- *             return (char *)foo;
- *     }
- */
-#define BUILD_ASSERT(cond) \
-       do { (void) sizeof(char [1 - 2*!(cond)]); } while(0)
-
-/**
- * BUILD_ASSERT_OR_ZERO - assert a build-time dependency, as an expression.
- * @cond: the compile-time condition which must be true.
- *
- * Your compile will fail if the condition isn't true, or can't be evaluated
- * by the compiler.  This can be used in an expression: its value is "0".
- *
- * Example:
- *     #define foo_to_char(foo)                                        \
- *              ((char *)(foo)                                         \
- *               + BUILD_ASSERT_OR_ZERO(offsetof(struct foo, string) == 0))
- */
-#define BUILD_ASSERT_OR_ZERO(cond) \
-       (sizeof(char [1 - 2*!(cond)]) - 1)
-
-#endif /* CCAN_BUILD_ASSERT_H */
diff --git a/lib/ccan/build_assert/test/compile_fail-expr.c b/lib/ccan/build_assert/test/compile_fail-expr.c
deleted file mode 100644 (file)
index 109215b..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <ccan/build_assert/build_assert.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-       return BUILD_ASSERT_OR_ZERO(1 == 0);
-#else
-       return 0;
-#endif
-}
diff --git a/lib/ccan/build_assert/test/compile_fail.c b/lib/ccan/build_assert/test/compile_fail.c
deleted file mode 100644 (file)
index 37d95ed..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <ccan/build_assert/build_assert.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-       BUILD_ASSERT(1 == 0);
-#endif
-       return 0;
-}
diff --git a/lib/ccan/build_assert/test/compile_ok.c b/lib/ccan/build_assert/test/compile_ok.c
deleted file mode 100644 (file)
index 4105484..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <ccan/build_assert/build_assert.h>
-
-int main(int argc, char *argv[])
-{
-       BUILD_ASSERT(1 == 1);
-       return 0;
-}
diff --git a/lib/ccan/build_assert/test/run-BUILD_ASSERT_OR_ZERO.c b/lib/ccan/build_assert/test/run-BUILD_ASSERT_OR_ZERO.c
deleted file mode 100644 (file)
index 4185821..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <ccan/build_assert/build_assert.h>
-#include <ccan/tap/tap.h>
-
-int main(int argc, char *argv[])
-{
-       plan_tests(1);
-       ok1(BUILD_ASSERT_OR_ZERO(1 == 1) == 0);
-       return exit_status();
-}
diff --git a/lib/ccan/build_assert/test/run-EXPR_BUILD_ASSERT.c b/lib/ccan/build_assert/test/run-EXPR_BUILD_ASSERT.c
deleted file mode 100644 (file)
index 91bbbbb..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <ccan/build_assert/build_assert.h>
-#include <ccan/tap/tap.h>
-
-int main(int argc, char *argv[])
-{
-       plan_tests(1);
-       ok1(EXPR_BUILD_ASSERT(1 == 1) == 0);
-       return exit_status();
-}
diff --git a/lib/ccan/cast/LICENSE b/lib/ccan/cast/LICENSE
deleted file mode 100644 (file)
index 2d2d780..0000000
+++ /dev/null
@@ -1,510 +0,0 @@
-
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
-       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL.  It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
-                            Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations
-below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-\f
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it
-becomes a de-facto standard.  To achieve this, non-free programs must
-be allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-\f
-                  GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control
-compilation and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-\f
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at least
-    three years, to give the same user the materials specified in
-    Subsection 6a, above, for a charge no more than the cost of
-    performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-\f
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply, and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License
-may add an explicit geographical distribution limitation excluding those
-countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-                            NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-                     END OF TERMS AND CONDITIONS
-\f
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms
-of the ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.
-It is safest to attach them to the start of each source file to most
-effectively convey the exclusion of warranty; and each file should
-have at least the "copyright" line and a pointer to where the full
-notice is found.
-
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or
-your school, if any, to sign a "copyright disclaimer" for the library,
-if necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James
-  Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
-
-
diff --git a/lib/ccan/cast/_info b/lib/ccan/cast/_info
deleted file mode 100644 (file)
index cd5dd45..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-#include <string.h>
-#include "config.h"
-
-/**
- * cast - routines for safer casting.
- *
- * Often you want to cast in a limited way, such as removing a const or
- * switching between integer types.  However, normal casts will work on
- * almost any type, making them dangerous when the code changes.
- *
- * These C++-inspired macros serve two purposes: they make it clear the
- * exact reason for the cast, and they also (with some compilers) cause
- * errors when misused.
- *
- * Based on Jan Engelhardt's libHX macros: http://libhx.sourceforge.net/
- *
- * Author: Jan Engelhardt
- * Maintainer: Rusty Russell <rusty@rustcorp.com.au>
- * License: LGPL (v2.1 or any later version)
- *
- * Example:
- *     // Given "test" contains "3 t's in 'test string'
- *     #include <ccan/cast/cast.h>
- *     #include <stdint.h>
- *     #include <stdio.h>
- *
- *     // Find char @orig in @str, if @repl, replace them.  Return number.
- *     static size_t find_chars(char *str, char orig, char repl)
- *     {
- *             size_t i, count = 0;
- *             for (i = 0; str[i]; i++) {
- *                     if (str[i] == orig) {
- *                             count++;
- *                             if (repl)
- *                                     str[i] = repl;
- *                     }
- *             }
- *             return count;
- *     }
- *
- *     // Terrible hash function.
- *     static uint64_t hash_string(const unsigned char *str)
- *     {
- *             size_t i;
- *             uint64_t hash = 0;
- *             for (i = 0; str[i]; i++)
- *                     hash += str[i];
- *             return hash;
- *     }
- *
- *     int main(int argc, char *argv[])
- *     {
- *             uint64_t hash;
- *
- *             // find_chars wants a non-const string, but doesn't
- *             // need it if repl == 0.
- *             printf("%zu %c's in 'test string'\n",
- *                    find_chars(cast_const(char *, "test string"),
- *                               argv[1][0], 0),
- *                    argv[1][0]);
- *
- *             // hash_string wants an unsigned char.
- *             hash = hash_string(cast_signed(unsigned char *, argv[1]));
- *
- *             // Need a long long to hand to printf.
- *             printf("Hash of '%s' = %llu\n", argv[1],
- *                    cast_static(unsigned long long, hash));
- *             return 0;
- *     }
- *
- */
-int main(int argc, char *argv[])
-{
-       /* Expect exactly one argument */
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               printf("ccan/build_assert\n");
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/cast/cast.h b/lib/ccan/cast/cast.h
deleted file mode 100644 (file)
index 1f3a7aa..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/* Licensed under LGPLv2.1+ - see LICENSE file for details */
-#ifndef CCAN_CAST_H
-#define CCAN_CAST_H
-#include "config.h"
-#include <stdint.h>
-#include <ccan/build_assert/build_assert.h>
-
-/**
- * cast_signed - cast a (const) char * to/from (const) signed/unsigned char *.
- * @type: some char * variant.
- * @expr: expression (of some char * variant) to cast.
- *
- * Some libraries insist on an unsigned char in various places; cast_signed
- * makes sure (with suitable compiler) that the expression you are casting
- * only differs in signed/unsigned, not in type or const-ness.
- */
-#define cast_signed(type, expr)                                                \
-       (0 ? BUILD_ASSERT_OR_ZERO(cast_sign_compatible(type, (expr))) : \
-        (type)(expr))
-
-/**
- * cast_const - remove a const qualifier from a pointer.
- * @type: some pointer type.
- * @expr: expression to cast.
- *
- * This ensures that you are only removing the const qualifier from an
- * expression.  The expression must otherwise match @type.
- *
- * We cast via intptr_t to suppress gcc's -Wcast-qual (which SAMBA
- * uses), and via the ? : so Sun CC doesn't complain about the result
- * not being constant.
- *
- * If @type is a pointer to a pointer, you must use cast_const2 (etc).
- *
- * Example:
- *     // Dumb open-coded strstr variant.
- *     static char *find_needle(const char *haystack)
- *     {
- *             size_t i;
- *             for (i = 0; i < strlen(haystack); i++)
- *             if (memcmp("needle", haystack+i, strlen("needle")) == 0)
- *                     return cast_const(char *, haystack+i);
- *             return NULL;
- *     }
- */
-#define cast_const(type, expr)                                         \
-        (0 ? BUILD_ASSERT_OR_ZERO(cast_const_compat1((expr), type)) :   \
-         (type)(intptr_t)(expr))
-
-/**
- * cast_const2 - remove a const qualifier from a pointer to a pointer.
- * @type: some pointer to pointer type.
- * @expr: expression to cast.
- *
- * This ensures that you are only removing the const qualifier from an
- * expression.  The expression must otherwise match @type.
- */
-#define cast_const2(type, expr)                                                \
-        (0 ? BUILD_ASSERT_OR_ZERO(cast_const_compat2((expr), type)) :   \
-        (type)(intptr_t)(expr))
-
-/**
- * cast_const3 - remove a const from a pointer to a pointer to a pointer..
- * @type: some pointer to pointer to pointer type.
- * @expr: expression to cast.
- *
- * This ensures that you are only removing the const qualifier from an
- * expression.  The expression must otherwise match @type.
- */
-#define cast_const3(type, expr)                                                \
-        (0 ? BUILD_ASSERT_OR_ZERO(cast_const_compat3((expr), type)) :   \
-        (type)(intptr_t)(expr))
-
-
-/**
- * cast_static - explicit mimic of implicit cast.
- * @type: some type.
- * @expr: expression to cast.
- *
- * This ensures that the cast is not to or from a pointer: it can only be
- * an implicit cast, such as a pointer to a similar const pointer, or between
- * integral types.
- */
-#if HAVE_COMPOUND_LITERALS
-#define cast_static(type, expr)                        \
-       ((struct { type x; }){(expr)}.x)
-#else
-#define cast_static(type, expr)                        \
-       ((type)(expr))
-#endif
-
-/* Herein lies the gcc magic to evoke compile errors. */
-#if HAVE_BUILTIN_CHOOSE_EXPR && HAVE_BUILTIN_TYPES_COMPATIBLE_P && HAVE_TYPEOF
-#define cast_sign_compatible(t, e) \
-  __builtin_choose_expr(                                               \
-         __builtin_types_compatible_p(__typeof__(t), char *) ||        \
-         __builtin_types_compatible_p(__typeof__(t), signed char *) || \
-         __builtin_types_compatible_p(__typeof__(t), unsigned char *), \
-         /* if type is not const qualified */                          \
-         __builtin_types_compatible_p(__typeof__(e), char *) ||        \
-         __builtin_types_compatible_p(__typeof__(e), signed char *) || \
-         __builtin_types_compatible_p(__typeof__(e), unsigned char *), \
-         /* and if it is... */                                         \
-         __builtin_types_compatible_p(__typeof__(e), const char *) ||  \
-         __builtin_types_compatible_p(__typeof__(e), const signed char *) || \
-         __builtin_types_compatible_p(__typeof__(e), const unsigned char *) ||\
-         __builtin_types_compatible_p(__typeof__(e), char *) ||        \
-         __builtin_types_compatible_p(__typeof__(e), signed char *) || \
-         __builtin_types_compatible_p(__typeof__(e), unsigned char *)  \
-         )
-
-#define cast_const_strip1(expr)                        \
-       __typeof__(*(union { int z; __typeof__(expr) x; }){0}.x)
-#define cast_const_strip2(expr) \
-       __typeof__(**(union { int z; __typeof__(expr) x; }){0}.x)
-#define cast_const_strip3(expr) \
-       __typeof__(***(union { int z; __typeof__(expr) x; }){0}.x)
-#define cast_const_compat1(expr, type)                                 \
-       __builtin_types_compatible_p(cast_const_strip1(expr),           \
-                                    cast_const_strip1(type))
-#define cast_const_compat2(expr, type)                                 \
-       __builtin_types_compatible_p(cast_const_strip2(expr),           \
-                                    cast_const_strip2(type))
-#define cast_const_compat3(expr, type)                                 \
-       __builtin_types_compatible_p(cast_const_strip3(expr),           \
-                                    cast_const_strip3(type))
-#else
-#define cast_sign_compatible(type, expr)               \
-       (sizeof(*(type)0) == 1 && sizeof(*(expr)) == 1)
-#define cast_const_compat1(expr, type)         (1)
-#define cast_const_compat2(expr, type)         (1)
-#define cast_const_compat3(expr, type)         (1)
-#endif
-#endif /* CCAN_CAST_H */
diff --git a/lib/ccan/cast/test/compile_fail-cast_const.c b/lib/ccan/cast/test/compile_fail-cast_const.c
deleted file mode 100644 (file)
index 277f3de..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <ccan/cast/cast.h>
-#include <stdlib.h>
-
-/* Note: this *isn't* sizeof(char) on all platforms. */
-struct char_struct {
-       char c;
-};
-
-int main(int argc, char *argv[])
-{
-       char *uc;
-       const
-#ifdef FAIL
-               struct char_struct
-#else
-               char
-#endif
-               *p = NULL;
-
-       uc = cast_const(char *, p);
-       (void) uc; /* Suppress unused-but-set-variable warning. */
-       return 0;
-}
-
-#ifdef FAIL
-#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if cast_const can only use size"
-#endif
-#endif
diff --git a/lib/ccan/cast/test/compile_fail-cast_const2.c b/lib/ccan/cast/test/compile_fail-cast_const2.c
deleted file mode 100644 (file)
index e671e88..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <ccan/cast/cast.h>
-#include <stdlib.h>
-
-/* Note: this *isn't* sizeof(char) on all platforms. */
-struct char_struct {
-       char c;
-};
-
-int main(int argc, char *argv[])
-{
-       char **uc;
-       const
-#ifdef FAIL
-               struct char_struct
-#else
-               char
-#endif
-               **p = NULL;
-
-       uc = cast_const2(char **, p);
-       (void) uc; /* Suppress unused-but-set-variable warning. */
-       return 0;
-}
-
-#ifdef FAIL
-#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if cast_const can only use size"
-#endif
-#endif
diff --git a/lib/ccan/cast/test/compile_fail-cast_const3.c b/lib/ccan/cast/test/compile_fail-cast_const3.c
deleted file mode 100644 (file)
index e958e2d..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <ccan/cast/cast.h>
-#include <stdlib.h>
-
-/* Note: this *isn't* sizeof(char) on all platforms. */
-struct char_struct {
-       char c;
-};
-
-int main(int argc, char *argv[])
-{
-       char ***uc;
-       const
-#ifdef FAIL
-               struct char_struct
-#else
-               char
-#endif
-               ***p = NULL;
-
-       uc = cast_const3(char ***, p);
-       (void) uc; /* Suppress unused-but-set-variable warning. */
-       return 0;
-}
-
-#ifdef FAIL
-#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if cast_const can only use size"
-#endif
-#endif
diff --git a/lib/ccan/cast/test/compile_fail-cast_signed-const.c b/lib/ccan/cast/test/compile_fail-cast_signed-const.c
deleted file mode 100644 (file)
index 9971dc8..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <ccan/cast/cast.h>
-#include <stdlib.h>
-
-int main(int argc, char *argv[])
-{
-       unsigned char *uc;
-#ifdef FAIL
-       const
-#endif
-       char
-               *p = NULL;
-
-       uc = cast_signed(unsigned char *, p);
-       (void) uc; /* Suppress unused-but-set-variable warning. */
-       return 0;
-}
-
-#ifdef FAIL
-#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if cast_const can only use size"
-#endif
-#endif
diff --git a/lib/ccan/cast/test/compile_fail-cast_signed-sizesame.c b/lib/ccan/cast/test/compile_fail-cast_signed-sizesame.c
deleted file mode 100644 (file)
index 2bc40b2..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <ccan/cast/cast.h>
-#include <stdlib.h>
-
-/* Note: this *isn't* sizeof(char) on all platforms. */
-struct char_struct {
-       char c;
-};
-
-int main(int argc, char *argv[])
-{
-       unsigned char *uc;
-#ifdef FAIL
-       struct char_struct
-#else
-       char
-#endif
-               *p = NULL;
-
-       uc = cast_signed(unsigned char *, p);
-
-       (void) uc; /* Suppress unused-but-set-variable warning. */
-       return 0;
-}
-
-#ifdef FAIL
-#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if cast_signed can only use size"
-#endif
-#endif
diff --git a/lib/ccan/cast/test/compile_fail-cast_signed.c b/lib/ccan/cast/test/compile_fail-cast_signed.c
deleted file mode 100644 (file)
index 66bcc0a..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <ccan/cast/cast.h>
-#include <stdlib.h>
-
-int main(int argc, char *argv[])
-{
-       unsigned char *uc;
-#ifdef FAIL
-       int
-#else
-       char
-#endif
-               *p = NULL;
-
-       uc = cast_signed(unsigned char *, p);
-       (void) uc; /* Suppress unused-but-set-variable warning. */
-       return 0;
-}
diff --git a/lib/ccan/cast/test/compile_fail-cast_static-2.c b/lib/ccan/cast/test/compile_fail-cast_static-2.c
deleted file mode 100644 (file)
index 8a12025..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <ccan/cast/cast.h>
-#include <stdlib.h>
-
-int main(int argc, char *argv[])
-{
-       char *c;
-#ifdef FAIL
-       long
-#else
-       char
-#endif
-               *p = 0;
-
-       c = cast_static(char *, p);
-       (void) c; /* Suppress unused-but-set-variable warning. */
-       return 0;
-}
-
-#ifdef FAIL
-#if !HAVE_COMPOUND_LITERALS
-#error "Unfortunately we don't fail if cast_static is a noop"
-#endif
-#endif
diff --git a/lib/ccan/cast/test/compile_fail-cast_static-3.c b/lib/ccan/cast/test/compile_fail-cast_static-3.c
deleted file mode 100644 (file)
index 6296b75..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <ccan/cast/cast.h>
-#include <stdlib.h>
-
-int main(int argc, char *argv[])
-{
-       char *c;
-#ifdef FAIL
-       const
-#endif
-               char *p = 0;
-
-       c = cast_static(char *, p);
-       (void) c; /* Suppress unused-but-set-variable warning. */
-       return 0;
-}
-
-#ifdef FAIL
-#if !HAVE_COMPOUND_LITERALS
-#error "Unfortunately we don't fail if cast_static is a noop"
-#endif
-#endif
diff --git a/lib/ccan/cast/test/compile_fail-cast_static.c b/lib/ccan/cast/test/compile_fail-cast_static.c
deleted file mode 100644 (file)
index a4ebf61..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <ccan/cast/cast.h>
-#include <stdlib.h>
-
-int main(int argc, char *argv[])
-{
-       long c;
-#ifdef FAIL
-       char *
-#else
-       char
-#endif
-               x = 0;
-
-       c = cast_static(long, x);
-       (void) c; /* Suppress unused-but-set-variable warning. */
-       return 0;
-}
-
-#ifdef FAIL
-#if !HAVE_COMPOUND_LITERALS
-#error "Unfortunately we don't fail if cast_static without compound literals"
-#endif
-#endif
diff --git a/lib/ccan/cast/test/compile_ok-cast_void.c b/lib/ccan/cast/test/compile_ok-cast_void.c
deleted file mode 100644 (file)
index c649d28..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <ccan/cast/cast.h>
-
-static void *remove_void(const void *p)
-{
-       return cast_const(void *, p);
-}
-
-int main(void)
-{
-       void *p = remove_void("foo");
-       return !p;
-}
diff --git a/lib/ccan/cast/test/compile_ok-static.c b/lib/ccan/cast/test/compile_ok-static.c
deleted file mode 100644 (file)
index 98b667e..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/* OpenIndiana's CC (aka suncc) has issues with constants: make sure
- * we are one! */
-#include <ccan/cast/cast.h>
-
-static char *p = cast_const(char *, (const char *)"hello");
-
-int main(int argc, char *argv[])
-{
-       return p[0] == argv[0][0];
-}
diff --git a/lib/ccan/check_type/_info b/lib/ccan/check_type/_info
deleted file mode 100644 (file)
index 33448b4..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * check_type - routines for compile time type checking
- *
- * C has fairly weak typing: ints get automatically converted to longs, signed
- * to unsigned, etc.  There are some cases where this is best avoided, and
- * these macros provide methods for evoking warnings (or build errors) when
- * a precise type isn't used.
- *
- * On compilers which don't support typeof() these routines are less effective,
- * since they have to use sizeof() which can only distiguish between types of
- * different size.
- *
- * License: Public domain
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-#if !HAVE_TYPEOF
-               printf("ccan/build_assert\n");
-#endif
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/check_type/check_type.h b/lib/ccan/check_type/check_type.h
deleted file mode 100644 (file)
index b199347..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef CCAN_CHECK_TYPE_H
-#define CCAN_CHECK_TYPE_H
-#include "config.h"
-
-/**
- * check_type - issue a warning or build failure if type is not correct.
- * @expr: the expression whose type we should check (not evaluated).
- * @type: the exact type we expect the expression to be.
- *
- * This macro is usually used within other macros to try to ensure that a macro
- * argument is of the expected type.  No type promotion of the expression is
- * done: an unsigned int is not the same as an int!
- *
- * check_type() always evaluates to 0.
- *
- * If your compiler does not support typeof, then the best we can do is fail
- * to compile if the sizes of the types are unequal (a less complete check).
- *
- * Example:
- *     // They should always pass a 64-bit value to _set_some_value!
- *     #define set_some_value(expr)                    \
- *             _set_some_value((check_type((expr), uint64_t), (expr)))
- */
-
-/**
- * check_types_match - issue a warning or build failure if types are not same.
- * @expr1: the first expression (not evaluated).
- * @expr2: the second expression (not evaluated).
- *
- * This macro is usually used within other macros to try to ensure that
- * arguments are of identical types.  No type promotion of the expressions is
- * done: an unsigned int is not the same as an int!
- *
- * check_types_match() always evaluates to 0.
- *
- * If your compiler does not support typeof, then the best we can do is fail
- * to compile if the sizes of the types are unequal (a less complete check).
- *
- * Example:
- *     // Do subtraction to get to enclosing type, but make sure that
- *     // pointer is of correct type for that member.
- *     #define container_of(mbr_ptr, encl_type, mbr)                   \
- *             (check_types_match((mbr_ptr), &((encl_type *)0)->mbr),  \
- *              ((encl_type *)                                         \
- *               ((char *)(mbr_ptr) - offsetof(enclosing_type, mbr))))
- */
-#if HAVE_TYPEOF
-#define check_type(expr, type)                 \
-       ((typeof(expr) *)0 != (type *)0)
-
-#define check_types_match(expr1, expr2)                \
-       ((typeof(expr1) *)0 != (typeof(expr2) *)0)
-#else
-#include <ccan/build_assert/build_assert.h>
-/* Without typeof, we can only test the sizes. */
-#define check_type(expr, type)                                 \
-       BUILD_ASSERT_OR_ZERO(sizeof(expr) == sizeof(type))
-
-#define check_types_match(expr1, expr2)                                \
-       BUILD_ASSERT_OR_ZERO(sizeof(expr1) == sizeof(expr2))
-#endif /* HAVE_TYPEOF */
-
-#endif /* CCAN_CHECK_TYPE_H */
diff --git a/lib/ccan/check_type/test/compile_fail-check_type.c b/lib/ccan/check_type/test/compile_fail-check_type.c
deleted file mode 100644 (file)
index fe7d6a2..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <ccan/check_type/check_type.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-       check_type(argc, char);
-#endif
-       return 0;
-}
diff --git a/lib/ccan/check_type/test/compile_fail-check_type_unsigned.c b/lib/ccan/check_type/test/compile_fail-check_type_unsigned.c
deleted file mode 100644 (file)
index 574d4ae..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <ccan/check_type/check_type.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if HAVE_TYPEOF
-       check_type(argc, unsigned int);
-#else
-       /* This doesn't work without typeof, so just fail */
-#error "Fail without typeof"
-#endif
-#endif
-       return 0;
-}
diff --git a/lib/ccan/check_type/test/compile_fail-check_types_match.c b/lib/ccan/check_type/test/compile_fail-check_types_match.c
deleted file mode 100644 (file)
index cbd6e9b..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <ccan/check_type/check_type.h>
-
-int main(int argc, char *argv[])
-{
-       unsigned char x = argc;
-#ifdef FAIL
-       check_types_match(argc, x);
-#endif
-       return x;
-}
diff --git a/lib/ccan/check_type/test/run.c b/lib/ccan/check_type/test/run.c
deleted file mode 100644 (file)
index 83b903c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <ccan/check_type/check_type.h>
-#include <ccan/tap/tap.h>
-
-int main(int argc, char *argv[])
-{
-       int x = 0, y = 0;
-
-       plan_tests(9);
-
-       ok1(check_type(argc, int) == 0);
-       ok1(check_type(&argc, int *) == 0);
-       ok1(check_types_match(argc, argc) == 0);
-       ok1(check_types_match(argc, x) == 0);
-       ok1(check_types_match(&argc, &x) == 0);
-
-       ok1(check_type(x++, int) == 0);
-       ok(x == 0, "check_type does not evaluate expression");
-       ok1(check_types_match(x++, y++) == 0);
-       ok(x == 0 && y == 0, "check_types_match does not evaluate expressions");
-
-       return exit_status();
-}
diff --git a/lib/ccan/compiler/LICENSE b/lib/ccan/compiler/LICENSE
deleted file mode 100644 (file)
index cca7fc2..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
-  This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
-  0. Additional Definitions.
-
-  As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
-  "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
-  An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
-  A "Combined Work" is a work produced by combining or linking an
-Application with the Library.  The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
-  The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
-  The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
-  1. Exception to Section 3 of the GNU GPL.
-
-  You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
-  2. Conveying Modified Versions.
-
-  If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
-   a) under this License, provided that you make a good faith effort to
-   ensure that, in the event an Application does not supply the
-   function or data, the facility still operates, and performs
-   whatever part of its purpose remains meaningful, or
-
-   b) under the GNU GPL, with none of the additional permissions of
-   this License applicable to that copy.
-
-  3. Object Code Incorporating Material from Library Header Files.
-
-  The object code form of an Application may incorporate material from
-a header file that is part of the Library.  You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
-   a) Give prominent notice with each copy of the object code that the
-   Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the object code with a copy of the GNU GPL and this license
-   document.
-
-  4. Combined Works.
-
-  You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
-   a) Give prominent notice with each copy of the Combined Work that
-   the Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the Combined Work with a copy of the GNU GPL and this license
-   document.
-
-   c) For a Combined Work that displays copyright notices during
-   execution, include the copyright notice for the Library among
-   these notices, as well as a reference directing the user to the
-   copies of the GNU GPL and this license document.
-
-   d) Do one of the following:
-
-       0) Convey the Minimal Corresponding Source under the terms of this
-       License, and the Corresponding Application Code in a form
-       suitable for, and under terms that permit, the user to
-       recombine or relink the Application with a modified version of
-       the Linked Version to produce a modified Combined Work, in the
-       manner specified by section 6 of the GNU GPL for conveying
-       Corresponding Source.
-
-       1) Use a suitable shared library mechanism for linking with the
-       Library.  A suitable mechanism is one that (a) uses at run time
-       a copy of the Library already present on the user's computer
-       system, and (b) will operate properly with a modified version
-       of the Library that is interface-compatible with the Linked
-       Version.
-
-   e) Provide Installation Information, but only if you would otherwise
-   be required to provide such information under section 6 of the
-   GNU GPL, and only to the extent that such information is
-   necessary to install and execute a modified version of the
-   Combined Work produced by recombining or relinking the
-   Application with a modified version of the Linked Version. (If
-   you use option 4d0, the Installation Information must accompany
-   the Minimal Corresponding Source and Corresponding Application
-   Code. If you use option 4d1, you must provide the Installation
-   Information in the manner specified by section 6 of the GNU GPL
-   for conveying Corresponding Source.)
-
-  5. Combined Libraries.
-
-  You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
-   a) Accompany the combined library with a copy of the same work based
-   on the Library, uncombined with any other library facilities,
-   conveyed under the terms of this License.
-
-   b) Give prominent notice with the combined library that part of it
-   is a work based on the Library, and explaining where to find the
-   accompanying uncombined form of the same work.
-
-  6. Revised Versions of the GNU Lesser General Public License.
-
-  The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
-  Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
-  If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/lib/ccan/compiler/_info b/lib/ccan/compiler/_info
deleted file mode 100644 (file)
index 9f39453..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#include <string.h>
-#include <stdio.h>
-#include "config.h"
-
-/**
- * compiler - macros for common compiler extensions
- *
- * Abstracts away some compiler hints.  Currently these include:
- * - COLD
- *     For functions not called in fast paths (aka. cold functions)
- * - PRINTF_FMT
- *     For functions which take printf-style parameters.
- * - CONST_FUNCTION
- *     For functions which return the same value for same parameters.
- * - NEEDED
- *     For functions and variables which must be emitted even if unused.
- * - UNNEEDED
- *     For functions and variables which need not be emitted if unused.
- * - UNUSED
- *     For parameters which are not used.
- * - IS_COMPILE_CONSTANT()
- *     For using different tradeoffs for compiletime vs runtime evaluation.
- *
- * License: Public Domain
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- *
- * Example:
- *     #include <ccan/compiler/compiler.h>
- *     #include <stdio.h>
- *     #include <stdarg.h>
- *
- *     // Example of a (slow-path) logging function.
- *     static int log_threshold = 2;
- *     static void COLD PRINTF_FMT(2,3)
- *             logger(int level, const char *fmt, ...)
- *     {
- *             va_list ap;
- *             va_start(ap, fmt);
- *             if (level >= log_threshold)
- *                     vfprintf(stderr, fmt, ap);
- *             va_end(ap);
- *     }
- *
- *     int main(int argc, char *argv[])
- *     {
- *             if (argc != 1) {
- *                     logger(3, "Don't want %i arguments!\n", argc-1);
- *                     return 1;
- *             }
- *             return 0;
- *     }
- */
-int main(int argc, char *argv[])
-{
-       /* Expect exactly one argument */
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/compiler/compiler.h b/lib/ccan/compiler/compiler.h
deleted file mode 100644 (file)
index fcb89c8..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-#ifndef CCAN_COMPILER_H
-#define CCAN_COMPILER_H
-#include "config.h"
-
-#ifndef COLD
-#if HAVE_ATTRIBUTE_COLD
-/**
- * COLD - a function is unlikely to be called.
- *
- * Used to mark an unlikely code path and optimize appropriately.
- * It is usually used on logging or error routines.
- *
- * Example:
- * static void COLD moan(const char *reason)
- * {
- *     fprintf(stderr, "Error: %s (%s)\n", reason, strerror(errno));
- * }
- */
-#define COLD __attribute__((cold))
-#else
-#define COLD
-#endif
-#endif
-
-#ifndef NORETURN
-#if HAVE_ATTRIBUTE_NORETURN
-/**
- * NORETURN - a function does not return
- *
- * Used to mark a function which exits; useful for suppressing warnings.
- *
- * Example:
- * static void NORETURN fail(const char *reason)
- * {
- *     fprintf(stderr, "Error: %s (%s)\n", reason, strerror(errno));
- *     exit(1);
- * }
- */
-#define NORETURN __attribute__((noreturn))
-#else
-#define NORETURN
-#endif
-#endif
-
-#ifndef PRINTF_FMT
-#if HAVE_ATTRIBUTE_PRINTF
-/**
- * PRINTF_FMT - a function takes printf-style arguments
- * @nfmt: the 1-based number of the function's format argument.
- * @narg: the 1-based number of the function's first variable argument.
- *
- * This allows the compiler to check your parameters as it does for printf().
- *
- * Example:
- * void PRINTF_FMT(2,3) my_printf(const char *prefix, const char *fmt, ...);
- */
-#define PRINTF_FMT(nfmt, narg) \
-       __attribute__((format(__printf__, nfmt, narg)))
-#else
-#define PRINTF_FMT(nfmt, narg)
-#endif
-#endif
-
-#ifndef CONST_FUNCTION
-#if HAVE_ATTRIBUTE_CONST
-/**
- * CONST_FUNCTION - a function's return depends only on its argument
- *
- * This allows the compiler to assume that the function will return the exact
- * same value for the exact same arguments.  This implies that the function
- * must not use global variables, or dereference pointer arguments.
- */
-#define CONST_FUNCTION __attribute__((const))
-#else
-#define CONST_FUNCTION
-#endif
-#endif
-
-#if HAVE_ATTRIBUTE_UNUSED
-#ifndef UNNEEDED
-/**
- * UNNEEDED - a variable/function may not be needed
- *
- * This suppresses warnings about unused variables or functions, but tells
- * the compiler that if it is unused it need not emit it into the source code.
- *
- * Example:
- * // With some preprocessor options, this is unnecessary.
- * static UNNEEDED int counter;
- *
- * // With some preprocessor options, this is unnecessary.
- * static UNNEEDED void add_to_counter(int add)
- * {
- *     counter += add;
- * }
- */
-#define UNNEEDED __attribute__((unused))
-#endif
-
-#ifndef NEEDED
-#if HAVE_ATTRIBUTE_USED
-/**
- * NEEDED - a variable/function is needed
- *
- * This suppresses warnings about unused variables or functions, but tells
- * the compiler that it must exist even if it (seems) unused.
- *
- * Example:
- *     // Even if this is unused, these are vital for debugging.
- *     static NEEDED int counter;
- *     static NEEDED void dump_counter(void)
- *     {
- *             printf("Counter is %i\n", counter);
- *     }
- */
-#define NEEDED __attribute__((used))
-#else
-/* Before used, unused functions and vars were always emitted. */
-#define NEEDED __attribute__((unused))
-#endif
-#endif
-
-#ifndef UNUSED
-/**
- * UNUSED - a parameter is unused
- *
- * Some compilers (eg. gcc with -W or -Wunused) warn about unused
- * function parameters.  This suppresses such warnings and indicates
- * to the reader that it's deliberate.
- *
- * Example:
- *     // This is used as a callback, so needs to have this prototype.
- *     static int some_callback(void *unused UNUSED)
- *     {
- *             return 0;
- *     }
- */
-#define UNUSED __attribute__((unused))
-#endif
-#else
-#ifndef UNNEEDED
-#define UNNEEDED
-#endif
-#ifndef NEEDED
-#define NEEDED
-#endif
-#ifndef UNUSED
-#define UNUSED
-#endif
-#endif
-
-#ifndef IS_COMPILE_CONSTANT
-#if HAVE_BUILTIN_CONSTANT_P
-/**
- * IS_COMPILE_CONSTANT - does the compiler know the value of this expression?
- * @expr: the expression to evaluate
- *
- * When an expression manipulation is complicated, it is usually better to
- * implement it in a function.  However, if the expression being manipulated is
- * known at compile time, it is better to have the compiler see the entire
- * expression so it can simply substitute the result.
- *
- * This can be done using the IS_COMPILE_CONSTANT() macro.
- *
- * Example:
- *     enum greek { ALPHA, BETA, GAMMA, DELTA, EPSILON };
- *
- *     // Out-of-line version.
- *     const char *greek_name(enum greek greek);
- *
- *     // Inline version.
- *     static inline const char *_greek_name(enum greek greek)
- *     {
- *             switch (greek) {
- *             case ALPHA: return "alpha";
- *             case BETA: return "beta";
- *             case GAMMA: return "gamma";
- *             case DELTA: return "delta";
- *             case EPSILON: return "epsilon";
- *             default: return "**INVALID**";
- *             }
- *     }
- *
- *     // Use inline if compiler knows answer.  Otherwise call function
- *     // to avoid copies of the same code everywhere.
- *     #define greek_name(g)                                           \
- *              (IS_COMPILE_CONSTANT(greek) ? _greek_name(g) : greek_name(g))
- */
-#define IS_COMPILE_CONSTANT(expr) __builtin_constant_p(expr)
-#else
-/* If we don't know, assume it's not. */
-#define IS_COMPILE_CONSTANT(expr) 0
-#endif
-#endif
-
-#ifndef WARN_UNUSED_RESULT
-#if HAVE_WARN_UNUSED_RESULT
-/**
- * WARN_UNUSED_RESULT - warn if a function return value is unused.
- *
- * Used to mark a function where it is extremely unlikely that the caller
- * can ignore the result, eg realloc().
- *
- * Example:
- * // buf param may be freed by this; need return value!
- * static char *WARN_UNUSED_RESULT enlarge(char *buf, unsigned *size)
- * {
- *     return realloc(buf, (*size) *= 2);
- * }
- */
-#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
-#else
-#define WARN_UNUSED_RESULT
-#endif
-#endif
-#endif /* CCAN_COMPILER_H */
diff --git a/lib/ccan/compiler/test/compile_fail-printf.c b/lib/ccan/compiler/test/compile_fail-printf.c
deleted file mode 100644 (file)
index 8f34ae5..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <ccan/compiler/compiler.h>
-
-static void PRINTF_FMT(2,3) my_printf(int x, const char *fmt, ...)
-{
-}
-
-int main(int argc, char *argv[])
-{
-       unsigned int i = 0;
-
-       my_printf(1, "Not a pointer "
-#ifdef FAIL
-                 "%p",
-#if !HAVE_ATTRIBUTE_PRINTF
-#error "Unfortunately we don't fail if !HAVE_ATTRIBUTE_PRINTF."
-#endif
-#else
-                 "%i",
-#endif
-                 i);
-       return 0;
-}
diff --git a/lib/ccan/compiler/test/run-is_compile_constant.c b/lib/ccan/compiler/test/run-is_compile_constant.c
deleted file mode 100644 (file)
index a66f2e1..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <ccan/compiler/compiler.h>
-#include <ccan/tap/tap.h>
-
-int main(int argc, char *argv[])
-{
-       plan_tests(2);
-
-       ok1(!IS_COMPILE_CONSTANT(argc));
-#if HAVE_BUILTIN_CONSTANT_P
-       ok1(IS_COMPILE_CONSTANT(7));
-#else
-       pass("If !HAVE_BUILTIN_CONSTANT_P, IS_COMPILE_CONSTANT always false");
-#endif
-       return exit_status();
-}
diff --git a/lib/ccan/container_of/_info b/lib/ccan/container_of/_info
deleted file mode 100644 (file)
index 2f45ca7..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * container_of - routine for upcasting
- *
- * It is often convenient to create code where the caller registers a pointer
- * to a generic structure and a callback.  The callback might know that the
- * pointer points to within a larger structure, and container_of gives a
- * convenient and fairly type-safe way of returning to the enclosing structure.
- *
- * This idiom is an alternative to providing a void * pointer for every
- * callback.
- *
- * Example:
- *     #include <stdio.h>
- *     #include <ccan/container_of/container_of.h>
- *
- *     struct timer {
- *             void *members;
- *     };
- *
- *     struct info {
- *             int my_stuff;
- *             struct timer timer;
- *     };
- *
- *     static void register_timer(struct timer *timer)
- *     {
- *             //...
- *     }
- *
- *     static void my_timer_callback(struct timer *timer)
- *     {
- *             struct info *info = container_of(timer, struct info, timer);
- *             printf("my_stuff is %u\n", info->my_stuff);
- *     }
- *
- *     int main(void)
- *     {
- *             struct info info = { .my_stuff = 1 };
- *
- *             register_timer(&info.timer);
- *             // ...
- *             return 0;
- *     }
- *
- * License: Public domain
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               printf("ccan/check_type\n");
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/container_of/container_of.h b/lib/ccan/container_of/container_of.h
deleted file mode 100644 (file)
index 1c9d147..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-#ifndef CCAN_CONTAINER_OF_H
-#define CCAN_CONTAINER_OF_H
-#include <stddef.h>
-
-#include "config.h"
-#include <ccan/check_type/check_type.h>
-
-/**
- * container_of - get pointer to enclosing structure
- * @member_ptr: pointer to the structure member
- * @containing_type: the type this member is within
- * @member: the name of this member within the structure.
- *
- * Given a pointer to a member of a structure, this macro does pointer
- * subtraction to return the pointer to the enclosing type.
- *
- * Example:
- *     struct foo {
- *             int fielda, fieldb;
- *             // ...
- *     };
- *     struct info {
- *             int some_other_field;
- *             struct foo my_foo;
- *     };
- *
- *     static struct info *foo_to_info(struct foo *foo)
- *     {
- *             return container_of(foo, struct info, my_foo);
- *     }
- */
-#define container_of(member_ptr, containing_type, member)              \
-        ((containing_type *)                                           \
-         ((char *)(member_ptr)                                         \
-          - container_off(containing_type, member))                    \
-         + check_types_match(*(member_ptr), ((containing_type *)0)->member))
-
-/**
- * container_off - get offset to enclosing structure
- * @containing_type: the type this member is within
- * @member: the name of this member within the structure.
- *
- * Given a pointer to a member of a structure, this macro does
- * typechecking and figures out the offset to the enclosing type.
- *
- * Example:
- *     struct foo {
- *             int fielda, fieldb;
- *             // ...
- *     };
- *     struct info {
- *             int some_other_field;
- *             struct foo my_foo;
- *     };
- *
- *     static struct info *foo_to_info(struct foo *foo)
- *     {
- *             size_t off = container_off(struct info, my_foo);
- *             return (void *)((char *)foo - off);
- *     }
- */
-#define container_off(containing_type, member) \
-       offsetof(containing_type, member)
-
-/**
- * container_of_var - get pointer to enclosing structure using a variable
- * @member_ptr: pointer to the structure member
- * @container_var: a pointer of same type as this member's container
- * @member: the name of this member within the structure.
- *
- * Given a pointer to a member of a structure, this macro does pointer
- * subtraction to return the pointer to the enclosing type.
- *
- * Example:
- *     static struct info *foo_to_i(struct foo *foo)
- *     {
- *             struct info *i = container_of_var(foo, i, my_foo);
- *             return i;
- *     }
- */
-#if HAVE_TYPEOF
-#define container_of_var(member_ptr, container_var, member) \
-       container_of(member_ptr, typeof(*container_var), member)
-#else
-#define container_of_var(member_ptr, container_var, member)    \
-       ((void *)((char *)(member_ptr)  -                       \
-                 container_off_var(container_var, member)))
-#endif
-
-/**
- * container_off_var - get offset of a field in enclosing structure
- * @container_var: a pointer to a container structure
- * @member: the name of a member within the structure.
- *
- * Given (any) pointer to a structure and a its member name, this
- * macro does pointer subtraction to return offset of member in a
- * structure memory layout.
- *
- */
-#if HAVE_TYPEOF
-#define container_off_var(var, member)         \
-       container_off(typeof(*var), member)
-#else
-#define container_off_var(var, member)                 \
-       ((char *)&(var)->member - (char *)(var))
-#endif
-
-#endif /* CCAN_CONTAINER_OF_H */
diff --git a/lib/ccan/container_of/test/compile_fail-bad-type.c b/lib/ccan/container_of/test/compile_fail-bad-type.c
deleted file mode 100644 (file)
index b7a1459..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <ccan/container_of/container_of.h>
-#include <stdlib.h>
-
-struct foo {
-       int a;
-       char b;
-};
-
-int main(int argc, char *argv[])
-{
-       struct foo foo = { .a = 1, .b = 2 };
-       int *intp = &foo.a;
-       char *p;
-
-#ifdef FAIL
-       /* p is a char *, but this gives a struct foo * */
-       p = container_of(intp, struct foo, a);
-#else
-       p = (char *)intp;
-#endif
-       return p == NULL;
-}
diff --git a/lib/ccan/container_of/test/compile_fail-types.c b/lib/ccan/container_of/test/compile_fail-types.c
deleted file mode 100644 (file)
index cae1c7a..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <ccan/container_of/container_of.h>
-#include <stdlib.h>
-
-struct foo {
-       int a;
-       char b;
-};
-
-int main(int argc, char *argv[])
-{
-       struct foo foo = { .a = 1, .b = 2 }, *foop;
-       int *intp = &foo.a;
-
-#ifdef FAIL
-       /* b is a char, but intp is an int * */
-       foop = container_of(intp, struct foo, b);
-#else
-       foop = NULL;
-#endif
-       (void) foop; /* Suppress unused-but-set-variable warning. */
-       return intp == NULL;
-}
diff --git a/lib/ccan/container_of/test/compile_fail-var-types.c b/lib/ccan/container_of/test/compile_fail-var-types.c
deleted file mode 100644 (file)
index f254d92..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <ccan/container_of/container_of.h>
-#include <stdlib.h>
-
-struct foo {
-       int a;
-       char b;
-};
-
-int main(int argc, char *argv[])
-{
-       struct foo foo = { .a = 1, .b = 2 }, *foop;
-       int *intp = &foo.a;
-
-#ifdef FAIL
-       /* b is a char, but intp is an int * */
-       foop = container_of_var(intp, foop, b);
-#if !HAVE_TYPEOF
-#error "Unfortunately we don't fail if we don't have typeof."
-#endif
-#else
-       foop = NULL;
-#endif
-       (void) foop; /* Suppress unused-but-set-variable warning. */
-       return intp == NULL;
-}
diff --git a/lib/ccan/container_of/test/run.c b/lib/ccan/container_of/test/run.c
deleted file mode 100644 (file)
index 5da440a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <ccan/container_of/container_of.h>
-#include <ccan/tap/tap.h>
-
-struct foo {
-       int a;
-       char b;
-};
-
-int main(int argc, char *argv[])
-{
-       struct foo foo = { .a = 1, .b = 2 };
-       int *intp = &foo.a;
-       char *charp = &foo.b;
-
-       plan_tests(8);
-       ok1(container_of(intp, struct foo, a) == &foo);
-       ok1(container_of(charp, struct foo, b) == &foo);
-       ok1(container_of_var(intp, &foo, a) == &foo);
-       ok1(container_of_var(charp, &foo, b) == &foo);
-
-       ok1(container_off(struct foo, a) == 0);
-       ok1(container_off(struct foo, b) == offsetof(struct foo, b));
-       ok1(container_off_var(&foo, a) == 0);
-       ok1(container_off_var(&foo, b) == offsetof(struct foo, b));
-       return exit_status();
-}
diff --git a/lib/ccan/endian/LICENSE b/lib/ccan/endian/LICENSE
deleted file mode 100644 (file)
index 5522aa5..0000000
+++ /dev/null
@@ -1,508 +0,0 @@
-
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
-       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL.  It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
-                            Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations
-below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-\f
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it
-becomes a de-facto standard.  To achieve this, non-free programs must
-be allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-\f
-                  GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control
-compilation and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-\f
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at least
-    three years, to give the same user the materials specified in
-    Subsection 6a, above, for a charge no more than the cost of
-    performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-\f
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply, and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License
-may add an explicit geographical distribution limitation excluding those
-countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-                            NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-                     END OF TERMS AND CONDITIONS
-\f
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms
-of the ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.
-It is safest to attach them to the start of each source file to most
-effectively convey the exclusion of warranty; and each file should
-have at least the "copyright" line and a pointer to where the full
-notice is found.
-
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or
-your school, if any, to sign a "copyright disclaimer" for the library,
-if necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James
-  Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/lib/ccan/endian/_info b/lib/ccan/endian/_info
deleted file mode 100644 (file)
index 0c768d5..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * endian - endian conversion macros for simple types
- *
- * Portable protocols (such as on-disk formats, or network protocols)
- * are often defined to be a particular endian: little-endian (least
- * significant bytes first) or big-endian (most significant bytes
- * first).
- *
- * Similarly, some CPUs lay out values in memory in little-endian
- * order (most commonly, Intel's 8086 and derivatives), or big-endian
- * order (almost everyone else).
- *
- * This module provides conversion routines, inspired by the linux kernel.
- *
- * Example:
- *     #include <stdio.h>
- *     #include <err.h>
- *     #include <ccan/endian/endian.h>
- *
- *     //
- *     int main(int argc, char *argv[])
- *     {
- *             uint32_t value;
- *
- *             if (argc != 2)
- *                     errx(1, "Usage: %s <value>", argv[0]);
- *
- *             value = atoi(argv[1]);
- *             printf("native:        %08x\n", value);
- *             printf("little-endian: %08x\n", cpu_to_le32(value));
- *             printf("big-endian:    %08x\n", cpu_to_be32(value));
- *             printf("byte-reversed: %08x\n", bswap_32(value));
- *             exit(0);
- *     }
- *
- * License: LGPL (v2.1 or any later version)
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0)
-               /* Nothing */
-               return 0;
-
-       return 1;
-}
diff --git a/lib/ccan/endian/endian.h b/lib/ccan/endian/endian.h
deleted file mode 100644 (file)
index 5219111..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-/* Licensed under LGPLv2.1+ - see LICENSE file for details */
-#ifndef CCAN_ENDIAN_H
-#define CCAN_ENDIAN_H
-#include <stdint.h>
-#include "config.h"
-
-#if HAVE_BYTESWAP_H
-#include <byteswap.h>
-#else
-/**
- * bswap_16 - reverse bytes in a uint16_t value.
- * @val: value whose bytes to swap.
- *
- * Example:
- *     // Output contains "1024 is 4 as two bytes reversed"
- *     printf("1024 is %u as two bytes reversed\n", bswap_16(1024));
- */
-static inline uint16_t bswap_16(uint16_t val)
-{
-       return ((val & (uint16_t)0x00ffU) << 8)
-               | ((val & (uint16_t)0xff00U) >> 8);
-}
-
-/**
- * bswap_32 - reverse bytes in a uint32_t value.
- * @val: value whose bytes to swap.
- *
- * Example:
- *     // Output contains "1024 is 262144 as four bytes reversed"
- *     printf("1024 is %u as four bytes reversed\n", bswap_32(1024));
- */
-static inline uint32_t bswap_32(uint32_t val)
-{
-       return ((val & (uint32_t)0x000000ffUL) << 24)
-               | ((val & (uint32_t)0x0000ff00UL) <<  8)
-               | ((val & (uint32_t)0x00ff0000UL) >>  8)
-               | ((val & (uint32_t)0xff000000UL) >> 24);
-}
-#endif /* !HAVE_BYTESWAP_H */
-
-#if !HAVE_BSWAP_64
-/**
- * bswap_64 - reverse bytes in a uint64_t value.
- * @val: value whose bytes to swap.
- *
- * Example:
- *     // Output contains "1024 is 1125899906842624 as eight bytes reversed"
- *     printf("1024 is %llu as eight bytes reversed\n",
- *             (unsigned long long)bswap_64(1024));
- */
-static inline uint64_t bswap_64(uint64_t val)
-{
-       return ((val & (uint64_t)0x00000000000000ffULL) << 56)
-               | ((val & (uint64_t)0x000000000000ff00ULL) << 40)
-               | ((val & (uint64_t)0x0000000000ff0000ULL) << 24)
-               | ((val & (uint64_t)0x00000000ff000000ULL) <<  8)
-               | ((val & (uint64_t)0x000000ff00000000ULL) >>  8)
-               | ((val & (uint64_t)0x0000ff0000000000ULL) >> 24)
-               | ((val & (uint64_t)0x00ff000000000000ULL) >> 40)
-               | ((val & (uint64_t)0xff00000000000000ULL) >> 56);
-}
-#endif
-
-/* Sanity check the defines.  We don't handle weird endianness. */
-#if !HAVE_LITTLE_ENDIAN && !HAVE_BIG_ENDIAN
-#error "Unknown endian"
-#elif HAVE_LITTLE_ENDIAN && HAVE_BIG_ENDIAN
-#error "Can't compile for both big and little endian."
-#endif
-
-/**
- * cpu_to_le64 - convert a uint64_t value to little-endian
- * @native: value to convert
- */
-static inline uint64_t cpu_to_le64(uint64_t native)
-{
-#if HAVE_LITTLE_ENDIAN
-       return native;
-#else
-       return bswap_64(native);
-#endif
-}
-
-/**
- * cpu_to_le32 - convert a uint32_t value to little-endian
- * @native: value to convert
- */
-static inline uint32_t cpu_to_le32(uint32_t native)
-{
-#if HAVE_LITTLE_ENDIAN
-       return native;
-#else
-       return bswap_32(native);
-#endif
-}
-
-/**
- * cpu_to_le16 - convert a uint16_t value to little-endian
- * @native: value to convert
- */
-static inline uint16_t cpu_to_le16(uint16_t native)
-{
-#if HAVE_LITTLE_ENDIAN
-       return native;
-#else
-       return bswap_16(native);
-#endif
-}
-
-/**
- * le64_to_cpu - convert a little-endian uint64_t value
- * @le_val: little-endian value to convert
- */
-static inline uint64_t le64_to_cpu(uint64_t le_val)
-{
-#if HAVE_LITTLE_ENDIAN
-       return le_val;
-#else
-       return bswap_64(le_val);
-#endif
-}
-
-/**
- * le32_to_cpu - convert a little-endian uint32_t value
- * @le_val: little-endian value to convert
- */
-static inline uint32_t le32_to_cpu(uint32_t le_val)
-{
-#if HAVE_LITTLE_ENDIAN
-       return le_val;
-#else
-       return bswap_32(le_val);
-#endif
-}
-
-/**
- * le16_to_cpu - convert a little-endian uint16_t value
- * @le_val: little-endian value to convert
- */
-static inline uint16_t le16_to_cpu(uint16_t le_val)
-{
-#if HAVE_LITTLE_ENDIAN
-       return le_val;
-#else
-       return bswap_16(le_val);
-#endif
-}
-
-/**
- * cpu_to_be64 - convert a uint64_t value to big endian.
- * @native: value to convert
- */
-static inline uint64_t cpu_to_be64(uint64_t native)
-{
-#if HAVE_LITTLE_ENDIAN
-       return bswap_64(native);
-#else
-       return native;
-#endif
-}
-
-/**
- * cpu_to_be32 - convert a uint32_t value to big endian.
- * @native: value to convert
- */
-static inline uint32_t cpu_to_be32(uint32_t native)
-{
-#if HAVE_LITTLE_ENDIAN
-       return bswap_32(native);
-#else
-       return native;
-#endif
-}
-
-/**
- * cpu_to_be16 - convert a uint16_t value to big endian.
- * @native: value to convert
- */
-static inline uint16_t cpu_to_be16(uint16_t native)
-{
-#if HAVE_LITTLE_ENDIAN
-       return bswap_16(native);
-#else
-       return native;
-#endif
-}
-
-/**
- * be64_to_cpu - convert a big-endian uint64_t value
- * @be_val: big-endian value to convert
- */
-static inline uint64_t be64_to_cpu(uint64_t be_val)
-{
-#if HAVE_LITTLE_ENDIAN
-       return bswap_64(be_val);
-#else
-       return be_val;
-#endif
-}
-
-/**
- * be32_to_cpu - convert a big-endian uint32_t value
- * @be_val: big-endian value to convert
- */
-static inline uint32_t be32_to_cpu(uint32_t be_val)
-{
-#if HAVE_LITTLE_ENDIAN
-       return bswap_32(be_val);
-#else
-       return be_val;
-#endif
-}
-
-/**
- * be16_to_cpu - convert a big-endian uint16_t value
- * @be_val: big-endian value to convert
- */
-static inline uint16_t be16_to_cpu(uint16_t be_val)
-{
-#if HAVE_LITTLE_ENDIAN
-       return bswap_16(be_val);
-#else
-       return be_val;
-#endif
-}
-
-#endif /* CCAN_ENDIAN_H */
diff --git a/lib/ccan/endian/test/run.c b/lib/ccan/endian/test/run.c
deleted file mode 100644 (file)
index a00fce7..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-#include <ccan/endian/endian.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <ccan/tap/tap.h>
-
-int main(int argc, char *argv[])
-{
-       union {
-               uint64_t u64;
-               unsigned char u64_bytes[8];
-       } u64;
-       union {
-               uint32_t u32;
-               unsigned char u32_bytes[4];
-       } u32;
-       union {
-               uint16_t u16;
-               unsigned char u16_bytes[2];
-       } u16;
-
-       plan_tests(48);
-
-       /* Straight swap tests. */
-       u64.u64_bytes[0] = 0x00;
-       u64.u64_bytes[1] = 0x11;
-       u64.u64_bytes[2] = 0x22;
-       u64.u64_bytes[3] = 0x33;
-       u64.u64_bytes[4] = 0x44;
-       u64.u64_bytes[5] = 0x55;
-       u64.u64_bytes[6] = 0x66;
-       u64.u64_bytes[7] = 0x77;
-       u64.u64 = bswap_64(u64.u64);
-       ok1(u64.u64_bytes[7] == 0x00);
-       ok1(u64.u64_bytes[6] == 0x11);
-       ok1(u64.u64_bytes[5] == 0x22);
-       ok1(u64.u64_bytes[4] == 0x33);
-       ok1(u64.u64_bytes[3] == 0x44);
-       ok1(u64.u64_bytes[2] == 0x55);
-       ok1(u64.u64_bytes[1] == 0x66);
-       ok1(u64.u64_bytes[0] == 0x77);
-
-       u32.u32_bytes[0] = 0x00;
-       u32.u32_bytes[1] = 0x11;
-       u32.u32_bytes[2] = 0x22;
-       u32.u32_bytes[3] = 0x33;
-       u32.u32 = bswap_32(u32.u32);
-       ok1(u32.u32_bytes[3] == 0x00);
-       ok1(u32.u32_bytes[2] == 0x11);
-       ok1(u32.u32_bytes[1] == 0x22);
-       ok1(u32.u32_bytes[0] == 0x33);
-
-       u16.u16_bytes[0] = 0x00;
-       u16.u16_bytes[1] = 0x11;
-       u16.u16 = bswap_16(u16.u16);
-       ok1(u16.u16_bytes[1] == 0x00);
-       ok1(u16.u16_bytes[0] == 0x11);
-
-       /* Endian tests. */
-       u64.u64 = cpu_to_le64(0x0011223344556677ULL);
-       ok1(u64.u64_bytes[0] == 0x77);
-       ok1(u64.u64_bytes[1] == 0x66);
-       ok1(u64.u64_bytes[2] == 0x55);
-       ok1(u64.u64_bytes[3] == 0x44);
-       ok1(u64.u64_bytes[4] == 0x33);
-       ok1(u64.u64_bytes[5] == 0x22);
-       ok1(u64.u64_bytes[6] == 0x11);
-       ok1(u64.u64_bytes[7] == 0x00);
-       ok1(le64_to_cpu(u64.u64) == 0x0011223344556677ULL);
-
-       u64.u64 = cpu_to_be64(0x0011223344556677ULL);
-       ok1(u64.u64_bytes[7] == 0x77);
-       ok1(u64.u64_bytes[6] == 0x66);
-       ok1(u64.u64_bytes[5] == 0x55);
-       ok1(u64.u64_bytes[4] == 0x44);
-       ok1(u64.u64_bytes[3] == 0x33);
-       ok1(u64.u64_bytes[2] == 0x22);
-       ok1(u64.u64_bytes[1] == 0x11);
-       ok1(u64.u64_bytes[0] == 0x00);
-       ok1(be64_to_cpu(u64.u64) == 0x0011223344556677ULL);
-
-       u32.u32 = cpu_to_le32(0x00112233);
-       ok1(u32.u32_bytes[0] == 0x33);
-       ok1(u32.u32_bytes[1] == 0x22);
-       ok1(u32.u32_bytes[2] == 0x11);
-       ok1(u32.u32_bytes[3] == 0x00);
-       ok1(le32_to_cpu(u32.u32) == 0x00112233);
-
-       u32.u32 = cpu_to_be32(0x00112233);
-       ok1(u32.u32_bytes[3] == 0x33);
-       ok1(u32.u32_bytes[2] == 0x22);
-       ok1(u32.u32_bytes[1] == 0x11);
-       ok1(u32.u32_bytes[0] == 0x00);
-       ok1(be32_to_cpu(u32.u32) == 0x00112233);
-
-       u16.u16 = cpu_to_le16(0x0011);
-       ok1(u16.u16_bytes[0] == 0x11);
-       ok1(u16.u16_bytes[1] == 0x00);
-       ok1(le16_to_cpu(u16.u16) == 0x0011);
-
-       u16.u16 = cpu_to_be16(0x0011);
-       ok1(u16.u16_bytes[1] == 0x11);
-       ok1(u16.u16_bytes[0] == 0x00);
-       ok1(be16_to_cpu(u16.u16) == 0x0011);
-
-       exit(exit_status());
-}
diff --git a/lib/ccan/err/.depends b/lib/ccan/err/.depends
deleted file mode 100644 (file)
index ee4f1e4..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ccan/compiler
diff --git a/lib/ccan/err/_info b/lib/ccan/err/_info
deleted file mode 100644 (file)
index 97bc0f9..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * err - err(), errx(), warn() and warnx(), as per BSD's err.h.
- *
- * A few platforms don't provide err.h; for those, this provides replacements.
- * For most, it simple includes the system err.h.
- *
- * Unfortunately, you have to call err_set_progname() to tell the replacements
- * your program name, otherwise it prints "unknown program".
- *
- * Example:
- *     #include <ccan/err/err.h>
- *
- *     int main(int argc, char *argv[])
- *     {
- *             err_set_progname(argv[0]);
- *             if (argc != 1)
- *                     errx(1, "Expect no arguments");
- *             exit(0);
- *     }
- *
- * License: Public domain
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-#if !HAVE_ERR_H
-               printf("ccan/compiler\n");
-#endif
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/err/err.c b/lib/ccan/err/err.c
deleted file mode 100644 (file)
index 9e0e20c..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "err.h"
-
-#if !HAVE_ERR_H
-#include <stdarg.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-
-static const char *progname = "unknown program";
-
-void err_set_progname(const char *name)
-{
-       progname = name;
-}
-
-void NORETURN err(int eval, const char *fmt, ...)
-{
-       int err_errno = errno;
-       va_list ap;
-
-       fprintf(stderr, "%s: ", progname);
-       va_start(ap, fmt);
-       vfprintf(stderr, fmt, ap);
-       va_end(ap);
-       fprintf(stderr, ": %s\n", strerror(err_errno));
-       exit(eval);
-}
-
-void NORETURN errx(int eval, const char *fmt, ...)
-{
-       va_list ap;
-
-       fprintf(stderr, "%s: ", progname);
-       va_start(ap, fmt);
-       vfprintf(stderr, fmt, ap);
-       va_end(ap);
-       fprintf(stderr, "\n");
-       exit(eval);
-}
-
-void warn(const char *fmt, ...)
-{
-       int err_errno = errno;
-       va_list ap;
-
-       fprintf(stderr, "%s: ", progname);
-       va_start(ap, fmt);
-       vfprintf(stderr, fmt, ap);
-       va_end(ap);
-       fprintf(stderr, ": %s\n", strerror(err_errno));
-}
-
-void warnx(const char *fmt, ...)
-{
-       va_list ap;
-
-       fprintf(stderr, "%s: ", progname);
-       va_start(ap, fmt);
-       vfprintf(stderr, fmt, ap);
-       va_end(ap);
-       fprintf(stderr, "\n");
-}
-#endif
diff --git a/lib/ccan/err/err.h b/lib/ccan/err/err.h
deleted file mode 100644 (file)
index 58ad91c..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-#ifndef CCAN_ERR_H
-#define CCAN_ERR_H
-#include "config.h"
-
-#if HAVE_ERR_H
-#include <err.h>
-
-/* This is unnecessary with a real err.h.  See below */
-#define err_set_progname(name) ((void)name)
-
-#else
-#include <ccan/compiler/compiler.h>
-
-/**
- * err_set_progname - set the program name
- * @name: the name to use for err, errx, warn and warnx
- *
- * The BSD err.h calls know the program name, unfortunately there's no
- * portable way for the CCAN replacements to do that on other systems.
- *
- * If you don't call this with argv[0], it will be "unknown program".
- *
- * Example:
- *     err_set_progname(argv[0]);
- */
-void err_set_progname(const char *name);
-
-/**
- * err - exit(eval) with message based on format and errno.
- * @eval: the exit code
- * @fmt: the printf-style format string
- *
- * The format string is printed to stderr like so:
- *     <executable name>: <format>: <strerror(errno)>\n
- *
- * Example:
- *     char *p = strdup("hello");
- *     if (!p)
- *             err(1, "Failed to strdup 'hello'");
- */
-void NORETURN err(int eval, const char *fmt, ...);
-
-/**
- * errx - exit(eval) with message based on format.
- * @eval: the exit code
- * @fmt: the printf-style format string
- *
- * The format string is printed to stderr like so:
- *     <executable name>: <format>\n
- *
- * Example:
- *     if (argc != 1)
- *             errx(1, "I don't expect any arguments");
- */
-void NORETURN errx(int eval, const char *fmt, ...);
-
-/**
- * warn - print a message to stderr based on format and errno.
- * @eval: the exit code
- * @fmt: the printf-style format string
- *
- * The format string is printed to stderr like so:
- *     <executable name>: <format>: <strerror(errno)>\n
- *
- * Example:
- *     char *p = strdup("hello");
- *     if (!p)
- *             warn("Failed to strdup 'hello'");
- */
-void warn(const char *fmt, ...);
-
-/**
- * warnx - print a message to stderr based on format.
- * @eval: the exit code
- * @fmt: the printf-style format string
- *
- * The format string is printed to stderr like so:
- *     <executable name>: <format>\n
- *
- * Example:
- *     if (argc != 1)
- *             warnx("I don't expect any arguments (ignoring)");
- */
-void warnx(const char *fmt, ...);
-#endif
-
-#endif /* CCAN_ERR_H */
diff --git a/lib/ccan/err/test/run.c b/lib/ccan/err/test/run.c
deleted file mode 100644 (file)
index 242e93f..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-#include <ccan/err/err.c>
-#include <ccan/tap/tap.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#define BUFFER_MAX 1024
-
-int main(int argc, char *argv[])
-{
-       int pfd[2];
-       const char *base;
-
-       plan_tests(24);
-
-       err_set_progname(argv[0]);
-
-       /* In case it only prints out the basename of argv[0]. */
-       base = strrchr(argv[0], '/');
-       if (base)
-               base++;
-       else
-               base = argv[0];
-
-       /* Test err() in child */
-       pipe(pfd);
-       fflush(stdout);
-       if (fork()) {
-               char buffer[BUFFER_MAX+1];
-               unsigned int i;
-               int status;
-
-               /* We are parent. */
-               close(pfd[1]);
-               for (i = 0; i < BUFFER_MAX; i++) {
-                       if (read(pfd[0], buffer + i, 1) == 0) {
-                               buffer[i] = '\0';
-                               ok1(strstr(buffer, "running err:"));
-                               ok1(strstr(buffer, strerror(ENOENT)));
-                               ok1(strstr(buffer, base));
-                               ok1(buffer[i-1] == '\n');
-                               break;
-                       }
-               }
-               close(pfd[0]);
-               ok1(wait(&status) != -1);
-               ok1(WIFEXITED(status));
-               ok1(WEXITSTATUS(status) == 17);
-       } else {
-               close(pfd[0]);
-               dup2(pfd[1], STDERR_FILENO);
-               errno = ENOENT;
-               err(17, "running %s", "err");
-               abort();
-       }
-
-       /* Test errx() in child */
-       pipe(pfd);
-       fflush(stdout);
-       if (fork()) {
-               char buffer[BUFFER_MAX+1];
-               unsigned int i;
-               int status;
-
-               /* We are parent. */
-               close(pfd[1]);
-               for (i = 0; i < BUFFER_MAX; i++) {
-                       if (read(pfd[0], buffer + i, 1) == 0) {
-                               buffer[i] = '\0';
-                               ok1(strstr(buffer, "running errx\n"));
-                               ok1(strstr(buffer, base));
-                               break;
-                       }
-               }
-               close(pfd[0]);
-               ok1(wait(&status) != -1);
-               ok1(WIFEXITED(status));
-               ok1(WEXITSTATUS(status) == 17);
-       } else {
-               close(pfd[0]);
-               dup2(pfd[1], STDERR_FILENO);
-               errx(17, "running %s", "errx");
-               abort();
-       }
-
-
-       /* Test warn() in child */
-       pipe(pfd);
-       fflush(stdout);
-       if (fork()) {
-               char buffer[BUFFER_MAX+1];
-               unsigned int i;
-               int status;
-
-               /* We are parent. */
-               close(pfd[1]);
-               for (i = 0; i < BUFFER_MAX; i++) {
-                       if (read(pfd[0], buffer + i, 1) == 0) {
-                               buffer[i] = '\0';
-                               ok1(strstr(buffer, "running warn:"));
-                               ok1(strstr(buffer, strerror(ENOENT)));
-                               ok1(strstr(buffer, base));
-                               ok1(buffer[i-1] == '\n');
-                               break;
-                       }
-               }
-               close(pfd[0]);
-               ok1(wait(&status) != -1);
-               ok1(WIFEXITED(status));
-               ok1(WEXITSTATUS(status) == 17);
-       } else {
-               close(pfd[0]);
-               dup2(pfd[1], STDERR_FILENO);
-               errno = ENOENT;
-               warn("running %s", "warn");
-               exit(17);
-       }
-
-       /* Test warnx() in child */
-       pipe(pfd);
-       fflush(stdout);
-       if (fork()) {
-               char buffer[BUFFER_MAX+1];
-               unsigned int i;
-               int status;
-
-               /* We are parent. */
-               close(pfd[1]);
-               for (i = 0; i < BUFFER_MAX; i++) {
-                       if (read(pfd[0], buffer + i, 1) == 0) {
-                               buffer[i] = '\0';
-                               ok1(strstr(buffer, "running warnx\n"));
-                               ok1(strstr(buffer, base));
-                               break;
-                       }
-               }
-               close(pfd[0]);
-               ok1(wait(&status) != -1);
-               ok1(WIFEXITED(status));
-               ok1(WEXITSTATUS(status) == 17);
-       } else {
-               close(pfd[0]);
-               dup2(pfd[1], STDERR_FILENO);
-               warnx("running %s", "warnx");
-               exit(17);
-       }
-       return exit_status();
-}
-
diff --git a/lib/ccan/failtest/LICENSE b/lib/ccan/failtest/LICENSE
deleted file mode 100644 (file)
index cca7fc2..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
-  This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
-  0. Additional Definitions.
-
-  As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
-  "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
-  An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
-  A "Combined Work" is a work produced by combining or linking an
-Application with the Library.  The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
-  The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
-  The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
-  1. Exception to Section 3 of the GNU GPL.
-
-  You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
-  2. Conveying Modified Versions.
-
-  If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
-   a) under this License, provided that you make a good faith effort to
-   ensure that, in the event an Application does not supply the
-   function or data, the facility still operates, and performs
-   whatever part of its purpose remains meaningful, or
-
-   b) under the GNU GPL, with none of the additional permissions of
-   this License applicable to that copy.
-
-  3. Object Code Incorporating Material from Library Header Files.
-
-  The object code form of an Application may incorporate material from
-a header file that is part of the Library.  You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
-   a) Give prominent notice with each copy of the object code that the
-   Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the object code with a copy of the GNU GPL and this license
-   document.
-
-  4. Combined Works.
-
-  You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
-   a) Give prominent notice with each copy of the Combined Work that
-   the Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the Combined Work with a copy of the GNU GPL and this license
-   document.
-
-   c) For a Combined Work that displays copyright notices during
-   execution, include the copyright notice for the Library among
-   these notices, as well as a reference directing the user to the
-   copies of the GNU GPL and this license document.
-
-   d) Do one of the following:
-
-       0) Convey the Minimal Corresponding Source under the terms of this
-       License, and the Corresponding Application Code in a form
-       suitable for, and under terms that permit, the user to
-       recombine or relink the Application with a modified version of
-       the Linked Version to produce a modified Combined Work, in the
-       manner specified by section 6 of the GNU GPL for conveying
-       Corresponding Source.
-
-       1) Use a suitable shared library mechanism for linking with the
-       Library.  A suitable mechanism is one that (a) uses at run time
-       a copy of the Library already present on the user's computer
-       system, and (b) will operate properly with a modified version
-       of the Library that is interface-compatible with the Linked
-       Version.
-
-   e) Provide Installation Information, but only if you would otherwise
-   be required to provide such information under section 6 of the
-   GNU GPL, and only to the extent that such information is
-   necessary to install and execute a modified version of the
-   Combined Work produced by recombining or relinking the
-   Application with a modified version of the Linked Version. (If
-   you use option 4d0, the Installation Information must accompany
-   the Minimal Corresponding Source and Corresponding Application
-   Code. If you use option 4d1, you must provide the Installation
-   Information in the manner specified by section 6 of the GNU GPL
-   for conveying Corresponding Source.)
-
-  5. Combined Libraries.
-
-  You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
-   a) Accompany the combined library with a copy of the same work based
-   on the Library, uncombined with any other library facilities,
-   conveyed under the terms of this License.
-
-   b) Give prominent notice with the combined library that part of it
-   is a work based on the Library, and explaining where to find the
-   accompanying uncombined form of the same work.
-
-  6. Revised Versions of the GNU Lesser General Public License.
-
-  The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
-  Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
-  If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/lib/ccan/failtest/_info b/lib/ccan/failtest/_info
deleted file mode 100644 (file)
index da65bcb..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * failtest - unit test helpers for testing malloc and other failures.
- *
- * The failtest module overrides various standard functions, and forks
- * your unit test at those points to test failure paths.  The failing
- * child are expected to fail (eg. when malloc fails), but should not
- * leak memory or crash.  After including failtest_override.h, you can
- * include failtest_restore.h to return to non-failing versions.
- *
- * The unit test is a normal CCAN tap-style test, except it should
- * start by calling failtest_init() and end by calling
- * failtest_exit().
- *
- * You can control what functions fail: see failtest_hook.
- *
- * Example:
- *     #include <stdio.h>
- *     #include <stdlib.h>
- *     #include <string.h>
- *     #include <ccan/tap/tap.h>
- *     #include <ccan/failtest/failtest_override.h>
- *     #include <ccan/failtest/failtest.h>
- *
- *     int main(int argc, char *argv[])
- *     {
- *             char *a, *b;
- *
- *             failtest_init(argc, argv);
- *             plan_tests(3);
- *
- *             // Simple malloc test.
- *             a = malloc(100);
- *             if (ok1(a)) {
- *                     // Fill the memory.
- *                     memset(a, 'x', 100);
- *                     b = realloc(a, 200);
- *                     if (ok1(b)) {
- *                             // Fill the rest of the memory.
- *                             memset(b + 100, 'y', 100);
- *                             // Check it got a copy of a as expected.
- *                             ok1(strspn(b, "x") == 100);
- *                             free(b);
- *                     } else {
- *                             // Easy to miss: free a on realloc failure!
- *                             free(a);
- *                     }
- *             }
- *             failtest_exit(exit_status());
- *     }
- *
- * License: LGPL
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- * Ccanlint:
- *     // valgrind seems to mess up rlimit.
- *     tests_pass_valgrind test/run-with-fdlimit.c:FAIL
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               printf("ccan/build_assert\n");
-               printf("ccan/compiler\n");
-               printf("ccan/err\n");
-               printf("ccan/hash\n");
-               printf("ccan/htable\n");
-               printf("ccan/list\n");
-               printf("ccan/read_write_all\n");
-               printf("ccan/str\n");
-               printf("ccan/time\n");
-               printf("ccan/tlist\n");
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/failtest/failtest.c b/lib/ccan/failtest/failtest.c
deleted file mode 100644 (file)
index cffe36c..0000000
+++ /dev/null
@@ -1,1732 +0,0 @@
-/* Licensed under LGPL - see LICENSE file for details */
-#include <ccan/failtest/failtest.h>
-#include <stdarg.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <poll.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/mman.h>
-#include <sys/resource.h>
-#include <signal.h>
-#include <assert.h>
-#include <ccan/err/err.h>
-#include <ccan/time/time.h>
-#include <ccan/read_write_all/read_write_all.h>
-#include <ccan/failtest/failtest_proto.h>
-#include <ccan/build_assert/build_assert.h>
-#include <ccan/hash/hash.h>
-#include <ccan/htable/htable_type.h>
-#include <ccan/str/str.h>
-#include <ccan/compiler/compiler.h>
-
-enum failtest_result (*failtest_hook)(struct tlist_calls *);
-
-static FILE *tracef = NULL, *warnf;
-static int traceindent = 0;
-
-unsigned int failtest_timeout_ms = 20000;
-
-const char *failpath;
-const char *debugpath;
-
-enum info_type {
-       WRITE,
-       RELEASE_LOCKS,
-       FAILURE,
-       SUCCESS,
-       UNEXPECTED
-};
-
-struct lock_info {
-       int fd;
-       /* end is inclusive: you can't have a 0-byte lock. */
-       off_t start, end;
-       int type;
-};
-
-/* We hash the call location together with its backtrace. */
-static size_t hash_call(const struct failtest_call *call)
-{
-       return hash(call->file, strlen(call->file),
-                   hash(&call->line, 1,
-                        hash(call->backtrace, call->backtrace_num,
-                             call->type)));
-}
-
-static bool call_eq(const struct failtest_call *call1,
-                   const struct failtest_call *call2)
-{
-       unsigned int i;
-
-       if (strcmp(call1->file, call2->file) != 0
-           || call1->line != call2->line
-           || call1->type != call2->type
-           || call1->backtrace_num != call2->backtrace_num)
-               return false;
-
-       for (i = 0; i < call1->backtrace_num; i++)
-               if (call1->backtrace[i] != call2->backtrace[i])
-                       return false;
-
-       return true;
-}
-
-/* Defines struct failtable. */
-HTABLE_DEFINE_TYPE(struct failtest_call, (struct failtest_call *), hash_call,
-                  call_eq, failtable);
-
-bool (*failtest_exit_check)(struct tlist_calls *history);
-
-/* The entire history of all calls. */
-static struct tlist_calls history = TLIST_INIT(history);
-/* If we're a child, the fd two write control info to the parent. */
-static int control_fd = -1;
-/* If we're a child, this is the first call we did ourselves. */
-static struct failtest_call *our_history_start = NULL;
-/* For printing runtime with --trace. */
-static struct timeval start;
-/* Set when failtest_hook returns FAIL_PROBE */
-static bool probing = false;
-/* Table to track duplicates. */
-static struct failtable failtable;
-
-/* Array of writes which our child did.  We report them on failure. */
-static struct write_call *child_writes = NULL;
-static unsigned int child_writes_num = 0;
-
-/* fcntl locking info. */
-static pid_t lock_owner;
-static struct lock_info *locks = NULL;
-static unsigned int lock_num = 0;
-
-/* Our original pid, which we return to anyone who asks. */
-static pid_t orig_pid;
-
-/* Mapping from failtest_type to char. */
-static const char info_to_arg[] = "mceoxprwfal";
-
-/* Dummy call used for failtest_undo wrappers. */
-static struct failtest_call unrecorded_call;
-
-struct contents_saved {
-       size_t count;
-       off_t off;
-       off_t old_len;
-       char contents[1];
-};
-
-/* File contents, saved in this child only. */
-struct saved_mmapped_file {
-       struct saved_mmapped_file *next;
-       struct failtest_call *opener;
-       struct contents_saved *s;
-};
-
-static struct saved_mmapped_file *saved_mmapped_files;
-
-#if HAVE_BACKTRACE
-#include <execinfo.h>
-
-static void **get_backtrace(unsigned int *num)
-{
-       static unsigned int max_back = 100;
-       void **ret;
-
-again:
-       ret = malloc(max_back * sizeof(void *));
-       *num = backtrace(ret, max_back);
-       if (*num == max_back) {
-               free(ret);
-               max_back *= 2;
-               goto again;
-       }
-       return ret;
-}
-#else
-/* This will test slightly less, since will consider all of the same
- * calls as identical.  But, it's slightly faster! */
-static void **get_backtrace(unsigned int *num)
-{
-       *num = 0;
-       return NULL;
-}
-#endif /* HAVE_BACKTRACE */
-
-static struct failtest_call *add_history_(enum failtest_call_type type,
-                                         bool can_leak,
-                                         const char *file,
-                                         unsigned int line,
-                                         const void *elem,
-                                         size_t elem_size)
-{
-       struct failtest_call *call;
-
-       /* NULL file is how we suppress failure. */
-       if (!file)
-               return &unrecorded_call;
-
-       call = malloc(sizeof *call);
-       call->type = type;
-       call->can_leak = can_leak;
-       call->file = file;
-       call->line = line;
-       call->cleanup = NULL;
-       call->backtrace = get_backtrace(&call->backtrace_num);
-       memcpy(&call->u, elem, elem_size);
-       tlist_add_tail(&history, call, list);
-       return call;
-}
-
-#define add_history(type, can_leak, file, line, elem)          \
-       add_history_((type), (can_leak), (file), (line), (elem), sizeof(*(elem)))
-
-/* We do a fake call inside a sizeof(), to check types. */
-#define set_cleanup(call, clean, type)                 \
-       (call)->cleanup = (void *)((void)sizeof(clean((type *)NULL, false),1), (clean))
-
-/* Dup the fd to a high value (out of the way I hope!), and close the old fd. */
-static int move_fd_to_high(int fd)
-{
-       int i;
-       struct rlimit lim;
-       int max;
-
-       if (getrlimit(RLIMIT_NOFILE, &lim) == 0) {
-               max = lim.rlim_cur;
-       } else
-               max = FD_SETSIZE;
-
-       for (i = max - 1; i > fd; i--) {
-               if (fcntl(i, F_GETFL) == -1 && errno == EBADF) {
-                       if (dup2(fd, i) == -1) {
-                               warn("Failed to dup fd %i to %i", fd, i);
-                               continue;
-                       }
-                       close(fd);
-                       return i;
-               }
-       }
-       /* Nothing?  Really?  Er... ok? */
-       return fd;
-}
-
-static bool read_write_info(int fd)
-{
-       struct write_call *w;
-       char *buf;
-
-       /* We don't need all of this, but it's simple. */
-       child_writes = realloc(child_writes,
-                              (child_writes_num+1) * sizeof(child_writes[0]));
-       w = &child_writes[child_writes_num];
-       if (!read_all(fd, w, sizeof(*w)))
-               return false;
-
-       w->buf = buf = malloc(w->count);
-       if (!read_all(fd, buf, w->count))
-               return false;
-
-       child_writes_num++;
-       return true;
-}
-
-static char *failpath_string(void)
-{
-       struct failtest_call *i;
-       char *ret = strdup("");
-       unsigned len = 0;
-
-       /* Inefficient, but who cares? */
-       tlist_for_each(&history, i, list) {
-               ret = realloc(ret, len + 2);
-               ret[len] = info_to_arg[i->type];
-               if (i->fail)
-                       ret[len] = toupper(ret[len]);
-               ret[++len] = '\0';
-       }
-       return ret;
-}
-
-static void do_warn(int e, const char *fmt, va_list ap)
-{
-       char *p = failpath_string();
-
-       vfprintf(warnf, fmt, ap);
-       if (e != -1)
-               fprintf(warnf, ": %s", strerror(e));
-       fprintf(warnf, " [%s]\n", p);
-       free(p);
-}
-
-static void fwarn(const char *fmt, ...)
-{
-       va_list ap;
-       int e = errno;
-
-       va_start(ap, fmt);
-       do_warn(e, fmt, ap);
-       va_end(ap);
-}
-
-
-static void fwarnx(const char *fmt, ...)
-{
-       va_list ap;
-
-       va_start(ap, fmt);
-       do_warn(-1, fmt, ap);
-       va_end(ap);
-}
-
-static void tell_parent(enum info_type type)
-{
-       if (control_fd != -1)
-               write_all(control_fd, &type, sizeof(type));
-}
-
-static void child_fail(const char *out, size_t outlen, const char *fmt, ...)
-{
-       va_list ap;
-       char *path = failpath_string();
-
-       va_start(ap, fmt);
-       vfprintf(stderr, fmt, ap);
-       va_end(ap);
-
-       fprintf(stderr, "%.*s", (int)outlen, out);
-       printf("To reproduce: --failpath=%s\n", path);
-       free(path);
-       tell_parent(FAILURE);
-       exit(1);
-}
-
-static void PRINTF_FMT(1, 2) trace(const char *fmt, ...)
-{
-       va_list ap;
-       unsigned int i;
-       char *p;
-       static int idx;
-
-       if (!tracef)
-               return;
-
-       for (i = 0; i < traceindent; i++)
-               fprintf(tracef, "  ");
-
-       p = failpath_string();
-       fprintf(tracef, "%i: %u: %s ", idx++, (unsigned int)getpid(), p);
-       va_start(ap, fmt);
-       vfprintf(tracef, fmt, ap);
-       va_end(ap);
-       free(p);
-}
-
-static pid_t child;
-
-static void hand_down(int signum)
-{
-       kill(child, signum);
-}
-
-static void release_locks(void)
-{
-       /* Locks were never acquired/reacquired? */
-       if (lock_owner == 0)
-               return;
-
-       /* We own them?  Release them all. */
-       if (lock_owner == getpid()) {
-               unsigned int i;
-               struct flock fl;
-               fl.l_type = F_UNLCK;
-               fl.l_whence = SEEK_SET;
-               fl.l_start = 0;
-               fl.l_len = 0;
-
-               trace("Releasing %u locks\n", lock_num);
-               for (i = 0; i < lock_num; i++)
-                       fcntl(locks[i].fd, F_SETLK, &fl);
-       } else {
-               /* Our parent must have them; pass request up. */
-               enum info_type type = RELEASE_LOCKS;
-               assert(control_fd != -1);
-               write_all(control_fd, &type, sizeof(type));
-       }
-       lock_owner = 0;
-}
-
-/* off_t is a signed type.  Getting its max is non-trivial. */
-static off_t off_max(void)
-{
-       BUILD_ASSERT(sizeof(off_t) == 4 || sizeof(off_t) == 8);
-       if (sizeof(off_t) == 4)
-               return (off_t)0x7FFFFFF;
-       else
-               return (off_t)0x7FFFFFFFFFFFFFFULL;
-}
-
-static void get_locks(void)
-{
-       unsigned int i;
-       struct flock fl;
-
-       if (lock_owner == getpid())
-               return;
-
-       if (lock_owner != 0) {
-               enum info_type type = RELEASE_LOCKS;
-               assert(control_fd != -1);
-               trace("Asking parent to release locks\n");
-               write_all(control_fd, &type, sizeof(type));
-       }
-
-       fl.l_whence = SEEK_SET;
-
-       for (i = 0; i < lock_num; i++) {
-               fl.l_type = locks[i].type;
-               fl.l_start = locks[i].start;
-               if (locks[i].end == off_max())
-                       fl.l_len = 0;
-               else
-                       fl.l_len = locks[i].end - locks[i].start + 1;
-
-               if (fcntl(locks[i].fd, F_SETLKW, &fl) != 0)
-                       abort();
-       }
-       trace("Acquired %u locks\n", lock_num);
-       lock_owner = getpid();
-}
-
-
-static struct contents_saved *save_contents(const char *filename,
-                                           int fd, size_t count, off_t off,
-                                           const char *why)
-{
-       struct contents_saved *s = malloc(sizeof(*s) + count);
-       ssize_t ret;
-
-       s->off = off;
-
-       ret = pread(fd, s->contents, count, off);
-       if (ret < 0) {
-               fwarn("failtest_write: failed to save old contents!");
-               s->count = 0;
-       } else
-               s->count = ret;
-
-       /* Use lseek to get the size of file, but we have to restore
-        * file offset */
-       off = lseek(fd, 0, SEEK_CUR);
-       s->old_len = lseek(fd, 0, SEEK_END);
-       lseek(fd, off, SEEK_SET);
-
-       trace("Saving %p %s %zu@%llu after %s (filelength %llu) via fd %i\n",
-             s, filename, s->count, (long long)s->off, why,
-             (long long)s->old_len, fd);
-       return s;
-}
-
-static void restore_contents(struct failtest_call *opener,
-                            struct contents_saved *s,
-                            bool restore_offset,
-                            const char *caller)
-{
-       int fd;
-
-       /* The top parent doesn't need to restore. */
-       if (control_fd == -1)
-               return;
-
-       /* Has the fd been closed? */
-       if (opener->u.open.closed) {
-               /* Reopen, replace fd, close silently as we clean up. */
-               fd = open(opener->u.open.pathname, O_RDWR);
-               if (fd < 0) {
-                       fwarn("failtest: could not reopen %s to clean up %s!",
-                             opener->u.open.pathname, caller);
-                       return;
-               }
-               /* Make it clearly distinguisable from a "normal" fd. */
-               fd = move_fd_to_high(fd);
-               trace("Reopening %s to restore it (was fd %i, now %i)\n",
-                     opener->u.open.pathname, opener->u.open.ret, fd);
-               opener->u.open.ret = fd;
-               opener->u.open.closed = false;
-       }
-       fd = opener->u.open.ret;
-
-       trace("Restoring %p %s %zu@%llu after %s (filelength %llu) via fd %i\n",
-             s, opener->u.open.pathname, s->count, (long long)s->off, caller,
-             (long long)s->old_len, fd);
-       if (pwrite(fd, s->contents, s->count, s->off) != s->count) {
-               fwarn("failtest: write failed cleaning up %s for %s!",
-                     opener->u.open.pathname, caller);
-       }
-
-       if (ftruncate(fd, s->old_len) != 0) {
-               fwarn("failtest_write: truncate failed cleaning up %s for %s!",
-                     opener->u.open.pathname, caller);
-       }
-
-       if (restore_offset) {
-               trace("Restoring offset of fd %i to %llu\n",
-                     fd, (long long)s->off);
-               lseek(fd, s->off, SEEK_SET);
-       }
-}
-
-/* We save/restore most things on demand, but always do mmaped files. */
-static void save_mmapped_files(void)
-{
-       struct failtest_call *i;
-       trace("Saving mmapped files in child\n");
-
-       tlist_for_each_rev(&history, i, list) {
-               struct mmap_call *m = &i->u.mmap;
-               struct saved_mmapped_file *s;
-
-               if (i->type != FAILTEST_MMAP)
-                       continue;
-
-               /* FIXME: We only handle mmapped files where fd is still open. */
-               if (m->opener->u.open.closed)
-                       continue;
-
-               s = malloc(sizeof *s);
-               s->s = save_contents(m->opener->u.open.pathname,
-                                    m->fd, m->length, m->offset,
-                                    "mmapped file before fork");
-               s->opener = m->opener;
-               s->next = saved_mmapped_files;
-               saved_mmapped_files = s;
-       }
-}
-
-static void free_mmapped_files(bool restore)
-{
-       trace("%s mmapped files in child\n",
-             restore ? "Restoring" : "Discarding");
-       while (saved_mmapped_files) {
-               struct saved_mmapped_file *next = saved_mmapped_files->next;
-               if (restore)
-                       restore_contents(saved_mmapped_files->opener,
-                                        saved_mmapped_files->s, false,
-                                        "saved mmap");
-               free(saved_mmapped_files->s);
-               free(saved_mmapped_files);
-               saved_mmapped_files = next;
-       }
-}
-
-/* Returns a FAILTEST_OPEN, FAILTEST_PIPE or NULL. */
-static struct failtest_call *opener_of(int fd)
-{
-       struct failtest_call *i;
-
-       /* Don't get confused and match genuinely failed opens. */
-       if (fd < 0)
-               return NULL;
-
-       /* Figure out the set of live fds. */
-       tlist_for_each_rev(&history, i, list) {
-               if (i->fail)
-                       continue;
-               switch (i->type) {
-               case FAILTEST_CLOSE:
-                       if (i->u.close.fd == fd) {
-                               return NULL;
-                       }
-                       break;
-               case FAILTEST_OPEN:
-                       if (i->u.open.ret == fd) {
-                               if (i->u.open.closed)
-                                       return NULL;
-                               return i;
-                       }
-                       break;
-               case FAILTEST_PIPE:
-                       if (i->u.pipe.fds[0] == fd || i->u.pipe.fds[1] == fd) {
-                               return i;
-                       }
-                       break;
-               default:
-                       break;
-               }
-       }
-
-       /* FIXME: socket, dup, etc are untracked! */
-       return NULL;
-}
-
-static void free_call(struct failtest_call *call)
-{
-       /* We don't do this in cleanup: needed even for failed opens. */
-       if (call->type == FAILTEST_OPEN)
-               free((char *)call->u.open.pathname);
-       free(call->backtrace);
-       tlist_del_from(&history, call, list);
-       free(call);
-}
-
-/* Free up memory, so valgrind doesn't report leaks. */
-static void free_everything(void)
-{
-       struct failtest_call *i;
-
-       while ((i = tlist_top(&history, list)) != NULL)
-               free_call(i);
-
-       failtable_clear(&failtable);
-}
-
-static NORETURN void failtest_cleanup(bool forced_cleanup, int status)
-{
-       struct failtest_call *i;
-       bool restore = true;
-
-       /* For children, we don't care if they "failed" the testing. */
-       if (control_fd != -1)
-               status = 0;
-       else
-               /* We don't restore contents for original parent. */
-               restore = false;
-
-       /* Cleanup everything, in reverse order. */
-       tlist_for_each_rev(&history, i, list) {
-               /* Don't restore things our parent did. */
-               if (i == our_history_start)
-                       restore = false;
-
-               if (i->fail)
-                       continue;
-
-               if (i->cleanup)
-                       i->cleanup(&i->u, restore);
-
-               /* But their program shouldn't leak, even on failure. */
-               if (!forced_cleanup && i->can_leak) {
-                       printf("Leak at %s:%u: --failpath=%s\n",
-                              i->file, i->line, failpath_string());
-                       status = 1;
-               }
-       }
-
-       /* Put back mmaped files the way our parent (if any) expects. */
-       free_mmapped_files(true);
-
-       free_everything();
-       if (status == 0)
-               tell_parent(SUCCESS);
-       else
-               tell_parent(FAILURE);
-       exit(status);
-}
-
-static bool following_path(void)
-{
-       if (!failpath)
-               return false;
-       /* + means continue after end, like normal. */
-       if (*failpath == '+') {
-               failpath = NULL;
-               return false;
-       }
-       return true;
-}
-
-static bool follow_path(struct failtest_call *call)
-{
-       if (*failpath == '\0') {
-               /* Continue, but don't inject errors. */
-               return call->fail = false;
-       }
-
-       if (tolower((unsigned char)*failpath) != info_to_arg[call->type])
-               errx(1, "Failpath expected '%s' got '%c'\n",
-                    failpath, info_to_arg[call->type]);
-       call->fail = cisupper(*(failpath++));
-                       if (call->fail)
-                               call->can_leak = false;
-       return call->fail;
-}
-
-static bool should_fail(struct failtest_call *call)
-{
-       int status;
-       int control[2], output[2];
-       enum info_type type = UNEXPECTED;
-       char *out = NULL;
-       size_t outlen = 0;
-       struct failtest_call *dup;
-
-       if (call == &unrecorded_call)
-               return false;
-
-       if (following_path())
-               return follow_path(call);
-
-       /* Attach debugger if they asked for it. */
-       if (debugpath) {
-               char *path;
-
-               /* Pretend this last call matches whatever path wanted:
-                * keeps valgrind happy. */
-               call->fail = cisupper(debugpath[strlen(debugpath)-1]);
-               path = failpath_string();
-
-               if (streq(path, debugpath)) {
-                       char str[80];
-
-                       /* Don't timeout. */
-                       signal(SIGUSR1, SIG_IGN);
-                       sprintf(str, "xterm -e gdb /proc/%u/exe %u &",
-                               (unsigned int)getpid(), (unsigned int)getpid());
-                       if (system(str) == 0)
-                               sleep(5);
-               } else {
-                       /* Ignore last character: could be upper or lower. */
-                       path[strlen(path)-1] = '\0';
-                       if (!strstarts(debugpath, path)) {
-                               fprintf(stderr,
-                                       "--debugpath not followed: %s\n", path);
-                               debugpath = NULL;
-                       }
-               }
-               free(path);
-       }
-
-       /* Are we probing?  If so, we never fail twice. */
-       if (probing) {
-               trace("Not failing %c due to FAIL_PROBE return\n",
-                     info_to_arg[call->type]);
-               return call->fail = false;
-       }
-
-       /* Don't fail more than once in the same place. */
-       dup = failtable_get(&failtable, call);
-       if (dup) {
-               trace("Not failing %c due to duplicate\n",
-                     info_to_arg[call->type]);
-               return call->fail = false;
-       }
-
-       if (failtest_hook) {
-               switch (failtest_hook(&history)) {
-               case FAIL_OK:
-                       break;
-               case FAIL_PROBE:
-                       probing = true;
-                       break;
-               case FAIL_DONT_FAIL:
-                       trace("Not failing %c due to failhook return\n",
-                             info_to_arg[call->type]);
-                       call->fail = false;
-                       return false;
-               default:
-                       abort();
-               }
-       }
-
-       /* Add it to our table of calls. */
-       failtable_add(&failtable, call);
-
-       /* We're going to fail in the child. */
-       call->fail = true;
-       if (pipe(control) != 0 || pipe(output) != 0)
-               err(1, "opening pipe");
-
-       /* Move out the way, to high fds. */
-       control[0] = move_fd_to_high(control[0]);
-       control[1] = move_fd_to_high(control[1]);
-       output[0] = move_fd_to_high(output[0]);
-       output[1] = move_fd_to_high(output[1]);
-
-       /* Prevent double-printing (in child and parent) */
-       fflush(stdout);
-       fflush(warnf);
-       if (tracef)
-               fflush(tracef);
-       child = fork();
-       if (child == -1)
-               err(1, "forking failed");
-
-       if (child == 0) {
-               traceindent++;
-               if (tracef) {
-                       struct timeval diff;
-                       const char *p;
-                       char *failpath;
-                       struct failtest_call *c;
-
-                       c = tlist_tail(&history, list);
-                       diff = time_sub(time_now(), start);
-                       failpath = failpath_string();
-                       p = strrchr(c->file, '/');
-                       if (p)
-                               p++;
-                       else
-                               p = c->file;
-                       trace("%u->%u (%u.%02u): %s (%s:%u)\n",
-                             (unsigned int)getppid(), (unsigned int)getpid(),
-                             (int)diff.tv_sec, (int)diff.tv_usec / 10000,
-                             failpath, p, c->line);
-                       free(failpath);
-               }
-               /* From here on, we have to clean up! */
-               our_history_start = tlist_tail(&history, list);
-               close(control[0]);
-               close(output[0]);
-               /* Don't swallow stderr if we're tracing. */
-               if (!tracef) {
-                       dup2(output[1], STDOUT_FILENO);
-                       dup2(output[1], STDERR_FILENO);
-                       if (output[1] != STDOUT_FILENO
-                           && output[1] != STDERR_FILENO)
-                               close(output[1]);
-               }
-               control_fd = move_fd_to_high(control[1]);
-
-               /* Forget any of our parent's saved files. */
-               free_mmapped_files(false);
-
-               /* Now, save any files we need to. */
-               save_mmapped_files();
-
-               /* Failed calls can't leak. */
-               call->can_leak = false;
-
-               return true;
-       }
-
-       signal(SIGUSR1, hand_down);
-
-       close(control[1]);
-       close(output[1]);
-
-       /* We grab output so we can display it; we grab writes so we
-        * can compare. */
-       do {
-               struct pollfd pfd[2];
-               int ret;
-
-               pfd[0].fd = output[0];
-               pfd[0].events = POLLIN|POLLHUP;
-               pfd[1].fd = control[0];
-               pfd[1].events = POLLIN|POLLHUP;
-
-               if (type == SUCCESS)
-                       ret = poll(pfd, 1, failtest_timeout_ms);
-               else
-                       ret = poll(pfd, 2, failtest_timeout_ms);
-
-               if (ret == 0)
-                       hand_down(SIGUSR1);
-               if (ret < 0) {
-                       if (errno == EINTR)
-                               continue;
-                       err(1, "Poll returned %i", ret);
-               }
-
-               if (pfd[0].revents & POLLIN) {
-                       ssize_t len;
-
-                       out = realloc(out, outlen + 8192);
-                       len = read(output[0], out + outlen, 8192);
-                       outlen += len;
-               } else if (type != SUCCESS && (pfd[1].revents & POLLIN)) {
-                       if (read_all(control[0], &type, sizeof(type))) {
-                               if (type == WRITE) {
-                                       if (!read_write_info(control[0]))
-                                               break;
-                               } else if (type == RELEASE_LOCKS) {
-                                       release_locks();
-                                       /* FIXME: Tell them we're done... */
-                               }
-                       }
-               } else if (pfd[0].revents & POLLHUP) {
-                       break;
-               }
-       } while (type != FAILURE);
-
-       close(output[0]);
-       close(control[0]);
-       waitpid(child, &status, 0);
-       if (!WIFEXITED(status)) {
-               if (WTERMSIG(status) == SIGUSR1)
-                       child_fail(out, outlen, "Timed out");
-               else
-                       child_fail(out, outlen, "Killed by signal %u: ",
-                                  WTERMSIG(status));
-       }
-       /* Child printed failure already, just pass up exit code. */
-       if (type == FAILURE) {
-               fprintf(stderr, "%.*s", (int)outlen, out);
-               tell_parent(type);
-               exit(WEXITSTATUS(status) ? WEXITSTATUS(status) : 1);
-       }
-       if (WEXITSTATUS(status) != 0)
-               child_fail(out, outlen, "Exited with status %i: ",
-                          WEXITSTATUS(status));
-
-       free(out);
-       signal(SIGUSR1, SIG_DFL);
-
-       /* Only child does probe. */
-       probing = false;
-
-       /* We continue onwards without failing. */
-       call->fail = false;
-       return false;
-}
-
-static void cleanup_calloc(struct calloc_call *call, bool restore)
-{
-       trace("undoing calloc %p\n", call->ret);
-       free(call->ret);
-}
-
-void *failtest_calloc(size_t nmemb, size_t size,
-                     const char *file, unsigned line)
-{
-       struct failtest_call *p;
-       struct calloc_call call;
-       call.nmemb = nmemb;
-       call.size = size;
-       p = add_history(FAILTEST_CALLOC, true, file, line, &call);
-
-       if (should_fail(p)) {
-               p->u.calloc.ret = NULL;
-               p->error = ENOMEM;
-       } else {
-               p->u.calloc.ret = calloc(nmemb, size);
-               set_cleanup(p, cleanup_calloc, struct calloc_call);
-       }
-       trace("calloc %zu x %zu %s:%u -> %p\n",
-             nmemb, size, file, line, p->u.calloc.ret);
-       errno = p->error;
-       return p->u.calloc.ret;
-}
-
-static void cleanup_malloc(struct malloc_call *call, bool restore)
-{
-       trace("undoing malloc %p\n", call->ret);
-       free(call->ret);
-}
-
-void *failtest_malloc(size_t size, const char *file, unsigned line)
-{
-       struct failtest_call *p;
-       struct malloc_call call;
-       call.size = size;
-
-       p = add_history(FAILTEST_MALLOC, true, file, line, &call);
-       if (should_fail(p)) {
-               p->u.malloc.ret = NULL;
-               p->error = ENOMEM;
-       } else {
-               p->u.malloc.ret = malloc(size);
-               set_cleanup(p, cleanup_malloc, struct malloc_call);
-       }
-       trace("malloc %zu %s:%u -> %p\n",
-             size, file, line, p->u.malloc.ret);
-       errno = p->error;
-       return p->u.malloc.ret;
-}
-
-static void cleanup_realloc(struct realloc_call *call, bool restore)
-{
-       trace("undoing realloc %p\n", call->ret);
-       free(call->ret);
-}
-
-/* Walk back and find out if we got this ptr from a previous routine. */
-static void fixup_ptr_history(void *ptr, const char *why)
-{
-       struct failtest_call *i;
-
-       /* Start at end of history, work back. */
-       tlist_for_each_rev(&history, i, list) {
-               switch (i->type) {
-               case FAILTEST_REALLOC:
-                       if (i->u.realloc.ret == ptr) {
-                               trace("found realloc %p %s:%u matching %s\n",
-                                     ptr, i->file, i->line, why);
-                               i->cleanup = NULL;
-                               i->can_leak = false;
-                               return;
-                       }
-                       break;
-               case FAILTEST_MALLOC:
-                       if (i->u.malloc.ret == ptr) {
-                               trace("found malloc %p %s:%u matching %s\n",
-                                     ptr, i->file, i->line, why);
-                               i->cleanup = NULL;
-                               i->can_leak = false;
-                               return;
-                       }
-                       break;
-               case FAILTEST_CALLOC:
-                       if (i->u.calloc.ret == ptr) {
-                               trace("found calloc %p %s:%u matching %s\n",
-                                     ptr, i->file, i->line, why);
-                               i->cleanup = NULL;
-                               i->can_leak = false;
-                               return;
-                       }
-                       break;
-               default:
-                       break;
-               }
-       }
-       trace("Did not find %p matching %s\n", ptr, why);
-}
-
-void *failtest_realloc(void *ptr, size_t size, const char *file, unsigned line)
-{
-       struct failtest_call *p;
-       struct realloc_call call;
-       call.size = size;
-       p = add_history(FAILTEST_REALLOC, true, file, line, &call);
-
-       /* FIXME: Try one child moving allocation, one not. */
-       if (should_fail(p)) {
-               p->u.realloc.ret = NULL;
-               p->error = ENOMEM;
-       } else {
-               /* Don't catch this one in the history fixup... */
-               p->u.realloc.ret = NULL;
-               fixup_ptr_history(ptr, "realloc");
-               p->u.realloc.ret = realloc(ptr, size);
-               set_cleanup(p, cleanup_realloc, struct realloc_call);
-       }
-       trace("realloc %p %s:%u -> %p\n",
-             ptr, file, line, p->u.realloc.ret);
-       errno = p->error;
-       return p->u.realloc.ret;
-}
-
-/* FIXME: Record free, so we can terminate fixup_ptr_history correctly.
- * If there's an alloc we don't see, it could get confusing if it matches
- * a previous allocation we did see. */
-void failtest_free(void *ptr)
-{
-       fixup_ptr_history(ptr, "free");
-       trace("free %p\n", ptr);
-       free(ptr);
-}
-
-
-static struct contents_saved *save_file(const char *pathname)
-{
-       int fd;
-       struct contents_saved *s;
-
-       fd = open(pathname, O_RDONLY);
-       if (fd < 0)
-               return NULL;
-
-       s = save_contents(pathname, fd, lseek(fd, 0, SEEK_END), 0,
-                         "open with O_TRUNC");
-       close(fd);
-       return s;
-}
-
-/* Optimization: don't create a child for an open which *we know*
- * would fail anyway. */
-static bool open_would_fail(const char *pathname, int flags)
-{
-       if ((flags & O_ACCMODE) == O_RDONLY)
-               return access(pathname, R_OK) != 0;
-       if (!(flags & O_CREAT)) {
-               if ((flags & O_ACCMODE) == O_WRONLY)
-                       return access(pathname, W_OK) != 0;
-               if ((flags & O_ACCMODE) == O_RDWR)
-                       return access(pathname, W_OK) != 0
-                               || access(pathname, R_OK) != 0;
-       }
-       /* FIXME: We could check if it exists, for O_CREAT|O_EXCL */
-       return false;
-}
-
-static void cleanup_open(struct open_call *call, bool restore)
-{
-       if (restore && call->saved)
-               restore_contents(container_of(call, struct failtest_call,
-                                             u.open),
-                                call->saved, false, "open with O_TRUNC");
-       if (!call->closed) {
-               trace("Cleaning up open %s by closing fd %i\n",
-                     call->pathname, call->ret);
-               close(call->ret);
-               call->closed = true;
-       }
-       free(call->saved);
-}
-
-int failtest_open(const char *pathname,
-                 const char *file, unsigned line, ...)
-{
-       struct failtest_call *p;
-       struct open_call call;
-       va_list ap;
-
-       call.pathname = strdup(pathname);
-       va_start(ap, line);
-       call.flags = va_arg(ap, int);
-       call.always_save = false;
-       call.closed = false;
-       if (call.flags & O_CREAT) {
-               call.mode = va_arg(ap, int);
-               va_end(ap);
-       }
-       p = add_history(FAILTEST_OPEN, true, file, line, &call);
-       /* Avoid memory leak! */
-       if (p == &unrecorded_call)
-               free((char *)call.pathname);
-
-       if (should_fail(p)) {
-               /* Don't bother inserting failures that would happen anyway. */
-               if (open_would_fail(pathname, call.flags)) {
-                       trace("Open would have failed anyway: stopping\n");
-                       failtest_cleanup(true, 0);
-               }
-               p->u.open.ret = -1;
-               /* FIXME: Play with error codes? */
-               p->error = EACCES;
-       } else {
-               /* Save the old version if they're truncating it. */
-               if (call.flags & O_TRUNC)
-                       p->u.open.saved = save_file(pathname);
-               else
-                       p->u.open.saved = NULL;
-               p->u.open.ret = open(pathname, call.flags, call.mode);
-               if (p->u.open.ret == -1) {
-                       p->u.open.closed = true;
-                       p->can_leak = false;
-               } else {
-                       set_cleanup(p, cleanup_open, struct open_call);
-               }
-       }
-       trace("open %s %s:%u -> %i (opener %p)\n",
-             pathname, file, line, p->u.open.ret, &p->u.open);
-       errno = p->error;
-       return p->u.open.ret;
-}
-
-static void cleanup_mmap(struct mmap_call *mmap, bool restore)
-{
-       trace("cleaning up mmap @%p (opener %p)\n",
-             mmap->ret, mmap->opener);
-       if (restore)
-               restore_contents(mmap->opener, mmap->saved, false, "mmap");
-       free(mmap->saved);
-}
-
-void *failtest_mmap(void *addr, size_t length, int prot, int flags,
-                   int fd, off_t offset, const char *file, unsigned line)
-{
-       struct failtest_call *p;
-       struct mmap_call call;
-
-       call.addr = addr;
-       call.length = length;
-       call.prot = prot;
-       call.flags = flags;
-       call.offset = offset;
-       call.fd = fd;
-       call.opener = opener_of(fd);
-
-       /* If we don't know what file it was, don't fail. */
-       if (!call.opener) {
-               if (fd != -1) {
-                       fwarnx("failtest_mmap: couldn't figure out source for"
-                              " fd %i at %s:%u", fd, file, line);
-               }
-               addr = mmap(addr, length, prot, flags, fd, offset);
-               trace("mmap of fd %i -> %p (opener = NULL)\n", fd, addr);
-               return addr;
-       }
-
-       p = add_history(FAILTEST_MMAP, false, file, line, &call);
-       if (should_fail(p)) {
-               p->u.mmap.ret = MAP_FAILED;
-               p->error = ENOMEM;
-       } else {
-               p->u.mmap.ret = mmap(addr, length, prot, flags, fd, offset);
-               /* Save contents if we're writing to a normal file */
-               if (p->u.mmap.ret != MAP_FAILED
-                   && (prot & PROT_WRITE)
-                   && call.opener->type == FAILTEST_OPEN) {
-                       const char *fname = call.opener->u.open.pathname;
-                       p->u.mmap.saved = save_contents(fname, fd, length,
-                                                       offset, "being mmapped");
-                       set_cleanup(p, cleanup_mmap, struct mmap_call);
-               }
-       }
-       trace("mmap of fd %i %s:%u -> %p (opener = %p)\n",
-             fd, file, line, addr, call.opener);
-       errno = p->error;
-       return p->u.mmap.ret;
-}
-
-/* Since OpenBSD can't handle adding args, we use this file and line.
- * This will make all mmaps look the same, reducing coverage. */
-void *failtest_mmap_noloc(void *addr, size_t length, int prot, int flags,
-                         int fd, off_t offset)
-{
-       return failtest_mmap(addr, length, prot, flags, fd, offset,
-                            __FILE__, __LINE__);
-}
-
-static void cleanup_pipe(struct pipe_call *call, bool restore)
-{
-       trace("cleaning up pipe fd=%i%s,%i%s\n",
-             call->fds[0], call->closed[0] ? "(already closed)" : "",
-             call->fds[1], call->closed[1] ? "(already closed)" : "");
-       if (!call->closed[0])
-               close(call->fds[0]);
-       if (!call->closed[1])
-               close(call->fds[1]);
-}
-
-int failtest_pipe(int pipefd[2], const char *file, unsigned line)
-{
-       struct failtest_call *p;
-       struct pipe_call call;
-
-       p = add_history(FAILTEST_PIPE, true, file, line, &call);
-       if (should_fail(p)) {
-               p->u.open.ret = -1;
-               /* FIXME: Play with error codes? */
-               p->error = EMFILE;
-       } else {
-               p->u.pipe.ret = pipe(p->u.pipe.fds);
-               p->u.pipe.closed[0] = p->u.pipe.closed[1] = false;
-               set_cleanup(p, cleanup_pipe, struct pipe_call);
-       }
-
-       trace("pipe %s:%u -> %i,%i\n", file, line,
-             p->u.pipe.ret ? -1 : p->u.pipe.fds[0],
-             p->u.pipe.ret ? -1 : p->u.pipe.fds[1]);
-
-       /* This causes valgrind to notice if they use pipefd[] after failure */
-       memcpy(pipefd, p->u.pipe.fds, sizeof(p->u.pipe.fds));
-       errno = p->error;
-       return p->u.pipe.ret;
-}
-
-static void cleanup_read(struct read_call *call, bool restore)
-{
-       if (restore) {
-               trace("cleaning up read on fd %i: seeking to %llu\n",
-                     call->fd, (long long)call->off);
-
-               /* Read (not readv!) moves file offset! */
-               if (lseek(call->fd, call->off, SEEK_SET) != call->off) {
-                       fwarn("Restoring lseek pointer failed (read)");
-               }
-       }
-}
-
-static ssize_t failtest_add_read(int fd, void *buf, size_t count, off_t off,
-                                bool is_pread, const char *file, unsigned line)
-{
-       struct failtest_call *p;
-       struct read_call call;
-       call.fd = fd;
-       call.buf = buf;
-       call.count = count;
-       call.off = off;
-       p = add_history(FAILTEST_READ, false, file, line, &call);
-
-       /* FIXME: Try partial read returns. */
-       if (should_fail(p)) {
-               p->u.read.ret = -1;
-               p->error = EIO;
-       } else {
-               if (is_pread)
-                       p->u.read.ret = pread(fd, buf, count, off);
-               else {
-                       p->u.read.ret = read(fd, buf, count);
-                       if (p->u.read.ret != -1)
-                               set_cleanup(p, cleanup_read, struct read_call);
-               }
-       }
-       trace("%sread %s:%u fd %i %zu@%llu -> %zd\n",
-             is_pread ? "p" : "", file, line, fd, count, (long long)off,
-             p->u.read.ret);
-       errno = p->error;
-       return p->u.read.ret;
-}
-
-static void cleanup_write(struct write_call *write, bool restore)
-{
-       trace("cleaning up write on %s\n", write->opener->u.open.pathname);
-       if (restore)
-               restore_contents(write->opener, write->saved, !write->is_pwrite,
-                                "write");
-       free(write->saved);
-}
-
-static ssize_t failtest_add_write(int fd, const void *buf,
-                                 size_t count, off_t off,
-                                 bool is_pwrite,
-                                 const char *file, unsigned line)
-{
-       struct failtest_call *p;
-       struct write_call call;
-
-       call.fd = fd;
-       call.buf = buf;
-       call.count = count;
-       call.off = off;
-       call.is_pwrite = is_pwrite;
-       call.opener = opener_of(fd);
-       p = add_history(FAILTEST_WRITE, false, file, line, &call);
-
-       /* If we're a child, we need to make sure we write the same thing
-        * to non-files as the parent does, so tell it. */
-       if (control_fd != -1 && off == (off_t)-1) {
-               enum info_type type = WRITE;
-
-               write_all(control_fd, &type, sizeof(type));
-               write_all(control_fd, &p->u.write, sizeof(p->u.write));
-               write_all(control_fd, buf, count);
-       }
-
-       /* FIXME: Try partial write returns. */
-       if (should_fail(p)) {
-               p->u.write.ret = -1;
-               p->error = EIO;
-       } else {
-               bool is_file;
-               assert(call.opener == p->u.write.opener);
-
-               if (p->u.write.opener) {
-                       is_file = (p->u.write.opener->type == FAILTEST_OPEN);
-               } else {
-                       /* We can't unwind it, so at least check same
-                        * in parent and child. */
-                       is_file = false;
-               }
-
-               /* FIXME: We assume same write order in parent and child */
-               if (!is_file && child_writes_num != 0) {
-                       if (child_writes[0].fd != fd)
-                               errx(1, "Child wrote to fd %u, not %u?",
-                                    child_writes[0].fd, fd);
-                       if (child_writes[0].off != p->u.write.off)
-                               errx(1, "Child wrote to offset %zu, not %zu?",
-                                    (size_t)child_writes[0].off,
-                                    (size_t)p->u.write.off);
-                       if (child_writes[0].count != count)
-                               errx(1, "Child wrote length %zu, not %zu?",
-                                    child_writes[0].count, count);
-                       if (memcmp(child_writes[0].buf, buf, count)) {
-                               child_fail(NULL, 0,
-                                          "Child wrote differently to"
-                                          " fd %u than we did!\n", fd);
-                       }
-                       free((char *)child_writes[0].buf);
-                       child_writes_num--;
-                       memmove(&child_writes[0], &child_writes[1],
-                               sizeof(child_writes[0]) * child_writes_num);
-
-                       /* Child wrote it already. */
-                       trace("write %s:%i on fd %i already done by child\n",
-                             file, line, fd);
-                       p->u.write.ret = count;
-                       errno = p->error;
-                       return p->u.write.ret;
-               }
-
-               if (is_file) {
-                       p->u.write.saved = save_contents(call.opener->u.open.pathname,
-                                                        fd, count, off,
-                                                        "being overwritten");
-                       set_cleanup(p, cleanup_write, struct write_call);
-               }
-
-               /* Though off is current seek ptr for write case, we need to
-                * move it.  write() does that for us. */
-               if (p->u.write.is_pwrite)
-                       p->u.write.ret = pwrite(fd, buf, count, off);
-               else
-                       p->u.write.ret = write(fd, buf, count);
-       }
-       trace("%swrite %s:%i %zu@%llu on fd %i -> %zd\n",
-             p->u.write.is_pwrite ? "p" : "",
-             file, line, count, (long long)off, fd, p->u.write.ret);
-       errno = p->error;
-       return p->u.write.ret;
-}
-
-ssize_t failtest_pwrite(int fd, const void *buf, size_t count, off_t offset,
-                       const char *file, unsigned line)
-{
-       return failtest_add_write(fd, buf, count, offset, true, file, line);
-}
-
-ssize_t failtest_write(int fd, const void *buf, size_t count,
-                      const char *file, unsigned line)
-{
-       return failtest_add_write(fd, buf, count, lseek(fd, 0, SEEK_CUR), false,
-                                 file, line);
-}
-
-ssize_t failtest_pread(int fd, void *buf, size_t count, off_t off,
-                      const char *file, unsigned line)
-{
-       return failtest_add_read(fd, buf, count, off, true, file, line);
-}
-
-ssize_t failtest_read(int fd, void *buf, size_t count,
-                     const char *file, unsigned line)
-{
-       return failtest_add_read(fd, buf, count, lseek(fd, 0, SEEK_CUR), false,
-                                file, line);
-}
-
-static struct lock_info *WARN_UNUSED_RESULT
-add_lock(struct lock_info *locks, int fd, off_t start, off_t end, int type)
-{
-       unsigned int i;
-       struct lock_info *l;
-
-       for (i = 0; i < lock_num; i++) {
-               l = &locks[i];
-
-               if (l->fd != fd)
-                       continue;
-               /* Four cases we care about:
-                * Start overlap:
-                *      l =    |      |
-                *      new = |   |
-                * Mid overlap:
-                *      l =    |      |
-                *      new =    |  |
-                * End overlap:
-                *      l =    |      |
-                *      new =      |    |
-                * Total overlap:
-                *      l =    |      |
-                *      new = |         |
-                */
-               if (start > l->start && end < l->end) {
-                       /* Mid overlap: trim entry, add new one. */
-                       off_t new_start, new_end;
-                       new_start = end + 1;
-                       new_end = l->end;
-                       trace("splitting lock on fd %i from %llu-%llu"
-                             " to %llu-%llu\n",
-                             fd, (long long)l->start, (long long)l->end,
-                             (long long)l->start, (long long)start - 1);
-                       l->end = start - 1;
-                       locks = add_lock(locks,
-                                        fd, new_start, new_end, l->type);
-                       l = &locks[i];
-               } else if (start <= l->start && end >= l->end) {
-                       /* Total overlap: eliminate entry. */
-                       trace("erasing lock on fd %i %llu-%llu\n",
-                             fd, (long long)l->start, (long long)l->end);
-                       l->end = 0;
-                       l->start = 1;
-               } else if (end >= l->start && end < l->end) {
-                       trace("trimming lock on fd %i from %llu-%llu"
-                             " to %llu-%llu\n",
-                             fd, (long long)l->start, (long long)l->end,
-                             (long long)end + 1, (long long)l->end);
-                       /* Start overlap: trim entry. */
-                       l->start = end + 1;
-               } else if (start > l->start && start <= l->end) {
-                       trace("trimming lock on fd %i from %llu-%llu"
-                             " to %llu-%llu\n",
-                             fd, (long long)l->start, (long long)l->end,
-                             (long long)l->start, (long long)start - 1);
-                       /* End overlap: trim entry. */
-                       l->end = start-1;
-               }
-               /* Nothing left?  Remove it. */
-               if (l->end < l->start) {
-                       trace("forgetting lock on fd %i\n", fd);
-                       memmove(l, l + 1, (--lock_num - i) * sizeof(l[0]));
-                       i--;
-               }
-       }
-
-       if (type != F_UNLCK) {
-               locks = realloc(locks, (lock_num + 1) * sizeof(*locks));
-               l = &locks[lock_num++];
-               l->fd = fd;
-               l->start = start;
-               l->end = end;
-               l->type = type;
-               trace("new lock on fd %i %llu-%llu\n",
-                     fd, (long long)l->start, (long long)l->end);
-       }
-       return locks;
-}
-
-/* We trap this so we can record it: we don't fail it. */
-int failtest_close(int fd, const char *file, unsigned line)
-{
-       struct close_call call;
-       struct failtest_call *p, *opener;
-
-       /* Do this before we add ourselves to history! */
-       opener = opener_of(fd);
-
-       call.fd = fd;
-       p = add_history(FAILTEST_CLOSE, false, file, line, &call);
-       p->fail = false;
-
-       /* Consume close from failpath (shouldn't tell us to fail). */
-       if (following_path()) {
-               if (follow_path(p))
-                       abort();
-       }
-
-       trace("close on fd %i\n", fd);
-       if (fd < 0)
-               return close(fd);
-
-       /* Mark opener as not leaking, remove its cleanup function. */
-       if (opener) {
-               trace("close on fd %i found opener %p\n", fd, opener);
-               if (opener->type == FAILTEST_PIPE) {
-                       /* From a pipe? */
-                       if (opener->u.pipe.fds[0] == fd) {
-                               assert(!opener->u.pipe.closed[0]);
-                               opener->u.pipe.closed[0] = true;
-                       } else if (opener->u.pipe.fds[1] == fd) {
-                               assert(!opener->u.pipe.closed[1]);
-                               opener->u.pipe.closed[1] = true;
-                       } else
-                               abort();
-                       opener->can_leak = (!opener->u.pipe.closed[0]
-                                           || !opener->u.pipe.closed[1]);
-               } else if (opener->type == FAILTEST_OPEN) {
-                       opener->u.open.closed = true;
-                       opener->can_leak = false;
-               } else
-                       abort();
-       }
-
-       /* Restore offset now, in case parent shared (can't do after close!). */
-       if (control_fd != -1) {
-               struct failtest_call *i;
-
-               tlist_for_each_rev(&history, i, list) {
-                       if (i == our_history_start)
-                               break;
-                       if (i == opener)
-                               break;
-                       if (i->type == FAILTEST_LSEEK && i->u.lseek.fd == fd) {
-                               trace("close on fd %i undoes lseek\n", fd);
-                               /* This seeks back. */
-                               i->cleanup(&i->u, true);
-                               i->cleanup = NULL;
-                       } else if (i->type == FAILTEST_WRITE
-                                  && i->u.write.fd == fd
-                                  && !i->u.write.is_pwrite) {
-                               trace("close on fd %i undoes write"
-                                     " offset change\n", fd);
-                               /* Write (not pwrite!) moves file offset! */
-                               if (lseek(fd, i->u.write.off, SEEK_SET)
-                                   != i->u.write.off) {
-                                       fwarn("Restoring lseek pointer failed (write)");
-                               }
-                       } else if (i->type == FAILTEST_READ
-                                  && i->u.read.fd == fd) {
-                               /* preads don't *have* cleanups */
-                               if (i->cleanup) {
-                                       trace("close on fd %i undoes read"
-                                             " offset change\n", fd);
-                                       /* This seeks back. */
-                                       i->cleanup(&i->u, true);
-                                       i->cleanup = NULL;
-                               }
-                       }
-               }
-       }
-
-       /* Close unlocks everything. */
-       locks = add_lock(locks, fd, 0, off_max(), F_UNLCK);
-       return close(fd);
-}
-
-/* Zero length means "to end of file" */
-static off_t end_of(off_t start, off_t len)
-{
-       if (len == 0)
-               return off_max();
-       return start + len - 1;
-}
-
-/* FIXME: This only handles locks, really. */
-int failtest_fcntl(int fd, const char *file, unsigned line, int cmd, ...)
-{
-       struct failtest_call *p;
-       struct fcntl_call call;
-       va_list ap;
-
-       call.fd = fd;
-       call.cmd = cmd;
-
-       /* Argument extraction. */
-       switch (cmd) {
-       case F_SETFL:
-       case F_SETFD:
-               va_start(ap, cmd);
-               call.arg.l = va_arg(ap, long);
-               va_end(ap);
-               trace("fcntl on fd %i F_SETFL/F_SETFD\n", fd);
-               return fcntl(fd, cmd, call.arg.l);
-       case F_GETFD:
-       case F_GETFL:
-               trace("fcntl on fd %i F_GETFL/F_GETFD\n", fd);
-               return fcntl(fd, cmd);
-       case F_GETLK:
-               trace("fcntl on fd %i F_GETLK\n", fd);
-               get_locks();
-               va_start(ap, cmd);
-               call.arg.fl = *va_arg(ap, struct flock *);
-               va_end(ap);
-               return fcntl(fd, cmd, &call.arg.fl);
-       case F_SETLK:
-       case F_SETLKW:
-               trace("fcntl on fd %i F_SETLK%s\n",
-                     fd, cmd == F_SETLKW ? "W" : "");
-               va_start(ap, cmd);
-               call.arg.fl = *va_arg(ap, struct flock *);
-               va_end(ap);
-               break;
-       default:
-               /* This means you need to implement it here. */
-               err(1, "failtest: unknown fcntl %u", cmd);
-       }
-
-       p = add_history(FAILTEST_FCNTL, false, file, line, &call);
-
-       if (should_fail(p)) {
-               p->u.fcntl.ret = -1;
-               if (p->u.fcntl.cmd == F_SETLK)
-                       p->error = EAGAIN;
-               else
-                       p->error = EDEADLK;
-       } else {
-               get_locks();
-               p->u.fcntl.ret = fcntl(p->u.fcntl.fd, p->u.fcntl.cmd,
-                                      &p->u.fcntl.arg.fl);
-               if (p->u.fcntl.ret == -1)
-                       p->error = errno;
-               else {
-                       /* We don't handle anything else yet. */
-                       assert(p->u.fcntl.arg.fl.l_whence == SEEK_SET);
-                       locks = add_lock(locks,
-                                        p->u.fcntl.fd,
-                                        p->u.fcntl.arg.fl.l_start,
-                                        end_of(p->u.fcntl.arg.fl.l_start,
-                                               p->u.fcntl.arg.fl.l_len),
-                                        p->u.fcntl.arg.fl.l_type);
-               }
-       }
-       trace("fcntl on fd %i -> %i\n", fd, p->u.fcntl.ret);
-       errno = p->error;
-       return p->u.fcntl.ret;
-}
-
-static void cleanup_lseek(struct lseek_call *call, bool restore)
-{
-       if (restore) {
-               trace("cleaning up lseek on fd %i -> %llu\n",
-                     call->fd, (long long)call->old_off);
-               if (lseek(call->fd, call->old_off, SEEK_SET) != call->old_off)
-                       fwarn("Restoring lseek pointer failed");
-       }
-}
-
-/* We trap this so we can undo it: we don't fail it. */
-off_t failtest_lseek(int fd, off_t offset, int whence, const char *file,
-                    unsigned int line)
-{
-       struct failtest_call *p;
-       struct lseek_call call;
-       call.fd = fd;
-       call.offset = offset;
-       call.whence = whence;
-       call.old_off = lseek(fd, 0, SEEK_CUR);
-
-       p = add_history(FAILTEST_LSEEK, false, file, line, &call);
-       p->fail = false;
-
-       /* Consume lseek from failpath. */
-       if (failpath)
-               if (should_fail(p))
-                       abort();
-
-       p->u.lseek.ret = lseek(fd, offset, whence);
-
-       if (p->u.lseek.ret != (off_t)-1)
-               set_cleanup(p, cleanup_lseek, struct lseek_call);
-
-       trace("lseek %s:%u on fd %i from %llu to %llu%s\n",
-             file, line, fd, (long long)call.old_off, (long long)offset,
-             whence == SEEK_CUR ? " (from current off)" :
-             whence == SEEK_END ? " (from end)" :
-             whence == SEEK_SET ? "" : " (invalid whence)");
-       return p->u.lseek.ret;
-}
-
-
-pid_t failtest_getpid(const char *file, unsigned line)
-{
-       /* You must call failtest_init first! */
-       assert(orig_pid);
-       return orig_pid;
-}
-
-void failtest_init(int argc, char *argv[])
-{
-       unsigned int i;
-
-       orig_pid = getpid();
-
-       warnf = fdopen(move_fd_to_high(dup(STDERR_FILENO)), "w");
-       for (i = 1; i < argc; i++) {
-               if (!strncmp(argv[i], "--failpath=", strlen("--failpath="))) {
-                       failpath = argv[i] + strlen("--failpath=");
-               } else if (strcmp(argv[i], "--trace") == 0) {
-                       tracef = warnf;
-                       failtest_timeout_ms = -1;
-               } else if (!strncmp(argv[i], "--debugpath=",
-                                   strlen("--debugpath="))) {
-                       debugpath = argv[i] + strlen("--debugpath=");
-               }
-       }
-       failtable_init(&failtable);
-       start = time_now();
-}
-
-bool failtest_has_failed(void)
-{
-       return control_fd != -1;
-}
-
-void failtest_exit(int status)
-{
-       trace("failtest_exit with status %i\n", status);
-       if (failtest_exit_check) {
-               if (!failtest_exit_check(&history))
-                       child_fail(NULL, 0, "failtest_exit_check failed\n");
-       }
-
-       failtest_cleanup(false, status);
-}
diff --git a/lib/ccan/failtest/failtest.d b/lib/ccan/failtest/failtest.d
deleted file mode 100644 (file)
index 6aa295d..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-ccan/failtest/failtest.o: ccan/failtest/failtest.c \
- ccan/failtest/failtest.h config.h \
- /usr/include/i386-linux-gnu/sys/types.h /usr/include/features.h \
- /usr/include/i386-linux-gnu/bits/predefs.h \
- /usr/include/i386-linux-gnu/sys/cdefs.h \
- /usr/include/i386-linux-gnu/bits/wordsize.h \
- /usr/include/i386-linux-gnu/gnu/stubs.h \
- /usr/include/i386-linux-gnu/gnu/stubs-32.h \
- /usr/include/i386-linux-gnu/bits/types.h \
- /usr/include/i386-linux-gnu/bits/typesizes.h /usr/include/time.h \
- /usr/lib/gcc/i686-linux-gnu/4.5.4/include/stddef.h /usr/include/endian.h \
- /usr/include/i386-linux-gnu/bits/endian.h \
- /usr/include/i386-linux-gnu/bits/byteswap.h \
- /usr/include/i386-linux-gnu/sys/select.h \
- /usr/include/i386-linux-gnu/bits/select.h \
- /usr/include/i386-linux-gnu/bits/sigset.h \
- /usr/include/i386-linux-gnu/bits/time.h \
- /usr/include/i386-linux-gnu/sys/sysmacros.h \
- /usr/include/i386-linux-gnu/bits/pthreadtypes.h \
- /usr/lib/gcc/i686-linux-gnu/4.5.4/include/stdbool.h /usr/include/fcntl.h \
- /usr/include/i386-linux-gnu/bits/fcntl.h \
- /usr/include/i386-linux-gnu/bits/uio.h \
- /usr/include/i386-linux-gnu/bits/stat.h ccan/compiler/compiler.h \
- ccan/tlist/tlist.h ccan/list/list.h /usr/include/assert.h \
- ccan/container_of/container_of.h ccan/check_type/check_type.h \
- ccan/tcon/tcon.h /usr/lib/gcc/i686-linux-gnu/4.5.4/include/stdarg.h \
- /usr/include/string.h /usr/include/xlocale.h /usr/include/stdio.h \
- /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
- /usr/include/i386-linux-gnu/bits/stdio_lim.h \
- /usr/include/i386-linux-gnu/bits/sys_errlist.h /usr/include/ctype.h \
- /usr/include/err.h /usr/include/unistd.h \
- /usr/include/i386-linux-gnu/bits/posix_opt.h \
- /usr/include/i386-linux-gnu/bits/environments.h \
- /usr/include/i386-linux-gnu/bits/confname.h /usr/include/getopt.h \
- /usr/include/poll.h /usr/include/i386-linux-gnu/sys/poll.h \
- /usr/include/i386-linux-gnu/bits/poll.h /usr/include/errno.h \
- /usr/include/i386-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
- /usr/include/i386-linux-gnu/asm/errno.h /usr/include/asm-generic/errno.h \
- /usr/include/asm-generic/errno-base.h \
- /usr/include/i386-linux-gnu/sys/wait.h /usr/include/signal.h \
- /usr/include/i386-linux-gnu/bits/signum.h \
- /usr/include/i386-linux-gnu/bits/siginfo.h \
- /usr/include/i386-linux-gnu/bits/sigaction.h \
- /usr/include/i386-linux-gnu/bits/sigcontext.h \
- /usr/include/i386-linux-gnu/asm/sigcontext.h /usr/include/linux/types.h \
- /usr/include/i386-linux-gnu/asm/types.h /usr/include/asm-generic/types.h \
- /usr/include/asm-generic/int-ll64.h \
- /usr/include/i386-linux-gnu/asm/bitsperlong.h \
- /usr/include/asm-generic/bitsperlong.h /usr/include/linux/posix_types.h \
- /usr/include/linux/stddef.h \
- /usr/include/i386-linux-gnu/asm/posix_types.h \
- /usr/include/i386-linux-gnu/asm/posix_types_32.h \
- /usr/include/i386-linux-gnu/bits/sigstack.h \
- /usr/include/i386-linux-gnu/sys/ucontext.h \
- /usr/include/i386-linux-gnu/bits/sigthread.h \
- /usr/include/i386-linux-gnu/sys/resource.h \
- /usr/include/i386-linux-gnu/bits/resource.h \
- /usr/include/i386-linux-gnu/bits/waitflags.h \
- /usr/include/i386-linux-gnu/bits/waitstatus.h \
- /usr/include/i386-linux-gnu/sys/stat.h \
- /usr/include/i386-linux-gnu/sys/time.h \
- /usr/include/i386-linux-gnu/sys/mman.h \
- /usr/include/i386-linux-gnu/bits/mman.h ccan/time/time.h \
- /usr/lib/gcc/i686-linux-gnu/4.5.4/include/stdint.h /usr/include/stdint.h \
- /usr/include/i386-linux-gnu/bits/wchar.h \
- ccan/read_write_all/read_write_all.h ccan/failtest/failtest_proto.h \
- /usr/include/stdlib.h /usr/include/alloca.h \
- ccan/build_assert/build_assert.h ccan/hash/hash.h \
- ccan/htable/htable_type.h ccan/htable/htable.h ccan/str/str.h \
- ccan/str/str_debug.h /usr/include/execinfo.h
diff --git a/lib/ccan/failtest/failtest.h b/lib/ccan/failtest/failtest.h
deleted file mode 100644 (file)
index f4b6ec8..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-/* Licensed under LGPL - see LICENSE file for details */
-#ifndef CCAN_FAILTEST_H
-#define CCAN_FAILTEST_H
-#include "config.h"
-#if HAVE_FILE_OFFSET_BITS
-#define _FILE_OFFSET_BITS 64
-#endif
-#include <sys/types.h>
-#include <stdbool.h>
-#include <fcntl.h>
-#include <ccan/compiler/compiler.h>
-#include <ccan/tlist/tlist.h>
-
-/**
- * failtest_init - initialize the failtest module
- * @argc: the number of commandline arguments
- * @argv: the commandline argument array
- *
- * This initializes the module, and in particular if argv[1] is "--failpath="
- * then it ensures that failures follow that pattern.  This allows easy
- * debugging of complex failure paths.
- */
-void failtest_init(int argc, char *argv[]);
-
-/**
- * failtest_exit - clean up and exit the test
- * @status: the status (usually exit_status() from ccan/tap).
- *
- * This cleans up and changes to files made in this child, and exits the test.
- * It also calls your failtest_default_hook, if any.
- *
- * A child which does not exit via failtest_exit() will cause the overall test
- * to fail.
- */
-void NORETURN failtest_exit(int status);
-
-/**
- * enum failtest_call_type - discriminator for failtest_call.u
- */
-enum failtest_call_type {
-       FAILTEST_MALLOC,
-       FAILTEST_CALLOC,
-       FAILTEST_REALLOC,
-       FAILTEST_OPEN,
-       FAILTEST_CLOSE,
-       FAILTEST_PIPE,
-       FAILTEST_READ,
-       FAILTEST_WRITE,
-       FAILTEST_FCNTL,
-       FAILTEST_MMAP,
-       FAILTEST_LSEEK
-};
-
-struct calloc_call {
-       void *ret;
-       size_t nmemb;
-       size_t size;
-};
-
-struct malloc_call {
-       void *ret;
-       size_t size;
-};
-
-struct realloc_call {
-       void *ret;
-       void *ptr;
-       size_t size;
-};
-
-struct open_call {
-       int ret;
-       const char *pathname;
-       int flags;
-       mode_t mode;
-       bool always_save;
-       bool closed;
-       /* This is used for O_TRUNC opens on existing files. */
-       struct contents_saved *saved;
-};
-
-struct close_call {
-       int fd;
-};
-
-struct pipe_call {
-       int ret;
-       int fds[2];
-       bool closed[2];
-};
-
-struct read_call {
-       ssize_t ret;
-       off_t off;
-       int fd;
-       void *buf;
-       size_t count;
-};
-
-struct write_call {
-       ssize_t ret;
-       int fd;
-       const void *buf;
-       size_t count;
-       off_t off;
-       bool is_pwrite;
-       struct failtest_call *opener;
-       struct contents_saved *saved;
-};
-
-struct fcntl_call {
-       int ret;
-       int fd;
-       int cmd;
-       union {
-               struct flock fl;
-               long l;
-               int i;
-       } arg;
-};
-
-struct mmap_call {
-       void *ret;
-       void *addr;
-       size_t length;
-       int prot;
-       int flags;
-       int fd;
-       off_t offset;
-       struct failtest_call *opener;
-       struct contents_saved *saved;
-};
-
-struct lseek_call {
-       ssize_t ret;
-       int fd;
-       off_t offset;
-       int whence;
-       off_t old_off;
-};
-
-/**
- * struct failtest_call - description of a call redirected to failtest module
- * @type: the call type
- * @file: the filename of the caller
- * @line: the line number of the caller
- * @fail: did this call fail
- * @error: the errno (if any)
- * @u: the union of call data
- *
- * This structure is used to represent the ordered history of calls.
- *
- * See Also:
- *     failtest_hook, failtest_exit_check
- */
-struct failtest_call {
-       /* We're in the history list. */
-       struct ccan_list_node list;
-       enum failtest_call_type type;
-       /* Where we were called from. */
-       const char *file;
-       unsigned int line;
-       /* Did we fail? */
-       bool fail;
-       /* What we set errno to. */
-       int error;
-       /* How do we clean this up? */
-       void (*cleanup)(void *u, bool restore);
-       /* Should their program have cleaned up? */
-       bool can_leak;
-       /* Backtrace of call chain. */
-       void **backtrace;
-       unsigned int backtrace_num;
-       /* The actual call data. */
-       union {
-               struct calloc_call calloc;
-               struct malloc_call malloc;
-               struct realloc_call realloc;
-               struct open_call open;
-               struct close_call close;
-               struct pipe_call pipe;
-               struct read_call read;
-               struct write_call write;
-               struct fcntl_call fcntl;
-               struct mmap_call mmap;
-               struct lseek_call lseek;
-       } u;
-};
-
-/* This defines struct tlist_calls. */
-TLIST_TYPE(calls, struct failtest_call);
-
-enum failtest_result {
-       /* Yes try failing this call. */
-       FAIL_OK,
-       /* No, don't try failing this call. */
-       FAIL_DONT_FAIL,
-       /* Try failing this call but don't go too far down that path. */
-       FAIL_PROBE,
-};
-
-/**
- * failtest_hook - whether a certain call should fail or not.
- * @history: the ordered history of all failtest calls.
- *
- * The default value of this hook is failtest_default_hook(), which returns
- * FAIL_OK (ie. yes, fail the call).
- *
- * You can override it, and avoid failing certain calls.  The parameters
- * of the call (but not the return value(s)) will be filled in for the last
- * call.
- *
- * Example:
- *     static enum failtest_result dont_fail_alloc(struct tlist_calls *history)
- *     {
- *             struct failtest_call *call;
- *             call = tlist_tail(history, list);
- *             if (call->type == FAILTEST_MALLOC
- *                     || call->type == FAILTEST_CALLOC
- *                     || call->type == FAILTEST_REALLOC)
- *                     return FAIL_DONT_FAIL;
- *             return FAIL_OK;
- *     }
- *     ...
- *             failtest_hook = dont_fail_alloc;
- */
-extern enum failtest_result (*failtest_hook)(struct tlist_calls *history);
-
-/**
- * failtest_exit_check - hook for additional checks on a failed child.
- * @history: the ordered history of all failtest calls.
- *
- * Your program might have additional checks to do on failure, such as
- * check that a file is not corrupted, or than an error message has been
- * logged.
- *
- * If this returns false, the path to this failure will be printed and the
- * overall test will fail.
- */
-extern bool (*failtest_exit_check)(struct tlist_calls *history);
-
-/**
- * failtest_has_failed - determine if a failure has occurred.
- *
- * Sometimes you want to exit immediately if you've experienced an
- * injected failure.  This is useful when you have four separate tests
- * in your test suite, and you don't want to do the next one if you've
- * had a failure in a previous one.
- */
-extern bool failtest_has_failed(void);
-
-/**
- * failtest_timeout_ms - how long to wait before killing child.
- *
- * Default is 20,000 (20 seconds).
- */
-extern unsigned int failtest_timeout_ms;
-#endif /* CCAN_FAILTEST_H */
diff --git a/lib/ccan/failtest/failtest_override.h b/lib/ccan/failtest/failtest_override.h
deleted file mode 100644 (file)
index 7d03188..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/* Licensed under LGPL - see LICENSE file for details */
-#ifndef CCAN_FAILTEST_OVERRIDE_H
-#define CCAN_FAILTEST_OVERRIDE_H
-/* This file is included before the source file to test. */
-#include "config.h"
-#if HAVE_FILE_OFFSET_BITS
-#define _FILE_OFFSET_BITS 64
-#endif
-
-/* Replacement of allocators. */
-#include <stdlib.h>
-
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-
-#undef calloc
-#define calloc(nmemb, size)    \
-       failtest_calloc((nmemb), (size), __FILE__, __LINE__)
-
-#undef malloc
-#define malloc(size)   \
-       failtest_malloc((size), __FILE__, __LINE__)
-
-#undef realloc
-#define realloc(ptr, size)                                     \
-       failtest_realloc((ptr), (size), __FILE__, __LINE__)
-
-#undef free
-#define free(ptr) \
-       failtest_free(ptr)
-
-/* Replacement of I/O. */
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#undef open
-#define open(pathname, ...) \
-       failtest_open((pathname), __FILE__, __LINE__, __VA_ARGS__)
-
-#undef pipe
-#define pipe(pipefd) \
-       failtest_pipe((pipefd), __FILE__, __LINE__)
-
-#undef read
-#define read(fd, buf, count) \
-       failtest_read((fd), (buf), (count), __FILE__, __LINE__)
-
-#undef write
-#define write(fd, buf, count) \
-       failtest_write((fd), (buf), (count), __FILE__, __LINE__)
-
-#undef pread
-#define pread(fd, buf, count, off)                             \
-       failtest_pread((fd), (buf), (count), (off), __FILE__, __LINE__)
-
-#undef pwrite
-#define pwrite(fd, buf, count, off)                                    \
-       failtest_pwrite((fd), (buf), (count), (off), __FILE__, __LINE__)
-
-#undef close
-#define close(fd) failtest_close(fd, __FILE__, __LINE__)
-
-#undef fcntl
-#define fcntl(fd, ...) failtest_fcntl((fd), __FILE__, __LINE__, __VA_ARGS__)
-
-#undef mmap
-/* OpenBSD doesn't idempotent-protect sys/mman.h, so we can't add args. */
-#ifdef __OpenBSD__
-#define mmap(addr, length, prot, flags, fd, offset)                    \
-       failtest_mmap_noloc((addr), (length), (prot), (flags), (fd), (offset))
-#else
-#define mmap(addr, length, prot, flags, fd, offset)                    \
-       failtest_mmap((addr), (length), (prot), (flags), (fd), (offset), \
-                     __FILE__, __LINE__)
-#endif /* !__OpenBSD__ */
-
-#undef lseek
-#define lseek(fd, offset, whence)                                      \
-       failtest_lseek((fd), (offset), (whence), __FILE__, __LINE__)
-
-/* Replacement of getpid (since failtest will fork). */
-#undef getpid
-#define getpid() failtest_getpid(__FILE__, __LINE__)
-
-#include <ccan/failtest/failtest_proto.h>
-
-#endif /* CCAN_FAILTEST_OVERRIDE_H */
diff --git a/lib/ccan/failtest/failtest_proto.h b/lib/ccan/failtest/failtest_proto.h
deleted file mode 100644 (file)
index 3c2df1d..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Licensed under LGPL - see LICENSE file for details */
-#ifndef CCAN_FAILTEST_PROTO_H
-#define CCAN_FAILTEST_PROTO_H
-#include <stdlib.h>
-
-/* Potentially-failing versions of routines; #defined in failtest.h */
-void *failtest_calloc(size_t nmemb, size_t size,
-                     const char *file, unsigned line);
-void *failtest_malloc(size_t size, const char *file, unsigned line);
-void *failtest_realloc(void *ptr, size_t size,
-                      const char *file, unsigned line);
-void failtest_free(void *ptr);
-int failtest_open(const char *pathname,
-                 const char *file, unsigned line, ...);
-int failtest_pipe(int pipefd[2], const char *file, unsigned line);
-ssize_t failtest_read(int fd, void *buf, size_t count,
-                     const char *file, unsigned line);
-ssize_t failtest_write(int fd, const void *buf, size_t count,
-                      const char *file, unsigned line);
-ssize_t failtest_pread(int fd, void *buf, size_t count, off_t offset,
-                      const char *file, unsigned line);
-ssize_t failtest_pwrite(int fd, const void *buf, size_t count, off_t offset,
-                       const char *file, unsigned line);
-void *failtest_mmap(void *addr, size_t length, int prot, int flags,
-                   int fd, off_t offset, const char *file, unsigned line);
-void *failtest_mmap_noloc(void *addr, size_t length, int prot, int flags,
-                         int fd, off_t offset);
-off_t failtest_lseek(int fd, off_t offset, int whence,
-                    const char *file, unsigned line);
-int failtest_close(int fd, const char *file, unsigned line);
-int failtest_fcntl(int fd, const char *file, unsigned line, int cmd, ...);
-pid_t failtest_getpid(const char *file, unsigned line);
-#endif /* CCAN_FAILTEST_PROTO_H */
diff --git a/lib/ccan/failtest/failtest_undo.h b/lib/ccan/failtest/failtest_undo.h
deleted file mode 100644 (file)
index 3bb953d..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Licensed under LGPL - see LICENSE file for details */
-#ifndef CCAN_FAILTEST_RESTORE_H
-#define CCAN_FAILTEST_RESTORE_H
-/* This file undoes the effect of failtest_override.h. */
-
-#undef calloc
-#define calloc(nmemb, size)    \
-       failtest_calloc((nmemb), (size), NULL, 0)
-
-#undef malloc
-#define malloc(size)   \
-       failtest_malloc((size), NULL, 0)
-
-#undef realloc
-#define realloc(ptr, size)                                     \
-       failtest_realloc((ptr), (size), NULL, 0)
-
-#undef open
-#define open(pathname, ...) \
-       failtest_open((pathname), NULL, 0, __VA_ARGS__)
-
-#undef pipe
-#define pipe(pipefd) \
-       failtest_pipe((pipefd), NULL, 0)
-
-#undef read
-#define read(fd, buf, count) \
-       failtest_read((fd), (buf), (count), NULL, 0)
-
-#undef write
-#define write(fd, buf, count) \
-       failtest_write((fd), (buf), (count), NULL, 0)
-
-#undef mmap
-#define mmap(addr, length, prot, flags, fd, offset) \
-       failtest_mmap((addr), (length), (prot), (flags), (fd), (offset), NULL, 0)
-
-#undef lseek
-#define lseek(fd, off, whence) \
-       failtest_lseek((fd), (off), (whence), NULL, 0)
-
-#undef close
-#define close(fd) failtest_close(fd)
-
-#undef fcntl
-#define fcntl(fd, ...) \
-       failtest_fcntl((fd), NULL, 0, __VA_ARGS__)
-
-#endif /* CCAN_FAILTEST_RESTORE_H */
diff --git a/lib/ccan/failtest/test/run-failpath.c b/lib/ccan/failtest/test/run-failpath.c
deleted file mode 100644 (file)
index 9795ee9..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <ccan/failtest/failtest.c>
-#include <stdlib.h>
-#include <setjmp.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <ccan/tap/tap.h>
-
-int main(void)
-{
-       int fds[2], fd;
-       void *p;
-
-       plan_tests(14);
-       failtest_init(0, NULL);
-
-       failpath = "mceopwrMCEOPWR";
-
-       ok1((p = failtest_malloc(10, "run-failpath.c", 1)) != NULL);
-       ok1(failtest_calloc(10, 5, "run-failpath.c", 1) != NULL);
-       ok1((p = failtest_realloc(p, 100, "run-failpath.c", 1)) != NULL);
-       ok1((fd = failtest_open("failpath-scratch", "run-failpath.c", 1,
-                               O_RDWR|O_CREAT, 0600)) >= 0);
-       ok1(failtest_pipe(fds, "run-failpath.c", 1) == 0);
-       ok1(failtest_write(fd, "xxxx", 4, "run-failpath.c", 1) == 4);
-       lseek(fd, 0, SEEK_SET);
-       ok1(failtest_read(fd, p, 5, "run-failpath.c", 1) == 4);
-
-       /* Now we're into the failures. */
-       ok1(failtest_malloc(10, "run-failpath.c", 1) == NULL);
-       ok1(failtest_calloc(10, 5, "run-failpath.c", 1) == NULL);
-       ok1(failtest_realloc(p, 100, "run-failpath.c", 1) == NULL);
-       ok1(failtest_open("failpath-scratch", "run-failpath.c", 1,
-                         O_RDWR|O_CREAT, 0600) == -1);
-       ok1(failtest_pipe(fds, "run-failpath.c", 1) == -1);
-       ok1(failtest_write(fd, "xxxx", 4, "run-failpath.c", 1) == -1);
-       lseek(fd, 0, SEEK_SET);
-       ok1(failtest_read(fd, p, 5, "run-failpath.c", 1) == -1);
-       return exit_status();
-}
diff --git a/lib/ccan/failtest/test/run-history.c b/lib/ccan/failtest/test/run-history.c
deleted file mode 100644 (file)
index b78682f..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/* Include the C files directly. */
-#include <ccan/failtest/failtest.c>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <ccan/tap/tap.h>
-
-int main(void)
-{
-       struct failtest_call *call;
-       struct calloc_call calloc_call;
-       struct malloc_call malloc_call;
-       struct realloc_call realloc_call;
-       struct open_call open_call;
-       struct pipe_call pipe_call;
-       struct read_call read_call;
-       struct write_call write_call;
-       struct mmap_call mmap_call;
-       char buf[20];
-       unsigned int i;
-       char *path;
-
-       /* This is how many tests you plan to run */
-       plan_tests(69);
-
-       calloc_call.ret = calloc(1, 2);
-       calloc_call.nmemb = 1;
-       calloc_call.size = 2;
-       call = add_history(FAILTEST_CALLOC, true,
-                          "run-history.c", 1, &calloc_call);
-       /* Normally should_fail would set this. */
-       call->fail = false;
-       ok1(call->type == FAILTEST_CALLOC);
-       ok1(call->can_leak == true);
-       ok1(strcmp(call->file, "run-history.c") == 0);
-       ok1(call->line == 1);
-       ok1(call->u.calloc.ret == calloc_call.ret);
-       ok1(call->u.calloc.nmemb == calloc_call.nmemb);
-       ok1(call->u.calloc.size == calloc_call.size);
-
-       malloc_call.ret = malloc(2);
-       malloc_call.size = 2;
-       call = add_history(FAILTEST_MALLOC, true,
-                          "run-history.c", 2, &malloc_call);
-       /* Normally should_fail would set this. */
-       call->fail = false;
-       ok1(call->type == FAILTEST_MALLOC);
-       ok1(call->can_leak == true);
-       ok1(strcmp(call->file, "run-history.c") == 0);
-       ok1(call->line == 2);
-       ok1(call->u.malloc.ret == malloc_call.ret);
-       ok1(call->u.malloc.size == malloc_call.size);
-
-       realloc_call.ret = realloc(malloc_call.ret, 3);
-       realloc_call.ptr = malloc_call.ret;
-       realloc_call.size = 3;
-       call = add_history(FAILTEST_REALLOC, true, "run-history.c", 3,
-                          &realloc_call);
-       /* Normally should_fail would set this. */
-       call->fail = false;
-       ok1(call->type == FAILTEST_REALLOC);
-       ok1(call->can_leak == true);
-       ok1(strcmp(call->file, "run-history.c") == 0);
-       ok1(call->line == 3);
-       ok1(call->u.realloc.ret == realloc_call.ret);
-       ok1(call->u.realloc.ptr == realloc_call.ptr);
-       ok1(call->u.realloc.size == realloc_call.size);
-
-       open_call.ret = open("test/run-history.c", O_RDONLY);
-       open_call.pathname = "test/run-history.c";
-       open_call.flags = O_RDONLY;
-       open_call.mode = 0;
-       open_call.closed = false;
-       call = add_history(FAILTEST_OPEN, true, "run-history.c", 4, &open_call);
-       /* Normally should_fail would set this. */
-       call->fail = false;
-       ok1(call->type == FAILTEST_OPEN);
-       ok1(call->can_leak == true);
-       ok1(strcmp(call->file, "run-history.c") == 0);
-       ok1(call->line == 4);
-       ok1(call->u.open.ret == open_call.ret);
-       ok1(strcmp(call->u.open.pathname, open_call.pathname) == 0);
-       ok1(call->u.open.flags == open_call.flags);
-       ok1(call->u.open.mode == open_call.mode);
-
-       pipe_call.ret = pipe(pipe_call.fds);
-       call = add_history(FAILTEST_PIPE, true, "run-history.c", 5, &pipe_call);
-       /* Normally should_fail would set this. */
-       call->fail = false;
-       ok1(call->type == FAILTEST_PIPE);
-       ok1(strcmp(call->file, "run-history.c") == 0);
-       ok1(call->can_leak == true);
-       ok1(call->line == 5);
-       ok1(call->u.pipe.ret == pipe_call.ret);
-       ok1(call->u.pipe.fds[0] == pipe_call.fds[0]);
-       ok1(call->u.pipe.fds[1] == pipe_call.fds[1]);
-
-       read_call.ret = read(open_call.ret, buf, 20);
-       read_call.buf = buf;
-       read_call.fd = open_call.ret;
-       read_call.count = 20;
-       call = add_history(FAILTEST_READ, false, "run-history.c", 6, &read_call);
-       /* Normally should_fail would set this. */
-       call->fail = false;
-       ok1(call->type == FAILTEST_READ);
-       ok1(call->can_leak == false);
-       ok1(strcmp(call->file, "run-history.c") == 0);
-       ok1(call->line == 6);
-       ok1(call->u.read.ret == read_call.ret);
-       ok1(call->u.read.buf == read_call.buf);
-       ok1(call->u.read.fd == read_call.fd);
-       ok1(call->u.read.count == read_call.count);
-
-       write_call.ret = 20;
-       write_call.buf = buf;
-       write_call.fd = open_call.ret;
-       write_call.count = 20;
-       write_call.opener = NULL;
-       call = add_history(FAILTEST_WRITE, false, "run-history.c", 7,
-                          &write_call);
-       /* Normally should_fail would set this. */
-       call->fail = false;
-       ok1(call->type == FAILTEST_WRITE);
-       ok1(call->can_leak == false);
-       ok1(strcmp(call->file, "run-history.c") == 0);
-       ok1(call->line == 7);
-       ok1(call->u.write.ret == write_call.ret);
-       ok1(call->u.write.buf == write_call.buf);
-       ok1(call->u.write.fd == write_call.fd);
-       ok1(call->u.write.count == write_call.count);
-       ok1(call->u.write.opener == write_call.opener);
-
-       mmap_call.ret = &mmap_call;
-       mmap_call.addr = NULL;
-       mmap_call.length = 4096;
-       mmap_call.prot = PROT_READ;
-       mmap_call.flags = 0;
-       mmap_call.fd = open_call.ret;
-       mmap_call.offset = 0;
-       mmap_call.opener = opener_of(open_call.ret);
-       ok1(mmap_call.opener->type == FAILTEST_OPEN);
-       mmap_call.saved = NULL;
-
-       call = add_history(FAILTEST_MMAP, false, "run-history.c", 8,
-                          &mmap_call);
-       /* Normally should_fail would set this. */
-       call->fail = false;
-       ok1(call->type == FAILTEST_MMAP);
-       ok1(call->can_leak == false);
-       ok1(strcmp(call->file, "run-history.c") == 0);
-       ok1(call->line == 8);
-       ok1(call->u.mmap.ret == mmap_call.ret);
-       ok1(call->u.mmap.addr == mmap_call.addr);
-       ok1(call->u.mmap.length == mmap_call.length);
-       ok1(call->u.mmap.prot == mmap_call.prot);
-       ok1(call->u.mmap.flags == mmap_call.flags);
-       ok1(call->u.mmap.fd == mmap_call.fd);
-       ok1(call->u.mmap.offset == mmap_call.offset);
-       ok1(call->u.mmap.opener == mmap_call.opener);
-       ok1(call->u.mmap.saved == mmap_call.saved);
-
-       i = 0;
-       tlist_for_each(&history, call, list)
-               i++;
-
-       ok1(i == 8);
-
-       tlist_for_each(&history, call, list)
-               call->fail = false;
-
-       path = failpath_string();
-       ok1(streq(path, "cmeoprwa"));
-       free(path);
-
-       tlist_for_each(&history, call, list)
-               call->fail = true;
-
-       path = failpath_string();
-       ok1(streq(path, "CMEOPRWA"));
-       free(path);
-
-       return exit_status();
-}
diff --git a/lib/ccan/failtest/test/run-locking.c b/lib/ccan/failtest/test/run-locking.c
deleted file mode 100644 (file)
index da0ee70..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/* Include the C files directly. */
-#include <ccan/failtest/failtest.c>
-#include <stdlib.h>
-#include <setjmp.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <assert.h>
-#include <ccan/tap/tap.h>
-
-#define SIZE 8
-
-/* We don't want to fork and fail; we're just testing lock recording. */
-static enum failtest_result dont_fail(struct tlist_calls *history)
-{
-       return FAIL_DONT_FAIL;
-}
-
-static bool place_lock(int fd, char lockarr[], unsigned pos, unsigned size,
-                      int type)
-{
-       struct flock fl;
-
-       /* Update record keeping. */
-       if (type == F_RDLCK)
-               memset(lockarr+pos, 1, size);
-       else if (type == F_WRLCK)
-               memset(lockarr+pos, 2, size);
-       else
-               memset(lockarr+pos, 0, size);
-
-       fl.l_whence = SEEK_SET;
-       fl.l_type = type;
-       fl.l_start = pos;
-       fl.l_len = size;
-       return failtest_fcntl(fd, "run-locking.c", 1, F_SETLK, &fl) == 0;
-}
-
-static char lock_lookup(int fd, unsigned pos)
-{
-       char ret = 0;
-       unsigned int i;
-       struct lock_info *l;
-
-       for (i = 0; i < lock_num; i++) {
-               l = &locks[i];
-
-               if (l->fd != fd)
-                       continue;
-
-               if (pos >= l->start && pos <= l->end) {
-                       if (ret)
-                               ret = 3;
-                       else if (l->type == F_RDLCK)
-                               ret = 1;
-                       else
-                               ret = 2;
-               }
-       }
-       return ret;
-}
-
-static bool test(int fd,
-                unsigned p1, unsigned s1,
-                unsigned p2, unsigned s2,
-                unsigned p3, unsigned s3)
-{
-       unsigned int i;
-       char lockarr[SIZE];
-
-       memset(lockarr, 0, sizeof(lockarr));
-
-       if (!place_lock(fd, lockarr, p1, s1, F_WRLCK))
-               return false;
-
-       if (!place_lock(fd, lockarr, p2, s2, F_RDLCK))
-               return false;
-
-       if (!place_lock(fd, lockarr, p3, s3, F_UNLCK))
-               return false;
-
-       for (i = 0; i < SIZE; i++) {
-               if (lock_lookup(fd, i) != lockarr[i])
-                       return false;
-       }
-
-       /* Reset lock info. */
-       lock_num = 0;
-       return true;
-}
-
-int main(void)
-{
-       int fd;
-       long flags;
-       unsigned int isize;
-
-       plan_tests(5835);
-       failtest_init(0, NULL);
-       failtest_hook = dont_fail;
-
-       fd = open("run-locking-scratch", O_RDWR|O_CREAT, 0600);
-       /* GETFL and SETFL wrappers should pass through. */
-       flags = fcntl(fd, F_GETFL);
-       ok1(failtest_fcntl(fd, "run-locking.c", 1, F_GETFL) == flags);
-       flags |= O_NONBLOCK;
-       ok1(failtest_fcntl(fd, "run-locking.c", 1, F_SETFL, flags) == 0);
-       ok1(failtest_fcntl(fd, "run-locking.c", 1, F_GETFL) == flags);
-
-       for (isize = 1; isize < 4; isize++) {
-               unsigned int ipos;
-               for (ipos = 0; ipos + isize < SIZE; ipos++) {
-                       unsigned int jsize;
-                       for (jsize = 1; jsize < 4; jsize++) {
-                               unsigned int jpos;
-                               for (jpos = 0; jpos + jsize < SIZE; jpos++) {
-                                       unsigned int ksize;
-                                       for (ksize = 1; ksize < 4; ksize++) {
-                                               unsigned int kpos;
-                                               for (kpos = 0;
-                                                    kpos + ksize < SIZE;
-                                                    kpos++) {
-                                                       ok1(test(fd,
-                                                                ipos, isize,
-                                                                jpos, jsize,
-                                                                kpos, ksize));
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-
-       return exit_status();
-}
diff --git a/lib/ccan/failtest/test/run-malloc.c b/lib/ccan/failtest/test/run-malloc.c
deleted file mode 100644 (file)
index 96641b8..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-#include "config.h"
-#include <stdlib.h>
-#include <setjmp.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <assert.h>
-#include <ccan/tap/tap.h>
-
-/* We don't actually want it to exit... */
-static jmp_buf exited;
-#define exit(status) longjmp(exited, (status) + 1)
-
-#define printf saved_printf
-static int saved_printf(const char *fmt, ...);
-
-#define fprintf saved_fprintf
-static int saved_fprintf(FILE *ignored, const char *fmt, ...);
-
-#define vfprintf saved_vfprintf
-static int saved_vfprintf(FILE *ignored, const char *fmt, va_list ap);
-
-/* Hack to avoid a memory leak which valgrind complains about. */
-#define realloc set_realloc
-static void *set_realloc(void *ptr, size_t size);
-
-#define free set_free
-static void set_free(void *ptr);
-
-/* Include the C files directly. */
-#include <ccan/failtest/failtest.c>
-
-#undef realloc
-#undef free
-
-static char *buffer;
-static void *set_realloc(void *ptr, size_t size)
-{
-       return buffer = realloc(ptr, size);
-}
-
-static void set_free(void *ptr)
-{
-       if (ptr == buffer)
-               buffer = NULL;
-       free(ptr);
-}
-
-static char *output = NULL;
-
-static int saved_vprintf(const char *fmt, va_list ap)
-{
-       int ret;
-       int len = 0;
-       va_list ap2;
-
-       va_copy(ap2, ap);
-       ret = vsnprintf(NULL, 0, fmt, ap2);
-       va_end(ap2);
-
-       if (output)
-               len = strlen(output);
-
-       output = realloc(output, len + ret + 1);
-       return vsprintf(output + len, fmt, ap);
-}
-
-static int saved_vfprintf(FILE *ignored, const char *fmt, va_list ap)
-{
-       return saved_vprintf(fmt, ap);
-}
-
-static int saved_printf(const char *fmt, ...)
-{
-       va_list ap;
-       int ret;
-
-       va_start(ap, fmt);
-       ret = saved_vprintf(fmt, ap);
-       va_end(ap);
-       return ret;
-}
-
-static int saved_fprintf(FILE *ignored, const char *fmt, ...)
-{
-       va_list ap;
-       int ret;
-
-       va_start(ap, fmt);
-       ret = saved_vprintf(fmt, ap);
-       va_end(ap);
-       return ret;
-}
-
-int main(void)
-{
-       int status;
-
-       plan_tests(3);
-       failtest_init(0, NULL);
-
-       status = setjmp(exited);
-       if (status == 0) {
-               char *p = failtest_malloc(1, "run-malloc.c", 1);
-               /* If we just segv, valgrind counts that as a failure.
-                * So kill ourselves creatively. */
-               if (!p)
-                       kill(getpid(), SIGSEGV);
-               fail("Expected child to crash!");
-       } else {
-               ok1(status == 2);
-               ok1(strstr(output, "Killed by signal"));
-               ok1(strstr(output, "--failpath=M\n"));
-       }
-       free(buffer);
-       return exit_status();
-}
diff --git a/lib/ccan/failtest/test/run-open.c b/lib/ccan/failtest/test/run-open.c
deleted file mode 100644 (file)
index 0166506..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Include the C files directly. */
-#include <ccan/failtest/failtest.c>
-#include <stdlib.h>
-#include <setjmp.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <assert.h>
-#include <ccan/tap/tap.h>
-
-int main(void)
-{
-       int fd, pfd[2], err;
-       char buf[] = "Hello world!";
-       struct stat st;
-
-       plan_tests(12);
-       failtest_init(0, NULL);
-
-       if (pipe(pfd))
-               abort();
-       fd = failtest_open("run-open-scratchpad", "run-open.c", 1,
-                          O_RDWR|O_CREAT, 0600);
-       if (fd == -1) {
-               /* We are the child: write error code for parent to check. */
-               err = errno;
-               if (write(pfd[1], &err, sizeof(err)) != sizeof(err))
-                       abort();
-               failtest_exit(0);
-       }
-       /* Check it is read-write. */
-       ok1(write(fd, buf, strlen(buf)) == strlen(buf));
-       lseek(fd, SEEK_SET, 0);
-       ok1(read(fd, buf, strlen("Hello world!")) == strlen("Hello world!"));
-       ok1(strcmp(buf, "Hello world!") == 0);
-
-       /* Check name and perms. */
-       ok1(stat("run-open-scratchpad", &st) == 0);
-       ok1(st.st_size == strlen(buf));
-       ok1(S_ISREG(st.st_mode));
-       ok1((st.st_mode & 0777) == 0600);
-
-       /* Check child got correct errno. */
-       ok1(read(pfd[0], &err, sizeof(err)) == sizeof(err));
-       ok1(err == EACCES);
-
-       /* Clean up. */
-       failtest_close(fd, "run-open.c", 1);
-       close(pfd[0]);
-       close(pfd[1]);
-
-       /* Two-arg open. */
-       if (pipe(pfd) != 0)
-               abort();
-       fd = failtest_open("run-open-scratchpad", "run-open.c", 1, O_RDONLY);
-       if (fd == -1) {
-               /* We are the child: write error code for parent to check. */
-               err = errno;
-               if (write(pfd[1], &err, sizeof(err)) != sizeof(err))
-                       abort();
-               failtest_exit(0);
-       }
-       /* Check it is read-only. */
-       ok1(write(fd, buf, strlen(buf)) == -1);
-       ok1(read(fd, buf, strlen("Hello world!")) == strlen("Hello world!"));
-       ok1(strcmp(buf, "Hello world!") == 0);
-       /* Clean up. */
-       failtest_close(fd, "run-open.c", 1);
-       close(pfd[0]);
-       close(pfd[1]);
-
-       return exit_status();
-}
diff --git a/lib/ccan/failtest/test/run-with-fdlimit.c b/lib/ccan/failtest/test/run-with-fdlimit.c
deleted file mode 100644 (file)
index 6b4483f..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Include the C files directly. */
-#include <ccan/failtest/failtest.c>
-#include <stdlib.h>
-#include <err.h>
-#include <ccan/tap/tap.h>
-
-int main(void)
-{
-       int fd, pfd[2], ecode;
-       struct rlimit lim;
-
-       if (getrlimit(RLIMIT_NOFILE, &lim) != 0)
-               err(1, "getrlimit RLIMIT_NOFILE fail?");
-
-       printf("rlimit = %lu/%lu (inf=%lu)\n",
-              (long)lim.rlim_cur, (long)lim.rlim_max,
-              (long)RLIM_INFINITY);
-       lim.rlim_cur /= 2;
-       if (lim.rlim_cur < 8)
-               errx(1, "getrlimit limit %li too low", (long)lim.rlim_cur);
-       if (setrlimit(RLIMIT_NOFILE, &lim) != 0)
-               err(1, "setrlimit RLIMIT_NOFILE (%li/%li)",
-                   (long)lim.rlim_cur, (long)lim.rlim_max);
-
-       plan_tests(2);
-       failtest_init(0, NULL);
-
-       if (pipe(pfd))
-               abort();
-
-       fd = failtest_open("run-with-fdlimit-scratch", "run-with_fdlimit.c", 1,
-                          O_RDWR|O_CREAT, 0600);
-       if (fd == -1) {
-               /* We are the child: write error code for parent to check. */
-               ecode = errno;
-               if (write(pfd[1], &ecode, sizeof(ecode)) != sizeof(ecode))
-                       abort();
-               failtest_exit(0);
-       }
-
-       /* Check child got correct errno. */
-       ok1(read(pfd[0], &ecode, sizeof(ecode)) == sizeof(ecode));
-       ok1(ecode == EACCES);
-
-       /* Clean up. */
-       failtest_close(fd, "run-open.c", 1);
-       close(pfd[0]);
-       close(pfd[1]);
-
-       return exit_status();
-}
diff --git a/lib/ccan/failtest/test/run-write.c b/lib/ccan/failtest/test/run-write.c
deleted file mode 100644 (file)
index 6a712fe..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Include the C files directly. */
-#include <ccan/failtest/failtest.c>
-#include <stdlib.h>
-#include <setjmp.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <assert.h>
-#include <ccan/tap/tap.h>
-
-int main(int argc, char *argv[])
-{
-       int fd;
-       char *p;
-       char buf[] = "Hello world!";
-
-       plan_tests(5);
-       failtest_init(argc, argv);
-
-       fd = failtest_open("run-write-scratchpad", __FILE__, __LINE__,
-                          O_RDWR|O_CREAT, 0600);
-       /* Child will fail, ignore. */
-       if (fd < 0)
-               failtest_exit(0);
-       if (write(fd, buf, strlen(buf)) != strlen(buf))
-               abort();
-       ok1(lseek(fd, 0, SEEK_CUR) == strlen(buf));
-
-       p = failtest_malloc(100, __FILE__, __LINE__);
-       if (!p) {
-               /* We are the child.  Do a heap of writes. */
-               unsigned int i;
-
-               for (i = 0; i < strlen(buf)+1; i++)
-                       if (failtest_write(fd, "x", 1, __FILE__, __LINE__)
-                           == 1)
-                               break;
-               failtest_close(fd, __FILE__, __LINE__);
-               failtest_exit(0);
-       }
-
-       /* Seek pointer should be left alone! */
-       ok1(lseek(fd, 0, SEEK_CUR) == strlen(buf));
-       /* Length should be restored. */
-       ok1(lseek(fd, 0, SEEK_END) == strlen(buf));
-       lseek(fd, 0, SEEK_SET);
-       ok1(read(fd, buf, strlen(buf)) == strlen("Hello world!"));
-       ok1(strcmp(buf, "Hello world!") == 0);
-       failtest_close(fd, __FILE__, __LINE__);
-
-       return exit_status();
-}
diff --git a/lib/ccan/hash/_info b/lib/ccan/hash/_info
deleted file mode 100644 (file)
index 5aeb912..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <string.h>
-#include <stdio.h>
-
-/**
- * hash - routines for hashing bytes
- *
- * When creating a hash table it's important to have a hash function
- * which mixes well and is fast.  This package supplies such functions.
- *
- * The hash functions come in two flavors: the normal ones and the
- * stable ones.  The normal ones can vary from machine-to-machine and
- * may change if we find better or faster hash algorithms in future.
- * The stable ones will always give the same results on any computer,
- * and on any version of this package.
- *
- * License: Public Domain
- * Maintainer: Rusty Russell <rusty@rustcorp.com.au>
- * Author: Bob Jenkins <bob_jenkins@burtleburtle.net>
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               printf("ccan/build_assert\n");
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/hash/hash.c b/lib/ccan/hash/hash.c
deleted file mode 100644 (file)
index 0fd6109..0000000
+++ /dev/null
@@ -1,925 +0,0 @@
-/*
--------------------------------------------------------------------------------
-lookup3.c, by Bob Jenkins, May 2006, Public Domain.
-
-These are functions for producing 32-bit hashes for hash table lookup.
-hash_word(), hashlittle(), hashlittle2(), hashbig(), mix(), and final()
-are externally useful functions.  Routines to test the hash are included
-if SELF_TEST is defined.  You can use this free for any purpose.  It's in
-the public domain.  It has no warranty.
-
-You probably want to use hashlittle().  hashlittle() and hashbig()
-hash byte arrays.  hashlittle() is is faster than hashbig() on
-little-endian machines.  Intel and AMD are little-endian machines.
-On second thought, you probably want hashlittle2(), which is identical to
-hashlittle() except it returns two 32-bit hashes for the price of one.
-You could implement hashbig2() if you wanted but I haven't bothered here.
-
-If you want to find a hash of, say, exactly 7 integers, do
-  a = i1;  b = i2;  c = i3;
-  mix(a,b,c);
-  a += i4; b += i5; c += i6;
-  mix(a,b,c);
-  a += i7;
-  final(a,b,c);
-then use c as the hash value.  If you have a variable length array of
-4-byte integers to hash, use hash_word().  If you have a byte array (like
-a character string), use hashlittle().  If you have several byte arrays, or
-a mix of things, see the comments above hashlittle().
-
-Why is this so big?  I read 12 bytes at a time into 3 4-byte integers,
-then mix those integers.  This is fast (you can do a lot more thorough
-mixing with 12*3 instructions on 3 integers than you can with 3 instructions
-on 1 byte), but shoehorning those bytes into integers efficiently is messy.
--------------------------------------------------------------------------------
-*/
-//#define SELF_TEST 1
-
-#if 0
-#include <stdio.h>      /* defines printf for tests */
-#include <time.h>       /* defines time_t for timings in the test */
-#include <stdint.h>     /* defines uint32_t etc */
-#include <sys/param.h>  /* attempt to define endianness */
-
-#ifdef linux
-# include <endian.h>    /* attempt to define endianness */
-#endif
-
-/*
- * My best guess at if you are big-endian or little-endian.  This may
- * need adjustment.
- */
-#if (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && \
-     __BYTE_ORDER == __LITTLE_ENDIAN) || \
-    (defined(i386) || defined(__i386__) || defined(__i486__) || \
-     defined(__i586__) || defined(__i686__) || defined(__x86_64) || \
-     defined(vax) || defined(MIPSEL))
-# define HASH_LITTLE_ENDIAN 1
-# define HASH_BIG_ENDIAN 0
-#elif (defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && \
-       __BYTE_ORDER == __BIG_ENDIAN) || \
-      (defined(sparc) || defined(POWERPC) || defined(mc68000) || defined(sel))
-# define HASH_LITTLE_ENDIAN 0
-# define HASH_BIG_ENDIAN 1
-#else
-# error Unknown endian
-#endif
-#endif /* old hash.c headers. */
-
-#include "hash.h"
-
-#if HAVE_LITTLE_ENDIAN
-#define HASH_LITTLE_ENDIAN 1
-#define HASH_BIG_ENDIAN 0
-#elif HAVE_BIG_ENDIAN
-#define HASH_LITTLE_ENDIAN 0
-#define HASH_BIG_ENDIAN 1
-#else
-#error Unknown endian
-#endif
-
-#define hashsize(n) ((uint32_t)1<<(n))
-#define hashmask(n) (hashsize(n)-1)
-#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
-
-/*
--------------------------------------------------------------------------------
-mix -- mix 3 32-bit values reversibly.
-
-This is reversible, so any information in (a,b,c) before mix() is
-still in (a,b,c) after mix().
-
-If four pairs of (a,b,c) inputs are run through mix(), or through
-mix() in reverse, there are at least 32 bits of the output that
-are sometimes the same for one pair and different for another pair.
-This was tested for:
-* pairs that differed by one bit, by two bits, in any combination
-  of top bits of (a,b,c), or in any combination of bottom bits of
-  (a,b,c).
-* "differ" is defined as +, -, ^, or ~^.  For + and -, I transformed
-  the output delta to a Gray code (a^(a>>1)) so a string of 1's (as
-  is commonly produced by subtraction) look like a single 1-bit
-  difference.
-* the base values were pseudorandom, all zero but one bit set, or
-  all zero plus a counter that starts at zero.
-
-Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that
-satisfy this are
-    4  6  8 16 19  4
-    9 15  3 18 27 15
-   14  9  3  7 17  3
-Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing
-for "differ" defined as + with a one-bit base and a two-bit delta.  I
-used http://burtleburtle.net/bob/hash/avalanche.html to choose
-the operations, constants, and arrangements of the variables.
-
-This does not achieve avalanche.  There are input bits of (a,b,c)
-that fail to affect some output bits of (a,b,c), especially of a.  The
-most thoroughly mixed value is c, but it doesn't really even achieve
-avalanche in c.
-
-This allows some parallelism.  Read-after-writes are good at doubling
-the number of bits affected, so the goal of mixing pulls in the opposite
-direction as the goal of parallelism.  I did what I could.  Rotates
-seem to cost as much as shifts on every machine I could lay my hands
-on, and rotates are much kinder to the top and bottom bits, so I used
-rotates.
--------------------------------------------------------------------------------
-*/
-#define mix(a,b,c) \
-{ \
-  a -= c;  a ^= rot(c, 4);  c += b; \
-  b -= a;  b ^= rot(a, 6);  a += c; \
-  c -= b;  c ^= rot(b, 8);  b += a; \
-  a -= c;  a ^= rot(c,16);  c += b; \
-  b -= a;  b ^= rot(a,19);  a += c; \
-  c -= b;  c ^= rot(b, 4);  b += a; \
-}
-
-/*
--------------------------------------------------------------------------------
-final -- final mixing of 3 32-bit values (a,b,c) into c
-
-Pairs of (a,b,c) values differing in only a few bits will usually
-produce values of c that look totally different.  This was tested for
-* pairs that differed by one bit, by two bits, in any combination
-  of top bits of (a,b,c), or in any combination of bottom bits of
-  (a,b,c).
-* "differ" is defined as +, -, ^, or ~^.  For + and -, I transformed
-  the output delta to a Gray code (a^(a>>1)) so a string of 1's (as
-  is commonly produced by subtraction) look like a single 1-bit
-  difference.
-* the base values were pseudorandom, all zero but one bit set, or
-  all zero plus a counter that starts at zero.
-
-These constants passed:
- 14 11 25 16 4 14 24
- 12 14 25 16 4 14 24
-and these came close:
-  4  8 15 26 3 22 24
- 10  8 15 26 3 22 24
- 11  8 15 26 3 22 24
--------------------------------------------------------------------------------
-*/
-#define final(a,b,c) \
-{ \
-  c ^= b; c -= rot(b,14); \
-  a ^= c; a -= rot(c,11); \
-  b ^= a; b -= rot(a,25); \
-  c ^= b; c -= rot(b,16); \
-  a ^= c; a -= rot(c,4);  \
-  b ^= a; b -= rot(a,14); \
-  c ^= b; c -= rot(b,24); \
-}
-
-/*
---------------------------------------------------------------------
- This works on all machines.  To be useful, it requires
- -- that the key be an array of uint32_t's, and
- -- that the length be the number of uint32_t's in the key
-
- The function hash_word() is identical to hashlittle() on little-endian
- machines, and identical to hashbig() on big-endian machines,
- except that the length has to be measured in uint32_ts rather than in
- bytes.  hashlittle() is more complicated than hash_word() only because
- hashlittle() has to dance around fitting the key bytes into registers.
---------------------------------------------------------------------
-*/
-uint32_t hash_u32(
-const uint32_t *k,                   /* the key, an array of uint32_t values */
-size_t          length,               /* the length of the key, in uint32_ts */
-uint32_t        initval)         /* the previous hash, or an arbitrary value */
-{
-  uint32_t a,b,c;
-
-  /* Set up the internal state */
-  a = b = c = 0xdeadbeef + (((uint32_t)length)<<2) + initval;
-
-  /*------------------------------------------------- handle most of the key */
-  while (length > 3)
-  {
-    a += k[0];
-    b += k[1];
-    c += k[2];
-    mix(a,b,c);
-    length -= 3;
-    k += 3;
-  }
-
-  /*------------------------------------------- handle the last 3 uint32_t's */
-  switch(length)                     /* all the case statements fall through */
-  {
-  case 3 : c+=k[2];
-  case 2 : b+=k[1];
-  case 1 : a+=k[0];
-    final(a,b,c);
-  case 0:     /* case 0: nothing left to add */
-    break;
-  }
-  /*------------------------------------------------------ report the result */
-  return c;
-}
-
-/*
--------------------------------------------------------------------------------
-hashlittle() -- hash a variable-length key into a 32-bit value
-  k       : the key (the unaligned variable-length array of bytes)
-  length  : the length of the key, counting by bytes
-  val2    : IN: can be any 4-byte value OUT: second 32 bit hash.
-Returns a 32-bit value.  Every bit of the key affects every bit of
-the return value.  Two keys differing by one or two bits will have
-totally different hash values.  Note that the return value is better
-mixed than val2, so use that first.
-
-The best hash table sizes are powers of 2.  There is no need to do
-mod a prime (mod is sooo slow!).  If you need less than 32 bits,
-use a bitmask.  For example, if you need only 10 bits, do
-  h = (h & hashmask(10));
-In which case, the hash table should have hashsize(10) elements.
-
-If you are hashing n strings (uint8_t **)k, do it like this:
-  for (i=0, h=0; i<n; ++i) h = hashlittle( k[i], len[i], h);
-
-By Bob Jenkins, 2006.  bob_jenkins@burtleburtle.net.  You may use this
-code any way you wish, private, educational, or commercial.  It's free.
-
-Use for hash table lookup, or anything where one collision in 2^^32 is
-acceptable.  Do NOT use for cryptographic purposes.
--------------------------------------------------------------------------------
-*/
-
-static uint32_t hashlittle( const void *key, size_t length, uint32_t *val2 )
-{
-  uint32_t a,b,c;                                          /* internal state */
-  union { const void *ptr; size_t i; } u;     /* needed for Mac Powerbook G4 */
-
-  /* Set up the internal state */
-  a = b = c = 0xdeadbeef + ((uint32_t)length) + *val2;
-
-  u.ptr = key;
-  if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) {
-    const uint32_t *k = (const uint32_t *)key;         /* read 32-bit chunks */
-    const uint8_t  *k8;
-
-    /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */
-    while (length > 12)
-    {
-      a += k[0];
-      b += k[1];
-      c += k[2];
-      mix(a,b,c);
-      length -= 12;
-      k += 3;
-    }
-
-    /*----------------------------- handle the last (probably partial) block */
-    /*
-     * "k[2]&0xffffff" actually reads beyond the end of the string, but
-     * then masks off the part it's not allowed to read.  Because the
-     * string is aligned, the masked-off tail is in the same word as the
-     * rest of the string.  Every machine with memory protection I've seen
-     * does it on word boundaries, so is OK with this.  But VALGRIND will
-     * still catch it and complain.  The masking trick does make the hash
-     * noticably faster for short strings (like English words).
-     *
-     * Not on my testing with gcc 4.5 on an intel i5 CPU, at least --RR.
-     */
-#if 0
-    switch(length)
-    {
-    case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
-    case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break;
-    case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break;
-    case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break;
-    case 8 : b+=k[1]; a+=k[0]; break;
-    case 7 : b+=k[1]&0xffffff; a+=k[0]; break;
-    case 6 : b+=k[1]&0xffff; a+=k[0]; break;
-    case 5 : b+=k[1]&0xff; a+=k[0]; break;
-    case 4 : a+=k[0]; break;
-    case 3 : a+=k[0]&0xffffff; break;
-    case 2 : a+=k[0]&0xffff; break;
-    case 1 : a+=k[0]&0xff; break;
-    case 0 : return c;              /* zero length strings require no mixing */
-    }
-
-#else /* make valgrind happy */
-
-    k8 = (const uint8_t *)k;
-    switch(length)
-    {
-    case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
-    case 11: c+=((uint32_t)k8[10])<<16;  /* fall through */
-    case 10: c+=((uint32_t)k8[9])<<8;    /* fall through */
-    case 9 : c+=k8[8];                   /* fall through */
-    case 8 : b+=k[1]; a+=k[0]; break;
-    case 7 : b+=((uint32_t)k8[6])<<16;   /* fall through */
-    case 6 : b+=((uint32_t)k8[5])<<8;    /* fall through */
-    case 5 : b+=k8[4];                   /* fall through */
-    case 4 : a+=k[0]; break;
-    case 3 : a+=((uint32_t)k8[2])<<16;   /* fall through */
-    case 2 : a+=((uint32_t)k8[1])<<8;    /* fall through */
-    case 1 : a+=k8[0]; break;
-    case 0 : return c;
-    }
-
-#endif /* !valgrind */
-
-  } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) {
-    const uint16_t *k = (const uint16_t *)key;         /* read 16-bit chunks */
-    const uint8_t  *k8;
-
-    /*--------------- all but last block: aligned reads and different mixing */
-    while (length > 12)
-    {
-      a += k[0] + (((uint32_t)k[1])<<16);
-      b += k[2] + (((uint32_t)k[3])<<16);
-      c += k[4] + (((uint32_t)k[5])<<16);
-      mix(a,b,c);
-      length -= 12;
-      k += 6;
-    }
-
-    /*----------------------------- handle the last (probably partial) block */
-    k8 = (const uint8_t *)k;
-    switch(length)
-    {
-    case 12: c+=k[4]+(((uint32_t)k[5])<<16);
-             b+=k[2]+(((uint32_t)k[3])<<16);
-             a+=k[0]+(((uint32_t)k[1])<<16);
-             break;
-    case 11: c+=((uint32_t)k8[10])<<16;     /* fall through */
-    case 10: c+=k[4];
-             b+=k[2]+(((uint32_t)k[3])<<16);
-             a+=k[0]+(((uint32_t)k[1])<<16);
-             break;
-    case 9 : c+=k8[8];                      /* fall through */
-    case 8 : b+=k[2]+(((uint32_t)k[3])<<16);
-             a+=k[0]+(((uint32_t)k[1])<<16);
-             break;
-    case 7 : b+=((uint32_t)k8[6])<<16;      /* fall through */
-    case 6 : b+=k[2];
-             a+=k[0]+(((uint32_t)k[1])<<16);
-             break;
-    case 5 : b+=k8[4];                      /* fall through */
-    case 4 : a+=k[0]+(((uint32_t)k[1])<<16);
-             break;
-    case 3 : a+=((uint32_t)k8[2])<<16;      /* fall through */
-    case 2 : a+=k[0];
-             break;
-    case 1 : a+=k8[0];
-             break;
-    case 0 : return c;                     /* zero length requires no mixing */
-    }
-
-  } else {                        /* need to read the key one byte at a time */
-    const uint8_t *k = (const uint8_t *)key;
-
-    /*--------------- all but the last block: affect some 32 bits of (a,b,c) */
-    while (length > 12)
-    {
-      a += k[0];
-      a += ((uint32_t)k[1])<<8;
-      a += ((uint32_t)k[2])<<16;
-      a += ((uint32_t)k[3])<<24;
-      b += k[4];
-      b += ((uint32_t)k[5])<<8;
-      b += ((uint32_t)k[6])<<16;
-      b += ((uint32_t)k[7])<<24;
-      c += k[8];
-      c += ((uint32_t)k[9])<<8;
-      c += ((uint32_t)k[10])<<16;
-      c += ((uint32_t)k[11])<<24;
-      mix(a,b,c);
-      length -= 12;
-      k += 12;
-    }
-
-    /*-------------------------------- last block: affect all 32 bits of (c) */
-    switch(length)                   /* all the case statements fall through */
-    {
-    case 12: c+=((uint32_t)k[11])<<24;
-    case 11: c+=((uint32_t)k[10])<<16;
-    case 10: c+=((uint32_t)k[9])<<8;
-    case 9 : c+=k[8];
-    case 8 : b+=((uint32_t)k[7])<<24;
-    case 7 : b+=((uint32_t)k[6])<<16;
-    case 6 : b+=((uint32_t)k[5])<<8;
-    case 5 : b+=k[4];
-    case 4 : a+=((uint32_t)k[3])<<24;
-    case 3 : a+=((uint32_t)k[2])<<16;
-    case 2 : a+=((uint32_t)k[1])<<8;
-    case 1 : a+=k[0];
-             break;
-    case 0 : return c;
-    }
-  }
-
-  final(a,b,c);
-  *val2 = b;
-  return c;
-}
-
-/*
- * hashbig():
- * This is the same as hash_word() on big-endian machines.  It is different
- * from hashlittle() on all machines.  hashbig() takes advantage of
- * big-endian byte ordering.
- */
-static uint32_t hashbig( const void *key, size_t length, uint32_t *val2)
-{
-  uint32_t a,b,c;
-  union { const void *ptr; size_t i; } u; /* to cast key to (size_t) happily */
-
-  /* Set up the internal state */
-  a = b = c = 0xdeadbeef + ((uint32_t)length) + *val2;
-
-  u.ptr = key;
-  if (HASH_BIG_ENDIAN && ((u.i & 0x3) == 0)) {
-    const uint32_t *k = (const uint32_t *)key;         /* read 32-bit chunks */
-    const uint8_t  *k8;
-
-    /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */
-    while (length > 12)
-    {
-      a += k[0];
-      b += k[1];
-      c += k[2];
-      mix(a,b,c);
-      length -= 12;
-      k += 3;
-    }
-
-    /*----------------------------- handle the last (probably partial) block */
-    /*
-     * "k[2]<<8" actually reads beyond the end of the string, but
-     * then shifts out the part it's not allowed to read.  Because the
-     * string is aligned, the illegal read is in the same word as the
-     * rest of the string.  Every machine with memory protection I've seen
-     * does it on word boundaries, so is OK with this.  But VALGRIND will
-     * still catch it and complain.  The masking trick does make the hash
-     * noticably faster for short strings (like English words).
-     *
-     * Not on my testing with gcc 4.5 on an intel i5 CPU, at least --RR.
-     */
-#if 0
-    switch(length)
-    {
-    case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
-    case 11: c+=k[2]&0xffffff00; b+=k[1]; a+=k[0]; break;
-    case 10: c+=k[2]&0xffff0000; b+=k[1]; a+=k[0]; break;
-    case 9 : c+=k[2]&0xff000000; b+=k[1]; a+=k[0]; break;
-    case 8 : b+=k[1]; a+=k[0]; break;
-    case 7 : b+=k[1]&0xffffff00; a+=k[0]; break;
-    case 6 : b+=k[1]&0xffff0000; a+=k[0]; break;
-    case 5 : b+=k[1]&0xff000000; a+=k[0]; break;
-    case 4 : a+=k[0]; break;
-    case 3 : a+=k[0]&0xffffff00; break;
-    case 2 : a+=k[0]&0xffff0000; break;
-    case 1 : a+=k[0]&0xff000000; break;
-    case 0 : return c;              /* zero length strings require no mixing */
-    }
-
-#else  /* make valgrind happy */
-
-    k8 = (const uint8_t *)k;
-    switch(length)                   /* all the case statements fall through */
-    {
-    case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
-    case 11: c+=((uint32_t)k8[10])<<8;  /* fall through */
-    case 10: c+=((uint32_t)k8[9])<<16;  /* fall through */
-    case 9 : c+=((uint32_t)k8[8])<<24;  /* fall through */
-    case 8 : b+=k[1]; a+=k[0]; break;
-    case 7 : b+=((uint32_t)k8[6])<<8;   /* fall through */
-    case 6 : b+=((uint32_t)k8[5])<<16;  /* fall through */
-    case 5 : b+=((uint32_t)k8[4])<<24;  /* fall through */
-    case 4 : a+=k[0]; break;
-    case 3 : a+=((uint32_t)k8[2])<<8;   /* fall through */
-    case 2 : a+=((uint32_t)k8[1])<<16;  /* fall through */
-    case 1 : a+=((uint32_t)k8[0])<<24; break;
-    case 0 : return c;
-    }
-
-#endif /* !VALGRIND */
-
-  } else {                        /* need to read the key one byte at a time */
-    const uint8_t *k = (const uint8_t *)key;
-
-    /*--------------- all but the last block: affect some 32 bits of (a,b,c) */
-    while (length > 12)
-    {
-      a += ((uint32_t)k[0])<<24;
-      a += ((uint32_t)k[1])<<16;
-      a += ((uint32_t)k[2])<<8;
-      a += ((uint32_t)k[3]);
-      b += ((uint32_t)k[4])<<24;
-      b += ((uint32_t)k[5])<<16;
-      b += ((uint32_t)k[6])<<8;
-      b += ((uint32_t)k[7]);
-      c += ((uint32_t)k[8])<<24;
-      c += ((uint32_t)k[9])<<16;
-      c += ((uint32_t)k[10])<<8;
-      c += ((uint32_t)k[11]);
-      mix(a,b,c);
-      length -= 12;
-      k += 12;
-    }
-
-    /*-------------------------------- last block: affect all 32 bits of (c) */
-    switch(length)                   /* all the case statements fall through */
-    {
-    case 12: c+=k[11];
-    case 11: c+=((uint32_t)k[10])<<8;
-    case 10: c+=((uint32_t)k[9])<<16;
-    case 9 : c+=((uint32_t)k[8])<<24;
-    case 8 : b+=k[7];
-    case 7 : b+=((uint32_t)k[6])<<8;
-    case 6 : b+=((uint32_t)k[5])<<16;
-    case 5 : b+=((uint32_t)k[4])<<24;
-    case 4 : a+=k[3];
-    case 3 : a+=((uint32_t)k[2])<<8;
-    case 2 : a+=((uint32_t)k[1])<<16;
-    case 1 : a+=((uint32_t)k[0])<<24;
-             break;
-    case 0 : return c;
-    }
-  }
-
-  final(a,b,c);
-  *val2 = b;
-  return c;
-}
-
-/* I basically use hashlittle here, but use native endian within each
- * element.  This delivers least-surprise: hash such as "int arr[] = {
- * 1, 2 }; hash_stable(arr, 2, 0);" will be the same on big and little
- * endian machines, even though a bytewise hash wouldn't be. */
-uint64_t hash64_stable_64(const void *key, size_t n, uint64_t base)
-{
-       const uint64_t *k = key;
-       uint32_t a,b,c;
-
-       /* Set up the internal state */
-       a = b = c = 0xdeadbeef + ((uint32_t)n*8) + (base >> 32) + base;
-
-       while (n > 3) {
-               a += (uint32_t)k[0];
-               b += (uint32_t)(k[0] >> 32);
-               c += (uint32_t)k[1];
-               mix(a,b,c);
-               a += (uint32_t)(k[1] >> 32);
-               b += (uint32_t)k[2];
-               c += (uint32_t)(k[2] >> 32);
-               mix(a,b,c);
-               n -= 3;
-               k += 3;
-       }
-       switch (n) {
-       case 2:
-               a += (uint32_t)k[0];
-               b += (uint32_t)(k[0] >> 32);
-               c += (uint32_t)k[1];
-               mix(a,b,c);
-               a += (uint32_t)(k[1] >> 32);
-               break;
-       case 1:
-               a += (uint32_t)k[0];
-               b += (uint32_t)(k[0] >> 32);
-               break;
-       case 0:
-               return c;
-       }
-       final(a,b,c);
-       return ((uint64_t)b << 32) | c;
-}
-
-uint64_t hash64_stable_32(const void *key, size_t n, uint64_t base)
-{
-       const uint32_t *k = key;
-       uint32_t a,b,c;
-
-       /* Set up the internal state */
-       a = b = c = 0xdeadbeef + ((uint32_t)n*4) + (base >> 32) + base;
-
-       while (n > 3) {
-               a += k[0];
-               b += k[1];
-               c += k[2];
-               mix(a,b,c);
-
-               n -= 3;
-               k += 3;
-       }
-       switch (n) {
-       case 2:
-               b += (uint32_t)k[1];
-       case 1:
-               a += (uint32_t)k[0];
-               break;
-       case 0:
-               return c;
-       }
-       final(a,b,c);
-       return ((uint64_t)b << 32) | c;
-}
-
-uint64_t hash64_stable_16(const void *key, size_t n, uint64_t base)
-{
-       const uint16_t *k = key;
-       uint32_t a,b,c;
-
-       /* Set up the internal state */
-       a = b = c = 0xdeadbeef + ((uint32_t)n*2) + (base >> 32) + base;
-
-       while (n > 6) {
-               a += (uint32_t)k[0] + ((uint32_t)k[1] << 16);
-               b += (uint32_t)k[2] + ((uint32_t)k[3] << 16);
-               c += (uint32_t)k[4] + ((uint32_t)k[5] << 16);
-               mix(a,b,c);
-
-               n -= 6;
-               k += 6;
-       }
-
-       switch (n) {
-       case 5:
-               c += (uint32_t)k[4];
-       case 4:
-               b += ((uint32_t)k[3] << 16);
-       case 3:
-               b += (uint32_t)k[2];
-       case 2:
-               a += ((uint32_t)k[1] << 16);
-       case 1:
-               a += (uint32_t)k[0];
-               break;
-       case 0:
-               return c;
-       }
-       final(a,b,c);
-       return ((uint64_t)b << 32) | c;
-}
-
-uint64_t hash64_stable_8(const void *key, size_t n, uint64_t base)
-{
-       uint32_t b32 = base + (base >> 32);
-       uint32_t lower = hashlittle(key, n, &b32);
-
-       return ((uint64_t)b32 << 32) | lower;
-}
-
-uint32_t hash_any(const void *key, size_t length, uint32_t base)
-{
-       if (HASH_BIG_ENDIAN)
-               return hashbig(key, length, &base);
-       else
-               return hashlittle(key, length, &base);
-}
-
-uint32_t hash_stable_64(const void *key, size_t n, uint32_t base)
-{
-       return hash64_stable_64(key, n, base);
-}
-
-uint32_t hash_stable_32(const void *key, size_t n, uint32_t base)
-{
-       return hash64_stable_32(key, n, base);
-}
-
-uint32_t hash_stable_16(const void *key, size_t n, uint32_t base)
-{
-       return hash64_stable_16(key, n, base);
-}
-
-uint32_t hash_stable_8(const void *key, size_t n, uint32_t base)
-{
-       return hashlittle(key, n, &base);
-}
-
-/* Jenkins' lookup8 is a 64 bit hash, but he says it's obsolete.  Use
- * the plain one and recombine into 64 bits. */
-uint64_t hash64_any(const void *key, size_t length, uint64_t base)
-{
-       uint32_t b32 = base + (base >> 32);
-       uint32_t lower;
-
-       if (HASH_BIG_ENDIAN)
-               lower = hashbig(key, length, &b32);
-       else
-               lower = hashlittle(key, length, &b32);
-
-       return ((uint64_t)b32 << 32) | lower;
-}
-
-#ifdef SELF_TEST
-
-/* used for timings */
-void driver1()
-{
-  uint8_t buf[256];
-  uint32_t i;
-  uint32_t h=0;
-  time_t a,z;
-
-  time(&a);
-  for (i=0; i<256; ++i) buf[i] = 'x';
-  for (i=0; i<1; ++i)
-  {
-    h = hashlittle(&buf[0],1,h);
-  }
-  time(&z);
-  if (z-a > 0) printf("time %d %.8x\n", z-a, h);
-}
-
-/* check that every input bit changes every output bit half the time */
-#define HASHSTATE 1
-#define HASHLEN   1
-#define MAXPAIR 60
-#define MAXLEN  70
-void driver2()
-{
-  uint8_t qa[MAXLEN+1], qb[MAXLEN+2], *a = &qa[0], *b = &qb[1];
-  uint32_t c[HASHSTATE], d[HASHSTATE], i=0, j=0, k, l, m=0, z;
-  uint32_t e[HASHSTATE],f[HASHSTATE],g[HASHSTATE],h[HASHSTATE];
-  uint32_t x[HASHSTATE],y[HASHSTATE];
-  uint32_t hlen;
-
-  printf("No more than %d trials should ever be needed \n",MAXPAIR/2);
-  for (hlen=0; hlen < MAXLEN; ++hlen)
-  {
-    z=0;
-    for (i=0; i<hlen; ++i)  /*----------------------- for each input byte, */
-    {
-      for (j=0; j<8; ++j)   /*------------------------ for each input bit, */
-      {
-       for (m=1; m<8; ++m) /*------------ for several possible initvals, */
-       {
-         for (l=0; l<HASHSTATE; ++l)
-           e[l]=f[l]=g[l]=h[l]=x[l]=y[l]=~((uint32_t)0);
-
-         /*---- check that every output bit is affected by that input bit */
-         for (k=0; k<MAXPAIR; k+=2)
-         {
-           uint32_t finished=1;
-           /* keys have one bit different */
-           for (l=0; l<hlen+1; ++l) {a[l] = b[l] = (uint8_t)0;}
-           /* have a and b be two keys differing in only one bit */
-           a[i] ^= (k<<j);
-           a[i] ^= (k>>(8-j));
-            c[0] = hashlittle(a, hlen, m);
-           b[i] ^= ((k+1)<<j);
-           b[i] ^= ((k+1)>>(8-j));
-            d[0] = hashlittle(b, hlen, m);
-           /* check every bit is 1, 0, set, and not set at least once */
-           for (l=0; l<HASHSTATE; ++l)
-           {
-             e[l] &= (c[l]^d[l]);
-             f[l] &= ~(c[l]^d[l]);
-             g[l] &= c[l];
-             h[l] &= ~c[l];
-             x[l] &= d[l];
-             y[l] &= ~d[l];
-             if (e[l]|f[l]|g[l]|h[l]|x[l]|y[l]) finished=0;
-           }
-           if (finished) break;
-         }
-         if (k>z) z=k;
-         if (k==MAXPAIR)
-         {
-            printf("Some bit didn't change: ");
-            printf("%.8x %.8x %.8x %.8x %.8x %.8x  ",
-                   e[0],f[0],g[0],h[0],x[0],y[0]);
-            printf("i %d j %d m %d len %d\n", i, j, m, hlen);
-         }
-         if (z==MAXPAIR) goto done;
-       }
-      }
-    }
-   done:
-    if (z < MAXPAIR)
-    {
-      printf("Mix success  %2d bytes  %2d initvals  ",i,m);
-      printf("required  %d  trials\n", z/2);
-    }
-  }
-  printf("\n");
-}
-
-/* Check for reading beyond the end of the buffer and alignment problems */
-void driver3()
-{
-  uint8_t buf[MAXLEN+20], *b;
-  uint32_t len;
-  uint8_t q[] = "This is the time for all good men to come to the aid of their country...";
-  uint32_t h;
-  uint8_t qq[] = "xThis is the time for all good men to come to the aid of their country...";
-  uint32_t i;
-  uint8_t qqq[] = "xxThis is the time for all good men to come to the aid of their country...";
-  uint32_t j;
-  uint8_t qqqq[] = "xxxThis is the time for all good men to come to the aid of their country...";
-  uint32_t ref,x,y;
-  uint8_t *p;
-
-  printf("Endianness.  These lines should all be the same (for values filled in):\n");
-  printf("%.8x                            %.8x                            %.8x\n",
-         hash_word((const uint32_t *)q, (sizeof(q)-1)/4, 13),
-         hash_word((const uint32_t *)q, (sizeof(q)-5)/4, 13),
-         hash_word((const uint32_t *)q, (sizeof(q)-9)/4, 13));
-  p = q;
-  printf("%.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x\n",
-         hashlittle(p, sizeof(q)-1, 13), hashlittle(p, sizeof(q)-2, 13),
-         hashlittle(p, sizeof(q)-3, 13), hashlittle(p, sizeof(q)-4, 13),
-         hashlittle(p, sizeof(q)-5, 13), hashlittle(p, sizeof(q)-6, 13),
-         hashlittle(p, sizeof(q)-7, 13), hashlittle(p, sizeof(q)-8, 13),
-         hashlittle(p, sizeof(q)-9, 13), hashlittle(p, sizeof(q)-10, 13),
-         hashlittle(p, sizeof(q)-11, 13), hashlittle(p, sizeof(q)-12, 13));
-  p = &qq[1];
-  printf("%.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x\n",
-         hashlittle(p, sizeof(q)-1, 13), hashlittle(p, sizeof(q)-2, 13),
-         hashlittle(p, sizeof(q)-3, 13), hashlittle(p, sizeof(q)-4, 13),
-         hashlittle(p, sizeof(q)-5, 13), hashlittle(p, sizeof(q)-6, 13),
-         hashlittle(p, sizeof(q)-7, 13), hashlittle(p, sizeof(q)-8, 13),
-         hashlittle(p, sizeof(q)-9, 13), hashlittle(p, sizeof(q)-10, 13),
-         hashlittle(p, sizeof(q)-11, 13), hashlittle(p, sizeof(q)-12, 13));
-  p = &qqq[2];
-  printf("%.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x\n",
-         hashlittle(p, sizeof(q)-1, 13), hashlittle(p, sizeof(q)-2, 13),
-         hashlittle(p, sizeof(q)-3, 13), hashlittle(p, sizeof(q)-4, 13),
-         hashlittle(p, sizeof(q)-5, 13), hashlittle(p, sizeof(q)-6, 13),
-         hashlittle(p, sizeof(q)-7, 13), hashlittle(p, sizeof(q)-8, 13),
-         hashlittle(p, sizeof(q)-9, 13), hashlittle(p, sizeof(q)-10, 13),
-         hashlittle(p, sizeof(q)-11, 13), hashlittle(p, sizeof(q)-12, 13));
-  p = &qqqq[3];
-  printf("%.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x\n",
-         hashlittle(p, sizeof(q)-1, 13), hashlittle(p, sizeof(q)-2, 13),
-         hashlittle(p, sizeof(q)-3, 13), hashlittle(p, sizeof(q)-4, 13),
-         hashlittle(p, sizeof(q)-5, 13), hashlittle(p, sizeof(q)-6, 13),
-         hashlittle(p, sizeof(q)-7, 13), hashlittle(p, sizeof(q)-8, 13),
-         hashlittle(p, sizeof(q)-9, 13), hashlittle(p, sizeof(q)-10, 13),
-         hashlittle(p, sizeof(q)-11, 13), hashlittle(p, sizeof(q)-12, 13));
-  printf("\n");
-
-  /* check that hashlittle2 and hashlittle produce the same results */
-  i=47; j=0;
-  hashlittle2(q, sizeof(q), &i, &j);
-  if (hashlittle(q, sizeof(q), 47) != i)
-    printf("hashlittle2 and hashlittle mismatch\n");
-
-  /* check that hash_word2 and hash_word produce the same results */
-  len = 0xdeadbeef;
-  i=47, j=0;
-  hash_word2(&len, 1, &i, &j);
-  if (hash_word(&len, 1, 47) != i)
-    printf("hash_word2 and hash_word mismatch %x %x\n",
-          i, hash_word(&len, 1, 47));
-
-  /* check hashlittle doesn't read before or after the ends of the string */
-  for (h=0, b=buf+1; h<8; ++h, ++b)
-  {
-    for (i=0; i<MAXLEN; ++i)
-    {
-      len = i;
-      for (j=0; j<i; ++j) *(b+j)=0;
-
-      /* these should all be equal */
-      ref = hashlittle(b, len, (uint32_t)1);
-      *(b+i)=(uint8_t)~0;
-      *(b-1)=(uint8_t)~0;
-      x = hashlittle(b, len, (uint32_t)1);
-      y = hashlittle(b, len, (uint32_t)1);
-      if ((ref != x) || (ref != y))
-      {
-       printf("alignment error: %.8x %.8x %.8x %d %d\n",ref,x,y,
-               h, i);
-      }
-    }
-  }
-}
-
-/* check for problems with nulls */
- void driver4()
-{
-  uint8_t buf[1];
-  uint32_t h,i,state[HASHSTATE];
-
-
-  buf[0] = ~0;
-  for (i=0; i<HASHSTATE; ++i) state[i] = 1;
-  printf("These should all be different\n");
-  for (i=0, h=0; i<8; ++i)
-  {
-    h = hashlittle(buf, 0, h);
-    printf("%2ld  0-byte strings, hash is  %.8x\n", i, h);
-  }
-}
-
-
-int main()
-{
-  driver1();   /* test that the key is hashed: used for timings */
-  driver2();   /* test that whole key is hashed thoroughly */
-  driver3();   /* test that nothing but the key is hashed */
-  driver4();   /* test hashing multiple buffers (all buffers are null) */
-  return 1;
-}
-
-#endif  /* SELF_TEST */
diff --git a/lib/ccan/hash/hash.h b/lib/ccan/hash/hash.h
deleted file mode 100644 (file)
index 5025c0d..0000000
+++ /dev/null
@@ -1,312 +0,0 @@
-#ifndef CCAN_HASH_H
-#define CCAN_HASH_H
-#include "config.h"
-#include <stdint.h>
-#include <stdlib.h>
-#include <ccan/build_assert/build_assert.h>
-
-/* Stolen mostly from: lookup3.c, by Bob Jenkins, May 2006, Public Domain.
- *
- * http://burtleburtle.net/bob/c/lookup3.c
- */
-
-/**
- * hash - fast hash of an array for internal use
- * @p: the array or pointer to first element
- * @num: the number of elements to hash
- * @base: the base number to roll into the hash (usually 0)
- *
- * The memory region pointed to by p is combined with the base to form
- * a 32-bit hash.
- *
- * This hash will have different results on different machines, so is
- * only useful for internal hashes (ie. not hashes sent across the
- * network or saved to disk).
- *
- * It may also change with future versions: it could even detect at runtime
- * what the fastest hash to use is.
- *
- * See also: hash64, hash_stable.
- *
- * Example:
- *     #include <ccan/hash/hash.h>
- *     #include <err.h>
- *     #include <stdio.h>
- *     #include <string.h>
- *
- *     // Simple demonstration: idential strings will have the same hash, but
- *     // two different strings will probably not.
- *     int main(int argc, char *argv[])
- *     {
- *             uint32_t hash1, hash2;
- *
- *             if (argc != 3)
- *                     err(1, "Usage: %s <string1> <string2>", argv[0]);
- *
- *             hash1 = hash(argv[1], strlen(argv[1]), 0);
- *             hash2 = hash(argv[2], strlen(argv[2]), 0);
- *             printf("Hash is %s\n", hash1 == hash2 ? "same" : "different");
- *             return 0;
- *     }
- */
-#define hash(p, num, base) hash_any((p), (num)*sizeof(*(p)), (base))
-
-/**
- * hash_stable - hash of an array for external use
- * @p: the array or pointer to first element
- * @num: the number of elements to hash
- * @base: the base number to roll into the hash (usually 0)
- *
- * The array of simple integer types pointed to by p is combined with
- * the base to form a 32-bit hash.
- *
- * This hash will have the same results on different machines, so can
- * be used for external hashes (ie. hashes sent across the network or
- * saved to disk).  The results will not change in future versions of
- * this module.
- *
- * Note that it is only legal to hand an array of simple integer types
- * to this hash (ie. char, uint16_t, int64_t, etc).  In these cases,
- * the same values will have the same hash result, even though the
- * memory representations of integers depend on the machine
- * endianness.
- *
- * See also:
- *     hash64_stable
- *
- * Example:
- *     #include <ccan/hash/hash.h>
- *     #include <err.h>
- *     #include <stdio.h>
- *     #include <string.h>
- *
- *     int main(int argc, char *argv[])
- *     {
- *             if (argc != 2)
- *                     err(1, "Usage: %s <string-to-hash>", argv[0]);
- *
- *             printf("Hash stable result is %u\n",
- *                    hash_stable(argv[1], strlen(argv[1]), 0));
- *             return 0;
- *     }
- */
-#define hash_stable(p, num, base)                                      \
-       (BUILD_ASSERT_OR_ZERO(sizeof(*(p)) == 8 || sizeof(*(p)) == 4    \
-                             || sizeof(*(p)) == 2 || sizeof(*(p)) == 1) + \
-        sizeof(*(p)) == 8 ? hash_stable_64((p), (num), (base))         \
-        : sizeof(*(p)) == 4 ? hash_stable_32((p), (num), (base))       \
-        : sizeof(*(p)) == 2 ? hash_stable_16((p), (num), (base))       \
-        : hash_stable_8((p), (num), (base)))
-
-/**
- * hash_u32 - fast hash an array of 32-bit values for internal use
- * @key: the array of uint32_t
- * @num: the number of elements to hash
- * @base: the base number to roll into the hash (usually 0)
- *
- * The array of uint32_t pointed to by @key is combined with the base
- * to form a 32-bit hash.  This is 2-3 times faster than hash() on small
- * arrays, but the advantage vanishes over large hashes.
- *
- * This hash will have different results on different machines, so is
- * only useful for internal hashes (ie. not hashes sent across the
- * network or saved to disk).
- */
-uint32_t hash_u32(const uint32_t *key, size_t num, uint32_t base);
-
-/**
- * hash_string - very fast hash of an ascii string
- * @str: the nul-terminated string
- *
- * The string is hashed, using a hash function optimized for ASCII and
- * similar strings.  It's weaker than the other hash functions.
- *
- * This hash may have different results on different machines, so is
- * only useful for internal hashes (ie. not hashes sent across the
- * network or saved to disk).  The results will be different from the
- * other hash functions in this module, too.
- */
-static inline uint32_t hash_string(const char *string)
-{
-       /* This is Karl Nelson <kenelson@ece.ucdavis.edu>'s X31 hash.
-        * It's a little faster than the (much better) lookup3 hash(): 56ns vs
-        * 84ns on my 2GHz Intel Core Duo 2 laptop for a 10 char string. */
-       uint32_t ret;
-
-       for (ret = 0; *string; string++)
-               ret = (ret << 5) - ret + *string;
-
-       return ret;
-}
-
-/**
- * hash64 - fast 64-bit hash of an array for internal use
- * @p: the array or pointer to first element
- * @num: the number of elements to hash
- * @base: the 64-bit base number to roll into the hash (usually 0)
- *
- * The memory region pointed to by p is combined with the base to form
- * a 64-bit hash.
- *
- * This hash will have different results on different machines, so is
- * only useful for internal hashes (ie. not hashes sent across the
- * network or saved to disk).
- *
- * It may also change with future versions: it could even detect at runtime
- * what the fastest hash to use is.
- *
- * See also: hash.
- *
- * Example:
- *     #include <ccan/hash/hash.h>
- *     #include <err.h>
- *     #include <stdio.h>
- *     #include <string.h>
- *
- *     // Simple demonstration: idential strings will have the same hash, but
- *     // two different strings will probably not.
- *     int main(int argc, char *argv[])
- *     {
- *             uint64_t hash1, hash2;
- *
- *             if (argc != 3)
- *                     err(1, "Usage: %s <string1> <string2>", argv[0]);
- *
- *             hash1 = hash64(argv[1], strlen(argv[1]), 0);
- *             hash2 = hash64(argv[2], strlen(argv[2]), 0);
- *             printf("Hash is %s\n", hash1 == hash2 ? "same" : "different");
- *             return 0;
- *     }
- */
-#define hash64(p, num, base) hash64_any((p), (num)*sizeof(*(p)), (base))
-
-/**
- * hash64_stable - 64 bit hash of an array for external use
- * @p: the array or pointer to first element
- * @num: the number of elements to hash
- * @base: the base number to roll into the hash (usually 0)
- *
- * The array of simple integer types pointed to by p is combined with
- * the base to form a 64-bit hash.
- *
- * This hash will have the same results on different machines, so can
- * be used for external hashes (ie. hashes sent across the network or
- * saved to disk).  The results will not change in future versions of
- * this module.
- *
- * Note that it is only legal to hand an array of simple integer types
- * to this hash (ie. char, uint16_t, int64_t, etc).  In these cases,
- * the same values will have the same hash result, even though the
- * memory representations of integers depend on the machine
- * endianness.
- *
- * See also:
- *     hash_stable
- *
- * Example:
- *     #include <ccan/hash/hash.h>
- *     #include <err.h>
- *     #include <stdio.h>
- *     #include <string.h>
- *
- *     int main(int argc, char *argv[])
- *     {
- *             if (argc != 2)
- *                     err(1, "Usage: %s <string-to-hash>", argv[0]);
- *
- *             printf("Hash stable result is %llu\n",
- *                    (long long)hash64_stable(argv[1], strlen(argv[1]), 0));
- *             return 0;
- *     }
- */
-#define hash64_stable(p, num, base)                                    \
-       (BUILD_ASSERT_OR_ZERO(sizeof(*(p)) == 8 || sizeof(*(p)) == 4    \
-                             || sizeof(*(p)) == 2 || sizeof(*(p)) == 1) + \
-        sizeof(*(p)) == 8 ? hash64_stable_64((p), (num), (base))       \
-        : sizeof(*(p)) == 4 ? hash64_stable_32((p), (num), (base))     \
-        : sizeof(*(p)) == 2 ? hash64_stable_16((p), (num), (base))     \
-        : hash64_stable_8((p), (num), (base)))
-
-
-/**
- * hashl - fast 32/64-bit hash of an array for internal use
- * @p: the array or pointer to first element
- * @num: the number of elements to hash
- * @base: the base number to roll into the hash (usually 0)
- *
- * This is either hash() or hash64(), on 32/64 bit long machines.
- */
-#define hashl(p, num, base)                                            \
-       (BUILD_ASSERT_OR_ZERO(sizeof(long) == sizeof(uint32_t)          \
-                             || sizeof(long) == sizeof(uint64_t)) +    \
-       (sizeof(long) == sizeof(uint64_t)                               \
-        ? hash64((p), (num), (base)) : hash((p), (num), (base))))
-
-/* Our underlying operations. */
-uint32_t hash_any(const void *key, size_t length, uint32_t base);
-uint32_t hash_stable_64(const void *key, size_t n, uint32_t base);
-uint32_t hash_stable_32(const void *key, size_t n, uint32_t base);
-uint32_t hash_stable_16(const void *key, size_t n, uint32_t base);
-uint32_t hash_stable_8(const void *key, size_t n, uint32_t base);
-uint64_t hash64_any(const void *key, size_t length, uint64_t base);
-uint64_t hash64_stable_64(const void *key, size_t n, uint64_t base);
-uint64_t hash64_stable_32(const void *key, size_t n, uint64_t base);
-uint64_t hash64_stable_16(const void *key, size_t n, uint64_t base);
-uint64_t hash64_stable_8(const void *key, size_t n, uint64_t base);
-
-/**
- * hash_pointer - hash a pointer for internal use
- * @p: the pointer value to hash
- * @base: the base number to roll into the hash (usually 0)
- *
- * The pointer p (not what p points to!) is combined with the base to form
- * a 32-bit hash.
- *
- * This hash will have different results on different machines, so is
- * only useful for internal hashes (ie. not hashes sent across the
- * network or saved to disk).
- *
- * Example:
- *     #include <ccan/hash/hash.h>
- *
- *     // Code to keep track of memory regions.
- *     struct region {
- *             struct region *chain;
- *             void *start;
- *             unsigned int size;
- *     };
- *     // We keep a simple hash table.
- *     static struct region *region_hash[128];
- *
- *     static void add_region(struct region *r)
- *     {
- *             unsigned int h = hash_pointer(r->start, 0);
- *
- *             r->chain = region_hash[h];
- *             region_hash[h] = r->chain;
- *     }
- *
- *     static struct region *find_region(const void *start)
- *     {
- *             struct region *r;
- *
- *             for (r = region_hash[hash_pointer(start, 0)]; r; r = r->chain)
- *                     if (r->start == start)
- *                             return r;
- *             return NULL;
- *     }
- */
-static inline uint32_t hash_pointer(const void *p, uint32_t base)
-{
-       if (sizeof(p) % sizeof(uint32_t) == 0) {
-               /* This convoluted union is the right way of aliasing. */
-               union {
-                       uint32_t u32[sizeof(p) / sizeof(uint32_t)];
-                       const void *p;
-               } u;
-               u.p = p;
-               return hash_u32(u.u32, sizeof(p) / sizeof(uint32_t), base);
-       } else
-               return hash(&p, 1, base);
-}
-#endif /* HASH_H */
diff --git a/lib/ccan/hash/test/api-hash_stable.c b/lib/ccan/hash/test/api-hash_stable.c
deleted file mode 100644 (file)
index bb58d16..0000000
+++ /dev/null
@@ -1,300 +0,0 @@
-#include <ccan/hash/hash.h>
-#include <ccan/tap/tap.h>
-#include <stdbool.h>
-#include <string.h>
-
-#define ARRAY_WORDS 5
-
-int main(int argc, char *argv[])
-{
-       unsigned int i;
-       uint8_t u8array[ARRAY_WORDS];
-       uint16_t u16array[ARRAY_WORDS];
-       uint32_t u32array[ARRAY_WORDS];
-       uint64_t u64array[ARRAY_WORDS];
-
-       /* Initialize arrays. */
-       for (i = 0; i < ARRAY_WORDS; i++) {
-               u8array[i] = i;
-               u16array[i] = i;
-               u32array[i] = i;
-               u64array[i] = i;
-       }
-
-       plan_tests(264);
-
-       /* hash_stable is API-guaranteed. */
-       ok1(hash_stable(u8array, ARRAY_WORDS, 0) == 0x1d4833cc);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 1) == 0x37125e2 );
-       ok1(hash_stable(u8array, ARRAY_WORDS, 2) == 0x330a007a);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 4) == 0x7b0df29b);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 8) == 0xe7e5d741);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 16) == 0xaae57471);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 32) == 0xc55399e5);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 64) == 0x67f21f7 );
-       ok1(hash_stable(u8array, ARRAY_WORDS, 128) == 0x1d795b71);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 256) == 0xeb961671);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 512) == 0xc2597247);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 1024) == 0x3f5c4d75);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 2048) == 0xe65cf4f9);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 4096) == 0xf2cd06cb);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 8192) == 0x443041e1);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 16384) == 0xdfc618f5);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 32768) == 0x5e3d5b97);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 65536) == 0xd5f64730);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 131072) == 0x372bbecc);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 262144) == 0x7c194c8d);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 524288) == 0x16cbb416);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 1048576) == 0x53e99222);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 2097152) == 0x6394554a);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 4194304) == 0xd83a506d);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 8388608) == 0x7619d9a4);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 16777216) == 0xfe98e5f6);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 33554432) == 0x6c262927);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 67108864) == 0x3f0106fd);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 134217728) == 0xc91e3a28);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 268435456) == 0x14229579);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 536870912) == 0x9dbefa76);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 1073741824) == 0xb05c0c78);
-       ok1(hash_stable(u8array, ARRAY_WORDS, 2147483648U) == 0x88f24d81);
-
-       ok1(hash_stable(u16array, ARRAY_WORDS, 0) == 0xecb5f507);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 1) == 0xadd666e6);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 2) == 0xea0f214c);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 4) == 0xae4051ba);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 8) == 0x6ed28026);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 16) == 0xa3917a19);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 32) == 0xf370f32b);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 64) == 0x807af460);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 128) == 0xb4c8cd83);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 256) == 0xa10cb5b0);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 512) == 0x8b7d7387);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 1024) == 0x9e49d1c );
-       ok1(hash_stable(u16array, ARRAY_WORDS, 2048) == 0x288830d1);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 4096) == 0xbe078a43);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 8192) == 0xa16d5d88);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 16384) == 0x46839fcd);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 32768) == 0x9db9bd4f);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 65536) == 0xedff58f8);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 131072) == 0x95ecef18);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 262144) == 0x23c31b7d);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 524288) == 0x1d85c7d0);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 1048576) == 0x25218842);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 2097152) == 0x711d985c);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 4194304) == 0x85470eca);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 8388608) == 0x99ed4ceb);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 16777216) == 0x67b3710c);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 33554432) == 0x77f1ab35);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 67108864) == 0x81f688aa);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 134217728) == 0x27b56ca5);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 268435456) == 0xf21ba203);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 536870912) == 0xd48d1d1 );
-       ok1(hash_stable(u16array, ARRAY_WORDS, 1073741824) == 0xa542b62d);
-       ok1(hash_stable(u16array, ARRAY_WORDS, 2147483648U) == 0xa04c7058);
-
-       ok1(hash_stable(u32array, ARRAY_WORDS, 0) == 0x13305f8c);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 1) == 0x171abf74);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 2) == 0x7646fcc7);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 4) == 0xa758ed5);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 8) == 0x2dedc2e4);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 16) == 0x28e2076b);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 32) == 0xb73091c5);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 64) == 0x87daf5db);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 128) == 0xa16dfe20);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 256) == 0x300c63c3);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 512) == 0x255c91fc);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 1024) == 0x6357b26);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 2048) == 0x4bc5f339);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 4096) == 0x1301617c);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 8192) == 0x506792c9);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 16384) == 0xcd596705);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 32768) == 0xa8713cac);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 65536) == 0x94d9794);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 131072) == 0xac753e8);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 262144) == 0xcd8bdd20);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 524288) == 0xd44faf80);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 1048576) == 0x2547ccbe);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 2097152) == 0xbab06dbc);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 4194304) == 0xaac0e882);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 8388608) == 0x443f48d0);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 16777216) == 0xdff49fcc);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 33554432) == 0x9ce0fd65);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 67108864) == 0x9ddb1def);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 134217728) == 0x86096f25);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 268435456) == 0xe713b7b5);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 536870912) == 0x5baeffc5);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 1073741824) == 0xde874f52);
-       ok1(hash_stable(u32array, ARRAY_WORDS, 2147483648U) == 0xeca13b4e);
-
-       ok1(hash_stable(u64array, ARRAY_WORDS, 0) == 0x12ef6302);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 1) == 0xe9aeb406);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 2) == 0xc4218ceb);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 4) == 0xb3d11412);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 8) == 0xdafbd654);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 16) == 0x9c336cba);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 32) == 0x65059721);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 64) == 0x95b5bbe6);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 128) == 0xe7596b84);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 256) == 0x503622a2);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 512) == 0xecdcc5ca);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 1024) == 0xc40d0513);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 2048) == 0xaab25e4d);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 4096) == 0xcc353fb9);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 8192) == 0x18e2319f);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 16384) == 0xfddaae8d);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 32768) == 0xef7976f2);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 65536) == 0x86359fc9);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 131072) == 0x8b5af385);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 262144) == 0x80d4ee31);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 524288) == 0x42f5f85b);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 1048576) == 0x9a6920e1);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 2097152) == 0x7b7c9850);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 4194304) == 0x69573e09);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 8388608) == 0xc942bc0e);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 16777216) == 0x7a89f0f1);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 33554432) == 0x2dd641ca);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 67108864) == 0x89bbd391);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 134217728) == 0xbcf88e31);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 268435456) == 0xfa7a3460);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 536870912) == 0x49a37be0);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 1073741824) == 0x1b346394);
-       ok1(hash_stable(u64array, ARRAY_WORDS, 2147483648U) == 0x6c3a1592);
-
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 0) == 16887282882572727244ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 1) == 12032777473133454818ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 2) == 18183407363221487738ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 4) == 17860764172704150171ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 8) == 18076051600675559233ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 16) == 9909361918431556721ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 32) == 12937969888744675813ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 64) == 5245669057381736951ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 128) == 4376874646406519665ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 256) == 14219974419871569521ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 512) == 2263415354134458951ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 1024) == 4953859694526221685ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 2048) == 3432228642067641593ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 4096) == 1219647244417697483ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 8192) == 7629939424585859553ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 16384) == 10041660531376789749ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 32768) == 13859885793922603927ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 65536) == 15069060338344675120ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 131072) == 818163430835601100ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 262144) == 14914314323019517069ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 524288) == 17518437749769352214ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 1048576) == 14920048004901212706ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 2097152) == 8758567366332536138ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 4194304) == 6226655736088907885ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 8388608) == 13716650013685832100ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 16777216) == 305325651636315638ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 33554432) == 16784147606583781671ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 67108864) == 16509467555140798205ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 134217728) == 8717281234694060584ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 268435456) == 8098476701725660537ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 536870912) == 16345871539461094006ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 1073741824) == 3755557000429964408ULL);
-       ok1(hash64_stable(u8array, ARRAY_WORDS, 2147483648U) == 15017348801959710081ULL);
-
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 0) == 1038028831307724039ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 1) == 10155473272642627302ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 2) == 5714751190106841420ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 4) == 3923885607767527866ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 8) == 3931017318293995558ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 16) == 1469696588339313177ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 32) == 11522218526952715051ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 64) == 6953517591561958496ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 128) == 7406689491740052867ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 256) == 10101844489704093104ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 512) == 12511348870707245959ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 1024) == 1614019938016861468ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 2048) == 5294796182374592721ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 4096) == 16089570706643716675ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 8192) == 1689302638424579464ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 16384) == 1446340172370386893ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 32768) == 16535503506744393039ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 65536) == 3496794142527150328ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 131072) == 6568245367474548504ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 262144) == 9487676460765485949ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 524288) == 4519762130966530000ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 1048576) == 15623412069215340610ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 2097152) == 544013388676438108ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 4194304) == 5594904760290840266ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 8388608) == 18098755780041592043ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 16777216) == 6389168672387330316ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 33554432) == 896986127732419381ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 67108864) == 13232626471143901354ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 134217728) == 53378562890493093ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 268435456) == 10072361400297824771ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 536870912) == 14511948118285144529ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 1073741824) == 6981033484844447277ULL);
-       ok1(hash64_stable(u16array, ARRAY_WORDS, 2147483648U) == 5619339091684126808ULL);
-
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 0) == 3037571077312110476ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 1) == 14732398743825071988ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 2) == 14949132158206672071ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 4) == 1291370080511561429ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 8) == 10792665964172133092ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 16) == 14250138032054339435ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 32) == 17136741522078732741ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 64) == 3260193403318236635ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 128) == 10526616652205653536ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 256) == 9019690373358576579ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 512) == 6997491436599677436ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 1024) == 18302783371416533798ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 2048) == 10149320644446516025ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 4096) == 7073759949410623868ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 8192) == 17442399482223760073ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 16384) == 2983906194216281861ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 32768) == 4975845419129060524ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 65536) == 594019910205413268ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 131072) == 11903010186073691112ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 262144) == 7339636527154847008ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 524288) == 15243305400579108736ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 1048576) == 16737926245392043198ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 2097152) == 15725083267699862972ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 4194304) == 12527834265678833794ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 8388608) == 13908436455987824848ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 16777216) == 9672773345173872588ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 33554432) == 2305314279896710501ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 67108864) == 1866733780381408751ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 134217728) == 11906263969465724709ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 268435456) == 5501594918093830069ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 536870912) == 15823785789276225477ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 1073741824) == 17353000723889475410ULL);
-       ok1(hash64_stable(u32array, ARRAY_WORDS, 2147483648U) == 7494736910655503182ULL);
-
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 0) == 9765419389786481410ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 1) == 11182806172127114246ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 2) == 2559155171395472619ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 4) == 3311692033324815378ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 8) == 1297175419505333844ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 16) == 617896928653569210ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 32) == 1517398559958603553ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 64) == 4504821917445110758ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 128) == 1971743331114904452ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 256) == 6177667912354374306ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 512) == 15570521289777792458ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 1024) == 9204559632415917331ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 2048) == 9008982669760028237ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 4096) == 14803537660281700281ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 8192) == 2873966517448487327ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 16384) == 5859277625928363661ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 32768) == 15520461285618185970ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 65536) == 16746489793331175369ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 131072) == 514952025484227461ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 262144) == 10867212269810675249ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 524288) == 9822204377278314587ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 1048576) == 3295088921987850465ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 2097152) == 7559197431498053712ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 4194304) == 1667267269116771849ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 8388608) == 2916804068951374862ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 16777216) == 14422558383125688561ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 33554432) == 10083112683694342602ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 67108864) == 7222777647078298513ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 134217728) == 18424513674048212529ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 268435456) == 14913668581101810784ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 536870912) == 14377721174297902048ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 1073741824) == 6031715005667500948ULL);
-       ok1(hash64_stable(u64array, ARRAY_WORDS, 2147483648U) == 4827100319722378642ULL);
-
-       return exit_status();
-}
diff --git a/lib/ccan/hash/test/run.c b/lib/ccan/hash/test/run.c
deleted file mode 100644 (file)
index dad8e86..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-#include <ccan/hash/hash.h>
-#include <ccan/tap/tap.h>
-#include <ccan/hash/hash.c>
-#include <stdbool.h>
-#include <string.h>
-
-#define ARRAY_WORDS 5
-
-int main(int argc, char *argv[])
-{
-       unsigned int i, j, k;
-       uint32_t array[ARRAY_WORDS], val;
-       char array2[sizeof(array) + sizeof(uint32_t)];
-       uint32_t results[256];
-
-       /* Initialize array. */
-       for (i = 0; i < ARRAY_WORDS; i++)
-               array[i] = i;
-
-       plan_tests(39);
-       /* Hash should be the same, indep of memory alignment. */
-       val = hash(array, ARRAY_WORDS, 0);
-       for (i = 0; i < sizeof(uint32_t); i++) {
-               memcpy(array2 + i, array, sizeof(array));
-               ok(hash(array2 + i, ARRAY_WORDS, 0) != val,
-                  "hash matched at offset %i", i);
-       }
-
-       /* Hash of random values should have random distribution:
-        * check one byte at a time. */
-       for (i = 0; i < sizeof(uint32_t); i++) {
-               unsigned int lowest = -1U, highest = 0;
-
-               memset(results, 0, sizeof(results));
-
-               for (j = 0; j < 256000; j++) {
-                       for (k = 0; k < ARRAY_WORDS; k++)
-                               array[k] = random();
-                       results[(hash(array, ARRAY_WORDS, 0) >> i*8)&0xFF]++;
-               }
-
-               for (j = 0; j < 256; j++) {
-                       if (results[j] < lowest)
-                               lowest = results[j];
-                       if (results[j] > highest)
-                               highest = results[j];
-               }
-               /* Expect within 20% */
-               ok(lowest > 800, "Byte %i lowest %i", i, lowest);
-               ok(highest < 1200, "Byte %i highest %i", i, highest);
-               diag("Byte %i, range %u-%u", i, lowest, highest);
-       }
-
-       /* Hash of random values should have random distribution:
-        * check one byte at a time. */
-       for (i = 0; i < sizeof(uint64_t); i++) {
-               unsigned int lowest = -1U, highest = 0;
-
-               memset(results, 0, sizeof(results));
-
-               for (j = 0; j < 256000; j++) {
-                       for (k = 0; k < ARRAY_WORDS; k++)
-                               array[k] = random();
-                       results[(hash64(array, sizeof(array)/sizeof(uint64_t),
-                                       0) >> i*8)&0xFF]++;
-               }
-
-               for (j = 0; j < 256; j++) {
-                       if (results[j] < lowest)
-                               lowest = results[j];
-                       if (results[j] > highest)
-                               highest = results[j];
-               }
-               /* Expect within 20% */
-               ok(lowest > 800, "Byte %i lowest %i", i, lowest);
-               ok(highest < 1200, "Byte %i highest %i", i, highest);
-               diag("Byte %i, range %u-%u", i, lowest, highest);
-       }
-
-       /* Hash of pointer values should also have random distribution. */
-       for (i = 0; i < sizeof(uint32_t); i++) {
-               unsigned int lowest = -1U, highest = 0;
-               char *p = malloc(256000);
-
-               memset(results, 0, sizeof(results));
-
-               for (j = 0; j < 256000; j++)
-                       results[(hash_pointer(p + j, 0) >> i*8)&0xFF]++;
-               free(p);
-
-               for (j = 0; j < 256; j++) {
-                       if (results[j] < lowest)
-                               lowest = results[j];
-                       if (results[j] > highest)
-                               highest = results[j];
-               }
-               /* Expect within 20% */
-               ok(lowest > 800, "hash_pointer byte %i lowest %i", i, lowest);
-               ok(highest < 1200, "hash_pointer byte %i highest %i",
-                  i, highest);
-               diag("hash_pointer byte %i, range %u-%u", i, lowest, highest);
-       }
-
-       if (sizeof(long) == sizeof(uint32_t))
-               ok1(hashl(array, ARRAY_WORDS, 0)
-                   == hash(array, ARRAY_WORDS, 0));
-       else
-               ok1(hashl(array, ARRAY_WORDS, 0)
-                   == hash64(array, ARRAY_WORDS, 0));
-
-       /* String hash: weak, so only test bottom byte */
-       for (i = 0; i < 1; i++) {
-               unsigned int num = 0, cursor, lowest = -1U, highest = 0;
-               char p[5];
-
-               memset(results, 0, sizeof(results));
-
-               memset(p, 'A', sizeof(p));
-               p[sizeof(p)-1] = '\0';
-
-               for (;;) {
-                       for (cursor = 0; cursor < sizeof(p)-1; cursor++) {
-                               p[cursor]++;
-                               if (p[cursor] <= 'z')
-                                       break;
-                               p[cursor] = 'A';
-                       }
-                       if (cursor == sizeof(p)-1)
-                               break;
-
-                       results[(hash_string(p) >> i*8)&0xFF]++;
-                       num++;
-               }
-
-               for (j = 0; j < 256; j++) {
-                       if (results[j] < lowest)
-                               lowest = results[j];
-                       if (results[j] > highest)
-                               highest = results[j];
-               }
-               /* Expect within 20% */
-               ok(lowest > 35000, "hash_pointer byte %i lowest %i", i, lowest);
-               ok(highest < 53000, "hash_pointer byte %i highest %i",
-                  i, highest);
-               diag("hash_pointer byte %i, range %u-%u", i, lowest, highest);
-       }
-
-       return exit_status();
-}
diff --git a/lib/ccan/htable/LICENSE b/lib/ccan/htable/LICENSE
deleted file mode 100644 (file)
index 2d2d780..0000000
+++ /dev/null
@@ -1,510 +0,0 @@
-
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
-       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL.  It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
-                            Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations
-below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-\f
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it
-becomes a de-facto standard.  To achieve this, non-free programs must
-be allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-\f
-                  GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control
-compilation and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-\f
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at least
-    three years, to give the same user the materials specified in
-    Subsection 6a, above, for a charge no more than the cost of
-    performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-\f
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply, and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License
-may add an explicit geographical distribution limitation excluding those
-countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-                            NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-                     END OF TERMS AND CONDITIONS
-\f
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms
-of the ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.
-It is safest to attach them to the start of each source file to most
-effectively convey the exclusion of warranty; and each file should
-have at least the "copyright" line and a pointer to where the full
-notice is found.
-
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or
-your school, if any, to sign a "copyright disclaimer" for the library,
-if necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James
-  Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
-
-
diff --git a/lib/ccan/htable/_info b/lib/ccan/htable/_info
deleted file mode 100644 (file)
index 1553da2..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-#include <string.h>
-#include <stdio.h>
-
-/**
- * htable - hash table routines
- *
- * A hash table is an efficient structure for looking up keys.  This version
- * grows with usage and allows efficient deletion.
- *
- * Example:
- *     #include <ccan/htable/htable.h>
- *     #include <ccan/hash/hash.h>
- *     #include <stdio.h>
- *     #include <err.h>
- *     #include <string.h>
- *
- *     struct name_to_digit {
- *             const char *name;
- *             unsigned int val;
- *     };
- *
- *     static struct name_to_digit map[] = {
- *             { "zero", 0},
- *             { "one", 1 },
- *             { "two", 2 },
- *             { "three", 3 },
- *             { "four", 4 },
- *             { "five", 5 },
- *             { "six", 6 },
- *             { "seven", 7 },
- *             { "eight", 8 },
- *             { "nine", 9 }
- *     };
- *
- *     // Wrapper for rehash function pointer.
- *     static size_t rehash(const void *e, void *unused)
- *     {
- *             return hash_string(((struct name_to_digit *)e)->name);
- *     }
- *
- *     // Comparison function.
- *     static bool streq(const void *e, void *string)
- *     {
- *             return strcmp(((struct name_to_digit *)e)->name, string) == 0;
- *     }
- *
- *     // We let them add their own aliases, eg. --alias=v=5
- *     static void add_alias(struct htable *ht, const char *alias)
- *     {
- *             char *eq;
- *             struct name_to_digit *n;
- *
- *             n = malloc(sizeof(*n));
- *             n->name = strdup(alias);
- *
- *             eq = strchr(n->name, '=');
- *             if (!eq || ((n->val = atoi(eq+1)) == 0 && !strcmp(eq+1, "0")))
- *                     errx(1, "Usage: --alias=<name>=<value>");
- *             *eq = '\0';
- *             htable_add(ht, hash_string(n->name), n);
- *     }
- *
- *     int main(int argc, char *argv[])
- *     {
- *             struct htable ht;
- *             unsigned int i;
- *             unsigned long val;
- *
- *             if (argc < 2)
- *                     errx(1, "Usage: %s [--alias=<name>=<val>]... <str>...",
- *                          argv[0]);
- *
- *             // Create and populate hash table.
- *             htable_init(&ht, rehash, NULL);
- *             for (i = 0; i < sizeof(map)/sizeof(map[0]); i++)
- *                     htable_add(&ht, hash_string(map[i].name), &map[i]);
- *
- *             // Add any aliases to the hash table.
- *             for (i = 1; i < argc; i++) {
- *                     if (!strncmp(argv[i], "--alias=", strlen("--alias=")))
- *                             add_alias(&ht, argv[i] + strlen("--alias="));
- *                     else
- *                             break;
- *             }
- *
- *             // Find the other args in the hash table.
- *             for (val = 0; i < argc; i++) {
- *                     struct name_to_digit *n;
- *                     n = htable_get(&ht, hash_string(argv[i]),
- *                                    streq, argv[i]);
- *                     if (!n)
- *                             errx(1, "Invalid digit name %s", argv[i]);
- *                     // Append it to the value we are building up.
- *                     val *= 10;
- *                     val += n->val;
- *             }
- *             printf("%lu\n", val);
- *             return 0;
- *     }
- *
- * License: LGPL (v2.1 or any later version)
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               printf("ccan/compiler\n");
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/htable/htable.c b/lib/ccan/htable/htable.c
deleted file mode 100644 (file)
index 0a01ead..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-/* Licensed under LGPLv2+ - see LICENSE file for details */
-#include <ccan/htable/htable.h>
-#include <ccan/compiler/compiler.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <stdbool.h>
-#include <assert.h>
-
-/* We use 0x1 as deleted marker. */
-#define HTABLE_DELETED (0x1)
-
-/* We clear out the bits which are always the same, and put metadata there. */
-static inline uintptr_t get_extra_ptr_bits(const struct htable *ht,
-                                          uintptr_t e)
-{
-       return e & ht->common_mask;
-}
-
-static inline void *get_raw_ptr(const struct htable *ht, uintptr_t e)
-{
-       return (void *)((e & ~ht->common_mask) | ht->common_bits);
-}
-
-static inline uintptr_t make_hval(const struct htable *ht,
-                                 const void *p, uintptr_t bits)
-{
-       return ((uintptr_t)p & ~ht->common_mask) | bits;
-}
-
-static inline bool entry_is_valid(uintptr_t e)
-{
-       return e > HTABLE_DELETED;
-}
-
-static inline uintptr_t get_hash_ptr_bits(const struct htable *ht,
-                                         size_t hash)
-{
-       /* Shuffling the extra bits (as specified in mask) down the
-        * end is quite expensive.  But the lower bits are redundant, so
-        * we fold the value first. */
-       return (hash ^ (hash >> ht->bits))
-               & ht->common_mask & ~ht->perfect_bit;
-}
-
-void htable_init(struct htable *ht,
-                size_t (*rehash)(const void *elem, void *priv), void *priv)
-{
-       struct htable empty = HTABLE_INITIALIZER(empty, NULL, NULL);
-       *ht = empty;
-       ht->rehash = rehash;
-       ht->priv = priv;
-       ht->table = &ht->perfect_bit;
-}
-
-void htable_clear(struct htable *ht)
-{
-       if (ht->table != &ht->perfect_bit)
-               free((void *)ht->table);
-       htable_init(ht, ht->rehash, ht->priv);
-}
-
-static size_t hash_bucket(const struct htable *ht, size_t h)
-{
-       return h & ((1 << ht->bits)-1);
-}
-
-static void *htable_val(const struct htable *ht,
-                       struct htable_iter *i, size_t hash, uintptr_t perfect)
-{
-       uintptr_t h2 = get_hash_ptr_bits(ht, hash) | perfect;
-
-       while (ht->table[i->off]) {
-               if (ht->table[i->off] != HTABLE_DELETED) {
-                       if (get_extra_ptr_bits(ht, ht->table[i->off]) == h2)
-                               return get_raw_ptr(ht, ht->table[i->off]);
-               }
-               i->off = (i->off + 1) & ((1 << ht->bits)-1);
-               h2 &= ~perfect;
-       }
-       return NULL;
-}
-
-void *htable_firstval(const struct htable *ht,
-                     struct htable_iter *i, size_t hash)
-{
-       i->off = hash_bucket(ht, hash);
-       return htable_val(ht, i, hash, ht->perfect_bit);
-}
-
-void *htable_nextval(const struct htable *ht,
-                    struct htable_iter *i, size_t hash)
-{
-       i->off = (i->off + 1) & ((1 << ht->bits)-1);
-       return htable_val(ht, i, hash, 0);
-}
-
-void *htable_first(const struct htable *ht, struct htable_iter *i)
-{
-       for (i->off = 0; i->off < (size_t)1 << ht->bits; i->off++) {
-               if (entry_is_valid(ht->table[i->off]))
-                       return get_raw_ptr(ht, ht->table[i->off]);
-       }
-       return NULL;
-}
-
-void *htable_next(const struct htable *ht, struct htable_iter *i)
-{
-       for (i->off++; i->off < (size_t)1 << ht->bits; i->off++) {
-               if (entry_is_valid(ht->table[i->off]))
-                       return get_raw_ptr(ht, ht->table[i->off]);
-       }
-       return NULL;
-}
-
-/* This does not expand the hash table, that's up to caller. */
-static void ht_add(struct htable *ht, const void *new, size_t h)
-{
-       size_t i;
-       uintptr_t perfect = ht->perfect_bit;
-
-       i = hash_bucket(ht, h);
-
-       while (entry_is_valid(ht->table[i])) {
-               perfect = 0;
-               i = (i + 1) & ((1 << ht->bits)-1);
-       }
-       ht->table[i] = make_hval(ht, new, get_hash_ptr_bits(ht, h)|perfect);
-}
-
-static COLD bool double_table(struct htable *ht)
-{
-       unsigned int i;
-       size_t oldnum = (size_t)1 << ht->bits;
-       uintptr_t *oldtable, e;
-
-       oldtable = ht->table;
-       ht->table = calloc(1 << (ht->bits+1), sizeof(size_t));
-       if (!ht->table) {
-               ht->table = oldtable;
-               return false;
-       }
-       ht->bits++;
-       ht->max = ((size_t)3 << ht->bits) / 4;
-       ht->max_with_deleted = ((size_t)9 << ht->bits) / 10;
-
-       /* If we lost our "perfect bit", get it back now. */
-       if (!ht->perfect_bit && ht->common_mask) {
-               for (i = 0; i < sizeof(ht->common_mask) * CHAR_BIT; i++) {
-                       if (ht->common_mask & ((size_t)1 << i)) {
-                               ht->perfect_bit = (size_t)1 << i;
-                               break;
-                       }
-               }
-       }
-
-       if (oldtable != &ht->perfect_bit) {
-               for (i = 0; i < oldnum; i++) {
-                       if (entry_is_valid(e = oldtable[i])) {
-                               void *p = get_raw_ptr(ht, e);
-                               ht_add(ht, p, ht->rehash(p, ht->priv));
-                       }
-               }
-               free(oldtable);
-       }
-       ht->deleted = 0;
-       return true;
-}
-
-static COLD void rehash_table(struct htable *ht)
-{
-       size_t start, i;
-       uintptr_t e;
-
-       /* Beware wrap cases: we need to start from first empty bucket. */
-       for (start = 0; ht->table[start]; start++);
-
-       for (i = 0; i < (size_t)1 << ht->bits; i++) {
-               size_t h = (i + start) & ((1 << ht->bits)-1);
-               e = ht->table[h];
-               if (!e)
-                       continue;
-               if (e == HTABLE_DELETED)
-                       ht->table[h] = 0;
-               else if (!(e & ht->perfect_bit)) {
-                       void *p = get_raw_ptr(ht, e);
-                       ht->table[h] = 0;
-                       ht_add(ht, p, ht->rehash(p, ht->priv));
-               }
-       }
-       ht->deleted = 0;
-}
-
-/* We stole some bits, now we need to put them back... */
-static COLD void update_common(struct htable *ht, const void *p)
-{
-       unsigned int i;
-       uintptr_t maskdiff, bitsdiff;
-
-       if (ht->elems == 0) {
-               ht->common_mask = -1;
-               ht->common_bits = (uintptr_t)p;
-               ht->perfect_bit = 1;
-               return;
-       }
-
-       /* Find bits which are unequal to old common set. */
-       maskdiff = ht->common_bits ^ ((uintptr_t)p & ht->common_mask);
-
-       /* These are the bits which go there in existing entries. */
-       bitsdiff = ht->common_bits & maskdiff;
-
-       for (i = 0; i < (size_t)1 << ht->bits; i++) {
-               if (!entry_is_valid(ht->table[i]))
-                       continue;
-               /* Clear the bits no longer in the mask, set them as
-                * expected. */
-               ht->table[i] &= ~maskdiff;
-               ht->table[i] |= bitsdiff;
-       }
-
-       /* Take away those bits from our mask, bits and perfect bit. */
-       ht->common_mask &= ~maskdiff;
-       ht->common_bits &= ~maskdiff;
-       ht->perfect_bit &= ~maskdiff;
-}
-
-bool htable_add(struct htable *ht, size_t hash, const void *p)
-{
-       if (ht->elems+1 > ht->max && !double_table(ht))
-               return false;
-       if (ht->elems+1 + ht->deleted > ht->max_with_deleted)
-               rehash_table(ht);
-       assert(p);
-       if (((uintptr_t)p & ht->common_mask) != ht->common_bits)
-               update_common(ht, p);
-
-       ht_add(ht, p, hash);
-       ht->elems++;
-       return true;
-}
-
-bool htable_del(struct htable *ht, size_t h, const void *p)
-{
-       struct htable_iter i;
-       void *c;
-
-       for (c = htable_firstval(ht,&i,h); c; c = htable_nextval(ht,&i,h)) {
-               if (c == p) {
-                       htable_delval(ht, &i);
-                       return true;
-               }
-       }
-       return false;
-}
-
-void htable_delval(struct htable *ht, struct htable_iter *i)
-{
-       assert(i->off < (size_t)1 << ht->bits);
-       assert(entry_is_valid(ht->table[i->off]));
-
-       ht->elems--;
-       ht->table[i->off] = HTABLE_DELETED;
-       ht->deleted++;
-}
diff --git a/lib/ccan/htable/htable.h b/lib/ccan/htable/htable.h
deleted file mode 100644 (file)
index ed668e7..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/* Licensed under LGPLv2+ - see LICENSE file for details */
-#ifndef CCAN_HTABLE_H
-#define CCAN_HTABLE_H
-#include "config.h"
-#include <stdint.h>
-#include <stdbool.h>
-#include <stdlib.h>
-
-/**
- * struct htable - private definition of a htable.
- *
- * It's exposed here so you can put it in your structures and so we can
- * supply inline functions.
- */
-struct htable {
-       size_t (*rehash)(const void *elem, void *priv);
-       void *priv;
-       unsigned int bits;
-       size_t elems, deleted, max, max_with_deleted;
-       /* These are the bits which are the same in all pointers. */
-       uintptr_t common_mask, common_bits;
-       uintptr_t perfect_bit;
-       uintptr_t *table;
-};
-
-/**
- * HTABLE_INITIALIZER - static initialization for a hash table.
- * @name: name of this htable.
- * @rehash: hash function to use for rehashing.
- * @priv: private argument to @rehash function.
- *
- * This is useful for setting up static and global hash tables.
- *
- * Example:
- *     // For simplicity's sake, say hash value is contents of elem.
- *     static size_t rehash(const void *elem, void *unused)
- *     {
- *             return *(size_t *)elem;
- *     }
- *     static struct htable ht = HTABLE_INITIALIZER(ht, rehash, NULL);
- */
-#define HTABLE_INITIALIZER(name, rehash, priv)                         \
-       { rehash, priv, 0, 0, 0, 0, 0, -1, 0, 0, &name.perfect_bit }
-
-/**
- * htable_init - initialize an empty hash table.
- * @ht: the hash table to initialize
- * @rehash: hash function to use for rehashing.
- * @priv: private argument to @rehash function.
- */
-void htable_init(struct htable *ht,
-                size_t (*rehash)(const void *elem, void *priv), void *priv);
-
-/**
- * htable_clear - empty a hash table.
- * @ht: the hash table to clear
- *
- * This doesn't do anything to any pointers left in it.
- */
-void htable_clear(struct htable *ht);
-
-/**
- * htable_rehash - use a hashtree's rehash function
- * @elem: the argument to rehash()
- *
- */
-size_t htable_rehash(const void *elem);
-
-/**
- * htable_add - add a pointer into a hash table.
- * @ht: the htable
- * @hash: the hash value of the object
- * @p: the non-NULL pointer
- *
- * Also note that this can only fail due to allocation failure.  Otherwise, it
- * returns true.
- */
-bool htable_add(struct htable *ht, size_t hash, const void *p);
-
-/**
- * htable_del - remove a pointer from a hash table
- * @ht: the htable
- * @hash: the hash value of the object
- * @p: the pointer
- *
- * Returns true if the pointer was found (and deleted).
- */
-bool htable_del(struct htable *ht, size_t hash, const void *p);
-
-/**
- * struct htable_iter - iterator or htable_first or htable_firstval etc.
- *
- * This refers to a location inside the hashtable.
- */
-struct htable_iter {
-       size_t off;
-};
-
-/**
- * htable_firstval - find a candidate for a given hash value
- * @htable: the hashtable
- * @i: the struct htable_iter to initialize
- * @hash: the hash value
- *
- * You'll need to check the value is what you want; returns NULL if none.
- * See Also:
- *     htable_delval()
- */
-void *htable_firstval(const struct htable *htable,
-                     struct htable_iter *i, size_t hash);
-
-/**
- * htable_nextval - find another candidate for a given hash value
- * @htable: the hashtable
- * @i: the struct htable_iter to initialize
- * @hash: the hash value
- *
- * You'll need to check the value is what you want; returns NULL if no more.
- */
-void *htable_nextval(const struct htable *htable,
-                    struct htable_iter *i, size_t hash);
-
-/**
- * htable_get - find an entry in the hash table
- * @ht: the hashtable
- * @h: the hash value of the entry
- * @cmp: the comparison function
- * @ptr: the pointer to hand to the comparison function.
- *
- * Convenient inline wrapper for htable_firstval/htable_nextval loop.
- */
-static inline void *htable_get(const struct htable *ht,
-                              size_t h,
-                              bool (*cmp)(const void *candidate, void *ptr),
-                              const void *ptr)
-{
-       struct htable_iter i;
-       void *c;
-
-       for (c = htable_firstval(ht,&i,h); c; c = htable_nextval(ht,&i,h)) {
-               if (cmp(c, (void *)ptr))
-                       return c;
-       }
-       return NULL;
-}
-
-/**
- * htable_first - find an entry in the hash table
- * @ht: the hashtable
- * @i: the struct htable_iter to initialize
- *
- * Get an entry in the hashtable; NULL if empty.
- */
-void *htable_first(const struct htable *htable, struct htable_iter *i);
-
-/**
- * htable_next - find another entry in the hash table
- * @ht: the hashtable
- * @i: the struct htable_iter to use
- *
- * Get another entry in the hashtable; NULL if all done.
- * This is usually used after htable_first or prior non-NULL htable_next.
- */
-void *htable_next(const struct htable *htable, struct htable_iter *i);
-
-/**
- * htable_delval - remove an iterated pointer from a hash table
- * @ht: the htable
- * @i: the htable_iter
- *
- * Usually used to delete a hash entry after it has been found with
- * htable_firstval etc.
- */
-void htable_delval(struct htable *ht, struct htable_iter *i);
-
-#endif /* CCAN_HTABLE_H */
diff --git a/lib/ccan/htable/htable_type.h b/lib/ccan/htable/htable_type.h
deleted file mode 100644 (file)
index 03cc46f..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Licensed under LGPLv2+ - see LICENSE file for details */
-#ifndef CCAN_HTABLE_TYPE_H
-#define CCAN_HTABLE_TYPE_H
-#include <ccan/htable/htable.h>
-#include "config.h"
-
-/**
- * HTABLE_DEFINE_TYPE - create a set of htable ops for a type
- * @type: a type whose pointers will be values in the hash.
- * @keyof: a function/macro to extract a key: <keytype> @keyof(const type *elem)
- * @hashfn: a hash function for a @key: size_t @hashfn(const <keytype> *)
- * @eqfn: an equality function keys: bool @eqfn(const type *, const <keytype> *)
- * @prefix: a prefix for all the functions to define (of form <name>_*)
- *
- * NULL values may not be placed into the hash table.
- *
- * This defines the type hashtable type and an iterator type:
- *     struct <name>;
- *     struct <name>_iter;
- *
- * It also defines initialization and freeing functions:
- *     void <name>_init(struct <name> *);
- *     void <name>_clear(struct <name> *);
- *
- * Add function only fails if we run out of memory:
- *     bool <name>_add(struct <name> *ht, const <type> *e);
- *
- * Delete and delete-by key return true if it was in the set:
- *     bool <name>_del(struct <name> *ht, const <type> *e);
- *     bool <name>_delkey(struct <name> *ht, const <keytype> *k);
- *
- * Find function return the matching element, or NULL:
- *     type *<name>_get(const struct @name *ht, const <keytype> *k);
- *
- * Iteration over hashtable is also supported:
- *     type *<name>_first(const struct <name> *ht, struct <name>_iter *i);
- *     type *<name>_next(const struct <name> *ht, struct <name>_iter *i);
- *
- * It's currently safe to iterate over a changing hashtable, but you might
- * miss an element.  Iteration isn't very efficient, either.
- *
- * You can use HTABLE_INITIALIZER like so:
- *     struct <name> ht = { HTABLE_INITIALIZER(ht.raw, <name>_hash, NULL) };
- */
-#define HTABLE_DEFINE_TYPE(type, keyof, hashfn, eqfn, name)            \
-       struct name { struct htable raw; };                             \
-       struct name##_iter { struct htable_iter i; };                   \
-       static inline size_t name##_hash(const void *elem, void *priv)  \
-       {                                                               \
-               return hashfn(keyof((const type *)elem));               \
-       }                                                               \
-       static inline void name##_init(struct name *ht)                 \
-       {                                                               \
-               htable_init(&ht->raw, name##_hash, NULL);               \
-       }                                                               \
-       static inline void name##_clear(struct name *ht)                \
-       {                                                               \
-               htable_clear(&ht->raw);                                 \
-       }                                                               \
-       static inline bool name##_add(struct name *ht, const type *elem) \
-       {                                                               \
-               return htable_add(&ht->raw, hashfn(keyof(elem)), elem); \
-       }                                                               \
-       static inline bool name##_del(struct name *ht, const type *elem) \
-       {                                                               \
-               return htable_del(&ht->raw, hashfn(keyof(elem)), elem); \
-       }                                                               \
-       static inline type *name##_get(const struct name *ht,           \
-                                      const HTABLE_KTYPE(keyof) k)     \
-       {                                                               \
-               /* Typecheck for eqfn */                                \
-               (void)sizeof(eqfn((const type *)NULL,                   \
-                                 keyof((const type *)NULL)));          \
-               return htable_get(&ht->raw,                             \
-                                 hashfn(k),                            \
-                                 (bool (*)(const void *, void *))(eqfn), \
-                                 k);                                   \
-       }                                                               \
-       static inline bool name##_delkey(struct name *ht,               \
-                                        const HTABLE_KTYPE(keyof) k)   \
-       {                                                               \
-               type *elem = name##_get(ht, k);                         \
-               if (elem)                                               \
-                       return name##_del(ht, elem);                    \
-               return false;                                           \
-       }                                                               \
-       static inline type *name##_first(const struct name *ht,         \
-                                        struct name##_iter *iter)      \
-       {                                                               \
-               return htable_first(&ht->raw, &iter->i);                \
-       }                                                               \
-       static inline type *name##_next(const struct name *ht,          \
-                                       struct name##_iter *iter)       \
-       {                                                               \
-               return htable_next(&ht->raw, &iter->i);                 \
-       }
-
-#if HAVE_TYPEOF
-#define HTABLE_KTYPE(keyof) typeof(keyof(NULL))
-#else
-#define HTABLE_KTYPE(keyof) void *
-#endif
-#endif /* CCAN_HTABLE_TYPE_H */
diff --git a/lib/ccan/htable/test/run-size.c b/lib/ccan/htable/test/run-size.c
deleted file mode 100644 (file)
index c92401c..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <ccan/htable/htable.h>
-#include <ccan/htable/htable.c>
-#include <ccan/tap/tap.h>
-#include <stdbool.h>
-#include <string.h>
-
-#define NUM_VALS 512
-
-/* We use the number divided by two as the hash (for lots of
-   collisions). */
-static size_t hash(const void *elem, void *unused)
-{
-       size_t h = *(uint64_t *)elem / 2;
-       return h;
-}
-
-int main(int argc, char *argv[])
-{
-       struct htable ht;
-       uint64_t val[NUM_VALS];
-       unsigned int i;
-
-       plan_tests((NUM_VALS) * 2);
-       for (i = 0; i < NUM_VALS; i++)
-               val[i] = i;
-
-       htable_init(&ht, hash, NULL);
-       for (i = 0; i < NUM_VALS; i++) {
-               ok1(ht.max >= i);
-               ok1(ht.max <= i * 2);
-               htable_add(&ht, hash(&val[i], NULL), &val[i]);
-       }
-       htable_clear(&ht);
-
-       return exit_status();
-}
diff --git a/lib/ccan/htable/test/run-type.c b/lib/ccan/htable/test/run-type.c
deleted file mode 100644 (file)
index f97e727..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-#include <ccan/htable/htable_type.h>
-#include <ccan/htable/htable.c>
-#include <ccan/tap/tap.h>
-#include <stdbool.h>
-#include <string.h>
-
-#define NUM_BITS 7
-#define NUM_VALS (1 << NUM_BITS)
-
-struct obj {
-       /* Makes sure we don't try to treat and obj as a key or vice versa */
-       unsigned char unused;
-       unsigned int key;
-};
-
-static const unsigned int *objkey(const struct obj *obj)
-{
-       return &obj->key;
-}
-
-/* We use the number divided by two as the hash (for lots of
-   collisions), plus set all the higher bits so we can detect if they
-   don't get masked out. */
-static size_t objhash(const unsigned int *key)
-{
-       size_t h = *key / 2;
-       h |= -1UL << NUM_BITS;
-       return h;
-}
-
-static bool cmp(const struct obj *obj, const unsigned int *key)
-{
-       return obj->key == *key;
-}
-
-HTABLE_DEFINE_TYPE(struct obj, objkey, objhash, cmp, htable_obj);
-
-static void add_vals(struct htable_obj *ht,
-                    struct obj val[], unsigned int num)
-{
-       unsigned int i;
-
-       for (i = 0; i < num; i++) {
-               if (htable_obj_get(ht, &i)) {
-                       fail("%u already in hash", i);
-                       return;
-               }
-               htable_obj_add(ht, &val[i]);
-               if (htable_obj_get(ht, &i) != &val[i]) {
-                       fail("%u not added to hash", i);
-                       return;
-               }
-       }
-       pass("Added %u numbers to hash", i);
-}
-
-static void find_vals(const struct htable_obj *ht,
-                     const struct obj val[], unsigned int num)
-{
-       unsigned int i;
-
-       for (i = 0; i < num; i++) {
-               if (htable_obj_get(ht, &i) != &val[i]) {
-                       fail("%u not found in hash", i);
-                       return;
-               }
-       }
-       pass("Found %u numbers in hash", i);
-}
-
-static void del_vals(struct htable_obj *ht,
-                    const struct obj val[], unsigned int num)
-{
-       unsigned int i;
-
-       for (i = 0; i < num; i++) {
-               if (!htable_obj_delkey(ht, &val[i].key)) {
-                       fail("%u not deleted from hash", i);
-                       return;
-               }
-       }
-       pass("Deleted %u numbers in hash", i);
-}
-
-static void del_vals_bykey(struct htable_obj *ht,
-                          const struct obj val[], unsigned int num)
-{
-       unsigned int i;
-
-       for (i = 0; i < num; i++) {
-               if (!htable_obj_delkey(ht, &i)) {
-                       fail("%u not deleted by key from hash", i);
-                       return;
-               }
-       }
-       pass("Deleted %u numbers by key from hash", i);
-}
-
-static bool check_mask(struct htable *ht, const struct obj val[], unsigned num)
-{
-       uint64_t i;
-
-       for (i = 0; i < num; i++) {
-               if (((uintptr_t)&val[i] & ht->common_mask) != ht->common_bits)
-                       return false;
-       }
-       return true;
-}
-
-int main(int argc, char *argv[])
-{
-       unsigned int i;
-       struct htable_obj ht;
-       struct obj val[NUM_VALS];
-       unsigned int dne;
-       void *p;
-       struct htable_obj_iter iter;
-
-       plan_tests(20);
-       for (i = 0; i < NUM_VALS; i++)
-               val[i].key = i;
-       dne = i;
-
-       htable_obj_init(&ht);
-       ok1(ht.raw.max == 0);
-       ok1(ht.raw.bits == 0);
-
-       /* We cannot find an entry which doesn't exist. */
-       ok1(!htable_obj_get(&ht, &dne));
-
-       /* Fill it, it should increase in size. */
-       add_vals(&ht, val, NUM_VALS);
-       ok1(ht.raw.bits == NUM_BITS + 1);
-       ok1(ht.raw.max < (1 << ht.raw.bits));
-
-       /* Mask should be set. */
-       ok1(ht.raw.common_mask != 0);
-       ok1(ht.raw.common_mask != -1);
-       ok1(check_mask(&ht.raw, val, NUM_VALS));
-
-       /* Find all. */
-       find_vals(&ht, val, NUM_VALS);
-       ok1(!htable_obj_get(&ht, &dne));
-
-       /* Walk once, should get them all. */
-       i = 0;
-       for (p = htable_obj_first(&ht,&iter); p; p = htable_obj_next(&ht, &iter))
-               i++;
-       ok1(i == NUM_VALS);
-
-       /* Delete all. */
-       del_vals(&ht, val, NUM_VALS);
-       ok1(!htable_obj_get(&ht, &val[0].key));
-
-       /* Worst case, a "pointer" which doesn't have any matching bits. */
-       htable_add(&ht.raw, 0, (void *)~(uintptr_t)&val[NUM_VALS-1]);
-       htable_obj_add(&ht, &val[NUM_VALS-1]);
-       ok1(ht.raw.common_mask == 0);
-       ok1(ht.raw.common_bits == 0);
-       /* Delete the bogus one before we trip over it. */
-       htable_del(&ht.raw, 0, (void *)~(uintptr_t)&val[NUM_VALS-1]);
-
-       /* Add the rest. */
-       add_vals(&ht, val, NUM_VALS-1);
-
-       /* Check we can find them all. */
-       find_vals(&ht, val, NUM_VALS);
-       ok1(!htable_obj_get(&ht, &dne));
-
-       /* Delete them all by key. */
-       del_vals_bykey(&ht, val, NUM_VALS);
-       htable_obj_clear(&ht);
-
-       return exit_status();
-}
diff --git a/lib/ccan/htable/test/run.c b/lib/ccan/htable/test/run.c
deleted file mode 100644 (file)
index 1a9e2de..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-#include <ccan/htable/htable.h>
-#include <ccan/htable/htable.c>
-#include <ccan/tap/tap.h>
-#include <stdbool.h>
-#include <string.h>
-
-#define NUM_BITS 7
-#define NUM_VALS (1 << NUM_BITS)
-
-/* We use the number divided by two as the hash (for lots of
-   collisions), plus set all the higher bits so we can detect if they
-   don't get masked out. */
-static size_t hash(const void *elem, void *unused)
-{
-       size_t h = *(uint64_t *)elem / 2;
-       h |= -1UL << NUM_BITS;
-       return h;
-}
-
-static bool objcmp(const void *htelem, void *cmpdata)
-{
-       return *(uint64_t *)htelem == *(uint64_t *)cmpdata;
-}
-
-static void add_vals(struct htable *ht,
-                    const uint64_t val[],
-                    unsigned int off, unsigned int num)
-{
-       uint64_t i;
-
-       for (i = off; i < off+num; i++) {
-               if (htable_get(ht, hash(&i, NULL), objcmp, &i)) {
-                       fail("%llu already in hash", (long long)i);
-                       return;
-               }
-               htable_add(ht, hash(&val[i], NULL), &val[i]);
-               if (htable_get(ht, hash(&i, NULL), objcmp, &i) != &val[i]) {
-                       fail("%llu not added to hash", (long long)i);
-                       return;
-               }
-       }
-       pass("Added %llu numbers to hash", (long long)i);
-}
-
-#if 0
-static void refill_vals(struct htable *ht,
-                       const uint64_t val[], unsigned int num)
-{
-       uint64_t i;
-
-       for (i = 0; i < num; i++) {
-               if (htable_get(ht, hash(&i, NULL), objcmp, &i))
-                       continue;
-               htable_add(ht, hash(&val[i], NULL), &val[i]);
-       }
-}
-#endif
-
-static void find_vals(struct htable *ht,
-                     const uint64_t val[], unsigned int num)
-{
-       uint64_t i;
-
-       for (i = 0; i < num; i++) {
-               if (htable_get(ht, hash(&i, NULL), objcmp, &i) != &val[i]) {
-                       fail("%llu not found in hash", (long long)i);
-                       return;
-               }
-       }
-       pass("Found %llu numbers in hash", (long long)i);
-}
-
-static void del_vals(struct htable *ht,
-                    const uint64_t val[], unsigned int num)
-{
-       uint64_t i;
-
-       for (i = 0; i < num; i++) {
-               if (!htable_del(ht, hash(&val[i], NULL), &val[i])) {
-                       fail("%llu not deleted from hash", (long long)i);
-                       return;
-               }
-       }
-       pass("Deleted %llu numbers in hash", (long long)i);
-}
-
-static bool check_mask(struct htable *ht, uint64_t val[], unsigned num)
-{
-       uint64_t i;
-
-       for (i = 0; i < num; i++) {
-               if (((uintptr_t)&val[i] & ht->common_mask) != ht->common_bits)
-                       return false;
-       }
-       return true;
-}
-
-int main(int argc, char *argv[])
-{
-       unsigned int i;
-       uintptr_t perfect_bit;
-       struct htable ht;
-       uint64_t val[NUM_VALS];
-       uint64_t dne;
-       void *p;
-       struct htable_iter iter;
-
-       plan_tests(29);
-       for (i = 0; i < NUM_VALS; i++)
-               val[i] = i;
-       dne = i;
-
-       htable_init(&ht, hash, NULL);
-       ok1(ht.max == 0);
-       ok1(ht.bits == 0);
-
-       /* We cannot find an entry which doesn't exist. */
-       ok1(!htable_get(&ht, hash(&dne, NULL), objcmp, &dne));
-
-       /* This should increase it once. */
-       add_vals(&ht, val, 0, 1);
-       ok1(ht.bits == 1);
-       ok1(ht.max == 1);
-       ok1(ht.common_mask == -1);
-
-       /* Mask should be set. */
-       ok1(check_mask(&ht, val, 1));
-
-       /* This should increase it again. */
-       add_vals(&ht, val, 1, 1);
-       ok1(ht.bits == 2);
-       ok1(ht.max == 3);
-
-       /* Mask should be set. */
-       ok1(ht.common_mask != 0);
-       ok1(ht.common_mask != -1);
-       ok1(check_mask(&ht, val, 2));
-
-       /* Now do the rest. */
-       add_vals(&ht, val, 2, NUM_VALS - 2);
-
-       /* Find all. */
-       find_vals(&ht, val, NUM_VALS);
-       ok1(!htable_get(&ht, hash(&dne, NULL), objcmp, &dne));
-
-       /* Walk once, should get them all. */
-       i = 0;
-       for (p = htable_first(&ht,&iter); p; p = htable_next(&ht, &iter))
-               i++;
-       ok1(i == NUM_VALS);
-
-       /* Delete all. */
-       del_vals(&ht, val, NUM_VALS);
-       ok1(!htable_get(&ht, hash(&val[0], NULL), objcmp, &val[0]));
-
-       /* Worst case, a "pointer" which doesn't have any matching bits. */
-       htable_add(&ht, 0, (void *)~(uintptr_t)&val[NUM_VALS-1]);
-       htable_add(&ht, hash(&val[NUM_VALS-1], NULL), &val[NUM_VALS-1]);
-       ok1(ht.common_mask == 0);
-       ok1(ht.common_bits == 0);
-       /* Get rid of bogus pointer before we trip over it! */
-       htable_del(&ht, 0, (void *)~(uintptr_t)&val[NUM_VALS-1]);
-
-       /* Add the rest. */
-       add_vals(&ht, val, 0, NUM_VALS-1);
-
-       /* Check we can find them all. */
-       find_vals(&ht, val, NUM_VALS);
-       ok1(!htable_get(&ht, hash(&dne, NULL), objcmp, &dne));
-
-       /* Corner cases: wipe out the perfect bit using bogus pointer. */
-       htable_clear(&ht);
-       htable_add(&ht, 0, (void *)((uintptr_t)&val[NUM_VALS-1]));
-       ok1(ht.perfect_bit);
-       perfect_bit = ht.perfect_bit;
-       htable_add(&ht, 0, (void *)((uintptr_t)&val[NUM_VALS-1]
-                                  | perfect_bit));
-       ok1(ht.perfect_bit == 0);
-       htable_del(&ht, 0, (void *)((uintptr_t)&val[NUM_VALS-1] | perfect_bit));
-
-       /* Enlarging should restore it... */
-       add_vals(&ht, val, 0, NUM_VALS-1);
-
-       ok1(ht.perfect_bit != 0);
-       htable_clear(&ht);
-
-       return exit_status();
-}
diff --git a/lib/ccan/htable/tools/Makefile b/lib/ccan/htable/tools/Makefile
deleted file mode 100644 (file)
index a21c51c..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-CFLAGS=-Wall -Werror -O3 -I../../..
-#CFLAGS=-Wall -Werror -g -I../../..
-
-all: speed stringspeed hsearchspeed
-
-speed: speed.o hash.o
-
-speed.o: speed.c ../htable.h ../htable.c
-
-hash.o: ../../hash/hash.c
-       $(CC) $(CFLAGS) -c -o $@ $<
-
-stringspeed: stringspeed.o hash.o ../../talloc.o ../../str_talloc.o ../../grab_file.o ../../str.o ../../time.o ../../noerr.o
-
-stringspeed.o: speed.c ../htable.h ../htable.c
-
-hsearchspeed: hsearchspeed.o ../../talloc.o ../../str_talloc.o ../../grab_file.o ../../str.o ../../time.o ../../noerr.o
-
-clean:
-       rm -f stringspeed speed hsearchspeed *.o
diff --git a/lib/ccan/htable/tools/hsearchspeed.c b/lib/ccan/htable/tools/hsearchspeed.c
deleted file mode 100644 (file)
index ea1a3f5..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Simple speed tests for a hash of strings using hsearch */
-#include <ccan/htable/htable_type.h>
-#include <ccan/htable/htable.c>
-#include <ccan/str_talloc/str_talloc.h>
-#include <ccan/grab_file/grab_file.h>
-#include <ccan/talloc/talloc.h>
-#include <ccan/hash/hash.h>
-#include <ccan/time/time.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <search.h>
-
-/* Nanoseconds per operation */
-static size_t normalize(const struct timeval *start,
-                       const struct timeval *stop,
-                       unsigned int num)
-{
-       struct timeval diff;
-
-       timersub(stop, start, &diff);
-
-       /* Floating point is more accurate here. */
-       return (double)(diff.tv_sec * 1000000 + diff.tv_usec)
-               / num * 1000;
-}
-
-int main(int argc, char *argv[])
-{
-       size_t i, j, num;
-       struct timeval start, stop;
-       char **w;
-       ENTRY *words, *misswords;
-
-       w = strsplit(NULL, grab_file(NULL,
-                                    argv[1] ? argv[1] : "/usr/share/dict/words",
-                                    NULL), "\n");
-       num = talloc_array_length(w) - 1;
-       printf("%zu words\n", num);
-
-       hcreate(num+num/3);
-
-       words = talloc_array(w, ENTRY, num);
-       for (i = 0; i < num; i++) {
-               words[i].key = w[i];
-               words[i].data = words[i].key;
-       }
-
-       /* Append and prepend last char for miss testing. */
-       misswords = talloc_array(w, ENTRY, num);
-       for (i = 0; i < num; i++) {
-               char lastc;
-               if (strlen(w[i]))
-                       lastc = w[i][strlen(w[i])-1];
-               else
-                       lastc = 'z';
-               misswords[i].key = talloc_asprintf(misswords, "%c%s%c%c",
-                                                  lastc, w[i],
-                                                  lastc, lastc);
-       }
-
-       printf("#01: Initial insert: ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               hsearch(words[i], ENTER);
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#02: Initial lookup (match): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               if (hsearch(words[i], FIND)->data != words[i].data)
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#03: Initial lookup (miss): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++) {
-               if (hsearch(misswords[i], FIND))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       /* Lookups in order are very cache-friendly for judy; try random */
-       printf("#04: Initial lookup (random): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0, j = 0; i < num; i++, j = (j + 10007) % num)
-               if (hsearch(words[i], FIND)->data != words[i].data)
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       return 0;
-}
diff --git a/lib/ccan/htable/tools/speed.c b/lib/ccan/htable/tools/speed.c
deleted file mode 100644 (file)
index 0b4e434..0000000
+++ /dev/null
@@ -1,376 +0,0 @@
-/* Simple speed tests for hashtables. */
-#include <ccan/htable/htable_type.h>
-#include <ccan/htable/htable.c>
-#include <ccan/hash/hash.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-static size_t hashcount;
-struct object {
-       /* The key. */
-       unsigned int key;
-
-       /* Some contents. Doubles as consistency check. */
-       struct object *self;
-};
-
-static const unsigned int *objkey(const struct object *obj)
-{
-       return &obj->key;
-}
-
-static size_t hash_obj(const unsigned int *key)
-{
-       hashcount++;
-       return hashl(key, 1, 0);
-}
-
-static bool cmp(const struct object *object, const unsigned int *key)
-{
-       return object->key == *key;
-}
-
-HTABLE_DEFINE_TYPE(struct object, objkey, hash_obj, cmp, htable_obj);
-
-static unsigned int popcount(unsigned long val)
-{
-#if HAVE_BUILTIN_POPCOUNTL
-       return __builtin_popcountl(val);
-#else
-       if (sizeof(long) == sizeof(u64)) {
-               u64 v = val;
-               v = (v & 0x5555555555555555ULL)
-                       + ((v >> 1) & 0x5555555555555555ULL);
-               v = (v & 0x3333333333333333ULL)
-                       + ((v >> 1) & 0x3333333333333333ULL);
-               v = (v & 0x0F0F0F0F0F0F0F0FULL)
-                       + ((v >> 1) & 0x0F0F0F0F0F0F0F0FULL);
-               v = (v & 0x00FF00FF00FF00FFULL)
-                       + ((v >> 1) & 0x00FF00FF00FF00FFULL);
-               v = (v & 0x0000FFFF0000FFFFULL)
-                       + ((v >> 1) & 0x0000FFFF0000FFFFULL);
-               v = (v & 0x00000000FFFFFFFFULL)
-                       + ((v >> 1) & 0x00000000FFFFFFFFULL);
-               return v;
-       }
-       val = (val & 0x55555555ULL) + ((val >> 1) & 0x55555555ULL);
-       val = (val & 0x33333333ULL) + ((val >> 1) & 0x33333333ULL);
-       val = (val & 0x0F0F0F0FULL) + ((val >> 1) & 0x0F0F0F0FULL);
-       val = (val & 0x00FF00FFULL) + ((val >> 1) & 0x00FF00FFULL);
-       val = (val & 0x0000FFFFULL) + ((val >> 1) & 0x0000FFFFULL);
-       return val;
-#endif
-}
-
-static size_t perfect(const struct htable *ht)
-{
-       size_t i, placed_perfect = 0;
-
-       for (i = 0; i < ((size_t)1 << ht->bits); i++) {
-               if (!entry_is_valid(ht->table[i]))
-                       continue;
-               if (hash_bucket(ht, ht->rehash(get_raw_ptr(ht, ht->table[i]),
-                                              ht->priv)) == i) {
-                       assert((ht->table[i] & ht->perfect_bit)
-                              == ht->perfect_bit);
-                       placed_perfect++;
-               }
-       }
-       return placed_perfect;
-}
-
-static size_t count_deleted(const struct htable *ht)
-{
-       size_t i, delete_markers = 0;
-
-       for (i = 0; i < ((size_t)1 << ht->bits); i++) {
-               if (ht->table[i] == HTABLE_DELETED)
-                       delete_markers++;
-       }
-       return delete_markers;
-}
-
-/* Nanoseconds per operation */
-static size_t normalize(const struct timeval *start,
-                       const struct timeval *stop,
-                       unsigned int num)
-{
-       struct timeval diff;
-
-       timersub(stop, start, &diff);
-
-       /* Floating point is more accurate here. */
-       return (double)(diff.tv_sec * 1000000 + diff.tv_usec)
-               / num * 1000;
-}
-
-static size_t worst_run(struct htable *ht, size_t *deleted)
-{
-       size_t longest = 0, len = 0, this_del = 0, i;
-
-       *deleted = 0;
-       /* This doesn't take into account end-wrap, but gives an idea. */
-       for (i = 0; i < ((size_t)1 << ht->bits); i++) {
-               if (ht->table[i]) {
-                       len++;
-                       if (ht->table[i] == HTABLE_DELETED)
-                               this_del++;
-               } else {
-                       if (len > longest) {
-                               longest = len;
-                               *deleted = this_del;
-                       }
-                       len = 0;
-                       this_del = 0;
-               }
-       }
-       return longest;
-}
-
-int main(int argc, char *argv[])
-{
-       struct object *objs;
-       size_t i, j, num, deleted;
-       struct timeval start, stop;
-       struct htable_obj ht;
-       bool make_dumb = false;
-
-       if (argv[1] && strcmp(argv[1], "--dumb") == 0) {
-               argv++;
-               make_dumb = true;
-       }
-       num = argv[1] ? atoi(argv[1]) : 1000000;
-       objs = calloc(num, sizeof(objs[0]));
-
-       for (i = 0; i < num; i++) {
-               objs[i].key = i;
-               objs[i].self = &objs[i];
-       }
-
-       htable_obj_init(&ht);
-
-       printf("Initial insert: ");
-       fflush(stdout);
-       gettimeofday(&start, NULL);
-       for (i = 0; i < num; i++)
-               htable_obj_add(&ht, objs[i].self);
-       gettimeofday(&stop, NULL);
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-       printf("Details: hash size %u, mask bits %u, perfect %.0f%%\n",
-              1U << ht.raw.bits, popcount(ht.raw.common_mask),
-              perfect(&ht.raw) * 100.0 / ht.raw.elems);
-
-       if (make_dumb) {
-               /* Screw with mask, to hobble us. */
-               update_common(&ht.raw, (void *)~ht.raw.common_bits);
-               printf("Details: DUMB MODE: mask bits %u\n",
-                      popcount(ht.raw.common_mask));
-       }
-
-       printf("Initial lookup (match): ");
-       fflush(stdout);
-       gettimeofday(&start, NULL);
-       for (i = 0; i < num; i++)
-               if (htable_obj_get(&ht, &i)->self != objs[i].self)
-                       abort();
-       gettimeofday(&stop, NULL);
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("Initial lookup (miss): ");
-       fflush(stdout);
-       gettimeofday(&start, NULL);
-       for (i = 0; i < num; i++) {
-               unsigned int n = i + num;
-               if (htable_obj_get(&ht, &n))
-                       abort();
-       }
-       gettimeofday(&stop, NULL);
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       /* Lookups in order are very cache-friendly for judy; try random */
-       printf("Initial lookup (random): ");
-       fflush(stdout);
-       gettimeofday(&start, NULL);
-       for (i = 0, j = 0; i < num; i++, j = (j + 10007) % num)
-               if (htable_obj_get(&ht, &j)->self != &objs[j])
-                       abort();
-       gettimeofday(&stop, NULL);
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       hashcount = 0;
-       printf("Initial delete all: ");
-       fflush(stdout);
-       gettimeofday(&start, NULL);
-       for (i = 0; i < num; i++)
-               if (!htable_obj_del(&ht, objs[i].self))
-                       abort();
-       gettimeofday(&stop, NULL);
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-       printf("Details: rehashes %zu\n", hashcount);
-
-       printf("Initial re-inserting: ");
-       fflush(stdout);
-       gettimeofday(&start, NULL);
-       for (i = 0; i < num; i++)
-               htable_obj_add(&ht, objs[i].self);
-       gettimeofday(&stop, NULL);
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       hashcount = 0;
-       printf("Deleting first half: ");
-       fflush(stdout);
-       gettimeofday(&start, NULL);
-       for (i = 0; i < num; i+=2)
-               if (!htable_obj_del(&ht, objs[i].self))
-                       abort();
-       gettimeofday(&stop, NULL);
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("Details: rehashes %zu, delete markers %zu\n",
-              hashcount, count_deleted(&ht.raw));
-
-       printf("Adding (a different) half: ");
-       fflush(stdout);
-
-       for (i = 0; i < num; i+=2)
-               objs[i].key = num+i;
-
-       gettimeofday(&start, NULL);
-       for (i = 0; i < num; i+=2)
-               htable_obj_add(&ht, objs[i].self);
-       gettimeofday(&stop, NULL);
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("Details: delete markers %zu, perfect %.0f%%\n",
-              count_deleted(&ht.raw), perfect(&ht.raw) * 100.0 / ht.raw.elems);
-
-       printf("Lookup after half-change (match): ");
-       fflush(stdout);
-       gettimeofday(&start, NULL);
-       for (i = 1; i < num; i+=2)
-               if (htable_obj_get(&ht, &i)->self != objs[i].self)
-                       abort();
-       for (i = 0; i < num; i+=2) {
-               unsigned int n = i + num;
-               if (htable_obj_get(&ht, &n)->self != objs[i].self)
-                       abort();
-       }
-       gettimeofday(&stop, NULL);
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("Lookup after half-change (miss): ");
-       fflush(stdout);
-       gettimeofday(&start, NULL);
-       for (i = 0; i < num; i++) {
-               unsigned int n = i + num * 2;
-               if (htable_obj_get(&ht, &n))
-                       abort();
-       }
-       gettimeofday(&stop, NULL);
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       /* Hashtables with delete markers can fill with markers over time.
-        * so do some changes to see how it operates in long-term. */
-       for (i = 0; i < 5; i++) {
-               if (i == 0) {
-                       /* We don't measure this: jmap is different. */
-                       printf("Details: initial churn\n");
-               } else {
-                       printf("Churning %s time: ",
-                              i == 1 ? "second"
-                              : i == 2 ? "third"
-                              : i == 3 ? "fourth"
-                              : "fifth");
-                       fflush(stdout);
-               }
-               gettimeofday(&start, NULL);
-               for (j = 0; j < num; j++) {
-                       if (!htable_obj_del(&ht, &objs[j]))
-                               abort();
-                       objs[j].key = num*i+j;
-                       if (!htable_obj_add(&ht, &objs[j]))
-                               abort();
-               }
-               gettimeofday(&stop, NULL);
-               if (i != 0)
-                       printf(" %zu ns\n", normalize(&start, &stop, num));
-       }
-
-       /* Spread out the keys more to try to make it harder. */
-       printf("Details: reinserting with spread\n");
-       for (i = 0; i < num; i++) {
-               if (!htable_obj_del(&ht, objs[i].self))
-                       abort();
-               objs[i].key = num * 5 + i * 9;
-               if (!htable_obj_add(&ht, objs[i].self))
-                       abort();
-       }
-       printf("Details: delete markers %zu, perfect %.0f%%\n",
-              count_deleted(&ht.raw), perfect(&ht.raw) * 100.0 / ht.raw.elems);
-       i = worst_run(&ht.raw, &deleted);
-       printf("Details: worst run %zu (%zu deleted)\n", i, deleted);
-
-       printf("Lookup after churn & spread (match): ");
-       fflush(stdout);
-       gettimeofday(&start, NULL);
-       for (i = 0; i < num; i++) {
-               unsigned int n = num * 5 + i * 9;
-               if (htable_obj_get(&ht, &n)->self != objs[i].self)
-                       abort();
-       }
-       gettimeofday(&stop, NULL);
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("Lookup after churn & spread (miss): ");
-       fflush(stdout);
-       gettimeofday(&start, NULL);
-       for (i = 0; i < num; i++) {
-               unsigned int n = num * (5 + 9) + i * 9;
-               if (htable_obj_get(&ht, &n))
-                       abort();
-       }
-       gettimeofday(&stop, NULL);
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("Lookup after churn & spread (random): ");
-       fflush(stdout);
-       gettimeofday(&start, NULL);
-       for (i = 0, j = 0; i < num; i++, j = (j + 10007) % num) {
-               unsigned int n = num * 5 + j * 9;
-               if (htable_obj_get(&ht, &n)->self != &objs[j])
-                       abort();
-       }
-       gettimeofday(&stop, NULL);
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       hashcount = 0;
-       printf("Deleting half after churn & spread: ");
-       fflush(stdout);
-       gettimeofday(&start, NULL);
-       for (i = 0; i < num; i+=2)
-               if (!htable_obj_del(&ht, objs[i].self))
-                       abort();
-       gettimeofday(&stop, NULL);
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("Adding (a different) half after churn & spread: ");
-       fflush(stdout);
-
-       for (i = 0; i < num; i+=2)
-               objs[i].key = num*6+i*9;
-
-       gettimeofday(&start, NULL);
-       for (i = 0; i < num; i+=2)
-               htable_obj_add(&ht, objs[i].self);
-       gettimeofday(&stop, NULL);
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("Details: delete markers %zu, perfect %.0f%%\n",
-              count_deleted(&ht.raw), perfect(&ht.raw) * 100.0 / ht.raw.elems);
-
-       return 0;
-}
diff --git a/lib/ccan/htable/tools/stringspeed.c b/lib/ccan/htable/tools/stringspeed.c
deleted file mode 100644 (file)
index 53ac4da..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-/* Simple speed tests for a hash of strings. */
-#include <ccan/htable/htable_type.h>
-#include <ccan/htable/htable.c>
-#include <ccan/str_talloc/str_talloc.h>
-#include <ccan/grab_file/grab_file.h>
-#include <ccan/talloc/talloc.h>
-#include <ccan/hash/hash.h>
-#include <ccan/time/time.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-static size_t hashcount;
-
-static const char *strkey(const char *str)
-{
-       return str;
-}
-
-static size_t hash_str(const char *key)
-{
-       hashcount++;
-       return hash(key, strlen(key), 0);
-}
-
-static bool cmp(const char *obj, const char *key)
-{
-       return strcmp(obj, key) == 0;
-}
-
-HTABLE_DEFINE_TYPE(char, strkey, hash_str, cmp, htable_str);
-
-/* Nanoseconds per operation */
-static size_t normalize(const struct timeval *start,
-                       const struct timeval *stop,
-                       unsigned int num)
-{
-       struct timeval diff;
-
-       timersub(stop, start, &diff);
-
-       /* Floating point is more accurate here. */
-       return (double)(diff.tv_sec * 1000000 + diff.tv_usec)
-               / num * 1000;
-}
-
-int main(int argc, char *argv[])
-{
-       size_t i, j, num;
-       struct timeval start, stop;
-       struct htable_str ht;
-       char **words, **misswords;
-
-       words = strsplit(NULL, grab_file(NULL,
-                                        argv[1] ? argv[1] : "/usr/share/dict/words",
-                                        NULL), "\n");
-       htable_str_init(&ht);
-       num = talloc_array_length(words) - 1;
-       /* Note that on my system, num is just > 98304, where we double! */
-       printf("%zu words\n", num);
-
-       /* Append and prepend last char for miss testing. */
-       misswords = talloc_array(words, char *, num);
-       for (i = 0; i < num; i++) {
-               char lastc;
-               if (strlen(words[i]))
-                       lastc = words[i][strlen(words[i])-1];
-               else
-                       lastc = 'z';
-               misswords[i] = talloc_asprintf(misswords, "%c%s%c%c",
-                                              lastc, words[i], lastc, lastc);
-       }
-
-       printf("#01: Initial insert: ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               htable_str_add(&ht, words[i]);
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("Bytes allocated: %zu\n",
-              sizeof(ht.raw.table[0]) << ht.raw.bits);
-
-       printf("#02: Initial lookup (match): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               if (htable_str_get(&ht, words[i]) != words[i])
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#03: Initial lookup (miss): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++) {
-               if (htable_str_get(&ht, misswords[i]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       /* Lookups in order are very cache-friendly for judy; try random */
-       printf("#04: Initial lookup (random): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0, j = 0; i < num; i++, j = (j + 10007) % num)
-               if (htable_str_get(&ht, words[j]) != words[j])
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       hashcount = 0;
-       printf("#05: Initial delete all: ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               if (!htable_str_del(&ht, words[i]))
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#06: Initial re-inserting: ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               htable_str_add(&ht, words[i]);
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       hashcount = 0;
-       printf("#07: Deleting first half: ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i+=2)
-               if (!htable_str_del(&ht, words[i]))
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#08: Adding (a different) half: ");
-       fflush(stdout);
-
-       start = time_now();
-       for (i = 0; i < num; i+=2)
-               htable_str_add(&ht, misswords[i]);
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#09: Lookup after half-change (match): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 1; i < num; i+=2)
-               if (htable_str_get(&ht, words[i]) != words[i])
-                       abort();
-       for (i = 0; i < num; i+=2) {
-               if (htable_str_get(&ht, misswords[i]) != misswords[i])
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#10: Lookup after half-change (miss): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i+=2)
-               if (htable_str_get(&ht, words[i]))
-                       abort();
-       for (i = 1; i < num; i+=2) {
-               if (htable_str_get(&ht, misswords[i]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       /* Hashtables with delete markers can fill with markers over time.
-        * so do some changes to see how it operates in long-term. */
-       printf("#11: Churn 1: ");
-       start = time_now();
-       for (j = 0; j < num; j+=2) {
-               if (!htable_str_del(&ht, misswords[j]))
-                       abort();
-               if (!htable_str_add(&ht, words[j]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#12: Churn 2: ");
-       start = time_now();
-       for (j = 1; j < num; j+=2) {
-               if (!htable_str_del(&ht, words[j]))
-                       abort();
-               if (!htable_str_add(&ht, misswords[j]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#13: Churn 3: ");
-       start = time_now();
-       for (j = 1; j < num; j+=2) {
-               if (!htable_str_del(&ht, misswords[j]))
-                       abort();
-               if (!htable_str_add(&ht, words[j]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       /* Now it's back to normal... */
-       printf("#14: Post-Churn lookup (match): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               if (htable_str_get(&ht, words[i]) != words[i])
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#15: Post-Churn lookup (miss): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++) {
-               if (htable_str_get(&ht, misswords[i]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       /* Lookups in order are very cache-friendly for judy; try random */
-       printf("#16: Post-Churn lookup (random): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0, j = 0; i < num; i++, j = (j + 10007) % num)
-               if (htable_str_get(&ht, words[j]) != words[j])
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       return 0;
-}
diff --git a/lib/ccan/ilog/LICENSE b/lib/ccan/ilog/LICENSE
deleted file mode 100644 (file)
index 5522aa5..0000000
+++ /dev/null
@@ -1,508 +0,0 @@
-
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
-       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL.  It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
-                            Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations
-below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-\f
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it
-becomes a de-facto standard.  To achieve this, non-free programs must
-be allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-\f
-                  GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control
-compilation and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-\f
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at least
-    three years, to give the same user the materials specified in
-    Subsection 6a, above, for a charge no more than the cost of
-    performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-\f
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply, and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License
-may add an explicit geographical distribution limitation excluding those
-countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-                            NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-                     END OF TERMS AND CONDITIONS
-\f
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms
-of the ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.
-It is safest to attach them to the start of each source file to most
-effectively convey the exclusion of warranty; and each file should
-have at least the "copyright" line and a pointer to where the full
-notice is found.
-
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or
-your school, if any, to sign a "copyright disclaimer" for the library,
-if necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James
-  Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/lib/ccan/ilog/_info b/lib/ccan/ilog/_info
deleted file mode 100644 (file)
index 9a92f4e..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * ilog - Integer logarithm.
- *
- * ilog_32() and ilog_64() compute the minimum number of bits required to store
- *  an unsigned 32-bit or 64-bit value without any leading zero bits.
- * This can also be thought of as the location of the highest set bit, with
- *  counting starting from one (so that 0 returns 0, 1 returns 1, and 2**31
- *  returns 32).
- * When the value is known to be non-zero ilog32_nz() and ilog64_nz() can
- *  compile into as few as two instructions, one of which may get optimized out
- *  later.
- * STATIC_ILOG_32 and STATIC_ILOG_64 allow computation on compile-time
- *  constants, so other compile-time constants can be derived from them.
- *
- * Example:
- *  #include <stdio.h>
- *  #include <limits.h>
- *  #include <ccan/ilog/ilog.h>
- *
- *  int main(void){
- *    int i;
- *    printf("ilog32(0x%08X)=%i\n",0,ilog32(0));
- *    for(i=1;i<=STATIC_ILOG_32(USHRT_MAX);i++){
- *      uint32_t v;
- *      v=(uint32_t)1U<<(i-1);
- *      //Here we know v is non-zero, so we can use ilog32_nz().
- *      printf("ilog32(0x%08X)=%i\n",v,ilog32_nz(v));
- *    }
- *    return 0;
- *  }
- *
- * License: LGPL (v2.1 or any later version)
- * Author: Timothy B. Terriberry <tterribe@xiph.org>
- */
-#include <string.h>
-#include <stdio.h>
-#include "config.h"
-
-int main(int _argc,const char *_argv[]){
-  /*Expect exactly one argument.*/
-  if(_argc!=2)return 1;
-  if(strcmp(_argv[1],"depends")==0){
-    printf("ccan/compiler\n");
-    return 0;
-  }
-  return 1;
-}
diff --git a/lib/ccan/ilog/ilog.c b/lib/ccan/ilog/ilog.c
deleted file mode 100644 (file)
index f42066c..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*(C) Timothy B. Terriberry (tterribe@xiph.org) 2001-2009 LGPL (v2 or later).
- * See LICENSE file for details. */
-#include "ilog.h"
-#include <limits.h>
-
-/*The fastest fallback strategy for platforms with fast multiplication appears
-   to be based on de Bruijn sequences~\cite{LP98}.
-  Tests confirmed this to be true even on an ARM11, where it is actually faster
-   than using the native clz instruction.
-  Define ILOG_NODEBRUIJN to use a simpler fallback on platforms where
-   multiplication or table lookups are too expensive.
-
-  @UNPUBLISHED{LP98,
-    author="Charles E. Leiserson and Harald Prokop",
-    title="Using de {Bruijn} Sequences to Index a 1 in a Computer Word",
-    month=Jun,
-    year=1998,
-    note="\url{http://supertech.csail.mit.edu/papers/debruijn.pdf}"
-  }*/
-static UNNEEDED const unsigned char DEBRUIJN_IDX32[32]={
-   0, 1,28, 2,29,14,24, 3,30,22,20,15,25,17, 4, 8,
-  31,27,13,23,21,19,16, 7,26,12,18, 6,11, 5,10, 9
-};
-
-/* We always compile these in, in case someone takes address of function. */
-#undef ilog32_nz
-#undef ilog32
-#undef ilog64_nz
-#undef ilog64
-
-int ilog32(uint32_t _v){
-/*On a Pentium M, this branchless version tested as the fastest version without
-   multiplications on 1,000,000,000 random 32-bit integers, edging out a
-   similar version with branches, and a 256-entry LUT version.*/
-# if defined(ILOG_NODEBRUIJN)
-  int ret;
-  int m;
-  ret=_v>0;
-  m=(_v>0xFFFFU)<<4;
-  _v>>=m;
-  ret|=m;
-  m=(_v>0xFFU)<<3;
-  _v>>=m;
-  ret|=m;
-  m=(_v>0xFU)<<2;
-  _v>>=m;
-  ret|=m;
-  m=(_v>3)<<1;
-  _v>>=m;
-  ret|=m;
-  ret+=_v>1;
-  return ret;
-/*This de Bruijn sequence version is faster if you have a fast multiplier.*/
-# else
-  int ret;
-  ret=_v>0;
-  _v|=_v>>1;
-  _v|=_v>>2;
-  _v|=_v>>4;
-  _v|=_v>>8;
-  _v|=_v>>16;
-  _v=(_v>>1)+1;
-  ret+=DEBRUIJN_IDX32[_v*0x77CB531U>>27&0x1F];
-  return ret;
-# endif
-}
-
-int ilog32_nz(uint32_t _v)
-{
-  return ilog32(_v);
-}
-
-int ilog64(uint64_t _v){
-# if defined(ILOG_NODEBRUIJN)
-  uint32_t v;
-  int      ret;
-  int      m;
-  ret=_v>0;
-  m=(_v>0xFFFFFFFFU)<<5;
-  v=(uint32_t)(_v>>m);
-  ret|=m;
-  m=(v>0xFFFFU)<<4;
-  v>>=m;
-  ret|=m;
-  m=(v>0xFFU)<<3;
-  v>>=m;
-  ret|=m;
-  m=(v>0xFU)<<2;
-  v>>=m;
-  ret|=m;
-  m=(v>3)<<1;
-  v>>=m;
-  ret|=m;
-  ret+=v>1;
-  return ret;
-# else
-/*If we don't have a 64-bit word, split it into two 32-bit halves.*/
-#  if LONG_MAX<9223372036854775807LL
-  uint32_t v;
-  int      ret;
-  int      m;
-  ret=_v>0;
-  m=(_v>0xFFFFFFFFU)<<5;
-  v=(uint32_t)(_v>>m);
-  ret|=m;
-  v|=v>>1;
-  v|=v>>2;
-  v|=v>>4;
-  v|=v>>8;
-  v|=v>>16;
-  v=(v>>1)+1;
-  ret+=DEBRUIJN_IDX32[v*0x77CB531U>>27&0x1F];
-  return ret;
-/*Otherwise do it in one 64-bit operation.*/
-#  else
-  static const unsigned char DEBRUIJN_IDX64[64]={
-     0, 1, 2, 7, 3,13, 8,19, 4,25,14,28, 9,34,20,40,
-     5,17,26,38,15,46,29,48,10,31,35,54,21,50,41,57,
-    63, 6,12,18,24,27,33,39,16,37,45,47,30,53,49,56,
-    62,11,23,32,36,44,52,55,61,22,43,51,60,42,59,58
-  };
-  int ret;
-  ret=_v>0;
-  _v|=_v>>1;
-  _v|=_v>>2;
-  _v|=_v>>4;
-  _v|=_v>>8;
-  _v|=_v>>16;
-  _v|=_v>>32;
-  _v=(_v>>1)+1;
-  ret+=DEBRUIJN_IDX64[_v*0x218A392CD3D5DBF>>58&0x3F];
-  return ret;
-#  endif
-# endif
-}
-
-int ilog64_nz(uint64_t _v)
-{
-  return ilog64(_v);
-}
diff --git a/lib/ccan/ilog/ilog.h b/lib/ccan/ilog/ilog.h
deleted file mode 100644 (file)
index e52f042..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/* Licensed under LGPLv2.1+ - see LICENSE file for details */
-#if !defined(_ilog_H)
-# define _ilog_H (1)
-# include "config.h"
-# include <stdint.h>
-# include <limits.h>
-# include <ccan/compiler/compiler.h>
-
-/**
- * ilog32 - Integer binary logarithm of a 32-bit value.
- * @_v: A 32-bit value.
- * Returns floor(log2(_v))+1, or 0 if _v==0.
- * This is the number of bits that would be required to represent _v in two's
- *  complement notation with all of the leading zeros stripped.
- * Note that many uses will resolve to the fast macro version instead.
- *
- * See Also:
- *     ilog32_nz(), ilog64()
- *
- * Example:
- *     // Rounds up to next power of 2 (if not a power of 2).
- *     static uint32_t round_up32(uint32_t i)
- *     {
- *             assert(i != 0);
- *             return 1U << ilog32(i-1);
- *     }
- */
-int ilog32(uint32_t _v) CONST_FUNCTION;
-
-/**
- * ilog32_nz - Integer binary logarithm of a non-zero 32-bit value.
- * @_v: A 32-bit value.
- * Returns floor(log2(_v))+1, or undefined if _v==0.
- * This is the number of bits that would be required to represent _v in two's
- *  complement notation with all of the leading zeros stripped.
- * Note that many uses will resolve to the fast macro version instead.
- * See Also:
- *     ilog32(), ilog64_nz()
- * Example:
- *     // Find Last Set (ie. highest bit set, 0 to 31).
- *     static uint32_t fls32(uint32_t i)
- *     {
- *             assert(i != 0);
- *             return ilog32_nz(i) - 1;
- *     }
- */
-int ilog32_nz(uint32_t _v) CONST_FUNCTION;
-
-/**
- * ilog64 - Integer binary logarithm of a 64-bit value.
- * @_v: A 64-bit value.
- * Returns floor(log2(_v))+1, or 0 if _v==0.
- * This is the number of bits that would be required to represent _v in two's
- *  complement notation with all of the leading zeros stripped.
- * Note that many uses will resolve to the fast macro version instead.
- * See Also:
- *     ilog64_nz(), ilog32()
- */
-int ilog64(uint64_t _v) CONST_FUNCTION;
-
-/**
- * ilog64_nz - Integer binary logarithm of a non-zero 64-bit value.
- * @_v: A 64-bit value.
- * Returns floor(log2(_v))+1, or undefined if _v==0.
- * This is the number of bits that would be required to represent _v in two's
- *  complement notation with all of the leading zeros stripped.
- * Note that many uses will resolve to the fast macro version instead.
- * See Also:
- *     ilog64(), ilog32_nz()
- */
-int ilog64_nz(uint64_t _v) CONST_FUNCTION;
-
-/**
- * STATIC_ILOG_32 - The integer logarithm of an (unsigned, 32-bit) constant.
- * @_v: A non-negative 32-bit constant.
- * Returns floor(log2(_v))+1, or 0 if _v==0.
- * This is the number of bits that would be required to represent _v in two's
- *  complement notation with all of the leading zeros stripped.
- * This macro should only be used when you need a compile-time constant,
- * otherwise ilog32 or ilog32_nz are just as fast and more flexible.
- *
- * Example:
- *     #define MY_PAGE_SIZE    4096
- *     #define MY_PAGE_BITS    (STATIC_ILOG_32(PAGE_SIZE) - 1)
- */
-#define STATIC_ILOG_32(_v) (STATIC_ILOG5((uint32_t)(_v)))
-
-/**
- * STATIC_ILOG_64 - The integer logarithm of an (unsigned, 64-bit) constant.
- * @_v: A non-negative 64-bit constant.
- * Returns floor(log2(_v))+1, or 0 if _v==0.
- * This is the number of bits that would be required to represent _v in two's
- *  complement notation with all of the leading zeros stripped.
- * This macro should only be used when you need a compile-time constant,
- * otherwise ilog64 or ilog64_nz are just as fast and more flexible.
- */
-#define STATIC_ILOG_64(_v) (STATIC_ILOG6((uint64_t)(_v)))
-
-/* Private implementation details */
-
-/*Note the casts to (int) below: this prevents "upgrading"
-   the type of an entire expression to an (unsigned) size_t.*/
-#if INT_MAX>=2147483647 && HAVE_BUILTIN_CLZ
-#define builtin_ilog32_nz(v) \
-       (((int)sizeof(unsigned)*CHAR_BIT) - __builtin_clz(v))
-#elif LONG_MAX>=2147483647L && HAVE_BUILTIN_CLZL
-#define builtin_ilog32_nz(v) \
-       (((int)sizeof(unsigned)*CHAR_BIT) - __builtin_clzl(v))
-#endif
-
-#if INT_MAX>=9223372036854775807LL && HAVE_BUILTIN_CLZ
-#define builtin_ilog64_nz(v) \
-       (((int)sizeof(unsigned)*CHAR_BIT) - __builtin_clz(v))
-#elif LONG_MAX>=9223372036854775807LL && HAVE_BUILTIN_CLZL
-#define builtin_ilog64_nz(v) \
-       (((int)sizeof(unsigned long)*CHAR_BIT) - __builtin_clzl(v))
-#elif HAVE_BUILTIN_CLZLL
-#define builtin_ilog64_nz(v) \
-       (((int)sizeof(unsigned long long)*CHAR_BIT) - __builtin_clzll(v))
-#endif
-
-#ifdef builtin_ilog32_nz
-#define ilog32(_v) (builtin_ilog32_nz(_v)&-!!(_v))
-#define ilog32_nz(_v) builtin_ilog32_nz(_v)
-#else
-#define ilog32_nz(_v) ilog32(_v)
-#define ilog32(_v) (IS_COMPILE_CONSTANT(_v) ? STATIC_ILOG_32(_v) : ilog32(_v))
-#endif /* builtin_ilog32_nz */
-
-#ifdef builtin_ilog64_nz
-#define ilog64(_v) (builtin_ilog64_nz(_v)&-!!(_v))
-#define ilog64_nz(_v) builtin_ilog64_nz(_v)
-#else
-#define ilog64_nz(_v) ilog64(_v)
-#define ilog64(_v) (IS_COMPILE_CONSTANT(_v) ? STATIC_ILOG_64(_v) : ilog64(_v))
-#endif /* builtin_ilog64_nz */
-
-/* Macros for evaluating compile-time constant ilog. */
-# define STATIC_ILOG0(_v) (!!(_v))
-# define STATIC_ILOG1(_v) (((_v)&0x2)?2:STATIC_ILOG0(_v))
-# define STATIC_ILOG2(_v) (((_v)&0xC)?2+STATIC_ILOG1((_v)>>2):STATIC_ILOG1(_v))
-# define STATIC_ILOG3(_v) \
- (((_v)&0xF0)?4+STATIC_ILOG2((_v)>>4):STATIC_ILOG2(_v))
-# define STATIC_ILOG4(_v) \
- (((_v)&0xFF00)?8+STATIC_ILOG3((_v)>>8):STATIC_ILOG3(_v))
-# define STATIC_ILOG5(_v) \
- (((_v)&0xFFFF0000)?16+STATIC_ILOG4((_v)>>16):STATIC_ILOG4(_v))
-# define STATIC_ILOG6(_v) \
- (((_v)&0xFFFFFFFF00000000ULL)?32+STATIC_ILOG5((_v)>>32):STATIC_ILOG5(_v))
-
-#endif /* _ilog_H */
diff --git a/lib/ccan/ilog/test/run-out-of-line.c b/lib/ccan/ilog/test/run-out-of-line.c
deleted file mode 100644 (file)
index 48205d3..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#include <ccan/ilog/ilog.h>
-#include <ccan/ilog/ilog.c>
-#include <stdio.h>
-#include <ccan/tap/tap.h>
-
-/*Dead simple (but slow) versions to compare against.*/
-
-static int test_ilog32(uint32_t _v){
-  int ret;
-  for(ret=0;_v;ret++)_v>>=1;
-  return ret;
-}
-
-static int test_ilog64(uint64_t _v){
-  int ret;
-  for(ret=0;_v;ret++)_v>>=1;
-  return ret;
-}
-
-#define NTRIALS (64)
-
-int main(int _argc,const char *_argv[]){
-  int i;
-  int j;
-  int (*il32)(uint32_t) = ilog32;
-  int (*il64)(uint64_t) = ilog64;
-  int (*il32_nz)(uint32_t) = ilog32_nz;
-  int (*il64_nz)(uint64_t) = ilog64_nz;
-
-  /*This is how many tests you plan to run.*/
-  plan_tests(33 * NTRIALS * 3 + 65 * NTRIALS * 3);
-  for(i=0;i<=32;i++){
-    uint32_t v;
-    /*Test each bit in turn (and 0).*/
-    v=i?(uint32_t)1U<<(i-1):0;
-    for(j=0;j<NTRIALS;j++){
-      int l;
-      l=test_ilog32(v);
-      ok1(STATIC_ILOG_32(v)==l);
-      ok1(il32(v)==l);
-      ok1(il32_nz(v) == l || v == 0);
-      /*Also try a few more pseudo-random values with at most the same number
-         of bits.*/
-      v=(1103515245U*v+12345U)&0xFFFFFFFFU>>((33-i)>>1)>>((32-i)>>1);
-    }
-  }
-
-  for(i=0;i<=64;i++){
-    uint64_t v;
-    /*Test each bit in turn (and 0).*/
-    v=i?(uint64_t)1U<<(i-1):0;
-    for(j=0;j<NTRIALS;j++){
-      int l;
-      l=test_ilog64(v);
-      ok1(STATIC_ILOG_64(v)==l);
-      ok1(il64(v)==l);
-      ok1(il64_nz(v) == l || v == 0);
-      /*Also try a few more pseudo-random values with at most the same number
-         of bits.*/
-      v=(uint64_t)((2862933555777941757ULL*v+3037000493ULL)
-       &0xFFFFFFFFFFFFFFFFULL>>((65-i)>>1)>>((64-i)>>1));
-    }
-  }
-  return exit_status();
-}
diff --git a/lib/ccan/ilog/test/run.c b/lib/ccan/ilog/test/run.c
deleted file mode 100644 (file)
index bda59f9..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-#include <ccan/ilog/ilog.h>
-#include <ccan/ilog/ilog.c>
-#include <stdio.h>
-#include <ccan/tap/tap.h>
-
-/*Dead simple (but slow) versions to compare against.*/
-
-static int test_ilog32(uint32_t _v){
-  int ret;
-  for(ret=0;_v;ret++)_v>>=1;
-  return ret;
-}
-
-static int test_ilog64(uint64_t _v){
-  int ret;
-  for(ret=0;_v;ret++)_v>>=1;
-  return ret;
-}
-
-#define NTRIALS (64)
-
-int main(int _argc,const char *_argv[]){
-  int i;
-  int j;
-  /*This is how many tests you plan to run.*/
-  plan_tests(33 * NTRIALS * 3 + 65 * NTRIALS * 3);
-  for(i=0;i<=32;i++){
-    uint32_t v;
-    /*Test each bit in turn (and 0).*/
-    v=i?(uint32_t)1U<<(i-1):0;
-    for(j=0;j<NTRIALS;j++){
-      int l;
-      l=test_ilog32(v);
-      ok1(STATIC_ILOG_32(v)==l);
-      ok1(ilog32(v)==l);
-      ok1(ilog32_nz(v) == l || v == 0);
-      /*Also try a few more pseudo-random values with at most the same number
-         of bits.*/
-      v=(1103515245U*v+12345U)&0xFFFFFFFFU>>((33-i)>>1)>>((32-i)>>1);
-    }
-  }
-
-  for(i=0;i<=64;i++){
-    uint64_t v;
-    /*Test each bit in turn (and 0).*/
-    v=i?(uint64_t)1U<<(i-1):0;
-    for(j=0;j<NTRIALS;j++){
-      int l;
-      l=test_ilog64(v);
-      ok1(STATIC_ILOG_64(v)==l);
-      ok1(ilog64(v)==l);
-      ok1(ilog64_nz(v) == l || v == 0);
-      /*Also try a few more pseudo-random values with at most the same number
-         of bits.*/
-      v=(uint64_t)((2862933555777941757ULL*v+3037000493ULL)
-       &0xFFFFFFFFFFFFFFFFULL>>((65-i)>>1)>>((64-i)>>1));
-    }
-  }
-  return exit_status();
-}
diff --git a/lib/ccan/likely/LICENSE b/lib/ccan/likely/LICENSE
deleted file mode 100644 (file)
index 5522aa5..0000000
+++ /dev/null
@@ -1,508 +0,0 @@
-
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
-       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL.  It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
-                            Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations
-below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-\f
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it
-becomes a de-facto standard.  To achieve this, non-free programs must
-be allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-\f
-                  GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control
-compilation and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-\f
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at least
-    three years, to give the same user the materials specified in
-    Subsection 6a, above, for a charge no more than the cost of
-    performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-\f
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply, and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License
-may add an explicit geographical distribution limitation excluding those
-countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-                            NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-                     END OF TERMS AND CONDITIONS
-\f
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms
-of the ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.
-It is safest to attach them to the start of each source file to most
-effectively convey the exclusion of warranty; and each file should
-have at least the "copyright" line and a pointer to where the full
-notice is found.
-
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or
-your school, if any, to sign a "copyright disclaimer" for the library,
-if necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James
-  Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/lib/ccan/likely/_info b/lib/ccan/likely/_info
deleted file mode 100644 (file)
index 252169b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#include <string.h>
-#include <stdio.h>
-#include "config.h"
-
-/**
- * likely - macros for annotating likely/unlikely branches in the code
- *
- * Inspired by Andi Kleen's macros for the Linux Kernel, these macros
- * help you annotate rare paths in your code for the convenience of the
- * compiler and the reader.
- *
- * License: LGPL (v2.1 or any later version)
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- *
- * Example:
- *     #include <ccan/likely/likely.h>
- *     #include <stdio.h>
- *
- *     int main(int argc, char *argv[])
- *     {
- *             // This example is silly: the compiler knows exit() is unlikely.
- *             if (unlikely(argc == 1)) {
- *                     fprintf(stderr, "Usage: %s <args>...\n", argv[0]);
- *                     return 1;
- *             }
- *             for (argc++; argv[argc]; argc++)
- *                     printf("%s\n", argv[argc]);
- *             return 0;
- *     }
- */
-int main(int argc, char *argv[])
-{
-       /* Expect exactly one argument */
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               printf("ccan/str\n");
-               printf("ccan/htable\n");
-               printf("ccan/hash\n");
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/likely/likely.c b/lib/ccan/likely/likely.c
deleted file mode 100644 (file)
index 1114efc..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Licensed under LGPLv2.1+ - see LICENSE file for details */
-#ifdef CCAN_LIKELY_DEBUG
-#include <ccan/likely/likely.h>
-#include <ccan/hash/hash.h>
-#include <ccan/htable/htable_type.h>
-#include <stdlib.h>
-#include <stdio.h>
-struct trace {
-       const char *condstr;
-       const char *file;
-       unsigned int line;
-       bool expect;
-       unsigned long count, right;
-};
-
-static size_t hash_trace(const struct trace *trace)
-{
-       return hash(trace->condstr, strlen(trace->condstr),
-                   hash(trace->file, strlen(trace->file),
-                        trace->line + trace->expect));
-}
-
-static bool trace_eq(const struct trace *t1, const struct trace *t2)
-{
-       return t1->condstr == t2->condstr
-               && t1->file == t2->file
-               && t1->line == t2->line
-               && t1->expect == t2->expect;
-}
-
-/* struct thash */
-HTABLE_DEFINE_TYPE(struct trace, (const struct trace *), hash_trace, trace_eq,
-                  thash);
-
-static struct thash htable
-= { HTABLE_INITIALIZER(htable.raw, thash_hash, NULL) };
-
-static void init_trace(struct trace *trace,
-                      const char *condstr, const char *file, unsigned int line,
-                      bool expect)
-{
-       trace->condstr = condstr;
-       trace->file = file;
-       trace->line = line;
-       trace->expect = expect;
-       trace->count = trace->right = 0;
-}
-
-static struct trace *add_trace(const struct trace *t)
-{
-       struct trace *trace = malloc(sizeof(*trace));
-       *trace = *t;
-       thash_add(&htable, trace);
-       return trace;
-}
-
-long _likely_trace(bool cond, bool expect,
-                  const char *condstr,
-                  const char *file, unsigned int line)
-{
-       struct trace *p, trace;
-
-       init_trace(&trace, condstr, file, line, expect);
-       p = thash_get(&htable, &trace);
-       if (!p)
-               p = add_trace(&trace);
-
-       p->count++;
-       if (cond == expect)
-               p->right++;
-
-       return cond;
-}
-
-static double right_ratio(const struct trace *t)
-{
-       return (double)t->right / t->count;
-}
-
-char *likely_stats(unsigned int min_hits, unsigned int percent)
-{
-       struct trace *worst;
-       double worst_ratio;
-       struct thash_iter i;
-       char *ret;
-       struct trace *t;
-
-       worst = NULL;
-       worst_ratio = 2;
-
-       /* This is O(n), but it's not likely called that often. */
-       for (t = thash_first(&htable, &i); t; t = thash_next(&htable, &i)) {
-               if (t->count >= min_hits) {
-                       if (right_ratio(t) < worst_ratio) {
-                               worst = t;
-                               worst_ratio = right_ratio(t);
-                       }
-               }
-       }
-
-       if (worst_ratio * 100 > percent)
-               return NULL;
-
-       ret = malloc(strlen(worst->condstr) +
-                    strlen(worst->file) +
-                    sizeof(long int) * 8 +
-                    sizeof("%s:%u:%slikely(%s) correct %u%% (%lu/%lu)"));
-       sprintf(ret, "%s:%u:%slikely(%s) correct %u%% (%lu/%lu)",
-               worst->file, worst->line,
-               worst->expect ? "" : "un", worst->condstr,
-               (unsigned)(worst_ratio * 100),
-               worst->right, worst->count);
-
-       thash_del(&htable, worst);
-       free(worst);
-
-       return ret;
-}
-
-void likely_stats_reset(void)
-{
-       struct thash_iter i;
-       struct trace *t;
-
-       /* This is a bit better than O(n^2), but we have to loop since
-        * first/next during delete is unreliable. */
-       while ((t = thash_first(&htable, &i)) != NULL) {
-               for (; t; t = thash_next(&htable, &i)) {
-                       thash_del(&htable, t);
-                       free(t);
-               }
-       }
-
-       thash_clear(&htable);
-}
-#endif /*CCAN_LIKELY_DEBUG*/
diff --git a/lib/ccan/likely/likely.h b/lib/ccan/likely/likely.h
deleted file mode 100644 (file)
index 8b72995..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/* Licensed under LGPLv2.1+ - see LICENSE file for details */
-#ifndef CCAN_LIKELY_H
-#define CCAN_LIKELY_H
-#include "config.h"
-#include <ccan/str/str.h>
-#include <stdbool.h>
-
-#ifndef CCAN_LIKELY_DEBUG
-#if HAVE_BUILTIN_EXPECT
-/**
- * likely - indicate that a condition is likely to be true.
- * @cond: the condition
- *
- * This uses a compiler extension where available to indicate a likely
- * code path and optimize appropriately; it's also useful for readers
- * to quickly identify exceptional paths through functions.  The
- * threshold for "likely" is usually considered to be between 90 and
- * 99%; marginal cases should not be marked either way.
- *
- * See Also:
- *     unlikely(), likely_stats()
- *
- * Example:
- *     // Returns false if we overflow.
- *     static inline bool inc_int(unsigned int *val)
- *     {
- *             (*val)++;
- *             if (likely(*val))
- *                     return true;
- *             return false;
- *     }
- */
-#ifndef likely
-#define likely(cond) __builtin_expect(!!(cond), 1)
-#endif
-
-/**
- * unlikely - indicate that a condition is unlikely to be true.
- * @cond: the condition
- *
- * This uses a compiler extension where available to indicate an unlikely
- * code path and optimize appropriately; see likely() above.
- *
- * See Also:
- *     likely(), likely_stats(), COLD (compiler.h)
- *
- * Example:
- *     // Prints a warning if we overflow.
- *     static inline void inc_int(unsigned int *val)
- *     {
- *             (*val)++;
- *             if (unlikely(*val == 0))
- *                     fprintf(stderr, "Overflow!");
- *     }
- */
-#ifndef unlikely
-#define unlikely(cond) __builtin_expect(!!(cond), 0)
-#endif
-#else
-#ifndef likely
-#define likely(cond) (!!(cond))
-#endif
-#ifndef unlikely
-#define unlikely(cond) (!!(cond))
-#endif
-#endif
-#else /* CCAN_LIKELY_DEBUG versions */
-#define likely(cond) \
-       (_likely_trace(!!(cond), 1, stringify(cond), __FILE__, __LINE__))
-#define unlikely(cond) \
-       (_likely_trace(!!(cond), 0, stringify(cond), __FILE__, __LINE__))
-
-long _likely_trace(bool cond, bool expect,
-                  const char *condstr,
-                  const char *file, unsigned int line);
-#endif
-
-#ifdef CCAN_LIKELY_DEBUG
-/**
- * likely_stats - return description of abused likely()/unlikely()
- * @min_hits: minimum number of hits
- * @percent: maximum percentage correct
- *
- * When CCAN_LIKELY_DEBUG is defined, likely() and unlikely() trace their
- * results: this causes a significant slowdown, but allows analysis of
- * whether the branches are labelled correctly.
- *
- * This function returns a malloc'ed description of the least-correct
- * usage of likely() or unlikely().  It ignores places which have been
- * called less than @min_hits times, and those which were predicted
- * correctly more than @percent of the time.  It returns NULL when
- * nothing meets those criteria.
- *
- * Note that this call is destructive; the returned offender is
- * removed from the trace so that the next call to likely_stats() will
- * return the next-worst likely()/unlikely() usage.
- *
- * Example:
- *     // Print every place hit more than twice which was wrong > 5%.
- *     static void report_stats(void)
- *     {
- *     #ifdef CCAN_LIKELY_DEBUG
- *             const char *bad;
- *
- *             while ((bad = likely_stats(2, 95)) != NULL) {
- *                     printf("Suspicious likely: %s", bad);
- *                     free(bad);
- *             }
- *     #endif
- *     }
- */
-char *likely_stats(unsigned int min_hits, unsigned int percent);
-
-/**
- * likely_stats_reset - free up memory of likely()/unlikely() branches.
- *
- * This can also plug memory leaks.
- */
-void likely_stats_reset(void);
-#endif /* CCAN_LIKELY_DEBUG */
-#endif /* CCAN_LIKELY_H */
diff --git a/lib/ccan/likely/test/run-debug.c b/lib/ccan/likely/test/run-debug.c
deleted file mode 100644 (file)
index afb21e2..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-#define CCAN_LIKELY_DEBUG 1
-#include <ccan/likely/likely.c>
-#include <ccan/likely/likely.h>
-#include <ccan/tap/tap.h>
-#include <stdlib.h>
-
-static bool one_seems_likely(unsigned int val)
-{
-       if (likely(val == 1))
-               return true;
-       return false;
-}
-
-static bool one_seems_unlikely(unsigned int val)
-{
-       if (unlikely(val == 1))
-               return true;
-       return false;
-}
-
-static bool likely_one_unlikely_two(unsigned int val1, unsigned int val2)
-{
-       /* Same line, check we don't get confused! */
-       if (likely(val1 == 1) && unlikely(val2 == 2))
-               return true;
-       return false;
-}
-
-int main(int argc, char *argv[])
-{
-       char *bad;
-
-       plan_tests(14);
-
-       /* Correct guesses. */
-       one_seems_likely(1);
-       ok1(likely_stats(0, 90) == NULL);
-       one_seems_unlikely(2);
-       ok1(likely_stats(0, 90) == NULL);
-
-       /* Incorrect guesses. */
-       one_seems_likely(0);
-       one_seems_likely(2);
-       /* Hasn't been hit 4 times, so this fails */
-       ok1(!likely_stats(4, 90));
-       bad = likely_stats(3, 90);
-       ok(strends(bad, "run-debug.c:9:likely(val == 1) correct 33% (1/3)"),
-          "likely_stats returned %s", bad);
-       free(bad);
-
-       /* Nothing else above 90% */
-       ok1(!likely_stats(0, 90));
-
-       /* This should get everything. */
-       bad = likely_stats(0, 100);
-       ok(strends(bad, "run-debug.c:16:unlikely(val == 1) correct 100% (1/1)"),
-          "likely_stats returned %s", bad);
-       free(bad);
-
-       /* Nothing left (table is actually cleared) */
-       ok1(!likely_stats(0, 100));
-
-       /* Make sure unlikely works */
-       one_seems_unlikely(0);
-       one_seems_unlikely(2);
-       one_seems_unlikely(1);
-
-       bad = likely_stats(0, 90);
-       ok(strends(bad, "run-debug.c:16:unlikely(val == 1) correct 66% (2/3)"),
-          "likely_stats returned %s", bad);
-       free(bad);
-       ok1(!likely_stats(0, 100));
-
-       likely_one_unlikely_two(1, 1);
-       likely_one_unlikely_two(1, 1);
-       likely_one_unlikely_two(1, 1);
-       ok1(!likely_stats(0, 90));
-       likely_one_unlikely_two(1, 2);
-
-       bad = likely_stats(0, 90);
-       ok(strends(bad, "run-debug.c:24:unlikely(val2 == 2) correct 75% (3/4)"),
-          "likely_stats returned %s", bad);
-       free(bad);
-       bad = likely_stats(0, 100);
-       ok(strends(bad, "run-debug.c:24:likely(val1 == 1) correct 100% (4/4)"),
-          "likely_stats returned %s", bad);
-       free(bad);
-
-       ok1(!likely_stats(0, 100));
-
-       /* Check that reset works! */
-       one_seems_unlikely(0);
-       one_seems_unlikely(2);
-       one_seems_unlikely(1);
-       likely_stats_reset();
-
-       ok1(!likely_stats(0, 100));
-
-       exit(exit_status());
-}
diff --git a/lib/ccan/likely/test/run.c b/lib/ccan/likely/test/run.c
deleted file mode 100644 (file)
index fa1dc9f..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <ccan/likely/likely.c>
-#include <ccan/likely/likely.h>
-#include <ccan/tap/tap.h>
-#include <stdlib.h>
-
-static bool one_seems_likely(unsigned int val)
-{
-       if (likely(val == 1))
-               return true;
-       return false;
-}
-
-static bool one_seems_unlikely(unsigned int val)
-{
-       if (unlikely(val == 1))
-               return true;
-       return false;
-}
-
-int main(int argc, char *argv[])
-{
-       plan_tests(4);
-
-       /* Without debug, we can only check that it doesn't effect functions. */
-       ok1(one_seems_likely(1));
-       ok1(!one_seems_likely(2));
-       ok1(one_seems_unlikely(1));
-       ok1(!one_seems_unlikely(2));
-       exit(exit_status());
-}
diff --git a/lib/ccan/list/.namespacize b/lib/ccan/list/.namespacize
deleted file mode 100644 (file)
index aa6f0b4..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-list_node_from_off_
-list_node_to_off_
-list_tail_
-list_top_
-list_del_from
-list_del
-list_empty
-list_add_tail
-list_add
-list_head_init
-list_check_node
-list_check
-list_head
-list_node
-list_off_var_
-list_off_
-list_del_from_off
-list_del_off
-list_add_off
-list_tail_off
-list_head_off
-list_entry_off
-list_for_each_safe_off
-list_for_each_off
-list_for_each_safe
-list_for_each_rev
-list_for_each
-list_tail
-list_top
-list_entry
-LIST_HEAD
-LIST_HEAD_INIT
-list_debug_node
-list_debug
diff --git a/lib/ccan/list/LICENSE b/lib/ccan/list/LICENSE
deleted file mode 100644 (file)
index 5522aa5..0000000
+++ /dev/null
@@ -1,508 +0,0 @@
-
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
-       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL.  It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
-                            Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations
-below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-\f
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it
-becomes a de-facto standard.  To achieve this, non-free programs must
-be allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-\f
-                  GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control
-compilation and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-\f
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at least
-    three years, to give the same user the materials specified in
-    Subsection 6a, above, for a charge no more than the cost of
-    performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-\f
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply, and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License
-may add an explicit geographical distribution limitation excluding those
-countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-                            NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-                     END OF TERMS AND CONDITIONS
-\f
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms
-of the ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.
-It is safest to attach them to the start of each source file to most
-effectively convey the exclusion of warranty; and each file should
-have at least the "copyright" line and a pointer to where the full
-notice is found.
-
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or
-your school, if any, to sign a "copyright disclaimer" for the library,
-if necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James
-  Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/lib/ccan/list/_info b/lib/ccan/list/_info
deleted file mode 100644 (file)
index a30659c..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * list - double linked list routines
- *
- * The list header contains routines for manipulating double linked lists.
- * It defines two types: struct list_head used for anchoring lists, and
- * struct list_node which is usually embedded in the structure which is placed
- * in the list.
- *
- * Example:
- *     #include <err.h>
- *     #include <stdio.h>
- *     #include <stdlib.h>
- *     #include <ccan/list/list.h>
- *
- *     struct parent {
- *             const char *name;
- *             struct list_head children;
- *             unsigned int num_children;
- *     };
- *
- *     struct child {
- *             const char *name;
- *             struct list_node list;
- *     };
- *
- *     int main(int argc, char *argv[])
- *     {
- *             struct parent p;
- *             struct child *c;
- *             unsigned int i;
- *
- *             if (argc < 2)
- *                     errx(1, "Usage: %s parent children...", argv[0]);
- *
- *             p.name = argv[1];
- *             list_head_init(&p.children);
- *             p.num_children = 0;
- *             for (i = 2; i < argc; i++) {
- *                     c = malloc(sizeof(*c));
- *                     c->name = argv[i];
- *                     list_add(&p.children, &c->list);
- *                     p.num_children++;
- *             }
- *
- *             printf("%s has %u children:", p.name, p.num_children);
- *             list_for_each(&p.children, c, list)
- *                     printf("%s ", c->name);
- *             printf("\n");
- *             return 0;
- *     }
- *
- * License: LGPL (v2.1 or any later version)
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               printf("ccan/container_of\n");
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/list/list.c b/lib/ccan/list/list.c
deleted file mode 100644 (file)
index 380212a..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Licensed under LGPLv2.1+ - see LICENSE file for details */
-#include <stdio.h>
-#include <stdlib.h>
-#include "list.h"
-
-static void *corrupt(const char *abortstr,
-                    const struct ccan_list_node *head,
-                    const struct ccan_list_node *node,
-                    unsigned int count)
-{
-       if (abortstr) {
-               fprintf(stderr,
-                       "%s: prev corrupt in node %p (%u) of %p\n",
-                       abortstr, node, count, head);
-               abort();
-       }
-       return NULL;
-}
-
-struct ccan_list_node *ccan_list_check_node(const struct ccan_list_node *node,
-                                 const char *abortstr)
-{
-       const struct ccan_list_node *p, *n;
-       int count = 0;
-
-       for (p = node, n = node->next; n != node; p = n, n = n->next) {
-               count++;
-               if (n->prev != p)
-                       return corrupt(abortstr, node, n, count);
-       }
-       /* Check prev on head node. */
-       if (node->prev != p)
-               return corrupt(abortstr, node, node, 0);
-
-       return (struct ccan_list_node *)node;
-}
-
-struct ccan_list_head *ccan_list_check(const struct ccan_list_head *h, const char *abortstr)
-{
-       if (!ccan_list_check_node(&h->n, abortstr))
-               return NULL;
-       return (struct ccan_list_head *)h;
-}
diff --git a/lib/ccan/list/list.d b/lib/ccan/list/list.d
deleted file mode 100644 (file)
index dd24958..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-ccan/list/list.o: ccan/list/list.c /usr/include/stdio.h \
- /usr/include/features.h /usr/include/i386-linux-gnu/bits/predefs.h \
- /usr/include/i386-linux-gnu/sys/cdefs.h \
- /usr/include/i386-linux-gnu/bits/wordsize.h \
- /usr/include/i386-linux-gnu/gnu/stubs.h \
- /usr/include/i386-linux-gnu/gnu/stubs-32.h \
- /usr/lib/gcc/i686-linux-gnu/4.5.4/include/stddef.h \
- /usr/include/i386-linux-gnu/bits/types.h \
- /usr/include/i386-linux-gnu/bits/typesizes.h /usr/include/libio.h \
- /usr/include/_G_config.h /usr/include/wchar.h \
- /usr/lib/gcc/i686-linux-gnu/4.5.4/include/stdarg.h \
- /usr/include/i386-linux-gnu/bits/stdio_lim.h \
- /usr/include/i386-linux-gnu/bits/sys_errlist.h /usr/include/stdlib.h \
- /usr/include/i386-linux-gnu/bits/waitflags.h \
- /usr/include/i386-linux-gnu/bits/waitstatus.h /usr/include/endian.h \
- /usr/include/i386-linux-gnu/bits/endian.h \
- /usr/include/i386-linux-gnu/bits/byteswap.h \
- /usr/include/i386-linux-gnu/sys/types.h /usr/include/time.h \
- /usr/include/i386-linux-gnu/sys/select.h \
- /usr/include/i386-linux-gnu/bits/select.h \
- /usr/include/i386-linux-gnu/bits/sigset.h \
- /usr/include/i386-linux-gnu/bits/time.h \
- /usr/include/i386-linux-gnu/sys/sysmacros.h \
- /usr/include/i386-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
- ccan/list/list.h /usr/lib/gcc/i686-linux-gnu/4.5.4/include/stdbool.h \
- /usr/include/assert.h ccan/container_of/container_of.h config.h \
- ccan/check_type/check_type.h
diff --git a/lib/ccan/list/list.h b/lib/ccan/list/list.h
deleted file mode 100644 (file)
index 10a2076..0000000
+++ /dev/null
@@ -1,469 +0,0 @@
-/* Licensed under LGPLv2.1+ - see LICENSE file for details */
-#ifndef CCAN_LIST_H
-#define CCAN_LIST_H
-#include <stdbool.h>
-#include <assert.h>
-#include <ccan/container_of/container_of.h>
-#include <ccan/check_type/check_type.h>
-
-/**
- * struct ccan_list_node - an entry in a doubly-linked list
- * @next: next entry (self if empty)
- * @prev: previous entry (self if empty)
- *
- * This is used as an entry in a linked list.
- * Example:
- *     struct child {
- *             const char *name;
- *             // Linked list of all us children.
- *             struct ccan_list_node list;
- *     };
- */
-struct ccan_list_node
-{
-       struct ccan_list_node *next, *prev;
-};
-
-/**
- * struct ccan_list_head - the head of a doubly-linked list
- * @h: the ccan_list_head (containing next and prev pointers)
- *
- * This is used as the head of a linked list.
- * Example:
- *     struct parent {
- *             const char *name;
- *             struct ccan_list_head children;
- *             unsigned int num_children;
- *     };
- */
-struct ccan_list_head
-{
-       struct ccan_list_node n;
-};
-
-/**
- * ccan_list_check - check head of a list for consistency
- * @h: the ccan_list_head
- * @abortstr: the location to print on aborting, or NULL.
- *
- * Because list_nodes have redundant information, consistency checking between
- * the back and forward links can be done.  This is useful as a debugging check.
- * If @abortstr is non-NULL, that will be printed in a diagnostic if the list
- * is inconsistent, and the function will abort.
- *
- * Returns the list head if the list is consistent, NULL if not (it
- * can never return NULL if @abortstr is set).
- *
- * See also: ccan_list_check_node()
- *
- * Example:
- *     static void dump_parent(struct parent *p)
- *     {
- *             struct child *c;
- *
- *             printf("%s (%u children):\n", p->name, p->num_children);
- *             ccan_list_check(&p->children, "bad child list");
- *             ccan_list_for_each(&p->children, c, list)
- *                     printf(" -> %s\n", c->name);
- *     }
- */
-struct ccan_list_head *ccan_list_check(const struct ccan_list_head *h, const char *abortstr);
-
-/**
- * ccan_list_check_node - check node of a list for consistency
- * @n: the ccan_list_node
- * @abortstr: the location to print on aborting, or NULL.
- *
- * Check consistency of the list node is in (it must be in one).
- *
- * See also: ccan_list_check()
- *
- * Example:
- *     static void dump_child(const struct child *c)
- *     {
- *             ccan_list_check_node(&c->list, "bad child list");
- *             printf("%s\n", c->name);
- *     }
- */
-struct ccan_list_node *ccan_list_check_node(const struct ccan_list_node *n,
-                                 const char *abortstr);
-
-#ifdef CCAN_LIST_DEBUG
-#define ccan_list_debug(h) ccan_list_check((h), __func__)
-#define ccan_list_debug_node(n) ccan_list_check_node((n), __func__)
-#else
-#define ccan_list_debug(h) (h)
-#define ccan_list_debug_node(n) (n)
-#endif
-
-/**
- * CCAN_LIST_HEAD_INIT - initializer for an empty ccan_list_head
- * @name: the name of the list.
- *
- * Explicit initializer for an empty list.
- *
- * See also:
- *     CCAN_LIST_HEAD, ccan_list_head_init()
- *
- * Example:
- *     static struct ccan_list_head my_list = CCAN_LIST_HEAD_INIT(my_list);
- */
-#define CCAN_LIST_HEAD_INIT(name) { { &name.n, &name.n } }
-
-/**
- * CCAN_LIST_HEAD - define and initialize an empty ccan_list_head
- * @name: the name of the list.
- *
- * The CCAN_LIST_HEAD macro defines a ccan_list_head and initializes it to an empty
- * list.  It can be prepended by "static" to define a static ccan_list_head.
- *
- * See also:
- *     CCAN_LIST_HEAD_INIT, ccan_list_head_init()
- *
- * Example:
- *     static CCAN_LIST_HEAD(my_global_list);
- */
-#define CCAN_LIST_HEAD(name) \
-       struct ccan_list_head name = CCAN_LIST_HEAD_INIT(name)
-
-/**
- * ccan_list_head_init - initialize a ccan_list_head
- * @h: the ccan_list_head to set to the empty list
- *
- * Example:
- *     ...
- *     struct parent *parent = malloc(sizeof(*parent));
- *
- *     ccan_list_head_init(&parent->children);
- *     parent->num_children = 0;
- */
-static inline void ccan_list_head_init(struct ccan_list_head *h)
-{
-       h->n.next = h->n.prev = &h->n;
-}
-
-/**
- * ccan_list_add - add an entry at the start of a linked list.
- * @h: the ccan_list_head to add the node to
- * @n: the ccan_list_node to add to the list.
- *
- * The ccan_list_node does not need to be initialized; it will be overwritten.
- * Example:
- *     struct child *child = malloc(sizeof(*child));
- *
- *     child->name = "marvin";
- *     ccan_list_add(&parent->children, &child->list);
- *     parent->num_children++;
- */
-static inline void ccan_list_add(struct ccan_list_head *h, struct ccan_list_node *n)
-{
-       n->next = h->n.next;
-       n->prev = &h->n;
-       h->n.next->prev = n;
-       h->n.next = n;
-       (void)ccan_list_debug(h);
-}
-
-/**
- * ccan_list_add_tail - add an entry at the end of a linked list.
- * @h: the ccan_list_head to add the node to
- * @n: the ccan_list_node to add to the list.
- *
- * The ccan_list_node does not need to be initialized; it will be overwritten.
- * Example:
- *     ccan_list_add_tail(&parent->children, &child->list);
- *     parent->num_children++;
- */
-static inline void ccan_list_add_tail(struct ccan_list_head *h, struct ccan_list_node *n)
-{
-       n->next = &h->n;
-       n->prev = h->n.prev;
-       h->n.prev->next = n;
-       h->n.prev = n;
-       (void)ccan_list_debug(h);
-}
-
-/**
- * ccan_list_empty - is a list empty?
- * @h: the ccan_list_head
- *
- * If the list is empty, returns true.
- *
- * Example:
- *     assert(ccan_list_empty(&parent->children) == (parent->num_children == 0));
- */
-static inline bool ccan_list_empty(const struct ccan_list_head *h)
-{
-       (void)ccan_list_debug(h);
-       return h->n.next == &h->n;
-}
-
-/**
- * ccan_list_del - delete an entry from an (unknown) linked list.
- * @n: the ccan_list_node to delete from the list.
- *
- * Note that this leaves @n in an undefined state; it can be added to
- * another list, but not deleted again.
- *
- * See also:
- *     ccan_list_del_from()
- *
- * Example:
- *     ccan_list_del(&child->list);
- *     parent->num_children--;
- */
-static inline void ccan_list_del(struct ccan_list_node *n)
-{
-       (void)ccan_list_debug_node(n);
-       n->next->prev = n->prev;
-       n->prev->next = n->next;
-#ifdef CCAN_LIST_DEBUG
-       /* Catch use-after-del. */
-       n->next = n->prev = NULL;
-#endif
-}
-
-/**
- * ccan_list_del_from - delete an entry from a known linked list.
- * @h: the ccan_list_head the node is in.
- * @n: the ccan_list_node to delete from the list.
- *
- * This explicitly indicates which list a node is expected to be in,
- * which is better documentation and can catch more bugs.
- *
- * See also: ccan_list_del()
- *
- * Example:
- *     ccan_list_del_from(&parent->children, &child->list);
- *     parent->num_children--;
- */
-static inline void ccan_list_del_from(struct ccan_list_head *h, struct ccan_list_node *n)
-{
-#ifdef CCAN_LIST_DEBUG
-       {
-               /* Thorough check: make sure it was in list! */
-               struct ccan_list_node *i;
-               for (i = h->n.next; i != n; i = i->next)
-                       assert(i != &h->n);
-       }
-#endif /* CCAN_LIST_DEBUG */
-
-       /* Quick test that catches a surprising number of bugs. */
-       assert(!ccan_list_empty(h));
-       ccan_list_del(n);
-}
-
-/**
- * ccan_list_entry - convert a ccan_list_node back into the structure containing it.
- * @n: the ccan_list_node
- * @type: the type of the entry
- * @member: the ccan_list_node member of the type
- *
- * Example:
- *     // First list entry is children.next; convert back to child.
- *     child = ccan_list_entry(parent->children.n.next, struct child, list);
- *
- * See Also:
- *     ccan_list_top(), ccan_list_for_each()
- */
-#define ccan_list_entry(n, type, member) container_of(n, type, member)
-
-/**
- * ccan_list_top - get the first entry in a list
- * @h: the ccan_list_head
- * @type: the type of the entry
- * @member: the ccan_list_node member of the type
- *
- * If the list is empty, returns NULL.
- *
- * Example:
- *     struct child *first;
- *     first = ccan_list_top(&parent->children, struct child, list);
- */
-#define ccan_list_top(h, type, member)                                 \
-       ((type *)ccan_list_top_((h), ccan_list_off_(type, member)))
-
-static inline const void *ccan_list_top_(const struct ccan_list_head *h, size_t off)
-{
-       if (ccan_list_empty(h))
-               return NULL;
-       return (const char *)h->n.next - off;
-}
-
-/**
- * ccan_list_tail - get the last entry in a list
- * @h: the ccan_list_head
- * @type: the type of the entry
- * @member: the ccan_list_node member of the type
- *
- * If the list is empty, returns NULL.
- *
- * Example:
- *     struct child *last;
- *     last = ccan_list_tail(&parent->children, struct child, list);
- */
-#define ccan_list_tail(h, type, member) \
-       ((type *)ccan_list_tail_((h), ccan_list_off_(type, member)))
-
-static inline const void *ccan_list_tail_(const struct ccan_list_head *h, size_t off)
-{
-       if (ccan_list_empty(h))
-               return NULL;
-       return (const char *)h->n.prev - off;
-}
-
-/**
- * ccan_list_for_each - iterate through a list.
- * @h: the ccan_list_head (warning: evaluated multiple times!)
- * @i: the structure containing the ccan_list_node
- * @member: the ccan_list_node member of the structure
- *
- * This is a convenient wrapper to iterate @i over the entire list.  It's
- * a for loop, so you can break and continue as normal.
- *
- * Example:
- *     ccan_list_for_each(&parent->children, child, list)
- *             printf("Name: %s\n", child->name);
- */
-#define ccan_list_for_each(h, i, member)                                       \
-       ccan_list_for_each_off(h, i, ccan_list_off_var_(i, member))
-
-/**
- * ccan_list_for_each_rev - iterate through a list backwards.
- * @h: the ccan_list_head
- * @i: the structure containing the ccan_list_node
- * @member: the ccan_list_node member of the structure
- *
- * This is a convenient wrapper to iterate @i over the entire list.  It's
- * a for loop, so you can break and continue as normal.
- *
- * Example:
- *     ccan_list_for_each_rev(&parent->children, child, list)
- *             printf("Name: %s\n", child->name);
- */
-#define ccan_list_for_each_rev(h, i, member)                                   \
-       for (i = container_of_var(ccan_list_debug(h)->n.prev, i, member);       \
-            &i->member != &(h)->n;                                     \
-            i = container_of_var(i->member.prev, i, member))
-
-/**
- * ccan_list_for_each_safe - iterate through a list, maybe during deletion
- * @h: the ccan_list_head
- * @i: the structure containing the ccan_list_node
- * @nxt: the structure containing the ccan_list_node
- * @member: the ccan_list_node member of the structure
- *
- * This is a convenient wrapper to iterate @i over the entire list.  It's
- * a for loop, so you can break and continue as normal.  The extra variable
- * @nxt is used to hold the next element, so you can delete @i from the list.
- *
- * Example:
- *     struct child *next;
- *     ccan_list_for_each_safe(&parent->children, child, next, list) {
- *             ccan_list_del(&child->list);
- *             parent->num_children--;
- *     }
- */
-#define ccan_list_for_each_safe(h, i, nxt, member)                             \
-       ccan_list_for_each_safe_off(h, i, nxt, ccan_list_off_var_(i, member))
-
-/**
- * ccan_list_for_each_off - iterate through a list of memory regions.
- * @h: the ccan_list_head
- * @i: the pointer to a memory region wich contains list node data.
- * @off: offset(relative to @i) at which list node data resides.
- *
- * This is a low-level wrapper to iterate @i over the entire list, used to
- * implement all oher, more high-level, for-each constructs. It's a for loop,
- * so you can break and continue as normal.
- *
- * WARNING! Being the low-level macro that it is, this wrapper doesn't know
- * nor care about the type of @i. The only assumtion made is that @i points
- * to a chunk of memory that at some @offset, relative to @i, contains a
- * properly filled `struct node_list' which in turn contains pointers to
- * memory chunks and it's turtles all the way down. Whith all that in mind
- * remember that given the wrong pointer/offset couple this macro will
- * happilly churn all you memory untill SEGFAULT stops it, in other words
- * caveat emptor.
- *
- * It is worth mentioning that one of legitimate use-cases for that wrapper
- * is operation on opaque types with known offset for `struct ccan_list_node'
- * member(preferably 0), because it allows you not to disclose the type of
- * @i.
- *
- * Example:
- *     ccan_list_for_each_off(&parent->children, child,
- *                             offsetof(struct child, list))
- *             printf("Name: %s\n", child->name);
- */
-#define ccan_list_for_each_off(h, i, off)                                    \
-  for (i = ccan_list_node_to_off_(ccan_list_debug(h)->n.next, (off));             \
-       ccan_list_node_from_off_((void *)i, (off)) != &(h)->n;                \
-       i = ccan_list_node_to_off_(ccan_list_node_from_off_((void *)i, (off))->next, \
-                             (off)))
-
-/**
- * ccan_list_for_each_safe_off - iterate through a list of memory regions, maybe
- * during deletion
- * @h: the ccan_list_head
- * @i: the pointer to a memory region wich contains list node data.
- * @nxt: the structure containing the ccan_list_node
- * @off: offset(relative to @i) at which list node data resides.
- *
- * For details see `ccan_list_for_each_off' and `ccan_list_for_each_safe'
- * descriptions.
- *
- * Example:
- *     ccan_list_for_each_safe_off(&parent->children, child,
- *             next, offsetof(struct child, list))
- *             printf("Name: %s\n", child->name);
- */
-#define ccan_list_for_each_safe_off(h, i, nxt, off)                          \
-  for (i = ccan_list_node_to_off_(ccan_list_debug(h)->n.next, (off)),             \
-         nxt = ccan_list_node_to_off_(ccan_list_node_from_off_(i, (off))->next,   \
-                                 (off));                                \
-       ccan_list_node_from_off_(i, (off)) != &(h)->n;                        \
-       i = nxt,                                                         \
-         nxt = ccan_list_node_to_off_(ccan_list_node_from_off_(i, (off))->next,   \
-                                 (off)))
-
-
-/* Other -off variants. */
-#define ccan_list_entry_off(n, type, off)              \
-       ((type *)ccan_list_node_from_off_((n), (off)))
-
-#define ccan_list_head_off(h, type, off)               \
-       ((type *)ccan_list_head_off((h), (off)))
-
-#define ccan_list_tail_off(h, type, off)               \
-       ((type *)ccan_list_tail_((h), (off)))
-
-#define ccan_list_add_off(h, n, off)                 \
-       ccan_list_add((h), ccan_list_node_from_off_((n), (off)))
-
-#define ccan_list_del_off(n, off)                    \
-       ccan_list_del(ccan_list_node_from_off_((n), (off)))
-
-#define ccan_list_del_from_off(h, n, off)                      \
-       ccan_list_del_from(h, ccan_list_node_from_off_((n), (off)))
-
-/* Offset helper functions so we only single-evaluate. */
-static inline void *ccan_list_node_to_off_(struct ccan_list_node *node, size_t off)
-{
-       return (void *)((char *)node - off);
-}
-static inline struct ccan_list_node *ccan_list_node_from_off_(void *ptr, size_t off)
-{
-       return (struct ccan_list_node *)((char *)ptr + off);
-}
-
-/* Get the offset of the member, but make sure it's a ccan_list_node. */
-#define ccan_list_off_(type, member)                                   \
-       (container_off(type, member) +                          \
-        check_type(((type *)0)->member, struct ccan_list_node))
-
-#define ccan_list_off_var_(var, member)                        \
-       (container_off_var(var, member) +               \
-        check_type(var->member, struct ccan_list_node))
-
-#endif /* CCAN_LIST_H */
diff --git a/lib/ccan/list/test/compile_ok-constant.c b/lib/ccan/list/test/compile_ok-constant.c
deleted file mode 100644 (file)
index acd8601..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#include <ccan/list/list.h>
-#include <ccan/tap/tap.h>
-#include <ccan/list/list.c>
-#include <stdbool.h>
-#include <stdio.h>
-
-struct child {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-static bool children(const struct ccan_list_head *list)
-{
-       return !ccan_list_empty(list);
-}
-
-static const struct child *first_child(const struct ccan_list_head *list)
-{
-       return ccan_list_top(list, struct child, list);
-}
-
-static const struct child *last_child(const struct ccan_list_head *list)
-{
-       return ccan_list_tail(list, struct child, list);
-}
-
-static void check_children(const struct ccan_list_head *list)
-{
-       ccan_list_check(list, "bad child list");
-}
-
-static void print_children(const struct ccan_list_head *list)
-{
-       const struct child *c;
-       ccan_list_for_each(list, c, list)
-               printf("%s\n", c->name);
-}
-
-int main(void)
-{
-       CCAN_LIST_HEAD(h);
-
-       children(&h);
-       first_child(&h);
-       last_child(&h);
-       check_children(&h);
-       print_children(&h);
-       return 0;
-}
diff --git a/lib/ccan/list/test/helper.c b/lib/ccan/list/test/helper.c
deleted file mode 100644 (file)
index f60eccc..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#include <stdlib.h>
-#include <stdbool.h>
-#include <time.h>
-
-#include <ccan/list/list.h>
-#include "helper.h"
-
-#define ANSWER_TO_THE_ULTIMATE_QUESTION_OF_LIFE_THE_UNIVERSE_AND_EVERYTHING \
-  (42)
-
-struct opaque {
-  struct ccan_list_node list;
-  size_t secret_offset;
-  char   secret_drawer[42];
-};
-
-static bool not_randomized = true;
-
-struct opaque *create_opaque_blob(void)
-{
-  struct opaque *blob = calloc(1, sizeof(struct opaque));
-
-  if (not_randomized) {
-    srandom((int)time(NULL));
-    not_randomized = false;
-  }
-
-  blob->secret_offset = random() % (sizeof(blob->secret_drawer));
-  blob->secret_drawer[blob->secret_offset] =
-    ANSWER_TO_THE_ULTIMATE_QUESTION_OF_LIFE_THE_UNIVERSE_AND_EVERYTHING;
-
-  return blob;
-}
-
-bool if_blobs_know_the_secret(struct opaque *blob)
-{
-  bool answer = true;
-  int i;
-  for (i = 0; i < sizeof(blob->secret_drawer) /
-               sizeof(blob->secret_drawer[0]); i++)
-          if (i != blob->secret_offset)
-                  answer = answer && (blob->secret_drawer[i] == 0);
-          else
-                  answer = answer &&
-                          (blob->secret_drawer[blob->secret_offset] ==
-           ANSWER_TO_THE_ULTIMATE_QUESTION_OF_LIFE_THE_UNIVERSE_AND_EVERYTHING);
-
-  return answer;
-}
-
-void destroy_opaque_blob(struct opaque *blob)
-{
-  free(blob);
-}
diff --git a/lib/ccan/list/test/helper.h b/lib/ccan/list/test/helper.h
deleted file mode 100644 (file)
index a09a3a9..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-/* These are in a separate C file so we can test undefined structures. */
-struct opaque;
-typedef struct opaque opaque_t;
-
-opaque_t *create_opaque_blob(void);
-bool if_blobs_know_the_secret(opaque_t *blob);
-void destroy_opaque_blob(opaque_t *blob);
diff --git a/lib/ccan/list/test/run-check-corrupt.c b/lib/ccan/list/test/run-check-corrupt.c
deleted file mode 100644 (file)
index af44992..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-#include <setjmp.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <err.h>
-
-/* We don't actually want it to exit... */
-static jmp_buf aborted;
-#define abort() longjmp(aborted, 1)
-
-#define fprintf my_fprintf
-static char printf_buffer[1000];
-
-static int my_fprintf(FILE *stream, const char *format, ...)
-{
-       va_list ap;
-       int ret;
-       va_start(ap, format);
-       ret = vsprintf(printf_buffer, format, ap);
-       va_end(ap);
-       return ret;
-}
-
-#include <ccan/list/list.h>
-#include <ccan/tap/tap.h>
-#include <ccan/list/list.c>
-
-int main(int argc, char *argv[])
-{
-       struct ccan_list_head list;
-       struct ccan_list_node n1;
-       char expect[100];
-
-       plan_tests(9);
-       /* Empty list. */
-       list.n.next = &list.n;
-       list.n.prev = &list.n;
-       ok1(ccan_list_check(&list, NULL) == &list);
-
-       /* Bad back ptr */
-       list.n.prev = &n1;
-       /* Non-aborting version. */
-       ok1(ccan_list_check(&list, NULL) == NULL);
-
-       /* Aborting version. */
-       sprintf(expect, "test message: prev corrupt in node %p (0) of %p\n",
-               &list, &list);
-       if (setjmp(aborted) == 0) {
-               ccan_list_check(&list, "test message");
-               fail("ccan_list_check on empty with bad back ptr didn't fail!");
-       } else {
-               ok1(strcmp(printf_buffer, expect) == 0);
-       }
-
-       /* n1 in list. */
-       list.n.next = &n1;
-       list.n.prev = &n1;
-       n1.prev = &list.n;
-       n1.next = &list.n;
-       ok1(ccan_list_check(&list, NULL) == &list);
-       ok1(ccan_list_check_node(&n1, NULL) == &n1);
-
-       /* Bad back ptr */
-       n1.prev = &n1;
-       ok1(ccan_list_check(&list, NULL) == NULL);
-       ok1(ccan_list_check_node(&n1, NULL) == NULL);
-
-       /* Aborting version. */
-       sprintf(expect, "test message: prev corrupt in node %p (1) of %p\n",
-               &n1, &list);
-       if (setjmp(aborted) == 0) {
-               ccan_list_check(&list, "test message");
-               fail("ccan_list_check on n1 bad back ptr didn't fail!");
-       } else {
-               ok1(strcmp(printf_buffer, expect) == 0);
-       }
-
-       sprintf(expect, "test message: prev corrupt in node %p (0) of %p\n",
-               &n1, &n1);
-       if (setjmp(aborted) == 0) {
-               ccan_list_check_node(&n1, "test message");
-               fail("ccan_list_check_node on n1 bad back ptr didn't fail!");
-       } else {
-               ok1(strcmp(printf_buffer, expect) == 0);
-       }
-
-       return exit_status();
-}
diff --git a/lib/ccan/list/test/run-list_del_from-assert.c b/lib/ccan/list/test/run-list_del_from-assert.c
deleted file mode 100644 (file)
index 37a3760..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#define CCAN_LIST_DEBUG 1
-#include <ccan/list/list.h>
-#include <ccan/tap/tap.h>
-#include <ccan/list/list.c>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <signal.h>
-
-int main(int argc, char *argv[])
-{
-       struct ccan_list_head list1, list2;
-       struct ccan_list_node n1, n2, n3;
-       pid_t child;
-       int status;
-
-       plan_tests(1);
-       ccan_list_head_init(&list1);
-       ccan_list_head_init(&list2);
-       ccan_list_add(&list1, &n1);
-       ccan_list_add(&list2, &n2);
-       ccan_list_add_tail(&list2, &n3);
-
-       child = fork();
-       if (child) {
-               wait(&status);
-       } else {
-               /* This should abort. */
-               ccan_list_del_from(&list1, &n3);
-               exit(0);
-       }
-
-       ok1(WIFSIGNALED(status) && WTERMSIG(status) == SIGABRT);
-       ccan_list_del_from(&list2, &n3);
-       return exit_status();
-}
diff --git a/lib/ccan/list/test/run-single-eval.c b/lib/ccan/list/test/run-single-eval.c
deleted file mode 100644 (file)
index 2737bec..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/* Make sure macros only evaluate their args once. */
-#include <ccan/list/list.h>
-#include <ccan/tap/tap.h>
-#include <ccan/list/list.c>
-
-struct parent {
-       const char *name;
-       struct ccan_list_head children;
-       unsigned int num_children;
-       int eval_count;
-};
-
-struct child {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-static CCAN_LIST_HEAD(static_list);
-
-#define ref(obj, counter) ((counter)++, (obj))
-
-int main(int argc, char *argv[])
-{
-       struct parent parent;
-       struct child c1, c2, c3, *c, *n;
-       unsigned int i;
-       unsigned int static_count = 0, parent_count = 0, list_count = 0,
-               node_count = 0;
-       struct ccan_list_head list = CCAN_LIST_HEAD_INIT(list);
-
-       plan_tests(74);
-       /* Test CCAN_LIST_HEAD, CCAN_LIST_HEAD_INIT, ccan_list_empty and check_list */
-       ok1(ccan_list_empty(ref(&static_list, static_count)));
-       ok1(static_count == 1);
-       ok1(ccan_list_check(ref(&static_list, static_count), NULL));
-       ok1(static_count == 2);
-       ok1(ccan_list_empty(ref(&list, list_count)));
-       ok1(list_count == 1);
-       ok1(ccan_list_check(ref(&list, list_count), NULL));
-       ok1(list_count == 2);
-
-       parent.num_children = 0;
-       ccan_list_head_init(ref(&parent.children, parent_count));
-       ok1(parent_count == 1);
-       /* Test ccan_list_head_init */
-       ok1(ccan_list_empty(ref(&parent.children, parent_count)));
-       ok1(parent_count == 2);
-       ok1(ccan_list_check(ref(&parent.children, parent_count), NULL));
-       ok1(parent_count == 3);
-
-       c2.name = "c2";
-       ccan_list_add(ref(&parent.children, parent_count), &c2.list);
-       ok1(parent_count == 4);
-       /* Test ccan_list_add and !ccan_list_empty. */
-       ok1(!ccan_list_empty(ref(&parent.children, parent_count)));
-       ok1(parent_count == 5);
-       ok1(c2.list.next == &parent.children.n);
-       ok1(c2.list.prev == &parent.children.n);
-       ok1(parent.children.n.next == &c2.list);
-       ok1(parent.children.n.prev == &c2.list);
-       /* Test ccan_list_check */
-       ok1(ccan_list_check(ref(&parent.children, parent_count), NULL));
-       ok1(parent_count == 6);
-
-       c1.name = "c1";
-       ccan_list_add(ref(&parent.children, parent_count), &c1.list);
-       ok1(parent_count == 7);
-       /* Test ccan_list_add and !ccan_list_empty. */
-       ok1(!ccan_list_empty(ref(&parent.children, parent_count)));
-       ok1(parent_count == 8);
-       ok1(c2.list.next == &parent.children.n);
-       ok1(c2.list.prev == &c1.list);
-       ok1(parent.children.n.next == &c1.list);
-       ok1(parent.children.n.prev == &c2.list);
-       ok1(c1.list.next == &c2.list);
-       ok1(c1.list.prev == &parent.children.n);
-       /* Test ccan_list_check */
-       ok1(ccan_list_check(ref(&parent.children, parent_count), NULL));
-       ok1(parent_count == 9);
-
-       c3.name = "c3";
-       ccan_list_add_tail(ref(&parent.children, parent_count), &c3.list);
-       ok1(parent_count == 10);
-       /* Test ccan_list_add_tail and !ccan_list_empty. */
-       ok1(!ccan_list_empty(ref(&parent.children, parent_count)));
-       ok1(parent_count == 11);
-       ok1(parent.children.n.next == &c1.list);
-       ok1(parent.children.n.prev == &c3.list);
-       ok1(c1.list.next == &c2.list);
-       ok1(c1.list.prev == &parent.children.n);
-       ok1(c2.list.next == &c3.list);
-       ok1(c2.list.prev == &c1.list);
-       ok1(c3.list.next == &parent.children.n);
-       ok1(c3.list.prev == &c2.list);
-       /* Test ccan_list_check */
-       ok1(ccan_list_check(ref(&parent.children, parent_count), NULL));
-       ok1(parent_count == 12);
-
-       /* Test ccan_list_check_node */
-       ok1(ccan_list_check_node(&c1.list, NULL));
-       ok1(ccan_list_check_node(&c2.list, NULL));
-       ok1(ccan_list_check_node(&c3.list, NULL));
-
-       /* Test ccan_list_top */
-       ok1(ccan_list_top(ref(&parent.children, parent_count), struct child, list) == &c1);
-       ok1(parent_count == 13);
-
-       /* Test ccan_list_tail */
-       ok1(ccan_list_tail(ref(&parent.children, parent_count), struct child, list) == &c3);
-       ok1(parent_count == 14);
-
-       /* Test ccan_list_for_each. */
-       i = 0;
-       ccan_list_for_each(&parent.children, c, list) {
-               switch (i++) {
-               case 0:
-                       ok1(c == &c1);
-                       break;
-               case 1:
-                       ok1(c == &c2);
-                       break;
-               case 2:
-                       ok1(c == &c3);
-                       break;
-               }
-               if (i > 2)
-                       break;
-       }
-       ok1(i == 3);
-
-       /* Test ccan_list_for_each_safe, ccan_list_del and ccan_list_del_from. */
-       i = 0;
-       ccan_list_for_each_safe(&parent.children, c, n, list) {
-               switch (i++) {
-               case 0:
-                       ok1(c == &c1);
-                       ccan_list_del(ref(&c->list, node_count));
-                       ok1(node_count == 1);
-                       break;
-               case 1:
-                       ok1(c == &c2);
-                       ccan_list_del_from(ref(&parent.children, parent_count),
-                                     ref(&c->list, node_count));
-                       ok1(node_count == 2);
-                       break;
-               case 2:
-                       ok1(c == &c3);
-                       ccan_list_del_from(ref(&parent.children, parent_count),
-                                     ref(&c->list, node_count));
-                       ok1(node_count == 3);
-                       break;
-               }
-               ok1(ccan_list_check(ref(&parent.children, parent_count), NULL));
-               if (i > 2)
-                       break;
-       }
-       ok1(i == 3);
-       ok1(parent_count == 19);
-       ok1(ccan_list_empty(ref(&parent.children, parent_count)));
-       ok1(parent_count == 20);
-
-       /* Test ccan_list_top/ccan_list_tail on empty list. */
-       ok1(ccan_list_top(ref(&parent.children, parent_count), struct child, list) == NULL);
-       ok1(parent_count == 21);
-       ok1(ccan_list_tail(ref(&parent.children, parent_count), struct child, list) == NULL);
-       ok1(parent_count == 22);
-       return exit_status();
-}
diff --git a/lib/ccan/list/test/run-with-debug.c b/lib/ccan/list/test/run-with-debug.c
deleted file mode 100644 (file)
index d090242..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/* Just like run.c, but with all debug checks enabled. */
-#define CCAN_LIST_DEBUG 1
-#include <ccan/list/test/run.c>
diff --git a/lib/ccan/list/test/run.c b/lib/ccan/list/test/run.c
deleted file mode 100644 (file)
index a93234d..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-#include <ccan/list/list.h>
-#include <ccan/tap/tap.h>
-#include <ccan/list/list.c>
-#include "helper.h"
-
-struct parent {
-       const char *name;
-       struct ccan_list_head children;
-       unsigned int num_children;
-};
-
-struct child {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-static CCAN_LIST_HEAD(static_list);
-
-int main(int argc, char *argv[])
-{
-       struct parent parent;
-       struct child c1, c2, c3, *c, *n;
-       unsigned int i;
-       struct ccan_list_head list = CCAN_LIST_HEAD_INIT(list);
-       opaque_t *q, *nq;
-       struct ccan_list_head opaque_list = CCAN_LIST_HEAD_INIT(opaque_list);
-
-       plan_tests(65);
-       /* Test CCAN_LIST_HEAD, CCAN_LIST_HEAD_INIT, ccan_list_empty and check_list */
-       ok1(ccan_list_empty(&static_list));
-       ok1(ccan_list_check(&static_list, NULL));
-       ok1(ccan_list_empty(&list));
-       ok1(ccan_list_check(&list, NULL));
-
-       parent.num_children = 0;
-       ccan_list_head_init(&parent.children);
-       /* Test ccan_list_head_init */
-       ok1(ccan_list_empty(&parent.children));
-       ok1(ccan_list_check(&parent.children, NULL));
-
-       c2.name = "c2";
-       ccan_list_add(&parent.children, &c2.list);
-       /* Test ccan_list_add and !ccan_list_empty. */
-       ok1(!ccan_list_empty(&parent.children));
-       ok1(c2.list.next == &parent.children.n);
-       ok1(c2.list.prev == &parent.children.n);
-       ok1(parent.children.n.next == &c2.list);
-       ok1(parent.children.n.prev == &c2.list);
-       /* Test ccan_list_check */
-       ok1(ccan_list_check(&parent.children, NULL));
-
-       c1.name = "c1";
-       ccan_list_add(&parent.children, &c1.list);
-       /* Test ccan_list_add and !ccan_list_empty. */
-       ok1(!ccan_list_empty(&parent.children));
-       ok1(c2.list.next == &parent.children.n);
-       ok1(c2.list.prev == &c1.list);
-       ok1(parent.children.n.next == &c1.list);
-       ok1(parent.children.n.prev == &c2.list);
-       ok1(c1.list.next == &c2.list);
-       ok1(c1.list.prev == &parent.children.n);
-       /* Test ccan_list_check */
-       ok1(ccan_list_check(&parent.children, NULL));
-
-       c3.name = "c3";
-       ccan_list_add_tail(&parent.children, &c3.list);
-       /* Test ccan_list_add_tail and !ccan_list_empty. */
-       ok1(!ccan_list_empty(&parent.children));
-       ok1(parent.children.n.next == &c1.list);
-       ok1(parent.children.n.prev == &c3.list);
-       ok1(c1.list.next == &c2.list);
-       ok1(c1.list.prev == &parent.children.n);
-       ok1(c2.list.next == &c3.list);
-       ok1(c2.list.prev == &c1.list);
-       ok1(c3.list.next == &parent.children.n);
-       ok1(c3.list.prev == &c2.list);
-       /* Test ccan_list_check */
-       ok1(ccan_list_check(&parent.children, NULL));
-
-       /* Test ccan_list_check_node */
-       ok1(ccan_list_check_node(&c1.list, NULL));
-       ok1(ccan_list_check_node(&c2.list, NULL));
-       ok1(ccan_list_check_node(&c3.list, NULL));
-
-       /* Test ccan_list_top */
-       ok1(ccan_list_top(&parent.children, struct child, list) == &c1);
-
-       /* Test ccan_list_tail */
-       ok1(ccan_list_tail(&parent.children, struct child, list) == &c3);
-
-       /* Test ccan_list_for_each. */
-       i = 0;
-       ccan_list_for_each(&parent.children, c, list) {
-               switch (i++) {
-               case 0:
-                       ok1(c == &c1);
-                       break;
-               case 1:
-                       ok1(c == &c2);
-                       break;
-               case 2:
-                       ok1(c == &c3);
-                       break;
-               }
-               if (i > 2)
-                       break;
-       }
-       ok1(i == 3);
-
-       /* Test ccan_list_for_each_rev. */
-       i = 0;
-       ccan_list_for_each_rev(&parent.children, c, list) {
-               switch (i++) {
-               case 0:
-                       ok1(c == &c3);
-                       break;
-               case 1:
-                       ok1(c == &c2);
-                       break;
-               case 2:
-                       ok1(c == &c1);
-                       break;
-               }
-               if (i > 2)
-                       break;
-       }
-       ok1(i == 3);
-
-       /* Test ccan_list_for_each_safe, ccan_list_del and ccan_list_del_from. */
-       i = 0;
-       ccan_list_for_each_safe(&parent.children, c, n, list) {
-               switch (i++) {
-               case 0:
-                       ok1(c == &c1);
-                       ccan_list_del(&c->list);
-                       break;
-               case 1:
-                       ok1(c == &c2);
-                       ccan_list_del_from(&parent.children, &c->list);
-                       break;
-               case 2:
-                       ok1(c == &c3);
-                       ccan_list_del_from(&parent.children, &c->list);
-                       break;
-               }
-               ok1(ccan_list_check(&parent.children, NULL));
-               if (i > 2)
-                       break;
-       }
-       ok1(i == 3);
-       ok1(ccan_list_empty(&parent.children));
-
-       /* Test ccan_list_for_each_off. */
-       ccan_list_add_tail(&opaque_list,
-                     (struct ccan_list_node *)create_opaque_blob());
-       ccan_list_add_tail(&opaque_list,
-                     (struct ccan_list_node *)create_opaque_blob());
-       ccan_list_add_tail(&opaque_list,
-                     (struct ccan_list_node *)create_opaque_blob());
-
-       i = 0;
-
-       ccan_list_for_each_off(&opaque_list, q, 0) {
-         i++;
-         ok1(if_blobs_know_the_secret(q));
-       }
-       ok1(i == 3);
-
-       /* Test ccan_list_for_each_safe_off, ccan_list_del_off and ccan_list_del_from_off. */
-       i = 0;
-       ccan_list_for_each_safe_off(&opaque_list, q, nq, 0) {
-               switch (i++) {
-               case 0:
-                       ok1(if_blobs_know_the_secret(q));
-                       ccan_list_del_off(q, 0);
-                       destroy_opaque_blob(q);
-                       break;
-               case 1:
-                       ok1(if_blobs_know_the_secret(q));
-                       ccan_list_del_from_off(&opaque_list, q, 0);
-                       destroy_opaque_blob(q);
-                       break;
-               case 2:
-                       ok1(c == &c3);
-                       ccan_list_del_from_off(&opaque_list, q, 0);
-                       destroy_opaque_blob(q);
-                       break;
-               }
-               ok1(ccan_list_check(&opaque_list, NULL));
-               if (i > 2)
-                       break;
-       }
-       ok1(i == 3);
-       ok1(ccan_list_empty(&opaque_list));
-
-       /* Test ccan_list_top/ccan_list_tail on empty list. */
-       ok1(ccan_list_top(&parent.children, struct child, list) == NULL);
-       ok1(ccan_list_tail(&parent.children, struct child, list) == NULL);
-       return exit_status();
-}
diff --git a/lib/ccan/read_write_all/LICENSE b/lib/ccan/read_write_all/LICENSE
deleted file mode 100644 (file)
index 5522aa5..0000000
+++ /dev/null
@@ -1,508 +0,0 @@
-
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
-       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL.  It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
-                            Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations
-below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-\f
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it
-becomes a de-facto standard.  To achieve this, non-free programs must
-be allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-\f
-                  GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control
-compilation and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-\f
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at least
-    three years, to give the same user the materials specified in
-    Subsection 6a, above, for a charge no more than the cost of
-    performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-\f
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply, and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License
-may add an explicit geographical distribution limitation excluding those
-countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-                            NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-                     END OF TERMS AND CONDITIONS
-\f
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms
-of the ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.
-It is safest to attach them to the start of each source file to most
-effectively convey the exclusion of warranty; and each file should
-have at least the "copyright" line and a pointer to where the full
-notice is found.
-
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or
-your school, if any, to sign a "copyright disclaimer" for the library,
-if necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James
-  Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/lib/ccan/read_write_all/_info b/lib/ccan/read_write_all/_info
deleted file mode 100644 (file)
index d70cbd1..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * read_write_all - read_all and write_all routines.
- *
- * Successful read and write calls may only partly complete if a
- * signal is received or they are not operating on a normal file.
- *
- * read_all() and write_all() do the looping for you.
- *
- * Example:
- *     #include <err.h>
- *     #include <stdio.h>
- *     #include <unistd.h>
- *     #include <ccan/read_write_all/read_write_all.h>
- *
- *     #define BUFFER_SIZE 10
- *     int main(int argc, char *argv[])
- *     {
- *             char buffer[BUFFER_SIZE+1];
- *
- *             if (!read_all(STDIN_FILENO, buffer, BUFFER_SIZE))
- *                     err(1, "Could not read %u characters", BUFFER_SIZE);
- *             buffer[BUFFER_SIZE] = '\0';
- *             printf("I read '%.*s'\n", BUFFER_SIZE, buffer);
- *             return 0;
- *     }
- *
- * License: LGPL (v2.1 or any later version)
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/read_write_all/read_write_all.c b/lib/ccan/read_write_all/read_write_all.c
deleted file mode 100644 (file)
index c66d521..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Licensed under LGPLv2+ - see LICENSE file for details */
-#include "read_write_all.h"
-#include <unistd.h>
-#include <errno.h>
-
-bool write_all(int fd, const void *data, size_t size)
-{
-       while (size) {
-               ssize_t done;
-
-               done = write(fd, data, size);
-               if (done < 0 && errno == EINTR)
-                       continue;
-               if (done <= 0)
-                       return false;
-               data = (const char *)data + done;
-               size -= done;
-       }
-
-       return true;
-}
-
-bool read_all(int fd, void *data, size_t size)
-{
-       while (size) {
-               ssize_t done;
-
-               done = read(fd, data, size);
-               if (done < 0 && errno == EINTR)
-                       continue;
-               if (done <= 0)
-                       return false;
-               data = (char *)data + done;
-               size -= done;
-       }
-
-       return true;
-}
diff --git a/lib/ccan/read_write_all/read_write_all.d b/lib/ccan/read_write_all/read_write_all.d
deleted file mode 100644 (file)
index f3f48f0..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-ccan/read_write_all/read_write_all.o: \
- ccan/read_write_all/read_write_all.c \
- ccan/read_write_all/read_write_all.h \
- /usr/lib/gcc/i686-linux-gnu/4.5.4/include/stddef.h \
- /usr/lib/gcc/i686-linux-gnu/4.5.4/include/stdbool.h \
- /usr/include/unistd.h /usr/include/features.h \
- /usr/include/i386-linux-gnu/bits/predefs.h \
- /usr/include/i386-linux-gnu/sys/cdefs.h \
- /usr/include/i386-linux-gnu/bits/wordsize.h \
- /usr/include/i386-linux-gnu/gnu/stubs.h \
- /usr/include/i386-linux-gnu/gnu/stubs-32.h \
- /usr/include/i386-linux-gnu/bits/posix_opt.h \
- /usr/include/i386-linux-gnu/bits/environments.h \
- /usr/include/i386-linux-gnu/bits/types.h \
- /usr/include/i386-linux-gnu/bits/typesizes.h \
- /usr/include/i386-linux-gnu/bits/confname.h /usr/include/getopt.h \
- /usr/include/errno.h /usr/include/i386-linux-gnu/bits/errno.h \
- /usr/include/linux/errno.h /usr/include/i386-linux-gnu/asm/errno.h \
- /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h
diff --git a/lib/ccan/read_write_all/read_write_all.h b/lib/ccan/read_write_all/read_write_all.h
deleted file mode 100644 (file)
index aa2635a..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/* Licensed under LGPLv2+ - see LICENSE file for details */
-#ifndef _CCAN_READ_WRITE_H
-#define _CCAN_READ_WRITE_H
-#include <stddef.h>
-#include <stdbool.h>
-
-bool write_all(int fd, const void *data, size_t size);
-bool read_all(int fd, void *data, size_t size);
-
-#endif /* _CCAN_READ_WRITE_H */
diff --git a/lib/ccan/read_write_all/test/run-read_all.c b/lib/ccan/read_write_all/test/run-read_all.c
deleted file mode 100644 (file)
index 29f81fc..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/* FIXME: Do something tricky to ensure we really do loop in read_all. */
-
-#include <ccan/read_write_all/read_write_all.h>
-#include <ccan/read_write_all/read_write_all.c>
-#include <ccan/tap/tap.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <sys/wait.h>
-#include <limits.h>
-#include <err.h>
-#include <stdlib.h>
-#include <string.h>
-
-static volatile int sigcount;
-static int p2c[2], c2p[2];
-static void got_signal(int sig)
-{
-       char c = 0;
-       if (write(p2c[1], &c, 1) == 1)
-               sigcount++;
-}
-
-/* < PIPE_BUF *will* be atomic.  But > PIPE_BUF only *might* be non-atomic. */
-#define BUFSZ (1024*1024)
-
-int main(int argc, char *argv[])
-{
-       char *buffer;
-       char c = 0;
-       int status;
-       pid_t child;
-
-       buffer = calloc(BUFSZ, 2);
-       plan_tests(6);
-
-       /* We fork and torture parent. */
-       if (pipe(p2c) != 0 || pipe(c2p) != 0)
-               err(1, "pipe");
-       child = fork();
-
-       if (!child) {
-               close(p2c[1]);
-               close(c2p[0]);
-               /* Child.  Make sure parent ready, then write in two parts. */
-               if (read(p2c[0], &c, 1) != 1)
-                       exit(1);
-               memset(buffer, 0xff, BUFSZ*2);
-               if (!write_all(c2p[1], buffer, BUFSZ))
-                       exit(2);
-               if (kill(getppid(), SIGUSR1) != 0)
-                       exit(3);
-               /* Make sure they get signal. */
-               if (read(p2c[0], &c, 1) != 1)
-                       exit(4);
-               if (write(c2p[1], buffer, BUFSZ) != BUFSZ)
-                       exit(5);
-               exit(0);
-       }
-       if (child == -1)
-               err(1, "forking");
-
-       close(p2c[0]);
-       close(c2p[1]);
-       signal(SIGUSR1, got_signal);
-       ok1(write(p2c[1], &c, 1) == 1);
-       ok1(read_all(c2p[0], buffer, BUFSZ*2));
-       ok1(memchr(buffer, 0, BUFSZ*2) == NULL);
-       ok1(sigcount == 1);
-       ok1(wait(&status) == child);
-       ok(WIFEXITED(status) && WEXITSTATUS(status) == 0,
-          "WIFEXITED(status) = %u, WEXITSTATUS(status) = %u",
-          WIFEXITED(status), WEXITSTATUS(status));
-       free(buffer);
-       return exit_status();
-}
diff --git a/lib/ccan/read_write_all/test/run-write_all.c b/lib/ccan/read_write_all/test/run-write_all.c
deleted file mode 100644 (file)
index e2baf48..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#include <ccan/read_write_all/read_write_all.h>
-#include <ccan/tap/tap.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <limits.h>
-#include <sys/wait.h>
-#include <err.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-static ssize_t test_write(int fd, const void *buf, size_t count);
-#define write test_write
-#include <ccan/read_write_all/read_write_all.c>
-#undef write
-
-static ssize_t write_return;
-
-static ssize_t test_write(int fd, const void *buf, size_t count)
-{
-       if (write_return == 0) {
-               errno = ENOSPC;
-               return 0;
-       }
-
-       if (write_return < 0) {
-               errno = -write_return;
-               /* Don't return EINTR more than once! */
-               if (errno == EINTR)
-                       write_return = count;
-               return -1;
-       }
-
-       if (write_return < count)
-               return write_return;
-       return count;
-}
-
-#define BUFSZ 1024
-
-int main(int argc, char *argv[])
-{
-       char *buffer;
-
-       buffer = malloc(BUFSZ);
-       plan_tests(8);
-
-       write_return = -ENOSPC;
-       ok1(!write_all(100, buffer, BUFSZ));
-       ok1(errno == ENOSPC);
-
-       write_return = -EINTR;
-       ok1(write_all(100, buffer, BUFSZ));
-       ok1(errno == EINTR);
-
-       write_return = 1;
-       errno = 0;
-       ok1(write_all(100, buffer, BUFSZ));
-       ok1(errno == 0);
-
-       write_return = BUFSZ;
-       ok1(write_all(100, buffer, BUFSZ));
-       ok1(errno == 0);
-       free(buffer);
-
-       return exit_status();
-}
diff --git a/lib/ccan/str/_info b/lib/ccan/str/_info
deleted file mode 100644 (file)
index a6858c3..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * str - string helper routines
- *
- * This is a grab bag of functions for string operations, designed to enhance
- * the standard string.h.
- *
- * Note that if you define CCAN_STR_DEBUG, you will get extra compile
- * checks on common misuses of the following functions (they will now
- * be out-of-line, so there is a runtime penalty!).
- *
- *     strstr, strchr, strrchr:
- *             Return const char * if first argument is const (gcc only).
- *
- *     isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph,
- *         islower, isprint, ispunct, isspace, isupper, isxdigit:
- *             Static and runtime check that input is EOF or an *unsigned*
- *             char, as per C standard (really!).
- *
- * Example:
- *     #include <stdio.h>
- *     #include <ccan/str/str.h>
- *
- *     int main(int argc, char *argv[])
- *     {
- *             if (argv[1] && streq(argv[1], "--verbose"))
- *                     printf("verbose set\n");
- *             if (argv[1] && strstarts(argv[1], "--"))
- *                     printf("Some option set\n");
- *             if (argv[1] && strends(argv[1], "cow-powers"))
- *                     printf("Magic option set\n");
- *             return 0;
- *     }
- *
- * License: Public domain
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               printf("ccan/build_assert\n");
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/str/debug.c b/lib/ccan/str/debug.c
deleted file mode 100644 (file)
index 027915b..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-#include "config.h"
-#include <ccan/str/str_debug.h>
-#include <assert.h>
-#include <ctype.h>
-#include <string.h>
-
-#ifdef CCAN_STR_DEBUG
-/* Because we mug the real ones with macros, we need our own wrappers. */
-int str_isalnum(int i)
-{
-       assert(i >= -1 && i < 256);
-       return isalnum(i);
-}
-
-int str_isalpha(int i)
-{
-       assert(i >= -1 && i < 256);
-       return isalpha(i);
-}
-
-int str_isascii(int i)
-{
-       assert(i >= -1 && i < 256);
-       return isascii(i);
-}
-
-#if HAVE_ISBLANK
-int str_isblank(int i)
-{
-       assert(i >= -1 && i < 256);
-       return isblank(i);
-}
-#endif
-
-int str_iscntrl(int i)
-{
-       assert(i >= -1 && i < 256);
-       return iscntrl(i);
-}
-
-int str_isdigit(int i)
-{
-       assert(i >= -1 && i < 256);
-       return isdigit(i);
-}
-
-int str_isgraph(int i)
-{
-       assert(i >= -1 && i < 256);
-       return isgraph(i);
-}
-
-int str_islower(int i)
-{
-       assert(i >= -1 && i < 256);
-       return islower(i);
-}
-
-int str_isprint(int i)
-{
-       assert(i >= -1 && i < 256);
-       return isprint(i);
-}
-
-int str_ispunct(int i)
-{
-       assert(i >= -1 && i < 256);
-       return ispunct(i);
-}
-
-int str_isspace(int i)
-{
-       assert(i >= -1 && i < 256);
-       return isspace(i);
-}
-
-int str_isupper(int i)
-{
-       assert(i >= -1 && i < 256);
-       return isupper(i);
-}
-
-int str_isxdigit(int i)
-{
-       assert(i >= -1 && i < 256);
-       return isxdigit(i);
-}
-
-#undef strstr
-#undef strchr
-#undef strrchr
-
-char *str_strstr(const char *haystack, const char *needle)
-{
-       return strstr(haystack, needle);
-}
-
-char *str_strchr(const char *haystack, int c)
-{
-       return strchr(haystack, c);
-}
-
-char *str_strrchr(const char *haystack, int c)
-{
-       return strrchr(haystack, c);
-}
-#endif
diff --git a/lib/ccan/str/str.c b/lib/ccan/str/str.c
deleted file mode 100644 (file)
index fa9809f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <ccan/str/str.h>
-
-size_t strcount(const char *haystack, const char *needle)
-{
-       size_t i = 0, nlen = strlen(needle);
-
-       while ((haystack = strstr(haystack, needle)) != NULL) {
-               i++;
-               haystack += nlen;
-       }
-       return i;
-}
diff --git a/lib/ccan/str/str.h b/lib/ccan/str/str.h
deleted file mode 100644 (file)
index 14cd65a..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/* Placed into the public domain. */
-#ifndef CCAN_STR_H
-#define CCAN_STR_H
-#include "config.h"
-#include <string.h>
-#include <stdbool.h>
-#include <ctype.h>
-
-/**
- * streq - Are two strings equal?
- * @a: first string
- * @b: first string
- *
- * This macro is arguably more readable than "!strcmp(a, b)".
- *
- * Example:
- *     if (streq(somestring, ""))
- *             printf("String is empty!\n");
- */
-#define streq(a,b) (strcmp((a),(b)) == 0)
-
-/**
- * strstarts - Does this string start with this prefix?
- * @str: string to test
- * @prefix: prefix to look for at start of str
- *
- * Example:
- *     if (strstarts(somestring, "foo"))
- *             printf("String %s begins with 'foo'!\n", somestring);
- */
-#define strstarts(str,prefix) (strncmp((str),(prefix),strlen(prefix)) == 0)
-
-/**
- * strends - Does this string end with this postfix?
- * @str: string to test
- * @postfix: postfix to look for at end of str
- *
- * Example:
- *     if (strends(somestring, "foo"))
- *             printf("String %s end with 'foo'!\n", somestring);
- */
-static inline bool strends(const char *str, const char *postfix)
-{
-       if (strlen(str) < strlen(postfix))
-               return false;
-
-       return streq(str + strlen(str) - strlen(postfix), postfix);
-}
-
-/**
- * stringify - Turn expression into a string literal
- * @expr: any C expression
- *
- * Example:
- *     #define PRINT_COND_IF_FALSE(cond) \
- *             ((cond) || printf("%s is false!", stringify(cond)))
- */
-#define stringify(expr)                stringify_1(expr)
-/* Double-indirection required to stringify expansions */
-#define stringify_1(expr)      #expr
-
-/**
- * strcount - Count number of (non-overlapping) occurrences of a substring.
- * @haystack: a C string
- * @needle: a substring
- *
- * Example:
- *     int i;
- *      i = strcount("aaa aaa", "a");  // i = 6;
- *      i = strcount("aaa aaa", "ab"); // i = 0;
- *      i = strcount("aaa aaa", "aa"); // i = 2;
- */
-size_t strcount(const char *haystack, const char *needle);
-
-/**
- * cisalnum - isalnum() which takes a char (and doesn't accept EOF)
- * @c: a character
- *
- * Surprisingly, the standard ctype.h isalnum() takes an int, which
- * must have the value of EOF (-1) or an unsigned char.  This variant
- * takes a real char, and doesn't accept EOF.
- */
-static inline bool cisalnum(char c)
-{
-       return isalnum((unsigned char)c);
-}
-static inline bool cisalpha(char c)
-{
-       return isalpha((unsigned char)c);
-}
-static inline bool cisascii(char c)
-{
-       return isascii((unsigned char)c);
-}
-#if HAVE_ISBLANK
-static inline bool cisblank(char c)
-{
-       return isblank((unsigned char)c);
-}
-#endif
-static inline bool ciscntrl(char c)
-{
-       return iscntrl((unsigned char)c);
-}
-static inline bool cisdigit(char c)
-{
-       return isdigit((unsigned char)c);
-}
-static inline bool cisgraph(char c)
-{
-       return isgraph((unsigned char)c);
-}
-static inline bool cislower(char c)
-{
-       return islower((unsigned char)c);
-}
-static inline bool cisprint(char c)
-{
-       return isprint((unsigned char)c);
-}
-static inline bool cispunct(char c)
-{
-       return ispunct((unsigned char)c);
-}
-static inline bool cisspace(char c)
-{
-       return isspace((unsigned char)c);
-}
-static inline bool cisupper(char c)
-{
-       return isupper((unsigned char)c);
-}
-static inline bool cisxdigit(char c)
-{
-       return isxdigit((unsigned char)c);
-}
-
-#include <ccan/str/str_debug.h>
-
-/* These checks force things out of line, hence they are under DEBUG. */
-#ifdef CCAN_STR_DEBUG
-#include <ccan/build_assert/build_assert.h>
-
-/* These are commonly misused: they take -1 or an *unsigned* char value. */
-#undef isalnum
-#undef isalpha
-#undef isascii
-#undef isblank
-#undef iscntrl
-#undef isdigit
-#undef isgraph
-#undef islower
-#undef isprint
-#undef ispunct
-#undef isspace
-#undef isupper
-#undef isxdigit
-
-/* You can use a char if char is unsigned. */
-#if HAVE_BUILTIN_TYPES_COMPATIBLE_P && HAVE_TYPEOF
-#define str_check_arg_(i)                                              \
-       ((i) + BUILD_ASSERT_OR_ZERO(!__builtin_types_compatible_p(typeof(i), \
-                                                                 char) \
-                                   || (char)255 > 0))
-#else
-#define str_check_arg_(i) (i)
-#endif
-
-#define isalnum(i) str_isalnum(str_check_arg_(i))
-#define isalpha(i) str_isalpha(str_check_arg_(i))
-#define isascii(i) str_isascii(str_check_arg_(i))
-#if HAVE_ISBLANK
-#define isblank(i) str_isblank(str_check_arg_(i))
-#endif
-#define iscntrl(i) str_iscntrl(str_check_arg_(i))
-#define isdigit(i) str_isdigit(str_check_arg_(i))
-#define isgraph(i) str_isgraph(str_check_arg_(i))
-#define islower(i) str_islower(str_check_arg_(i))
-#define isprint(i) str_isprint(str_check_arg_(i))
-#define ispunct(i) str_ispunct(str_check_arg_(i))
-#define isspace(i) str_isspace(str_check_arg_(i))
-#define isupper(i) str_isupper(str_check_arg_(i))
-#define isxdigit(i) str_isxdigit(str_check_arg_(i))
-
-#if HAVE_TYPEOF
-/* With GNU magic, we can make const-respecting standard string functions. */
-#undef strstr
-#undef strchr
-#undef strrchr
-
-/* + 0 is needed to decay array into pointer. */
-#define strstr(haystack, needle)                                       \
-       ((typeof((haystack) + 0))str_strstr((haystack), (needle)))
-#define strchr(haystack, c)                                    \
-       ((typeof((haystack) + 0))str_strchr((haystack), (c)))
-#define strrchr(haystack, c)                                   \
-       ((typeof((haystack) + 0))str_strrchr((haystack), (c)))
-#endif
-#endif /* CCAN_STR_DEBUG */
-
-#endif /* CCAN_STR_H */
diff --git a/lib/ccan/str/str_debug.h b/lib/ccan/str/str_debug.h
deleted file mode 100644 (file)
index 6b56477..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef CCAN_STR_DEBUG_H
-#define CCAN_STR_DEBUG_H
-
-/* #define CCAN_STR_DEBUG 1 */
-
-#ifdef CCAN_STR_DEBUG
-/* Because we mug the real ones with macros, we need our own wrappers. */
-int str_isalnum(int i);
-int str_isalpha(int i);
-int str_isascii(int i);
-#if HAVE_ISBLANK
-int str_isblank(int i);
-#endif
-int str_iscntrl(int i);
-int str_isdigit(int i);
-int str_isgraph(int i);
-int str_islower(int i);
-int str_isprint(int i);
-int str_ispunct(int i);
-int str_isspace(int i);
-int str_isupper(int i);
-int str_isxdigit(int i);
-
-char *str_strstr(const char *haystack, const char *needle);
-char *str_strchr(const char *s, int c);
-char *str_strrchr(const char *s, int c);
-#endif /* CCAN_STR_DEBUG */
-
-#endif /* CCAN_STR_DEBUG_H */
diff --git a/lib/ccan/str/test/compile_fail-isalnum.c b/lib/ccan/str/test/compile_fail-isalnum.c
deleted file mode 100644 (file)
index 930deff..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/str.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
-#error We need typeof to check isalnum.
-#endif
-       char
-#else
-       unsigned char
-#endif
-               c = argv[0][0];
-
-#ifdef FAIL
-       /* Fake fail on unsigned char platforms. */
-       BUILD_ASSERT((char)255 < 0);
-#endif
-
-       return isalnum(c);
-}
diff --git a/lib/ccan/str/test/compile_fail-isalpha.c b/lib/ccan/str/test/compile_fail-isalpha.c
deleted file mode 100644 (file)
index 2005109..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/str.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
-#error We need typeof to check isalpha.
-#endif
-       char
-#else
-       unsigned char
-#endif
-               c = argv[0][0];
-
-#ifdef FAIL
-       /* Fake fail on unsigned char platforms. */
-       BUILD_ASSERT((char)255 < 0);
-#endif
-
-       return isalpha(c);
-}
diff --git a/lib/ccan/str/test/compile_fail-isascii.c b/lib/ccan/str/test/compile_fail-isascii.c
deleted file mode 100644 (file)
index ee55e49..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/str.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
-#error We need typeof to check isascii.
-#endif
-       char
-#else
-       unsigned char
-#endif
-               c = argv[0][0];
-
-#ifdef FAIL
-       /* Fake fail on unsigned char platforms. */
-       BUILD_ASSERT((char)255 < 0);
-#endif
-
-       return isascii(c);
-}
diff --git a/lib/ccan/str/test/compile_fail-isblank.c b/lib/ccan/str/test/compile_fail-isblank.c
deleted file mode 100644 (file)
index f4cb961..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/str.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF || !HAVE_ISBLANK
-#error We need typeof to check isblank.
-#endif
-       char
-#else
-       unsigned char
-#endif
-               c = argv[0][0];
-
-#ifdef FAIL
-       /* Fake fail on unsigned char platforms. */
-       BUILD_ASSERT((char)255 < 0);
-#endif
-
-#if HAVE_ISBLANK
-       return isblank(c);
-#else
-       return c;
-#endif
-}
diff --git a/lib/ccan/str/test/compile_fail-iscntrl.c b/lib/ccan/str/test/compile_fail-iscntrl.c
deleted file mode 100644 (file)
index bc74146..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/str.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
-#error We need typeof to check iscntrl.
-#endif
-       char
-#else
-       unsigned char
-#endif
-               c = argv[0][0];
-
-#ifdef FAIL
-       /* Fake fail on unsigned char platforms. */
-       BUILD_ASSERT((char)255 < 0);
-#endif
-
-       return iscntrl(c);
-}
diff --git a/lib/ccan/str/test/compile_fail-isdigit.c b/lib/ccan/str/test/compile_fail-isdigit.c
deleted file mode 100644 (file)
index 71d1c71..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/str.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
-#error We need typeof to check isdigit.
-#endif
-       char
-#else
-       unsigned char
-#endif
-               c = argv[0][0];
-
-#ifdef FAIL
-       /* Fake fail on unsigned char platforms. */
-       BUILD_ASSERT((char)255 < 0);
-#endif
-
-       return isdigit(c);
-}
diff --git a/lib/ccan/str/test/compile_fail-islower.c b/lib/ccan/str/test/compile_fail-islower.c
deleted file mode 100644 (file)
index ca3f990..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/str.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
-#error We need typeof to check islower.
-#endif
-       char
-#else
-       unsigned char
-#endif
-               c = argv[0][0];
-
-#ifdef FAIL
-       /* Fake fail on unsigned char platforms. */
-       BUILD_ASSERT((char)255 < 0);
-#endif
-
-       return islower(c);
-}
diff --git a/lib/ccan/str/test/compile_fail-isprint.c b/lib/ccan/str/test/compile_fail-isprint.c
deleted file mode 100644 (file)
index 6432e41..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/str.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
-#error We need typeof to check isprint.
-#endif
-       char
-#else
-       unsigned char
-#endif
-               c = argv[0][0];
-
-#ifdef FAIL
-       /* Fake fail on unsigned char platforms. */
-       BUILD_ASSERT((char)255 < 0);
-#endif
-
-       return isprint(c);
-}
diff --git a/lib/ccan/str/test/compile_fail-ispunct.c b/lib/ccan/str/test/compile_fail-ispunct.c
deleted file mode 100644 (file)
index 5d941fc..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/str.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
-#error We need typeof to check ispunct.
-#endif
-       char
-#else
-       unsigned char
-#endif
-               c = argv[0][0];
-
-#ifdef FAIL
-       /* Fake fail on unsigned char platforms. */
-       BUILD_ASSERT((char)255 < 0);
-#endif
-
-       return ispunct(c);
-}
diff --git a/lib/ccan/str/test/compile_fail-isspace.c b/lib/ccan/str/test/compile_fail-isspace.c
deleted file mode 100644 (file)
index bfee1f8..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/str.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
-#error We need typeof to check isspace.
-#endif
-       char
-#else
-       unsigned char
-#endif
-               c = argv[0][0];
-
-#ifdef FAIL
-       /* Fake fail on unsigned char platforms. */
-       BUILD_ASSERT((char)255 < 0);
-#endif
-
-       return isspace(c);
-}
diff --git a/lib/ccan/str/test/compile_fail-isupper.c b/lib/ccan/str/test/compile_fail-isupper.c
deleted file mode 100644 (file)
index 4cf9fd3..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/str.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
-#error We need typeof to check isupper.
-#endif
-       char
-#else
-       unsigned char
-#endif
-               c = argv[0][0];
-
-#ifdef FAIL
-       /* Fake fail on unsigned char platforms. */
-       BUILD_ASSERT((char)255 < 0);
-#endif
-
-       return isupper(c);
-}
diff --git a/lib/ccan/str/test/compile_fail-isxdigit.c b/lib/ccan/str/test/compile_fail-isxdigit.c
deleted file mode 100644 (file)
index 65e6006..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/str.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF
-#error We need typeof to check isxdigit.
-#endif
-       char
-#else
-       unsigned char
-#endif
-               c = argv[0][0];
-
-#ifdef FAIL
-       /* Fake fail on unsigned char platforms. */
-       BUILD_ASSERT((char)255 < 0);
-#endif
-
-       return isxdigit(c);
-}
diff --git a/lib/ccan/str/test/compile_fail-strchr.c b/lib/ccan/str/test/compile_fail-strchr.c
deleted file mode 100644 (file)
index 74a7314..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/str.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if !HAVE_TYPEOF
-       #error We need typeof to check strstr.
-#endif
-#else
-       const
-#endif
-               char *ret;
-       const char *str = "hello";
-
-       ret = strchr(str, 'l');
-       return ret ? 0 : 1;
-}
diff --git a/lib/ccan/str/test/compile_fail-strrchr.c b/lib/ccan/str/test/compile_fail-strrchr.c
deleted file mode 100644 (file)
index ba7d17e..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/str.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if !HAVE_TYPEOF
-       #error We need typeof to check strstr.
-#endif
-#else
-       const
-#endif
-               char *ret;
-       const char *str = "hello";
-
-       ret = strrchr(str, 'l');
-       return ret ? 0 : 1;
-}
diff --git a/lib/ccan/str/test/compile_fail-strstr.c b/lib/ccan/str/test/compile_fail-strstr.c
deleted file mode 100644 (file)
index deefef6..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/str.h>
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-#if !HAVE_TYPEOF
-       #error We need typeof to check strstr.
-#endif
-#else
-       const
-#endif
-               char *ret;
-       const char *str = "hello";
-
-       ret = strstr(str, "hell");
-       return ret ? 0 : 1;
-}
diff --git a/lib/ccan/str/test/debug.c b/lib/ccan/str/test/debug.c
deleted file mode 100644 (file)
index 4bd384f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-/* We can't use the normal "#include the .c file" trick, since this is
-   contaminated by str.h's macro overrides.  So we put it in all tests
-   like this. */
-#define CCAN_STR_DEBUG 1
-#include <ccan/str/debug.c>
diff --git a/lib/ccan/str/test/run.c b/lib/ccan/str/test/run.c
deleted file mode 100644 (file)
index f253746..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-#include <ccan/str/str.h>
-#include <ccan/str/str.c>
-#include <stdlib.h>
-#include <stdio.h>
-#include <ccan/tap/tap.h>
-
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
-
-static const char *substrings[] = { "far", "bar", "baz", "b", "ba", "z", "ar",
-                                   NULL };
-
-#define NUM_SUBSTRINGS (ARRAY_SIZE(substrings) - 1)
-
-static char *strdup_rev(const char *s)
-{
-       char *ret = strdup(s);
-       unsigned int i;
-
-       for (i = 0; i < strlen(s); i++)
-               ret[i] = s[strlen(s) - i - 1];
-       return ret;
-}
-
-int main(int argc, char *argv[])
-{
-       unsigned int i, j, n;
-       char *strings[NUM_SUBSTRINGS * NUM_SUBSTRINGS];
-
-       n = 0;
-       for (i = 0; i < NUM_SUBSTRINGS; i++) {
-               for (j = 0; j < NUM_SUBSTRINGS; j++) {
-                       strings[n] = malloc(strlen(substrings[i])
-                                           + strlen(substrings[j]) + 1);
-                       sprintf(strings[n++], "%s%s",
-                               substrings[i], substrings[j]);
-               }
-       }
-
-       plan_tests(n * n * 5 + 16);
-       for (i = 0; i < n; i++) {
-               for (j = 0; j < n; j++) {
-                       unsigned int k, identical = 0;
-                       char *reva, *revb;
-
-                       /* Find first difference. */
-                       for (k = 0; strings[i][k]==strings[j][k]; k++) {
-                               if (k == strlen(strings[i])) {
-                                       identical = 1;
-                                       break;
-                               }
-                       }
-
-                       if (identical)
-                               ok1(streq(strings[i], strings[j]));
-                       else
-                               ok1(!streq(strings[i], strings[j]));
-
-                       /* Postfix test should be equivalent to prefix
-                        * test on reversed string. */
-                       reva = strdup_rev(strings[i]);
-                       revb = strdup_rev(strings[j]);
-
-                       if (!strings[i][k]) {
-                               ok1(strstarts(strings[j], strings[i]));
-                               ok1(strends(revb, reva));
-                       } else {
-                               ok1(!strstarts(strings[j], strings[i]));
-                               ok1(!strends(revb, reva));
-                       }
-                       if (!strings[j][k]) {
-                               ok1(strstarts(strings[i], strings[j]));
-                               ok1(strends(reva, revb));
-                       } else {
-                               ok1(!strstarts(strings[i], strings[j]));
-                               ok1(!strends(reva, revb));
-                       }
-                       free(reva);
-                       free(revb);
-               }
-       }
-
-       for (i = 0; i < n; i++)
-               free(strings[i]);
-
-       ok1(streq(stringify(NUM_SUBSTRINGS),
-                 "((sizeof(substrings) / sizeof(substrings[0])) - 1)"));
-       ok1(streq(stringify(ARRAY_SIZE(substrings)),
-                 "(sizeof(substrings) / sizeof(substrings[0]))"));
-       ok1(streq(stringify(i == 0), "i == 0"));
-
-       ok1(strcount("aaaaaa", "b") == 0);
-       ok1(strcount("aaaaaa", "a") == 6);
-       ok1(strcount("aaaaaa", "aa") == 3);
-       ok1(strcount("aaaaaa", "aaa") == 2);
-       ok1(strcount("aaaaaa", "aaaa") == 1);
-       ok1(strcount("aaaaaa", "aaaaa") == 1);
-       ok1(strcount("aaaaaa", "aaaaaa") == 1);
-       ok1(strcount("aaa aaa", "b") == 0);
-       ok1(strcount("aaa aaa", "a") == 6);
-       ok1(strcount("aaa aaa", "aa") == 2);
-       ok1(strcount("aaa aaa", "aaa") == 2);
-       ok1(strcount("aaa aaa", "aaaa") == 0);
-       ok1(strcount("aaa aaa", "aaaaa") == 0);
-
-       return exit_status();
-}
diff --git a/lib/ccan/strset/tools/Makefile b/lib/ccan/strset/tools/Makefile
deleted file mode 100644 (file)
index 77b1f7d..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-CFLAGS=-Wall -Werror -O3 -I../../..
-#CFLAGS=-Wall -Werror -g -I../../..
-
-all: cbspeed speed
-
-cbspeed: cbspeed.o ../../talloc.o ../../str_talloc.o ../../grab_file.o ../../str.o ../../time.o ../../noerr.o
-
-speed: speed.o ../../talloc.o ../../str_talloc.o ../../grab_file.o ../../str.o ../../time.o ../../noerr.o
-
-clean:
-       rm -f cbspeed speed speed.o cbspeed.o
diff --git a/lib/ccan/strset/tools/cbspeed.c b/lib/ccan/strset/tools/cbspeed.c
deleted file mode 100644 (file)
index a176649..0000000
+++ /dev/null
@@ -1,590 +0,0 @@
-/* Simple speed tests using original critbit code (modified not to allocate).
- *
- * Results on my 32 bit Intel(R) Core(TM) i5 CPU M 560  @ 2.67GHz, gcc 4.5.2:
- * Run 100 times: Min-Max(Avg)
- #01: Initial insert:   237-257(239)
- #02: Initial lookup (match):   180-197(181)
- #03: Initial lookup (miss):   171-190(172)
- #04: Initial lookup (random):   441-455(446)
- #05: Initial delete all:   127-148(128)
- #06: Initial re-inserting:   219-298(221)
- #07: Deleting first half:   101-109(102)
- #08: Adding (a different) half:   159-165(160)
- #09: Lookup after half-change (match):   203-216(204)
- #10: Lookup after half-change (miss):   217-225(218)
- #11: Churn 1:   298-311(300)
- #12: Churn 2:   298-318(301)
- #13: Churn 3:   301-322(304)
- #14: Post-Churn lookup (match):   189-196(190)
- #15: Post-Churn lookup (miss):   189-197(191)
- #16: Post-Churn lookup (random):   500-531(506)
- */
-#include <ccan/str_talloc/str_talloc.h>
-#include <ccan/grab_file/grab_file.h>
-#include <ccan/talloc/talloc.h>
-#include <ccan/time/time.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-/* CRITBIT source */
-typedef struct {
-  void *root;
-} critbit0_tree;
-
-int critbit0_contains(critbit0_tree *t, const char *u);
-int critbit0_insert(critbit0_tree *t, const char *u);
-int critbit0_delete(critbit0_tree *t, const char *u);
-void critbit0_clear(critbit0_tree *t);
-int critbit0_allprefixed(critbit0_tree *t, const char *prefix,
-                         int (*handle) (const char *, void *), void *arg);
-
-#define uint8 uint8_t
-#define uint32 uint32_t
-
-static size_t allocated;
-
-/*2:*/
-
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <sys/types.h>
-#include <errno.h>
-
-typedef struct{
-void*child[2];
-uint32 byte;
-uint8 otherbits;
-}critbit0_node;
-
-/*:2*//*3:*/
-
-int
-critbit0_contains(critbit0_tree*t,const char*u){
-const uint8*ubytes= (void*)u;
-const size_t ulen= strlen(u);
-uint8*p= t->root;
-
-/*4:*/
-
-if(!p)return 0;
-
-/*:4*/
-
-/*5:*/
-
-while(1&(intptr_t)p){
-critbit0_node*q= (void*)(p-1);
-/*6:*/
-
-uint8 c= 0;
-if(q->byte<ulen)c= ubytes[q->byte];
-const int direction= (1+(q->otherbits|c))>>8;
-
-/*:6*/
-
-p= q->child[direction];
-}
-
-/*:5*/
-
-/*7:*/
-
-return 0==strcmp(u,(const char*)p);
-
-/*:7*/
-
-}
-
-/*:3*//*8:*/
-
-int critbit0_insert(critbit0_tree*t,const char*u)
-{
-const uint8*const ubytes= (void*)u;
-const size_t ulen= strlen(u);
-uint8*p= t->root;
-
-/*9:*/
-
-if(!p){
-#if 0
-char*x;
-int a= posix_memalign((void**)&x,sizeof(void*),ulen+1);
-if(a)return 0;
-memcpy(x,u,ulen+1);
-t->root= x;
-#else
-t->root = (char *)u;
-#endif
-return 2;
-}
-
-/*:9*/
-
-/*5:*/
-
-while(1&(intptr_t)p){
-critbit0_node*q= (void*)(p-1);
-/*6:*/
-
-uint8 c= 0;
-if(q->byte<ulen)c= ubytes[q->byte];
-const int direction= (1+(q->otherbits|c))>>8;
-
-/*:6*/
-
-p= q->child[direction];
-}
-
-/*:5*/
-
-/*10:*/
-
-/*11:*/
-
-uint32 newbyte;
-uint32 newotherbits;
-
-for(newbyte= 0;newbyte<ulen;++newbyte){
-if(p[newbyte]!=ubytes[newbyte]){
-newotherbits= p[newbyte]^ubytes[newbyte];
-goto different_byte_found;
-}
-}
-
-if(p[newbyte]!=0){
-newotherbits= p[newbyte];
-goto different_byte_found;
-}
-return 1;
-
-different_byte_found:
-
-/*:11*/
-
-/*12:*/
-
-while(newotherbits&(newotherbits-1))newotherbits&= newotherbits-1;
-newotherbits^= 255;
-uint8 c= p[newbyte];
-int newdirection= (1+(newotherbits|c))>>8;
-
-/*:12*/
-
-
-/*:10*/
-
-/*13:*/
-
-/*14:*/
-
-critbit0_node*newnode;
-if(posix_memalign((void**)&newnode,sizeof(void*),sizeof(critbit0_node)))return 0;
-allocated++;
-char*x;
-#if 0
-if(posix_memalign((void**)&x,sizeof(void*),ulen+1)){
-free(newnode);
-return 0;
-}
-memcpy(x,ubytes,ulen+1);
-#else
-x = (char *)u;
-#endif
-newnode->byte= newbyte;
-newnode->otherbits= newotherbits;
-newnode->child[1-newdirection]= x;
-
-/*:14*/
-
-/*15:*/
-
-void**wherep= &t->root;
-for(;;){
-uint8*p= *wherep;
-if(!(1&(intptr_t)p))break;
-critbit0_node*q= (void*)(p-1);
-if(q->byte> newbyte)break;
-if(q->byte==newbyte&&q->otherbits> newotherbits)break;
-uint8 c= 0;
-if(q->byte<ulen)c= ubytes[q->byte];
-const int direction= (1+(q->otherbits|c))>>8;
-wherep= q->child+direction;
-}
-
-newnode->child[newdirection]= *wherep;
-*wherep= (void*)(1+(char*)newnode);
-
-/*:15*/
-
-
-/*:13*/
-
-
-return 2;
-}
-
-/*:8*//*16:*/
-
-int critbit0_delete(critbit0_tree*t,const char*u){
-const uint8*ubytes= (void*)u;
-const size_t ulen= strlen(u);
-uint8*p= t->root;
-void**wherep= &t->root;
-void**whereq= 0;
-critbit0_node*q= 0;
-int direction= 0;
-
-/*17:*/
-
-if(!p)return 0;
-
-/*:17*/
-
-/*18:*/
-
-while(1&(intptr_t)p){
-whereq= wherep;
-q= (void*)(p-1);
-uint8 c= 0;
-if(q->byte<ulen)c= ubytes[q->byte];
-direction= (1+(q->otherbits|c))>>8;
-wherep= q->child+direction;
-p= *wherep;
-}
-
-/*:18*/
-
-/*19:*/
-
-if(0!=strcmp(u,(const char*)p))return 0;
-#if 0
-free(p);
-#endif
-
-/*:19*/
-
-/*20:*/
-
-if(!whereq){
-t->root= 0;
-return 1;
-}
-
-*whereq= q->child[1-direction];
-free(q);
-allocated--;
-/*:20*/
-
-
-return 1;
-}
-
-/*:16*//*21:*/
-
-static void
-traverse(void*top){
-/*22:*/
-
-uint8*p= top;
-
-if(1&(intptr_t)p){
-critbit0_node*q= (void*)(p-1);
-traverse(q->child[0]);
-traverse(q->child[1]);
-free(q);
-allocated--;
-}else{
-#if 0
-free(p);
-#endif
-}
-
-/*:22*/
-
-}
-
-void critbit0_clear(critbit0_tree*t)
-{
-if(t->root)traverse(t->root);
-t->root= NULL;
-}
-
-/*:21*//*23:*/
-
-static int
-allprefixed_traverse(uint8*top,
-int(*handle)(const char*,void*),void*arg){
-/*26:*/
-
-if(1&(intptr_t)top){
-critbit0_node*q= (void*)(top-1);
-int direction;
-for(direction= 0;direction<2;++direction)
-switch(allprefixed_traverse(q->child[direction],handle,arg)){
-case 1:break;
-case 0:return 0;
-default:return-1;
-}
-return 1;
-}
-
-/*:26*/
-
-/*27:*/
-
-return handle((const char*)top,arg);/*:27*/
-
-}
-
-int
-critbit0_allprefixed(critbit0_tree*t,const char*prefix,
-int(*handle)(const char*,void*),void*arg){
-const uint8*ubytes= (void*)prefix;
-const size_t ulen= strlen(prefix);
-uint8*p= t->root;
-uint8*top= p;
-size_t i;
-
-if(!p)return 1;
-/*24:*/
-
-while(1&(intptr_t)p){
-critbit0_node*q= (void*)(p-1);
-uint8 c= 0;
-if(q->byte<ulen)c= ubytes[q->byte];
-const int direction= (1+(q->otherbits|c))>>8;
-p= q->child[direction];
-if(q->byte<ulen)top= p;
-}
-
-/*:24*/
-
-/*25:*/
-
-for(i= 0;i<ulen;++i){
-if(p[i]!=ubytes[i])return 1;
-}
-
-/*:25*/
-
-
-return allprefixed_traverse(top,handle,arg);
-}
-
-/*:23*/
-/* end critbit */
-
-/* Nanoseconds per operation */
-static size_t normalize(const struct timeval *start,
-                       const struct timeval *stop,
-                       unsigned int num)
-{
-       struct timeval diff;
-
-       timersub(stop, start, &diff);
-
-       /* Floating point is more accurate here. */
-       return (double)(diff.tv_sec * 1000000 + diff.tv_usec)
-               / num * 1000;
-}
-
-int main(int argc, char *argv[])
-{
-       size_t i, j, num;
-       struct timeval start, stop;
-       critbit0_tree ct;
-       char **words, **misswords;
-
-       words = strsplit(NULL, grab_file(NULL,
-                                        argv[1] ? argv[1] : "/usr/share/dict/words",
-                                        NULL), "\n");
-       ct.root = NULL;
-       num = talloc_array_length(words) - 1;
-       printf("%zu words\n", num);
-
-       /* Append and prepend last char for miss testing. */
-       misswords = talloc_array(words, char *, num);
-       for (i = 0; i < num; i++) {
-               char lastc;
-               if (strlen(words[i]))
-                       lastc = words[i][strlen(words[i])-1];
-               else
-                       lastc = 'z';
-               misswords[i] = talloc_asprintf(misswords, "%c%s%c%c",
-                                              lastc, words[i], lastc, lastc);
-       }
-
-       printf("#01: Initial insert: ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               critbit0_insert(&ct, words[i]);
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("Nodes allocated: %zu (%zu bytes)\n",
-              allocated, allocated * sizeof(critbit0_node));
-
-       printf("#02: Initial lookup (match): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               if (!critbit0_contains(&ct, words[i]))
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#03: Initial lookup (miss): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++) {
-               if (critbit0_contains(&ct, misswords[i]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       /* Lookups in order are very cache-friendly for judy; try random */
-       printf("#04: Initial lookup (random): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0, j = 0; i < num; i++, j = (j + 10007) % num)
-               if (!critbit0_contains(&ct, words[j]))
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#05: Initial delete all: ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               if (!critbit0_delete(&ct, words[i]))
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#06: Initial re-inserting: ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               critbit0_insert(&ct, words[i]);
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#07: Deleting first half: ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i+=2)
-               if (!critbit0_delete(&ct, words[i]))
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#08: Adding (a different) half: ");
-       fflush(stdout);
-
-       start = time_now();
-       for (i = 0; i < num; i+=2)
-               critbit0_insert(&ct, misswords[i]);
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#09: Lookup after half-change (match): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 1; i < num; i+=2)
-               if (!critbit0_contains(&ct, words[i]))
-                       abort();
-       for (i = 0; i < num; i+=2) {
-               if (!critbit0_contains(&ct, misswords[i]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#10: Lookup after half-change (miss): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i+=2)
-               if (critbit0_contains(&ct, words[i]))
-                       abort();
-       for (i = 1; i < num; i+=2) {
-               if (critbit0_contains(&ct, misswords[i]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       /* Hashtables with delete markers can fill with markers over time.
-        * so do some changes to see how it operates in long-term. */
-       printf("#11: Churn 1: ");
-       start = time_now();
-       for (j = 0; j < num; j+=2) {
-               if (!critbit0_delete(&ct, misswords[j]))
-                       abort();
-               if (critbit0_insert(&ct, words[j]) != 2)
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#12: Churn 2: ");
-       start = time_now();
-       for (j = 1; j < num; j+=2) {
-               if (!critbit0_delete(&ct, words[j]))
-                       abort();
-               if (critbit0_insert(&ct, misswords[j]) != 2)
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#13: Churn 3: ");
-       start = time_now();
-       for (j = 1; j < num; j+=2) {
-               if (!critbit0_delete(&ct, misswords[j]))
-                       abort();
-               if (critbit0_insert(&ct, words[j]) != 2)
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       /* Now it's back to normal... */
-       printf("#14: Post-Churn lookup (match): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               if (!critbit0_contains(&ct, words[i]))
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#15: Post-Churn lookup (miss): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++) {
-               if (critbit0_contains(&ct, misswords[i]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       /* Lookups in order are very cache-friendly for judy; try random */
-       printf("#16: Post-Churn lookup (random): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0, j = 0; i < num; i++, j = (j + 10007) % num)
-               if (!critbit0_contains(&ct, words[j]))
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       return 0;
-}
diff --git a/lib/ccan/strset/tools/speed.c b/lib/ccan/strset/tools/speed.c
deleted file mode 100644 (file)
index 9edb071..0000000
+++ /dev/null
@@ -1,243 +0,0 @@
-/* Simple speed tests using strset code.
- *
- * Results on my 32 bit Intel(R) Core(TM) i5 CPU M 560  @ 2.67GHz, gcc 4.5.2:
- * Run 100 times: Min-Max(Avg)
- #01: Initial insert:   212-219(214)
- #02: Initial lookup (match):   161-169(162)
- #03: Initial lookup (miss):   157-163(158)
- #04: Initial lookup (random):   450-479(453)
- #05: Initial delete all:   126-137(128)
- #06: Initial re-inserting:   193-198(194)
- #07: Deleting first half:   99-102(99)
- #08: Adding (a different) half:   143-154(144)
- #09: Lookup after half-change (match):   183-189(184)
- #10: Lookup after half-change (miss):   198-212(199)
- #11: Churn 1:   274-282(276)
- #12: Churn 2:   279-296(282)
- #13: Churn 3:   278-294(280)
- #14: Post-Churn lookup (match):   170-180(171)
- #15: Post-Churn lookup (miss):   175-186(176)
- #16: Post-Churn lookup (random):   522-534(525)
- */
-#include <ccan/str_talloc/str_talloc.h>
-#include <ccan/grab_file/grab_file.h>
-#include <ccan/talloc/talloc.h>
-#include <ccan/time/time.h>
-#include <ccan/strset/strset.c>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-/* Nanoseconds per operation */
-static size_t normalize(const struct timeval *start,
-                       const struct timeval *stop,
-                       unsigned int num)
-{
-       struct timeval diff;
-
-       timersub(stop, start, &diff);
-
-       /* Floating point is more accurate here. */
-       return (double)(diff.tv_sec * 1000000 + diff.tv_usec)
-               / num * 1000;
-}
-
-int main(int argc, char *argv[])
-{
-       size_t i, j, num;
-       struct timeval start, stop;
-       struct strset set;
-       char **words, **misswords;
-
-       words = strsplit(NULL, grab_file(NULL,
-                                        argv[1] ? argv[1] : "/usr/share/dict/words",
-                                        NULL), "\n");
-       strset_init(&set);
-       num = talloc_array_length(words) - 1;
-       printf("%zu words\n", num);
-
-       /* Append and prepend last char for miss testing. */
-       misswords = talloc_array(words, char *, num);
-       for (i = 0; i < num; i++) {
-               char lastc;
-               if (strlen(words[i]))
-                       lastc = words[i][strlen(words[i])-1];
-               else
-                       lastc = 'z';
-               misswords[i] = talloc_asprintf(misswords, "%c%s%c%c",
-                                              lastc, words[i], lastc, lastc);
-       }
-
-       printf("#01: Initial insert: ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               strset_set(&set, words[i]);
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-#if 0
-       printf("Nodes allocated: %zu (%zu bytes)\n",
-              allocated, allocated * sizeof(critbit0_node));
-#endif
-
-       printf("#02: Initial lookup (match): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               if (!strset_test(&set, words[i]))
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#03: Initial lookup (miss): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++) {
-               if (strset_test(&set, misswords[i]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       /* Lookups in order are very cache-friendly for judy; try random */
-       printf("#04: Initial lookup (random): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0, j = 0; i < num; i++, j = (j + 10007) % num)
-               if (!strset_test(&set, words[j]))
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#05: Initial delete all: ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               if (!strset_clear(&set, words[i]))
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#06: Initial re-inserting: ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               strset_set(&set, words[i]);
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#07: Deleting first half: ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i+=2)
-               if (!strset_clear(&set, words[i]))
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#08: Adding (a different) half: ");
-       fflush(stdout);
-
-       start = time_now();
-       for (i = 0; i < num; i+=2)
-               strset_set(&set, misswords[i]);
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#09: Lookup after half-change (match): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 1; i < num; i+=2)
-               if (!strset_test(&set, words[i]))
-                       abort();
-       for (i = 0; i < num; i+=2) {
-               if (!strset_test(&set, misswords[i]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#10: Lookup after half-change (miss): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i+=2)
-               if (strset_test(&set, words[i]))
-                       abort();
-       for (i = 1; i < num; i+=2) {
-               if (strset_test(&set, misswords[i]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       /* Hashtables with delete markers can fill with markers over time.
-        * so do some changes to see how it operates in long-term. */
-       printf("#11: Churn 1: ");
-       start = time_now();
-       for (j = 0; j < num; j+=2) {
-               if (!strset_clear(&set, misswords[j]))
-                       abort();
-               if (!strset_set(&set, words[j]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#12: Churn 2: ");
-       start = time_now();
-       for (j = 1; j < num; j+=2) {
-               if (!strset_clear(&set, words[j]))
-                       abort();
-               if (!strset_set(&set, misswords[j]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#13: Churn 3: ");
-       start = time_now();
-       for (j = 1; j < num; j+=2) {
-               if (!strset_clear(&set, misswords[j]))
-                       abort();
-               if (!strset_set(&set, words[j]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       /* Now it's back to normal... */
-       printf("#14: Post-Churn lookup (match): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++)
-               if (!strset_test(&set, words[i]))
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       printf("#15: Post-Churn lookup (miss): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0; i < num; i++) {
-               if (strset_test(&set, misswords[i]))
-                       abort();
-       }
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       /* Lookups in order are very cache-friendly for judy; try random */
-       printf("#16: Post-Churn lookup (random): ");
-       fflush(stdout);
-       start = time_now();
-       for (i = 0, j = 0; i < num; i++, j = (j + 10007) % num)
-               if (!strset_test(&set, words[j]))
-                       abort();
-       stop = time_now();
-       printf(" %zu ns\n", normalize(&start, &stop, num));
-
-       return 0;
-}
diff --git a/lib/ccan/tally/LICENSE b/lib/ccan/tally/LICENSE
deleted file mode 100644 (file)
index cca7fc2..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
-  This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
-  0. Additional Definitions.
-
-  As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
-  "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
-  An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
-  A "Combined Work" is a work produced by combining or linking an
-Application with the Library.  The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
-  The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
-  The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
-  1. Exception to Section 3 of the GNU GPL.
-
-  You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
-  2. Conveying Modified Versions.
-
-  If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
-   a) under this License, provided that you make a good faith effort to
-   ensure that, in the event an Application does not supply the
-   function or data, the facility still operates, and performs
-   whatever part of its purpose remains meaningful, or
-
-   b) under the GNU GPL, with none of the additional permissions of
-   this License applicable to that copy.
-
-  3. Object Code Incorporating Material from Library Header Files.
-
-  The object code form of an Application may incorporate material from
-a header file that is part of the Library.  You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
-   a) Give prominent notice with each copy of the object code that the
-   Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the object code with a copy of the GNU GPL and this license
-   document.
-
-  4. Combined Works.
-
-  You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
-   a) Give prominent notice with each copy of the Combined Work that
-   the Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the Combined Work with a copy of the GNU GPL and this license
-   document.
-
-   c) For a Combined Work that displays copyright notices during
-   execution, include the copyright notice for the Library among
-   these notices, as well as a reference directing the user to the
-   copies of the GNU GPL and this license document.
-
-   d) Do one of the following:
-
-       0) Convey the Minimal Corresponding Source under the terms of this
-       License, and the Corresponding Application Code in a form
-       suitable for, and under terms that permit, the user to
-       recombine or relink the Application with a modified version of
-       the Linked Version to produce a modified Combined Work, in the
-       manner specified by section 6 of the GNU GPL for conveying
-       Corresponding Source.
-
-       1) Use a suitable shared library mechanism for linking with the
-       Library.  A suitable mechanism is one that (a) uses at run time
-       a copy of the Library already present on the user's computer
-       system, and (b) will operate properly with a modified version
-       of the Library that is interface-compatible with the Linked
-       Version.
-
-   e) Provide Installation Information, but only if you would otherwise
-   be required to provide such information under section 6 of the
-   GNU GPL, and only to the extent that such information is
-   necessary to install and execute a modified version of the
-   Combined Work produced by recombining or relinking the
-   Application with a modified version of the Linked Version. (If
-   you use option 4d0, the Installation Information must accompany
-   the Minimal Corresponding Source and Corresponding Application
-   Code. If you use option 4d1, you must provide the Installation
-   Information in the manner specified by section 6 of the GNU GPL
-   for conveying Corresponding Source.)
-
-  5. Combined Libraries.
-
-  You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
-   a) Accompany the combined library with a copy of the same work based
-   on the Library, uncombined with any other library facilities,
-   conveyed under the terms of this License.
-
-   b) Give prominent notice with the combined library that part of it
-   is a work based on the Library, and explaining where to find the
-   accompanying uncombined form of the same work.
-
-  6. Revised Versions of the GNU Lesser General Public License.
-
-  The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
-  Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
-  If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/lib/ccan/tally/_info b/lib/ccan/tally/_info
deleted file mode 100644 (file)
index 6dab9b7..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * tally - running tally of integers
- *
- * The tally module implements simple analysis of a stream of integers.
- * Numbers are fed in via tally_add(), and then the mean, median, mode and
- * a histogram can be read out.
- *
- * Example:
- *     #include <stdio.h>
- *     #include <err.h>
- *     #include <ccan/tally/tally.h>
- *
- *     int main(int argc, char *argv[])
- *     {
- *             struct tally *t;
- *             unsigned int i;
- *             size_t err;
- *             ssize_t val;
- *             char *histogram;
- *
- *             if (argc < 2)
- *                     errx(1, "Usage: %s <number>...\n", argv[0]);
- *
- *             t = tally_new(100);
- *             for (i = 1; i < argc; i++)
- *                     tally_add(t, atol(argv[i]));
- *
- *             printf("Mean = %zi\n", tally_mean(t));
- *             val = tally_approx_median(t, &err);
- *             printf("Median = %zi (+/- %zu)\n", val, err);
- *             val = tally_approx_mode(t, &err);
- *             printf("Mode = %zi (+/- %zu)\n", val, err);
- *             histogram = tally_histogram(t, 50, 10);
- *             printf("Histogram:\n%s", histogram);
- *             free(histogram);
- *             return 0;
- *     }
- *
- * License: LGPL (v3 or any later version)
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               printf("ccan/build_assert\n");
-               printf("ccan/likely\n");
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/tally/tally.c b/lib/ccan/tally/tally.c
deleted file mode 100644 (file)
index 29f0555..0000000
+++ /dev/null
@@ -1,521 +0,0 @@
-/* Licensed under LGPLv3+ - see LICENSE file for details */
-#include <ccan/tally/tally.h>
-#include <ccan/build_assert/build_assert.h>
-#include <ccan/likely/likely.h>
-#include <stdint.h>
-#include <limits.h>
-#include <string.h>
-#include <stdio.h>
-#include <assert.h>
-#include <stdlib.h>
-
-#define SIZET_BITS (sizeof(size_t)*CHAR_BIT)
-
-/* We use power of 2 steps.  I tried being tricky, but it got buggy. */
-struct tally {
-       ssize_t min, max;
-       size_t total[2];
-       /* This allows limited frequency analysis. */
-       unsigned buckets, step_bits;
-       size_t counts[1 /* Actually: [buckets] */ ];
-};
-
-struct tally *tally_new(unsigned buckets)
-{
-       struct tally *tally;
-
-       /* There is always 1 bucket. */
-       if (buckets == 0) {
-               buckets = 1;
-       }
-
-       /* Overly cautious check for overflow. */
-       if (sizeof(*tally) * buckets / sizeof(*tally) != buckets) {
-               return NULL;
-       }
-
-       tally = (struct tally *)malloc(
-               sizeof(*tally) + sizeof(tally->counts[0])*(buckets-1));
-       if (tally == NULL) {
-               return NULL;
-       }
-
-       tally->max = ((size_t)1 << (SIZET_BITS - 1));
-       tally->min = ~tally->max;
-       tally->total[0] = tally->total[1] = 0;
-       tally->buckets = buckets;
-       tally->step_bits = 0;
-       memset(tally->counts, 0, sizeof(tally->counts[0])*buckets);
-       return tally;
-}
-
-static unsigned bucket_of(ssize_t min, unsigned step_bits, ssize_t val)
-{
-       /* Don't over-shift. */
-       if (step_bits == SIZET_BITS) {
-               return 0;
-       }
-       assert(step_bits < SIZET_BITS);
-       return (size_t)(val - min) >> step_bits;
-}
-
-/* Return the min value in bucket b. */
-static ssize_t bucket_min(ssize_t min, unsigned step_bits, unsigned b)
-{
-       /* Don't over-shift. */
-       if (step_bits == SIZET_BITS) {
-               return min;
-       }
-       assert(step_bits < SIZET_BITS);
-       return min + ((ssize_t)b << step_bits);
-}
-
-/* Does shifting by this many bits truncate the number? */
-static bool shift_overflows(size_t num, unsigned bits)
-{
-       if (bits == 0) {
-               return false;
-       }
-
-       return ((num << bits) >> 1) != (num << (bits - 1));
-}
-
-/* When min or max change, we may need to shuffle the frequency counts. */
-static void renormalize(struct tally *tally,
-                       ssize_t new_min, ssize_t new_max)
-{
-       size_t range, spill;
-       unsigned int i, old_min;
-
-       /* Uninitialized?  Don't do anything... */
-       if (tally->max < tally->min) {
-               goto update;
-       }
-
-       /* If we don't have sufficient range, increase step bits until
-        * buckets cover entire range of ssize_t anyway. */
-       range = (new_max - new_min) + 1;
-       while (!shift_overflows(tally->buckets, tally->step_bits)
-              && range > ((size_t)tally->buckets << tally->step_bits)) {
-               /* Collapse down. */
-               for (i = 1; i < tally->buckets; i++) {
-                       tally->counts[i/2] += tally->counts[i];
-                       tally->counts[i] = 0;
-               }
-               tally->step_bits++;
-       }
-
-       /* Now if minimum has dropped, move buckets up. */
-       old_min = bucket_of(new_min, tally->step_bits, tally->min);
-       memmove(tally->counts + old_min,
-               tally->counts,
-               sizeof(tally->counts[0]) * (tally->buckets - old_min));
-       memset(tally->counts, 0, sizeof(tally->counts[0]) * old_min);
-
-       /* If we moved boundaries, adjust buckets to that ratio. */
-       spill = (tally->min - new_min) % (1 << tally->step_bits);
-       for (i = 0; i < tally->buckets-1; i++) {
-               size_t adjust = (tally->counts[i] >> tally->step_bits) * spill;
-               tally->counts[i] -= adjust;
-               tally->counts[i+1] += adjust;
-       }
-
-update:
-       tally->min = new_min;
-       tally->max = new_max;
-}
-
-void tally_add(struct tally *tally, ssize_t val)
-{
-       ssize_t new_min = tally->min, new_max = tally->max;
-       bool need_renormalize = false;
-
-       if (val < tally->min) {
-               new_min = val;
-               need_renormalize = true;
-       }
-       if (val > tally->max) {
-               new_max = val;
-               need_renormalize = true;
-       }
-       if (need_renormalize) {
-               renormalize(tally, new_min, new_max);
-       }
-
-       /* 128-bit arithmetic!  If we didn't want exact mean, we could just
-        * pull it out of counts. */
-       if (val > 0 && tally->total[0] + val < tally->total[0]) {
-               tally->total[1]++;
-       } else if (val < 0 && tally->total[0] + val > tally->total[0]) {
-               tally->total[1]--;
-       }
-       tally->total[0] += val;
-       tally->counts[bucket_of(tally->min, tally->step_bits, val)]++;
-}
-
-size_t tally_num(const struct tally *tally)
-{
-       size_t i, num = 0;
-       for (i = 0; i < tally->buckets; i++) {
-               num += tally->counts[i];
-       }
-       return num;
-}
-
-ssize_t tally_min(const struct tally *tally)
-{
-       return tally->min;
-}
-
-ssize_t tally_max(const struct tally *tally)
-{
-       return tally->max;
-}
-
-/* FIXME: Own ccan module please! */
-static unsigned fls64(uint64_t val)
-{
-#if HAVE_BUILTIN_CLZL
-       if (val <= ULONG_MAX) {
-               /* This is significantly faster! */
-               return val ? sizeof(long) * CHAR_BIT - __builtin_clzl(val) : 0;
-       } else {
-#endif
-       uint64_t r = 64;
-
-       if (!val) {
-               return 0;
-       }
-       if (!(val & 0xffffffff00000000ull)) {
-               val <<= 32;
-               r -= 32;
-       }
-       if (!(val & 0xffff000000000000ull)) {
-               val <<= 16;
-               r -= 16;
-       }
-       if (!(val & 0xff00000000000000ull)) {
-               val <<= 8;
-               r -= 8;
-       }
-       if (!(val & 0xf000000000000000ull)) {
-               val <<= 4;
-               r -= 4;
-       }
-       if (!(val & 0xc000000000000000ull)) {
-               val <<= 2;
-               r -= 2;
-       }
-       if (!(val & 0x8000000000000000ull)) {
-               val <<= 1;
-               r -= 1;
-       }
-       return r;
-#if HAVE_BUILTIN_CLZL
-       }
-#endif
-}
-
-/* This is stolen straight from Hacker's Delight. */
-static uint64_t divlu64(uint64_t u1, uint64_t u0, uint64_t v)
-{
-       const uint64_t b = 4294967296ULL; /* Number base (32 bits). */
-       uint32_t un[4],           /* Dividend and divisor */
-               vn[2];            /* normalized and broken */
-                                 /* up into halfwords. */
-       uint32_t q[2];            /* Quotient as halfwords. */
-       uint64_t un1, un0,        /* Dividend and divisor */
-               vn0;              /* as fullwords. */
-       uint64_t qhat;            /* Estimated quotient digit. */
-       uint64_t rhat;            /* A remainder. */
-       uint64_t p;               /* Product of two digits. */
-       int64_t s, i, j, t, k;
-
-       if (u1 >= v) {            /* If overflow, return the largest */
-               return (uint64_t)-1; /* possible quotient. */
-       }
-
-       s = 64 - fls64(v);                /* 0 <= s <= 63. */
-       vn0 = v << s;             /* Normalize divisor. */
-       vn[1] = vn0 >> 32;        /* Break divisor up into */
-       vn[0] = vn0 & 0xFFFFFFFF; /* two 32-bit halves. */
-
-       // Shift dividend left.
-       un1 = ((u1 << s) | (u0 >> (64 - s))) & (-s >> 63);
-       un0 = u0 << s;
-       un[3] = un1 >> 32;        /* Break dividend up into */
-       un[2] = un1;              /* four 32-bit halfwords */
-       un[1] = un0 >> 32;        /* Note: storing into */
-       un[0] = un0;              /* halfwords truncates. */
-
-       for (j = 1; j >= 0; j--) {
-               /* Compute estimate qhat of q[j]. */
-               qhat = (un[j+2]*b + un[j+1])/vn[1];
-               rhat = (un[j+2]*b + un[j+1]) - qhat*vn[1];
-       again:
-               if (qhat >= b || qhat*vn[0] > b*rhat + un[j]) {
-                       qhat = qhat - 1;
-                       rhat = rhat + vn[1];
-                       if (rhat < b) {
-                               goto again;
-                       }
-               }
-
-               /* Multiply and subtract. */
-               k = 0;
-               for (i = 0; i < 2; i++) {
-                       p = qhat*vn[i];
-                       t = un[i+j] - k - (p & 0xFFFFFFFF);
-                       un[i+j] = t;
-                       k = (p >> 32) - (t >> 32);
-               }
-               t = un[j+2] - k;
-               un[j+2] = t;
-
-               q[j] = qhat;              /* Store quotient digit. */
-               if (t < 0) {              /* If we subtracted too */
-                       q[j] = q[j] - 1;  /* much, add back. */
-                       k = 0;
-                       for (i = 0; i < 2; i++) {
-                               t = un[i+j] + vn[i] + k;
-                               un[i+j] = t;
-                               k = t >> 32;
-                       }
-                       un[j+2] = un[j+2] + k;
-               }
-       } /* End j. */
-
-       return q[1]*b + q[0];
-}
-
-static int64_t divls64(int64_t u1, uint64_t u0, int64_t v)
-{
-       int64_t q, uneg, vneg, diff, borrow;
-
-       uneg = u1 >> 63;          /* -1 if u < 0. */
-       if (uneg) {               /* Compute the absolute */
-               u0 = -u0;         /* value of the dividend u. */
-               borrow = (u0 != 0);
-               u1 = -u1 - borrow;
-       }
-
-       vneg = v >> 63;           /* -1 if v < 0. */
-       v = (v ^ vneg) - vneg;    /* Absolute value of v. */
-
-       if ((uint64_t)u1 >= (uint64_t)v) {
-               goto overflow;
-       }
-
-       q = divlu64(u1, u0, v);
-
-       diff = uneg ^ vneg;       /* Negate q if signs of */
-       q = (q ^ diff) - diff;    /* u and v differed. */
-
-       if ((diff ^ q) < 0 && q != 0) {    /* If overflow, return the
-                                             largest */
-       overflow:                          /* possible neg. quotient. */
-               q = 0x8000000000000000ULL;
-       }
-       return q;
-}
-
-ssize_t tally_mean(const struct tally *tally)
-{
-       size_t count = tally_num(tally);
-       if (!count) {
-               return 0;
-       }
-
-       if (sizeof(tally->total[0]) == sizeof(uint32_t)) {
-               /* Use standard 64-bit arithmetic. */
-               int64_t total = tally->total[0]
-                       | (((uint64_t)tally->total[1]) << 32);
-               return total / count;
-       }
-       return divls64(tally->total[1], tally->total[0], count);
-}
-
-ssize_t tally_total(const struct tally *tally, ssize_t *overflow)
-{
-       if (overflow) {
-               *overflow = tally->total[1];
-               return tally->total[0];
-       }
-
-       /* If result is negative, make sure we can represent it. */
-       if (tally->total[1] & ((size_t)1 << (SIZET_BITS-1))) {
-               /* Must have only underflowed once, and must be able to
-                * represent result at ssize_t. */
-               if ((~tally->total[1])+1 != 0
-                   || (ssize_t)tally->total[0] >= 0) {
-                       /* Underflow, return minimum. */
-                       return (ssize_t)((size_t)1 << (SIZET_BITS - 1));
-               }
-       } else {
-               /* Result is positive, must not have overflowed, and must be
-                * able to represent as ssize_t. */
-               if (tally->total[1] || (ssize_t)tally->total[0] < 0) {
-                       /* Overflow.  Return maximum. */
-                       return (ssize_t)~((size_t)1 << (SIZET_BITS - 1));
-               }
-       }
-       return tally->total[0];
-}
-
-static ssize_t bucket_range(const struct tally *tally, unsigned b, size_t *err)
-{
-       ssize_t min, max;
-
-       min = bucket_min(tally->min, tally->step_bits, b);
-       if (b == tally->buckets - 1) {
-               max = tally->max;
-       } else {
-               max = bucket_min(tally->min, tally->step_bits, b+1) - 1;
-       }
-
-       /* FIXME: Think harder about cumulative error; is this enough?. */
-       *err = (max - min + 1) / 2;
-       /* Avoid overflow. */
-       return min + (max - min) / 2;
-}
-
-ssize_t tally_approx_median(const struct tally *tally, size_t *err)
-{
-       size_t count = tally_num(tally), total = 0;
-       unsigned int i;
-
-       for (i = 0; i < tally->buckets; i++) {
-               total += tally->counts[i];
-               if (total * 2 >= count) {
-                       break;
-               }
-       }
-       return bucket_range(tally, i, err);
-}
-
-ssize_t tally_approx_mode(const struct tally *tally, size_t *err)
-{
-       unsigned int i, min_best = 0, max_best = 0;
-
-       for (i = 0; i < tally->buckets; i++) {
-               if (tally->counts[i] > tally->counts[min_best]) {
-                       min_best = max_best = i;
-               } else if (tally->counts[i] == tally->counts[min_best]) {
-                       max_best = i;
-               }
-       }
-
-       /* We can have more than one best, making our error huge. */
-       if (min_best != max_best) {
-               ssize_t min, max;
-               min = bucket_range(tally, min_best, err);
-               max = bucket_range(tally, max_best, err);
-               max += *err;
-               *err += (size_t)(max - min);
-               return min + (max - min) / 2;
-       }
-
-       return bucket_range(tally, min_best, err);
-}
-
-static unsigned get_max_bucket(const struct tally *tally)
-{
-       unsigned int i;
-
-       for (i = tally->buckets; i > 0; i--) {
-               if (tally->counts[i-1]) {
-                       break;
-               }
-       }
-       return i;
-}
-
-char *tally_histogram(const struct tally *tally,
-                     unsigned width, unsigned height)
-{
-       unsigned int i, count, max_bucket, largest_bucket;
-       struct tally *tmp;
-       char *graph, *p;
-
-       assert(width >= TALLY_MIN_HISTO_WIDTH);
-       assert(height >= TALLY_MIN_HISTO_HEIGHT);
-
-       /* Ignore unused buckets. */
-       max_bucket = get_max_bucket(tally);
-
-       /* FIXME: It'd be nice to smooth here... */
-       if (height >= max_bucket) {
-               height = max_bucket;
-               tmp = NULL;
-       } else {
-               /* We create a temporary then renormalize so < height. */
-               /* FIXME: Antialias properly! */
-               tmp = tally_new(tally->buckets);
-               if (!tmp) {
-                       return NULL;
-               }
-               tmp->min = tally->min;
-               tmp->max = tally->max;
-               tmp->step_bits = tally->step_bits;
-               memcpy(tmp->counts, tally->counts,
-                      sizeof(tally->counts[0]) * tmp->buckets);
-               while ((max_bucket = get_max_bucket(tmp)) >= height) {
-                       renormalize(tmp, tmp->min, tmp->max * 2);
-               }
-               /* Restore max */
-               tmp->max = tally->max;
-               tally = tmp;
-               height = max_bucket;
-       }
-
-       /* Figure out longest line, for scale. */
-       largest_bucket = 0;
-       for (i = 0; i < tally->buckets; i++) {
-               if (tally->counts[i] > largest_bucket) {
-                       largest_bucket = tally->counts[i];
-               }
-       }
-
-       p = graph = (char *)malloc(height * (width + 1) + 1);
-       if (!graph) {
-               free(tmp);
-               return NULL;
-       }
-
-       for (i = 0; i < height; i++) {
-               unsigned covered = 1, row;
-
-               /* People expect minimum at the bottom. */
-               row = height - i - 1;
-               count = (double)tally->counts[row] / largest_bucket * (width-1)+1;
-
-               if (row == 0) {
-                       covered = snprintf(p, width, "%zi", tally->min);
-               } else if (row == height - 1) {
-                       covered = snprintf(p, width, "%zi", tally->max);
-               } else if (row == bucket_of(tally->min, tally->step_bits, 0)) {
-                       *p = '+';
-               } else {
-                       *p = '|';
-               }
-
-               if (covered > width) {
-                       covered = width;
-               }
-               p += covered;
-
-               if (count > covered) {
-                       count -= covered;
-                       memset(p, '*', count);
-               } else {
-                       count = 0;
-               }
-
-               p += count;
-               *p = '\n';
-               p++;
-       }
-       *p = '\0';
-       free(tmp);
-       return graph;
-}
diff --git a/lib/ccan/tally/tally.h b/lib/ccan/tally/tally.h
deleted file mode 100644 (file)
index c9272f1..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Licensed under LGPLv3+ - see LICENSE file for details */
-#ifndef CCAN_TALLY_H
-#define CCAN_TALLY_H
-#include "config.h"
-#include <sys/types.h>
-
-struct tally;
-
-/**
- * tally_new - allocate the tally structure.
- * @buckets: the number of frequency buckets.
- *
- * This allocates a tally structure using malloc().  The greater the value
- * of @buckets, the more accurate tally_approx_median() and tally_approx_mode()
- * and tally_histogram() will be, but more memory is consumed.  If you want
- * to use tally_histogram(), the optimal bucket value is the same as that
- * @height argument.
- */
-struct tally *tally_new(unsigned int buckets);
-
-/**
- * tally_add - add a value.
- * @tally: the tally structure.
- * @val: the value to add.
- */
-void tally_add(struct tally *tally, ssize_t val);
-
-/**
- * tally_num - how many times as tally_add been called?
- * @tally: the tally structure.
- */
-size_t tally_num(const struct tally *tally);
-
-/**
- * tally_min - the minimum value passed to tally_add.
- * @tally: the tally structure.
- *
- * Undefined if tally_num() == 0.
- */
-ssize_t tally_min(const struct tally *tally);
-
-/**
- * tally_max - the maximum value passed to tally_add.
- * @tally: the tally structure.
- *
- * Undefined if tally_num() == 0.
- */
-ssize_t tally_max(const struct tally *tally);
-
-/**
- * tally_mean - the mean value passed to tally_add.
- * @tally: the tally structure.
- *
- * Undefined if tally_num() == 0, but will not crash.
- */
-ssize_t tally_mean(const struct tally *tally);
-
-/**
- * tally_total - the total value passed to tally_add.
- * @tally: the tally structure.
- * @overflow: the overflow value (or NULL).
- *
- * If your total can't overflow a ssize_t, you don't need @overflow.
- * Otherwise, @overflow is the upper ssize_t, and the return value should
- * be treated as the lower size_t (ie. the sign bit is in @overflow).
- */
-ssize_t tally_total(const struct tally *tally, ssize_t *overflow);
-
-/**
- * tally_approx_median - the approximate median value passed to tally_add.
- * @tally: the tally structure.
- * @err: the error in the returned value (ie. real median is +/- @err).
- *
- * Undefined if tally_num() == 0, but will not crash.  Because we
- * don't reallocate, we don't store all values, so this median cannot be
- * exact.
- */
-ssize_t tally_approx_median(const struct tally *tally, size_t *err);
-
-/**
- * tally_approx_mode - the approximate mode value passed to tally_add.
- * @tally: the tally structure.
- * @err: the error in the returned value (ie. real mode is +/- @err).
- *
- * Undefined if tally_num() == 0, but will not crash.  Because we
- * don't reallocate, we don't store all values, so this mode cannot be
- * exact.  It could well be a value which was never passed to tally_add!
- */
-ssize_t tally_approx_mode(const struct tally *tally, size_t *err);
-
-#define TALLY_MIN_HISTO_WIDTH 8
-#define TALLY_MIN_HISTO_HEIGHT 3
-
-/**
- * tally_graph - return an ASCII image of the tally_add distribution
- * @tally: the tally structure.
- * @width: the maximum string width to use (>= TALLY_MIN_HISTO_WIDTH)
- * @height: the maximum string height to use (>= TALLY_MIN_HISTO_HEIGHT)
- *
- * Returns a malloc()ed string which draws a multi-line graph of the
- * distribution of values.  On out of memory returns NULL.
- */
-char *tally_histogram(const struct tally *tally,
-                     unsigned width, unsigned height);
-#endif /* CCAN_TALLY_H */
diff --git a/lib/ccan/tally/test/run-bucket_of.c b/lib/ccan/tally/test/run-bucket_of.c
deleted file mode 100644 (file)
index 5e12725..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-#include <ccan/tally/tally.c>
-#include <ccan/tap/tap.h>
-
-int main(void)
-{
-       unsigned int i, max_step;
-       ssize_t min, max;
-
-       max = (ssize_t)~(1ULL << (sizeof(max)*CHAR_BIT - 1));
-       min = (ssize_t)(1ULL << (sizeof(max)*CHAR_BIT - 1));
-       max_step = sizeof(max)*CHAR_BIT;
-
-       plan_tests(2 + 100 + 10 + 5
-                  + 2 + 100 + 5 + 4
-                  + (1 << 7) * (max_step - 7));
-
-       /* Single step, single bucket == easy. */
-       ok1(bucket_of(0, 0, 0) == 0);
-
-       /* Double step, still in first bucket. */
-       ok1(bucket_of(0, 1, 0) == 0);
-
-       /* Step 8. */
-       for (i = 0; i < 100; i++)
-               ok1(bucket_of(0, 3, i) == i >> 3);
-
-       /* 10 values in 5 buckets, step 2. */
-       for (i = 0; i < 10; i++)
-               ok1(bucket_of(0, 1, i) == i >> 1);
-
-       /* Extreme cases. */
-       ok1(bucket_of(min, 0, min) == 0);
-       ok1(bucket_of(min, max_step-1, min) == 0);
-       ok1(bucket_of(min, max_step-1, max) == 1);
-       ok1(bucket_of(min, max_step, min) == 0);
-       ok1(bucket_of(min, max_step, max) == 0);
-
-       /* Now, bucket_min() should match: */
-       ok1(bucket_min(0, 0, 0) == 0);
-
-       /* Double step, val in first bucket still 0. */
-       ok1(bucket_min(0, 1, 0) == 0);
-
-       /* Step 8. */
-       for (i = 0; i < 100; i++)
-               ok1(bucket_min(0, 3, i) == i << 3);
-
-       /* 10 values in 5 buckets, step 2. */
-       for (i = 0; i < 5; i++)
-               ok1(bucket_min(0, 1, i) == i << 1);
-
-       /* Extreme cases. */
-       ok1(bucket_min(min, 0, 0) == min);
-       ok1(bucket_min(min, max_step-1, 0) == min);
-       ok1(bucket_min(min, max_step-1, 1) == 0);
-       ok1(bucket_min(min, max_step, 0) == min);
-
-       /* Now, vary step and number of buckets, but bucket_min and bucket_of
-        * must agree. */
-       for (i = 0; i < (1 << 7); i++) {
-               unsigned int j;
-               for (j = 0; j < max_step - 7; j++) {
-                       ssize_t val;
-
-                       val = bucket_min(-(ssize_t)i, j, i);
-                       ok1(bucket_of(-(ssize_t)i, j, val) == i);
-               }
-       }
-
-       return exit_status();
-}
diff --git a/lib/ccan/tally/test/run-divlu64.c b/lib/ccan/tally/test/run-divlu64.c
deleted file mode 100644 (file)
index 057e474..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <ccan/tally/tally.c>
-#include <ccan/tap/tap.h>
-
-int main(void)
-{
-       unsigned int i, j;
-
-       plan_tests(5985);
-       /* Simple tests. */
-       for (i = 0; i < 127; i++) {
-               uint64_t u1, u0;
-               if (i < 64) {
-                       u1 = 0;
-                       u0 = 1ULL << i;
-                       j = 0;
-               } else {
-                       u1 = 1ULL << (i - 64);
-                       u0 = 0;
-                       j = i - 63;
-               }
-               for (; j < 63; j++) {
-                       uint64_t answer;
-                       if (j > i)
-                               answer = 0;
-                       else
-                               answer = 1ULL << (i - j);
-                       ok1(divlu64(u1, u0, 1ULL << j) == answer);
-               }
-       }
-       return exit_status();
-}
diff --git a/lib/ccan/tally/test/run-histogram.c b/lib/ccan/tally/test/run-histogram.c
deleted file mode 100644 (file)
index a9894ec..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-#include <ccan/tally/tally.c>
-#include <ccan/tap/tap.h>
-
-int main(void)
-{
-       int i;
-       struct tally *tally;
-       char *graph, *p;
-
-       plan_tests(100 + 1 + 10 + 1 + 100 + 1 + 10 + 1 + 10 * 2 + 1);
-
-       /* Uniform distribution, easy. */
-       tally = tally_new(100);
-       for (i = 0; i < 100; i++)
-               tally_add(tally, i);
-
-       /* 1:1 height. */
-       graph = p = tally_histogram(tally, 20, 100);
-       for (i = 0; i < 100; i++) {
-               char *eol = strchr(p, '\n');
-
-               /* We expect it filled all way to the end. */
-               ok1(eol - p == 20);
-               p = eol + 1;
-       }
-       ok1(!*p);
-       free(graph);
-
-       /* Reduced height. */
-       graph = p = tally_histogram(tally, 20, 10);
-       for (i = 0; i < 10; i++) {
-               char *eol = strchr(p, '\n');
-
-               /* First once can be truncated (bucket aliasing) */
-               if (eol) {
-                       ok1(eol - p == 20 || (eol - p < 20 && i == 0));
-               } else
-                       /* We should, at worst, half-fill graph */
-                       ok1(i > 5);
-
-               if (eol)
-                       p = eol + 1;
-       }
-       ok1(!*p);
-       free(graph);
-
-       /* Enlarged height (gets capped). */
-       graph = p = tally_histogram(tally, 20, 1000);
-       for (i = 0; i < 100; i++) {
-               char *eol = strchr(p, '\n');
-               /* We expect it filled all way to the end. */
-               ok1(eol - p == 20);
-               p = eol + 1;
-       }
-       ok1(!*p);
-       free(graph);
-       free(tally);
-
-       /* Distinctive increasing pattern. */
-       tally = tally_new(10);
-       for (i = 0; i < 10; i++) {
-               unsigned int j;
-               for (j = 0; j <= i; j++)
-                       tally_add(tally, i);
-       }
-
-       graph = p = tally_histogram(tally, 10, 10);
-       for (i = 0; i < 10; i++) {
-               char *eol = strchr(p, '\n');
-               ok1(eol - p == 10 - i);
-               p = eol + 1;
-       }
-       ok1(!*p);
-       diag("Here's the pretty: %s", graph);
-       free(graph);
-       free(tally);
-
-       /* With negative values. */
-       tally = tally_new(10);
-       for (i = 0; i < 10; i++) {
-               tally_add(tally, i - 5);
-       }
-
-       graph = p = tally_histogram(tally, 10, 10);
-       for (i = 0; i < 10; i++) {
-               char *eol = strchr(p, '\n');
-
-               /* We expect it filled all way to the end. */
-               ok1(eol - p == 10);
-
-               /* Check min/max labels. */
-               if (i == 0)
-                       ok1(strncmp(p, "4*", 2) == 0);
-               else if (i == 9)
-                       ok1(strncmp(p, "-5*", 3) == 0);
-               else if (i == 4)
-                       ok1(p[0] == '+'); /* 0 marker */
-               else
-                       ok1(p[0] == '|');
-               p = eol + 1;
-       }
-       ok1(!*p);
-       diag("Here's the pretty: %s", graph);
-       free(graph);
-       free(tally);
-
-       return exit_status();
-}
diff --git a/lib/ccan/tally/test/run-mean.c b/lib/ccan/tally/test/run-mean.c
deleted file mode 100644 (file)
index b43dea6..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <ccan/tally/tally.c>
-#include <ccan/tap/tap.h>
-
-int main(void)
-{
-       int i;
-       struct tally *tally = tally_new(0);
-       ssize_t min, max;
-
-       max = (ssize_t)~(1ULL << (sizeof(max)*CHAR_BIT - 1));
-       min = (ssize_t)(1ULL << (sizeof(max)*CHAR_BIT - 1));
-
-       plan_tests(100 + 100);
-       /* Simple mean test: should always be 0. */
-       for (i = 0; i < 100; i++) {
-               tally_add(tally, i);
-               tally_add(tally, -i);
-               ok1(tally_mean(tally) == 0);
-       }
-
-       /* Works for big values too... */
-       for (i = 0; i < 100; i++) {
-               tally_add(tally, max - i);
-               tally_add(tally, min + 1 + i);
-               ok1(tally_mean(tally) == 0);
-       }
-
-       free(tally);
-       return exit_status();
-}
diff --git a/lib/ccan/tally/test/run-median.c b/lib/ccan/tally/test/run-median.c
deleted file mode 100644 (file)
index b12fd8a..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <ccan/tally/tally.c>
-#include <ccan/tap/tap.h>
-
-int main(void)
-{
-       int i;
-       struct tally *tally = tally_new(100);
-       ssize_t min, max, median;
-       size_t err;
-
-       max = (ssize_t)~(1ULL << (sizeof(max)*CHAR_BIT - 1));
-       min = (ssize_t)(1ULL << (sizeof(max)*CHAR_BIT - 1));
-
-       plan_tests(100*2 + 100*2 + 100*2);
-       /* Simple median test: should always be around 0. */
-       for (i = 0; i < 100; i++) {
-               tally_add(tally, i);
-               tally_add(tally, -i);
-               median = tally_approx_median(tally, &err);
-               ok1(err <= 4);
-               ok1(median - (ssize_t)err <= 0 && median + (ssize_t)err >= 0);
-       }
-
-       /* Works for big values too... */
-       for (i = 0; i < 100; i++) {
-               tally_add(tally, max - i);
-               tally_add(tally, min + 1 + i);
-               median = tally_approx_median(tally, &err);
-               /* Error should be < 100th of max - min. */
-               ok1(err <= max / 100 * 2);
-               ok1(median - (ssize_t)err <= 0 && median + (ssize_t)err >= 0);
-       }
-       free(tally);
-
-       tally = tally_new(10);
-       for (i = 0; i < 100; i++) {
-               tally_add(tally, i);
-               median = tally_approx_median(tally, &err);
-               ok1(err <= i / 10 + 1);
-               ok1(median - (ssize_t)err <= i/2
-                   && median + (ssize_t)err >= i/2);
-       }
-       free(tally);
-
-       return exit_status();
-}
diff --git a/lib/ccan/tally/test/run-min-max.c b/lib/ccan/tally/test/run-min-max.c
deleted file mode 100644 (file)
index c92f6d3..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <ccan/tally/tally.c>
-#include <ccan/tap/tap.h>
-
-int main(void)
-{
-       int i;
-       struct tally *tally = tally_new(0);
-
-       plan_tests(100 * 4);
-       /* Test max, min and num. */
-       for (i = 0; i < 100; i++) {
-               tally_add(tally, i);
-               ok1(tally_num(tally) == i*2 + 1);
-               tally_add(tally, -i);
-               ok1(tally_num(tally) == i*2 + 2);
-               ok1(tally_max(tally) == i);
-               ok1(tally_min(tally) == -i);
-       }
-       free(tally);
-       return exit_status();
-}
diff --git a/lib/ccan/tally/test/run-mode.c b/lib/ccan/tally/test/run-mode.c
deleted file mode 100644 (file)
index cd2f230..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <ccan/tally/tally.c>
-#include <ccan/tap/tap.h>
-
-int main(void)
-{
-       int i;
-       struct tally *tally = tally_new(100);
-       ssize_t min, max, mode;
-       size_t err;
-
-       max = (ssize_t)~(1ULL << (sizeof(max)*CHAR_BIT - 1));
-       min = (ssize_t)(1ULL << (sizeof(max)*CHAR_BIT - 1));
-
-       plan_tests(100 + 50 + 100 + 100 + 10);
-       /* Simple mode test: should always be around 0 (we add that twice). */
-       for (i = 0; i < 100; i++) {
-               tally_add(tally, i);
-               tally_add(tally, -i);
-               mode = tally_approx_mode(tally, &err);
-               if (i < 50)
-                       ok1(err == 0);
-               ok1(mode - (ssize_t)err <= 0 && mode + (ssize_t)err >= 0);
-       }
-
-       /* Works for big values too... */
-       for (i = 0; i < 100; i++) {
-               tally_add(tally, max - i);
-               tally_add(tally, min + 1 + i);
-               mode = tally_approx_mode(tally, &err);
-               ok1(mode - (ssize_t)err <= 0 && mode + (ssize_t)err >= 0);
-       }
-       free(tally);
-
-       tally = tally_new(10);
-       tally_add(tally, 0);
-       for (i = 0; i < 100; i++) {
-               tally_add(tally, i);
-               mode = tally_approx_mode(tally, &err);
-               if (i < 10)
-                       ok1(err == 0);
-               ok1(mode - (ssize_t)err <= 0 && mode + (ssize_t)err >= 0);
-       }
-
-       free(tally);
-       return exit_status();
-}
diff --git a/lib/ccan/tally/test/run-renormalize.c b/lib/ccan/tally/test/run-renormalize.c
deleted file mode 100644 (file)
index 8fe9dbc..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <ccan/tally/tally.c>
-#include <ccan/tap/tap.h>
-
-int main(void)
-{
-       struct tally *tally = tally_new(2);
-
-       plan_tests(4);
-       tally->min = 0;
-       tally->max = 0;
-       tally->counts[0] = 1;
-
-       /* This renormalize should do nothing. */
-       renormalize(tally, 0, 1);
-       ok1(tally->counts[0] == 1);
-       ok1(tally->counts[1] == 0);
-       tally->counts[1]++;
-
-       /* This renormalize should collapse both into bucket 0. */
-       renormalize(tally, 0, 3);
-       ok1(tally->counts[0] == 2);
-       ok1(tally->counts[1] == 0);
-
-       free(tally);
-       return exit_status();
-}
diff --git a/lib/ccan/tally/test/run-total.c b/lib/ccan/tally/test/run-total.c
deleted file mode 100644 (file)
index d7d73e5..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#include <ccan/tally/tally.c>
-#include <ccan/tap/tap.h>
-
-int main(void)
-{
-       struct tally *tally;
-       ssize_t total, overflow;
-       ssize_t min, max;
-
-       max = (ssize_t)~(1ULL << (sizeof(max)*CHAR_BIT - 1));
-       min = (ssize_t)(1ULL << (sizeof(max)*CHAR_BIT - 1));
-
-       plan_tests(15);
-
-       /* Simple case. */
-       tally = tally_new(0);
-       tally_add(tally, min);
-       ok1(tally_total(tally, NULL) == min);
-       ok1(tally_total(tally, &overflow) == min);
-       ok1(overflow == -1);
-
-       /* Underflow. */
-       tally_add(tally, min);
-       total = tally_total(tally, &overflow);
-       ok1(overflow == -1);
-       ok1((size_t)total == 0);
-       ok1(tally_total(tally, NULL) == min);
-       free(tally);
-
-       /* Simple case. */
-       tally = tally_new(0);
-       tally_add(tally, max);
-       ok1(tally_total(tally, NULL) == max);
-       ok1(tally_total(tally, &overflow) == max);
-       ok1(overflow == 0);
-
-       /* Overflow into sign bit... */
-       tally_add(tally, max);
-       total = tally_total(tally, &overflow);
-       ok1(overflow == 0);
-       ok1((size_t)total == (size_t)-2);
-       ok1(tally_total(tally, NULL) == max);
-
-       /* Overflow into upper size_t. */
-       tally_add(tally, max);
-       total = tally_total(tally, &overflow);
-       ok1(overflow == 1);
-       if (sizeof(size_t) == 4)
-               ok1((size_t)total == 0x7FFFFFFD);
-       else if (sizeof(size_t) == 8)
-               ok1((size_t)total == 0x7FFFFFFFFFFFFFFDULL);
-       ok1(tally_total(tally, NULL) == max);
-       free(tally);
-
-       return exit_status();
-}
diff --git a/lib/ccan/tcon/_info b/lib/ccan/tcon/_info
deleted file mode 100644 (file)
index 02c0dd8..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#include "config.h"
-#include <string.h>
-
-/**
- * tcon - routines for creating typesafe generic containers
- *
- * This code lets users create a structure with a typecanary; your API
- * is then a set of macros which check the type canary before calling
- * the generic routines.
- *
- * Example:
- *     #include <ccan/tcon/tcon.h>
- *     #include <stdio.h>
- *
- *     // A simple container class.  Can only contain one thing though!
- *     struct container {
- *             void *contents;
- *     };
- *     static inline void container_add_raw(struct container *c, void *p)
- *     {
- *             c->contents = p;
- *     }
- *     static inline void *container_get_raw(struct container *c)
- *     {
- *             return c->contents;
- *     }
- *
- *     // This lets the user define their container type; includes a
- *     // "type canary" to check types against.
- *     #define DEFINE_TYPED_CONTAINER_STRUCT(name, type) \
- *             struct name { struct container raw; TCON(type canary); }
- *
- *     // These macros make sure the container type and pointer match.
- *     #define container_add(c, p) \
- *             container_add_raw(&tcon_check((c), canary, (p))->raw, (p))
- *     #define container_get(c) \
- *             tcon_cast((c), canary, container_get_raw(&(c)->raw))
- *
- *     // Now, let's define two different containers.
- *     DEFINE_TYPED_CONTAINER_STRUCT(int_container, int *);
- *     DEFINE_TYPED_CONTAINER_STRUCT(string_container, char *);
- *
- *     int main(int argc, char *argv[])
- *     {
- *             struct int_container ic;
- *             struct string_container sc;
- *
- *             // We would get a warning if we used the wrong types...
- *             container_add(&ic, &argc);
- *             container_add(&sc, argv[argc-1]);
- *
- *             printf("Last arg is %s of %i arguments\n",
- *                    container_get(&sc), *container_get(&ic) - 1);
- *             return 0;
- *     }
- *     // Given "foo" outputs "Last arg is foo of 1 arguments"
- *     // Given "foo bar" outputs "Last arg is bar of 2 arguments"
- *
- * License: Public domain
- *
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- */
-int main(int argc, char *argv[])
-{
-       /* Expect exactly one argument */
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/tcon/tcon.h b/lib/ccan/tcon/tcon.h
deleted file mode 100644 (file)
index 93c3ea6..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Placed into the public domain */
-#ifndef CCAN_TCON_H
-#define CCAN_TCON_H
-#include "config.h"
-
-/**
- * TCON - declare a _tcon type containing canary variables.
- * @decls: the semi-colon separated list of type canaries.
- *
- * This declares a _tcon member for a structure.  It should be the
- * last element in your structure; with sufficient compiler support it
- * will not use any actual storage.  tcon_check() will compare
- * expressions with one of these "type canaries" to cause warnings if
- * the container is misused.
- *
- * A type of "void *" will allow tcon_check() to pass on any (pointer) type.
- *
- * Example:
- *     // Simply typesafe linked list.
- *     struct list_head {
- *             struct list_head *prev, *next;
- *     };
- *
- *     struct string_list {
- *             struct list_head raw;
- *             TCON(char *canary);
- *     };
- *
- *     // More complex: mapping from one type to another.
- *     struct map {
- *             void *contents;
- *     };
- *
- *     struct int_to_string_map {
- *             struct map raw;
- *             TCON(char *charp_canary; int int_canary);
- *     };
- */
-#if HAVE_FLEXIBLE_ARRAY_MEMBER
-#define TCON(decls) struct { decls; } _tcon[]
-#else
-#define TCON(decls) struct { decls; } _tcon[1]
-#endif
-
-/**
- * tcon_check - typecheck a typed container
- * @x: the structure containing the TCON.
- * @canary: which canary to check against.
- * @expr: the expression whose type must match the TCON (not evaluated)
- *
- * This macro is used to check that the expression is the type
- * expected for this structure (note the "useless" sizeof() argument
- * which contains this comparison with the type canary).
- *
- * It evaluates to @x so you can chain it.
- *
- * Example:
- *     #define tlist_add(h, n, member) \
- *             list_add(&tcon_check((h), canary, (n))->raw, &(n)->member)
- */
-#define tcon_check(x, canary, expr)                            \
-       (sizeof((x)->_tcon[0].canary == (expr)) ? (x) : (x))
-
-/**
- * tcon_check_ptr - typecheck a typed container
- * @x: the structure containing the TCON.
- * @canary: which canary to check against.
- * @expr: the expression whose type must match &TCON (not evaluated)
- *
- * This macro is used to check that the expression is a pointer to the type
- * expected for this structure (note the "useless" sizeof() argument
- * which contains this comparison with the type canary), or NULL.
- *
- * It evaluates to @x so you can chain it.
- */
-#define tcon_check_ptr(x, canary, expr)                                \
-       (sizeof(&(x)->_tcon[0].canary == (expr)) ? (x) : (x))
-
-
-/**
- * tcon_type - the type within a container (or void *)
- * @x: the structure containing the TCON.
- * @canary: which canary to check against.
- */
-#if HAVE_TYPEOF
-#define tcon_type(x, canary) __typeof__((x)->_tcon[0].canary)
-#else
-#define tcon_type(x, canary) void *
-#endif
-
-/**
- * tcon_ptr_type - pointer to the type within a container (or void *)
- * @x: the structure containing the TCON.
- * @canary: which canary to check against.
- */
-#if HAVE_TYPEOF
-#define tcon_ptr_type(x, canary) __typeof__(&(x)->_tcon[0].canary)
-#else
-#define tcon_ptr_type(x, canary) void *
-#endif
-
-/**
- * tcon_cast - cast to a canary type for this container (or void *)
- * @x: a structure containing the TCON.
- * @canary: which canary to cast to.
- * @expr: the value to cast
- *
- * This is used to cast to the correct type for this container.  If the
- * platform doesn't HAVE_TYPEOF, then it casts to void * (which will
- * cause a warning if the user doesn't expect a pointer type).
- */
-#define tcon_cast(x, canary, expr) ((tcon_type((x), canary))(expr))
-#define tcon_cast_ptr(x, canary, expr) ((tcon_ptr_type((x), canary))(expr))
-
-#endif /* CCAN_TCON_H */
diff --git a/lib/ccan/tcon/test/compile_fail-tcon_cast.c b/lib/ccan/tcon/test/compile_fail-tcon_cast.c
deleted file mode 100644 (file)
index f80ef42..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <ccan/tcon/tcon.h>
-#include <stdlib.h>
-
-struct container {
-       void *p;
-};
-
-struct int_and_charp_container {
-       struct container raw;
-       TCON(int *tc1; char *tc2);
-};
-
-int main(int argc, char *argv[])
-{
-       struct int_and_charp_container icon;
-#ifdef FAIL
-#if !HAVE_TYPEOF
-#error We cannot detect type problems without HAVE_TYPEOF
-#endif
-       char *
-#else
-       int *
-#endif
-               x;
-
-       icon.raw.p = NULL;
-       x = tcon_cast(&icon, tc1, icon.raw.p);
-       return 0;
-}
diff --git a/lib/ccan/tcon/test/compile_fail.c b/lib/ccan/tcon/test/compile_fail.c
deleted file mode 100644 (file)
index 683bbd6..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <ccan/tcon/tcon.h>
-#include <stdlib.h>
-
-struct container {
-       void *p;
-};
-
-struct int_container {
-       struct container raw;
-       TCON(int *canary);
-};
-
-int main(int argc, char *argv[])
-{
-       struct int_container icon;
-#ifdef FAIL
-       char *
-#else
-       int *
-#endif
-               x = NULL;
-
-       tcon_check(&icon, canary, x)->raw.p = x;
-       return 0;
-}
diff --git a/lib/ccan/tcon/test/compile_ok-void.c b/lib/ccan/tcon/test/compile_ok-void.c
deleted file mode 100644 (file)
index 26b712f..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <ccan/tcon/tcon.h>
-#include <stdlib.h>
-
-struct container {
-       void *p;
-};
-
-struct void_container {
-       struct container raw;
-       TCON(void *canary);
-};
-
-int main(int argc, char *argv[])
-{
-       struct void_container vcon;
-
-       tcon_check(&vcon, canary, NULL)->raw.p = NULL;
-       tcon_check(&vcon, canary, argv[0])->raw.p = NULL;
-       tcon_check(&vcon, canary, main)->raw.p = NULL;
-       return 0;
-}
diff --git a/lib/ccan/tcon/test/compile_ok.c b/lib/ccan/tcon/test/compile_ok.c
deleted file mode 100644 (file)
index 447f0ee..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <ccan/tcon/tcon.h>
-#include <stdlib.h>
-
-struct container {
-       void *p;
-};
-
-struct int_container {
-       struct container raw;
-       TCON(int tc);
-};
-
-struct charp_and_int_container {
-       struct container raw;
-       TCON(int tc1; char *tc2);
-};
-
-int main(int argc, char *argv[])
-{
-       struct int_container icon;
-       struct charp_and_int_container cicon;
-
-       tcon_check(&icon, tc, 7)->raw.p = NULL;
-       tcon_check(&cicon, tc1, 7)->raw.p = argv[0];
-       tcon_check(&cicon, tc2, argv[0])->raw.p = argv[0];
-       return 0;
-}
diff --git a/lib/ccan/time/LICENSE b/lib/ccan/time/LICENSE
deleted file mode 100644 (file)
index 89de354..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/lib/ccan/time/_info b/lib/ccan/time/_info
deleted file mode 100644 (file)
index fdad275..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <string.h>
-#include "config.h"
-
-/**
- * time - routines for dealing with time
- *
- * This code provides convenient functions for working with time.
- *
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- * License: BSD-MIT
- *
- * Example:
- *     #include <ccan/time/time.h>
- *     #include <stdlib.h>
- *     #include <stdio.h>
- *     #include <err.h>
- *
- *     int main(int argc, char *argv[])
- *     {
- *             struct timeval t;
- *
- *             if (argc != 2)
- *                     errx(1, "Usage: %s <diff in millisec>", argv[0]);
- *
- *             t = time_now();
- *             if (argv[1][0] == '-')
- *                     t = time_sub(t, time_from_msec(atol(argv[1]+1)));
- *             else
- *                     t = time_add(t, time_from_msec(atol(argv[1])));
- *
- *             printf("%lu.%06u\n",
- *                    (unsigned long)t.tv_sec, (unsigned)t.tv_usec);
- *             return 0;
- *     }
- */
-int main(int argc, char *argv[])
-{
-       /* Expect exactly one argument */
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/time/test/run.c b/lib/ccan/time/test/run.c
deleted file mode 100644 (file)
index 8039169..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-#include <ccan/time/time.h>
-#include <ccan/time/time.c>
-#include <ccan/tap/tap.h>
-
-int main(void)
-{
-       struct timeval t1, t2, t3, zero = { 0, 0 };
-
-       plan_tests(46);
-
-       /* Test time_now */
-       t1 = time_now();
-       t2 = time_now();
-
-       /* Test time_sub. */
-       t3 = time_sub(t2, t1);
-       ok1(t3.tv_sec > 0 || t3.tv_usec >= 0);
-       t3 = time_sub(t2, t2);
-       ok1(t3.tv_sec == 0 && t3.tv_usec == 0);
-       t3 = time_sub(t1, t1);
-       ok1(t3.tv_sec == 0 && t3.tv_usec == 0);
-
-       /* Test time_eq */
-       ok1(time_eq(t1, t1));
-       ok1(time_eq(t2, t2));
-       ok1(!time_eq(t1, t3));
-       ok1(!time_eq(t2, t3));
-
-       /* Make sure t2 > t1. */
-       t3.tv_sec = 0;
-       t3.tv_usec = 1;
-       t2 = time_add(t2, t3);
-
-       /* Test time_less and time_greater. */
-       ok1(!time_eq(t1, t2));
-       ok1(!time_greater(t1, t2));
-       ok1(time_less(t1, t2));
-       ok1(time_greater(t2, t1));
-       ok1(!time_less(t2, t1));
-       t3.tv_sec = 0;
-       t3.tv_usec = 999999;
-       t2 = time_add(t2, t3);
-       ok1(!time_eq(t1, t2));
-       ok1(!time_greater(t1, t2));
-       ok1(time_less(t1, t2));
-       ok1(time_greater(t2, t1));
-       ok1(!time_less(t2, t1));
-
-       t3 = time_sub(t2, zero);
-       ok1(time_eq(t3, t2));
-       t3 = time_sub(t2, t2);
-       ok1(time_eq(t3, zero));
-
-       /* time_from_msec / time_to_msec */
-       t3 = time_from_msec(500);
-       ok1(t3.tv_sec == 0);
-       ok1(t3.tv_usec == 500000);
-       ok1(time_to_msec(t3) == 500);
-
-       t3 = time_from_msec(1000);
-       ok1(t3.tv_sec == 1);
-       ok1(t3.tv_usec == 0);
-       ok1(time_to_msec(t3) == 1000);
-
-       t3 = time_from_msec(1500);
-       ok1(t3.tv_sec == 1);
-       ok1(t3.tv_usec == 500000);
-       ok1(time_to_msec(t3) == 1500);
-
-       /* time_from_usec */
-       t3 = time_from_usec(500000);
-       ok1(t3.tv_sec == 0);
-       ok1(t3.tv_usec == 500000);
-       ok1(time_to_usec(t3) == 500000);
-
-       t3 = time_from_usec(1000000);
-       ok1(t3.tv_sec == 1);
-       ok1(t3.tv_usec == 0);
-       ok1(time_to_usec(t3) == 1000000);
-
-       t3 = time_from_usec(1500000);
-       ok1(t3.tv_sec == 1);
-       ok1(t3.tv_usec == 500000);
-       ok1(time_to_usec(t3) == 1500000);
-
-       /* Test wrapunder */
-       t3 = time_sub(time_sub(t2, time_from_msec(500)), time_from_msec(500));
-       ok1(t3.tv_sec == t2.tv_sec - 1);
-       ok1(t3.tv_usec == t2.tv_usec);
-
-       /* time_divide and time_multiply */
-       t1.tv_usec = 100;
-       t1.tv_sec = 100;
-
-       t3 = time_divide(t1, 2);
-       ok1(t3.tv_sec == 50);
-       ok1(t3.tv_usec == 50);
-
-       t3 = time_divide(t1, 100);
-       ok1(t3.tv_sec == 1);
-       ok1(t3.tv_usec == 1);
-
-       t3 = time_multiply(t3, 100);
-       ok1(time_eq(t3, t1));
-
-       t3 = time_divide(t1, 200);
-       ok1(t3.tv_sec == 0);
-       ok1(t3.tv_usec == 500000);
-
-       return exit_status();
-}
diff --git a/lib/ccan/time/time.c b/lib/ccan/time/time.c
deleted file mode 100644 (file)
index 5e36bf7..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/* Licensed under BSD-MIT - see LICENSE file for details */
-#include <ccan/time/time.h>
-#include <stdlib.h>
-#include <assert.h>
-
-struct timeval time_now(void)
-{
-       struct timeval now;
-       gettimeofday(&now, NULL);
-       return now;
-}
-
-bool time_greater(struct timeval a, struct timeval b)
-{
-       if (a.tv_sec > b.tv_sec)
-               return true;
-       else if (a.tv_sec < b.tv_sec)
-                return false;
-
-       return a.tv_usec > b.tv_usec;
-}
-
-bool time_less(struct timeval a, struct timeval b)
-{
-       if (a.tv_sec < b.tv_sec)
-               return true;
-       else if (a.tv_sec > b.tv_sec)
-                return false;
-
-       return a.tv_usec < b.tv_usec;
-}
-
-bool time_eq(struct timeval a, struct timeval b)
-{
-       return a.tv_sec == b.tv_sec && a.tv_usec == b.tv_usec;
-}
-
-struct timeval time_sub(struct timeval recent, struct timeval old)
-{
-       struct timeval diff;
-
-       diff.tv_sec = recent.tv_sec - old.tv_sec;
-       if (old.tv_usec > recent.tv_usec) {
-               diff.tv_sec--;
-               diff.tv_usec = 1000000 + recent.tv_usec - old.tv_usec;
-       } else
-               diff.tv_usec = recent.tv_usec - old.tv_usec;
-
-       assert(diff.tv_sec >= 0);
-       return diff;
-}
-
-struct timeval time_add(struct timeval a, struct timeval b)
-{
-       struct timeval sum;
-
-       sum.tv_sec = a.tv_sec + b.tv_sec;
-       sum.tv_usec = a.tv_usec + b.tv_usec;
-       if (sum.tv_usec > 1000000) {
-               sum.tv_sec++;
-               sum.tv_usec -= 1000000;
-       }
-       return sum;
-}
-
-struct timeval time_divide(struct timeval t, unsigned long div)
-{
-       return time_from_usec(time_to_usec(t) / div);
-}
-
-struct timeval time_multiply(struct timeval t, unsigned long mult)
-{
-       return time_from_usec(time_to_usec(t) * mult);
-}
-
-uint64_t time_to_msec(struct timeval t)
-{
-       uint64_t msec;
-
-       msec = t.tv_usec / 1000 + (uint64_t)t.tv_sec * 1000;
-       return msec;
-}
-
-uint64_t time_to_usec(struct timeval t)
-{
-       uint64_t usec;
-
-       usec = t.tv_usec + (uint64_t)t.tv_sec * 1000000;
-       return usec;
-}
-
-struct timeval time_from_msec(uint64_t msec)
-{
-       struct timeval t;
-
-       t.tv_usec = (msec % 1000) * 1000;
-       t.tv_sec = msec / 1000;
-       return t;
-}
-
-struct timeval time_from_usec(uint64_t usec)
-{
-       struct timeval t;
-
-       t.tv_usec = usec % 1000000;
-       t.tv_sec = usec / 1000000;
-       return t;
-}
diff --git a/lib/ccan/time/time.d b/lib/ccan/time/time.d
deleted file mode 100644 (file)
index d61a626..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-ccan/time/time.o: ccan/time/time.c ccan/time/time.h config.h \
- /usr/include/i386-linux-gnu/sys/time.h /usr/include/features.h \
- /usr/include/i386-linux-gnu/bits/predefs.h \
- /usr/include/i386-linux-gnu/sys/cdefs.h \
- /usr/include/i386-linux-gnu/bits/wordsize.h \
- /usr/include/i386-linux-gnu/gnu/stubs.h \
- /usr/include/i386-linux-gnu/gnu/stubs-32.h \
- /usr/include/i386-linux-gnu/bits/types.h \
- /usr/include/i386-linux-gnu/bits/typesizes.h /usr/include/time.h \
- /usr/include/i386-linux-gnu/bits/time.h \
- /usr/include/i386-linux-gnu/sys/select.h \
- /usr/include/i386-linux-gnu/bits/select.h \
- /usr/include/i386-linux-gnu/bits/sigset.h \
- /usr/lib/gcc/i686-linux-gnu/4.5.4/include/stdint.h /usr/include/stdint.h \
- /usr/include/i386-linux-gnu/bits/wchar.h \
- /usr/lib/gcc/i686-linux-gnu/4.5.4/include/stdbool.h \
- /usr/include/stdlib.h /usr/lib/gcc/i686-linux-gnu/4.5.4/include/stddef.h \
- /usr/include/i386-linux-gnu/bits/waitflags.h \
- /usr/include/i386-linux-gnu/bits/waitstatus.h /usr/include/endian.h \
- /usr/include/i386-linux-gnu/bits/endian.h \
- /usr/include/i386-linux-gnu/bits/byteswap.h /usr/include/xlocale.h \
- /usr/include/i386-linux-gnu/sys/types.h \
- /usr/include/i386-linux-gnu/sys/sysmacros.h \
- /usr/include/i386-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
- /usr/include/assert.h
diff --git a/lib/ccan/time/time.h b/lib/ccan/time/time.h
deleted file mode 100644 (file)
index fb2ee45..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-/* Licensed under BSD-MIT - see LICENSE file for details */
-#ifndef CCAN_TIME_H
-#define CCAN_TIME_H
-#include "config.h"
-#include <sys/time.h>
-#include <stdint.h>
-#include <stdbool.h>
-
-/**
- * time_now - return the current time
- *
- * Example:
- *     printf("Now is %lu seconds since epoch\n", (long)time_now().tv_sec);
- */
-struct timeval time_now(void);
-
-/**
- * time_greater - is a after b?
- * @a: one time.
- * @b: another time.
- *
- * Example:
- *     static bool timed_out(const struct timeval *start)
- *     {
- *     #define TIMEOUT time_from_msec(1000)
- *             return time_greater(time_now(), time_add(*start, TIMEOUT));
- *     }
- */
-bool time_greater(struct timeval a, struct timeval b);
-
-/**
- * time_less - is a before b?
- * @a: one time.
- * @b: another time.
- *
- * Example:
- *     static bool still_valid(const struct timeval *start)
- *     {
- *     #define TIMEOUT time_from_msec(1000)
- *             return time_less(time_now(), time_add(*start, TIMEOUT));
- *     }
- */
-bool time_less(struct timeval a, struct timeval b);
-
-/**
- * time_eq - is a equal to b?
- * @a: one time.
- * @b: another time.
- *
- * Example:
- *     #include <sys/types.h>
- *     #include <sys/wait.h>
- *
- *     // Can we fork in under a microsecond?
- *     static bool fast_fork(void)
- *     {
- *             struct timeval start = time_now();
- *             if (fork() != 0) {
- *                     exit(0);
- *             }
- *             wait(NULL);
- *             return time_eq(start, time_now());
- *     }
- */
-bool time_eq(struct timeval a, struct timeval b);
-
-/**
- * time_sub - subtract two times
- * @recent: the larger (more recent) time.
- * @old: the smaller (less recent) time.
- *
- * This returns a well formed struct timeval.
- *
- * Example:
- *     static bool was_recent(const struct timeval *start)
- *     {
- *             return time_sub(time_now(), *start).tv_sec < 1;
- *     }
- */
-struct timeval time_sub(struct timeval recent, struct timeval old);
-
-/**
- * time_add - add two times
- * @a: one time.
- * @b: another time.
- *
- * The times must not overflow, or the results are undefined.
- *
- * Example:
- *     // We do one every second.
- *     static struct timeval next_time(void)
- *     {
- *             return time_add(time_now(), time_from_msec(1000));
- *     }
- */
-struct timeval time_add(struct timeval a, struct timeval b);
-
-/**
- * time_divide - divide a time by a value.
- * @t: a time.
- * @div: number to divide it by.
- *
- * Example:
- *     // How long does it take to do a fork?
- *     static struct timeval forking_time(void)
- *     {
- *             struct timeval start = time_now();
- *             unsigned int i;
- *
- *             for (i = 0; i < 1000; i++) {
- *                     if (fork() != 0) {
- *                             exit(0);
- *                     }
- *                     wait(NULL);
- *             }
- *             return time_divide(time_sub(time_now(), start), i);
- *     }
- */
-struct timeval time_divide(struct timeval t, unsigned long div);
-
-/**
- * time_multiply - multiply a time by a value.
- * @t: a time.
- * @mult: number to multiply it by.
- *
- * Example:
- *     ...
- *     printf("Time to do 100000 forks would be %u sec\n",
- *            (unsigned)time_multiply(forking_time(), 1000000).tv_sec);
- */
-struct timeval time_multiply(struct timeval t, unsigned long mult);
-
-/**
- * time_to_msec - return number of milliseconds
- * @t: a time
- *
- * It's often more convenient to deal with time values as
- * milliseconds.  Note that this will fit into a 32-bit variable if
- * it's a time difference of less than ~7 weeks.
- *
- * Example:
- *     ...
- *     printf("Forking time is %u msec\n",
- *            (unsigned)time_to_msec(forking_time()));
- */
-uint64_t time_to_msec(struct timeval t);
-
-/**
- * time_to_usec - return number of microseconds
- * @t: a time
- *
- * It's often more convenient to deal with time values as
- * microseconds.  Note that this will fit into a 32-bit variable if
- * it's a time difference of less than ~1 hour.
- *
- * Example:
- *     ...
- *     printf("Forking time is %u usec\n",
- *            (unsigned)time_to_usec(forking_time()));
- *
- */
-uint64_t time_to_usec(struct timeval t);
-
-/**
- * time_from_msec - convert milliseconds to a timeval
- * @msec: time in milliseconds
- *
- * Example:
- *     // 1/2 second timeout
- *     #define TIMEOUT time_from_msec(500)
- */
-struct timeval time_from_msec(uint64_t msec);
-
-/**
- * time_from_usec - convert microseconds to a timeval
- * @usec: time in microseconds
- *
- * Example:
- *     // 1/2 second timeout
- *     #define TIMEOUT time_from_usec(500000)
- */
-struct timeval time_from_usec(uint64_t usec);
-
-#endif /* CCAN_TIME_H */
diff --git a/lib/ccan/tlist/LICENSE b/lib/ccan/tlist/LICENSE
deleted file mode 100644 (file)
index cca7fc2..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
-  This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
-  0. Additional Definitions.
-
-  As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
-  "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
-  An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
-  A "Combined Work" is a work produced by combining or linking an
-Application with the Library.  The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
-  The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
-  The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
-  1. Exception to Section 3 of the GNU GPL.
-
-  You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
-  2. Conveying Modified Versions.
-
-  If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
-   a) under this License, provided that you make a good faith effort to
-   ensure that, in the event an Application does not supply the
-   function or data, the facility still operates, and performs
-   whatever part of its purpose remains meaningful, or
-
-   b) under the GNU GPL, with none of the additional permissions of
-   this License applicable to that copy.
-
-  3. Object Code Incorporating Material from Library Header Files.
-
-  The object code form of an Application may incorporate material from
-a header file that is part of the Library.  You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
-   a) Give prominent notice with each copy of the object code that the
-   Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the object code with a copy of the GNU GPL and this license
-   document.
-
-  4. Combined Works.
-
-  You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
-   a) Give prominent notice with each copy of the Combined Work that
-   the Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the Combined Work with a copy of the GNU GPL and this license
-   document.
-
-   c) For a Combined Work that displays copyright notices during
-   execution, include the copyright notice for the Library among
-   these notices, as well as a reference directing the user to the
-   copies of the GNU GPL and this license document.
-
-   d) Do one of the following:
-
-       0) Convey the Minimal Corresponding Source under the terms of this
-       License, and the Corresponding Application Code in a form
-       suitable for, and under terms that permit, the user to
-       recombine or relink the Application with a modified version of
-       the Linked Version to produce a modified Combined Work, in the
-       manner specified by section 6 of the GNU GPL for conveying
-       Corresponding Source.
-
-       1) Use a suitable shared library mechanism for linking with the
-       Library.  A suitable mechanism is one that (a) uses at run time
-       a copy of the Library already present on the user's computer
-       system, and (b) will operate properly with a modified version
-       of the Library that is interface-compatible with the Linked
-       Version.
-
-   e) Provide Installation Information, but only if you would otherwise
-   be required to provide such information under section 6 of the
-   GNU GPL, and only to the extent that such information is
-   necessary to install and execute a modified version of the
-   Combined Work produced by recombining or relinking the
-   Application with a modified version of the Linked Version. (If
-   you use option 4d0, the Installation Information must accompany
-   the Minimal Corresponding Source and Corresponding Application
-   Code. If you use option 4d1, you must provide the Installation
-   Information in the manner specified by section 6 of the GNU GPL
-   for conveying Corresponding Source.)
-
-  5. Combined Libraries.
-
-  You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
-   a) Accompany the combined library with a copy of the same work based
-   on the Library, uncombined with any other library facilities,
-   conveyed under the terms of this License.
-
-   b) Give prominent notice with the combined library that part of it
-   is a work based on the Library, and explaining where to find the
-   accompanying uncombined form of the same work.
-
-  6. Revised Versions of the GNU Lesser General Public License.
-
-  The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
-  Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
-  If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/lib/ccan/tlist/_info b/lib/ccan/tlist/_info
deleted file mode 100644 (file)
index e18e2ef..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * tlist - typesafe double linked list routines
- *
- * The list header contains routines for manipulating double linked lists;
- * this extends it so you can create list head types which only accomodate
- * a specific entry type.
- *
- * Example:
- *     #include <err.h>
- *     #include <stdio.h>
- *     #include <stdlib.h>
- *     #include <ccan/tlist/tlist.h>
- *
- *     // We could use TLIST_TYPE(children, struct child) to define this.
- *     struct tlist_children {
- *             struct list_head raw;
- *             TCON(struct child *canary);
- *     };
- *     struct parent {
- *             const char *name;
- *             struct tlist_children children;
- *             unsigned int num_children;
- *     };
- *
- *     struct child {
- *             const char *name;
- *             struct list_node list;
- *     };
- *
- *     int main(int argc, char *argv[])
- *     {
- *             struct parent p;
- *             struct child *c;
- *             unsigned int i;
- *
- *             if (argc < 2)
- *                     errx(1, "Usage: %s parent children...", argv[0]);
- *
- *             p.name = argv[1];
- *             tlist_init(&p.children);
- *             for (i = 2; i < argc; i++) {
- *                     c = malloc(sizeof(*c));
- *                     c->name = argv[i];
- *                     tlist_add(&p.children, c, list);
- *                     p.num_children++;
- *             }
- *
- *             printf("%s has %u children:", p.name, p.num_children);
- *             tlist_for_each(&p.children, c, list)
- *                     printf("%s ", c->name);
- *             printf("\n");
- *             return 0;
- *     }
- *
- * License: LGPL
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               printf("ccan/list\n");
-               printf("ccan/tcon\n");
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/tlist/test/compile_fail-tlist_add.c b/lib/ccan/tlist/test/compile_fail-tlist_add.c
deleted file mode 100644 (file)
index addcf01..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <ccan/tlist/tlist.h>
-
-TLIST_TYPE(children, struct child);
-TLIST_TYPE(cousins, struct cousin);
-
-struct child {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-struct cousin {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-int main(int argc, char *argv[])
-{
-       struct tlist_children children;
-       struct tlist_cousins cousins;
-       struct child child = { "child" };
-       struct cousin cousin = { "cousin" };
-
-       tlist_init(&children);
-       tlist_init(&cousins);
-       tlist_add(&children, &child, list);
-       tlist_add(&cousins, &cousin, list);
-       tlist_del_from(&cousins, &cousin, list);
-#ifdef FAIL
-#if !HAVE_FLEXIBLE_ARRAY_MEMBER
-#error Need flexible array members to check type
-#endif
-       tlist_add(&children, &cousin, list);
-#endif
-       return 0;
-}
diff --git a/lib/ccan/tlist/test/compile_fail-tlist_add_tail.c b/lib/ccan/tlist/test/compile_fail-tlist_add_tail.c
deleted file mode 100644 (file)
index cfa5d89..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <ccan/tlist/tlist.h>
-
-TLIST_TYPE(children, struct child);
-TLIST_TYPE(cousins, struct cousin);
-
-struct child {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-struct cousin {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-int main(int argc, char *argv[])
-{
-       struct tlist_children children;
-       struct tlist_cousins cousins;
-       struct child child = { "child" };
-       struct cousin cousin = { "cousin" };
-
-       tlist_init(&children);
-       tlist_init(&cousins);
-       tlist_add(&children, &child, list);
-       tlist_add(&cousins, &cousin, list);
-       tlist_del_from(&cousins, &cousin, list);
-#ifdef FAIL
-#if !HAVE_FLEXIBLE_ARRAY_MEMBER
-#error Need flexible array members to check type
-#endif
-       tlist_add_tail(&children, &cousin, list);
-#endif
-       return 0;
-}
diff --git a/lib/ccan/tlist/test/compile_fail-tlist_del_from.c b/lib/ccan/tlist/test/compile_fail-tlist_del_from.c
deleted file mode 100644 (file)
index d3314da..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <ccan/tlist/tlist.h>
-
-TLIST_TYPE(children, struct child);
-TLIST_TYPE(cousins, struct cousin);
-
-struct child {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-struct cousin {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-int main(int argc, char *argv[])
-{
-       struct tlist_children children;
-       struct tlist_cousins cousins;
-       struct child child = { "child" };
-       struct cousin cousin = { "cousin" };
-
-       tlist_init(&children);
-       tlist_init(&cousins);
-       tlist_add(&children, &child, list);
-       tlist_add(&cousins, &cousin, list);
-#ifdef FAIL
-#if !HAVE_FLEXIBLE_ARRAY_MEMBER
-#error Need flexible array members to check type
-#endif
-       tlist_del_from(&children, &cousin, list);
-#endif
-       return 0;
-}
diff --git a/lib/ccan/tlist/test/compile_fail-tlist_for_each.c b/lib/ccan/tlist/test/compile_fail-tlist_for_each.c
deleted file mode 100644 (file)
index 6ea0183..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <ccan/tlist/tlist.h>
-
-TLIST_TYPE(children, struct child);
-
-struct child {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-struct cousin {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-int main(int argc, char *argv[])
-{
-       struct tlist_children children;
-       struct child child = { "child" };
-#ifdef FAIL
-#if !HAVE_FLEXIBLE_ARRAY_MEMBER
-#error Need flexible array members to check type
-#endif
-       struct cousin *c;
-#else
-       struct child *c;
-#endif
-
-       tlist_init(&children);
-       tlist_add(&children, &child, list);
-
-       tlist_for_each(&children, c, list)
-               (void) c; /* Suppress unused-but-set-variable warning. */
-       return 0;
-}
diff --git a/lib/ccan/tlist/test/compile_fail-tlist_for_each_safe.c b/lib/ccan/tlist/test/compile_fail-tlist_for_each_safe.c
deleted file mode 100644 (file)
index 41a3d92..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <ccan/tlist/tlist.h>
-
-TLIST_TYPE(children, struct child);
-
-struct child {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-struct cousin {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-int main(int argc, char *argv[])
-{
-       struct tlist_children children;
-       struct child child = { "child" };
-#ifdef FAIL
-#if !HAVE_FLEXIBLE_ARRAY_MEMBER
-#error Need flexible array members to check type
-#endif
-       struct cousin *c, *n;
-#else
-       struct child *c, *n;
-#endif
-
-       tlist_init(&children);
-       tlist_add(&children, &child, list);
-
-       tlist_for_each_safe(&children, c, n, list);
-       return 0;
-}
diff --git a/lib/ccan/tlist/test/compile_fail-tlist_tail.c b/lib/ccan/tlist/test/compile_fail-tlist_tail.c
deleted file mode 100644 (file)
index 4022abf..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <ccan/tlist/tlist.h>
-
-TLIST_TYPE(children, struct child);
-
-struct child {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-struct cousin {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-int main(int argc, char *argv[])
-{
-       struct tlist_children children;
-       struct child child = { "child" };
-#ifdef FAIL
-       struct cousin *c;
-#else
-       struct child *c;
-#endif
-
-       tlist_init(&children);
-       tlist_add(&children, &child, list);
-
-       c = tlist_tail(&children, list);
-       (void) c; /* Suppress unused-but-set-variable warning. */
-       return 0;
-}
diff --git a/lib/ccan/tlist/test/compile_fail-tlist_top.c b/lib/ccan/tlist/test/compile_fail-tlist_top.c
deleted file mode 100644 (file)
index ab3591f..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <ccan/tlist/tlist.h>
-
-TLIST_TYPE(children, struct child);
-
-struct child {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-struct cousin {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-int main(int argc, char *argv[])
-{
-       struct tlist_children children;
-       struct child child = { "child" };
-#ifdef FAIL
-       struct cousin *c;
-#else
-       struct child *c;
-#endif
-
-       tlist_init(&children);
-       tlist_add(&children, &child, list);
-
-       c = tlist_top(&children, list);
-       (void) c; /* Suppress unused-but-set-variable warning. */
-       return 0;
-}
diff --git a/lib/ccan/tlist/test/run.c b/lib/ccan/tlist/test/run.c
deleted file mode 100644 (file)
index fe75c49..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-#define CCAN_LIST_DEBUG 1
-#include <ccan/tlist/tlist.h>
-#include <ccan/tap/tap.h>
-
-TLIST_TYPE(children, struct child);
-
-struct parent {
-       const char *name;
-       struct tlist_children children;
-       unsigned int num_children;
-};
-
-struct child {
-       const char *name;
-       struct ccan_list_node list;
-};
-
-int main(int argc, char *argv[])
-{
-       struct parent parent;
-       struct child c1, c2, c3, *c, *n;
-       unsigned int i;
-       struct tlist_children tlist = TLIST_INIT(tlist);
-
-       plan_tests(48);
-       /* Test TLIST_INIT, and tlist_empty */
-       ok1(tlist_empty(&tlist));
-       ok1(tlist_check(&tlist, NULL));
-
-       parent.num_children = 0;
-       tlist_init(&parent.children);
-       /* Test tlist_init */
-       ok1(tlist_empty(&parent.children));
-       ok1(tlist_check(&parent.children, NULL));
-
-       c2.name = "c2";
-       tlist_add(&parent.children, &c2, list);
-       /* Test tlist_add and !tlist_empty. */
-       ok1(!tlist_empty(&parent.children));
-       ok1(c2.list.next == &parent.children.raw.n);
-       ok1(c2.list.prev == &parent.children.raw.n);
-       ok1(parent.children.raw.n.next == &c2.list);
-       ok1(parent.children.raw.n.prev == &c2.list);
-       /* Test tlist_check */
-       ok1(tlist_check(&parent.children, NULL));
-
-       c1.name = "c1";
-       tlist_add(&parent.children, &c1, list);
-       /* Test ccan_list_add and !ccan_list_empty. */
-       ok1(!tlist_empty(&parent.children));
-       ok1(c2.list.next == &parent.children.raw.n);
-       ok1(c2.list.prev == &c1.list);
-       ok1(parent.children.raw.n.next == &c1.list);
-       ok1(parent.children.raw.n.prev == &c2.list);
-       ok1(c1.list.next == &c2.list);
-       ok1(c1.list.prev == &parent.children.raw.n);
-       /* Test tlist_check */
-       ok1(tlist_check(&parent.children, NULL));
-
-       c3.name = "c3";
-       tlist_add_tail(&parent.children, &c3, list);
-       /* Test ccan_list_add_tail and !ccan_list_empty. */
-       ok1(!tlist_empty(&parent.children));
-       ok1(parent.children.raw.n.next == &c1.list);
-       ok1(parent.children.raw.n.prev == &c3.list);
-       ok1(c1.list.next == &c2.list);
-       ok1(c1.list.prev == &parent.children.raw.n);
-       ok1(c2.list.next == &c3.list);
-       ok1(c2.list.prev == &c1.list);
-       ok1(c3.list.next == &parent.children.raw.n);
-       ok1(c3.list.prev == &c2.list);
-       /* Test tlist_check */
-       ok1(tlist_check(&parent.children, NULL));
-
-       /* Test tlist_top */
-       ok1(tlist_top(&parent.children, list) == &c1);
-
-       /* Test ccan_list_tail */
-       ok1(tlist_tail(&parent.children, list) == &c3);
-
-       /* Test tlist_for_each. */
-       i = 0;
-       tlist_for_each(&parent.children, c, list) {
-               switch (i++) {
-               case 0:
-                       ok1(c == &c1);
-                       break;
-               case 1:
-                       ok1(c == &c2);
-                       break;
-               case 2:
-                       ok1(c == &c3);
-                       break;
-               }
-               if (i > 2)
-                       break;
-       }
-       ok1(i == 3);
-
-       /* Test tlist_for_each_rev. */
-       i = 0;
-       tlist_for_each_rev(&parent.children, c, list) {
-               switch (i++) {
-               case 0:
-                       ok1(c == &c3);
-                       break;
-               case 1:
-                       ok1(c == &c2);
-                       break;
-               case 2:
-                       ok1(c == &c1);
-                       break;
-               }
-               if (i > 2)
-                       break;
-       }
-       ok1(i == 3);
-
-       /* Test tlist_for_each_safe, tlist_del and tlist_del_from. */
-       i = 0;
-       tlist_for_each_safe(&parent.children, c, n, list) {
-               switch (i++) {
-               case 0:
-                       ok1(c == &c1);
-                       tlist_del(c, list);
-                       break;
-               case 1:
-                       ok1(c == &c2);
-                       tlist_del_from(&parent.children, c, list);
-                       break;
-               case 2:
-                       ok1(c == &c3);
-                       tlist_del_from(&parent.children, c, list);
-                       break;
-               }
-               ok1(tlist_check(&parent.children, NULL));
-               if (i > 2)
-                       break;
-       }
-       ok1(i == 3);
-       ok1(tlist_empty(&parent.children));
-
-       /* Test ccan_list_top/ccan_list_tail on empty list. */
-       ok1(tlist_top(&parent.children, list) == (struct child *)NULL);
-       ok1(tlist_tail(&parent.children, list) == (struct child *)NULL);
-       return exit_status();
-}
diff --git a/lib/ccan/tlist/tlist.h b/lib/ccan/tlist/tlist.h
deleted file mode 100644 (file)
index 571ed4e..0000000
+++ /dev/null
@@ -1,265 +0,0 @@
-/* Licensed under LGPL - see LICENSE file for details */
-#ifndef CCAN_TLIST_H
-#define CCAN_TLIST_H
-#include <ccan/list/list.h>
-#include <ccan/tcon/tcon.h>
-
-/**
- * TLIST_TYPE - declare a typed list type (struct tlist)
- * @suffix: the name to use (struct tlist_@suffix)
- * @type: the type the list will contain (void for any type)
- *
- * This declares a structure "struct tlist_@suffix" to use for
- * lists containing this type.  The actual list can be accessed using
- * ".raw" or tlist_raw().
- *
- * Example:
- *     // Defines struct tlist_children
- *     TLIST_TYPE(children, struct child);
- *     struct parent {
- *             const char *name;
- *             struct tlist_children children;
- *             unsigned int num_children;
- *     };
- *
- *     struct child {
- *             const char *name;
- *             struct ccan_list_node list;
- *     };
- */
-#define TLIST_TYPE(suffix, type)                       \
-       struct tlist_##suffix {                         \
-               struct ccan_list_head raw;                      \
-               TCON(type *canary);                     \
-       }
-
-/**
- * TLIST_INIT - initalizer for an empty tlist
- * @name: the name of the list.
- *
- * Explicit initializer for an empty list.
- *
- * See also:
- *     tlist_init()
- *
- * Example:
- *     static struct tlist_children my_list = TLIST_INIT(my_list);
- */
-#define TLIST_INIT(name) { CCAN_LIST_HEAD_INIT(name.raw) }
-
-/**
- * tlist_check - check head of a list for consistency
- * @h: the tlist_head
- * @abortstr: the location to print on aborting, or NULL.
- *
- * Because list_nodes have redundant information, consistency checking between
- * the back and forward links can be done.  This is useful as a debugging check.
- * If @abortstr is non-NULL, that will be printed in a diagnostic if the list
- * is inconsistent, and the function will abort.
- *
- * Returns non-NULL if the list is consistent, NULL otherwise (it
- * can never return NULL if @abortstr is set).
- *
- * See also: ccan_list_check()
- *
- * Example:
- *     static void dump_parent(struct parent *p)
- *     {
- *             struct child *c;
- *
- *             printf("%s (%u children):\n", p->name, p->num_children);
- *             tlist_check(&p->children, "bad child list");
- *             tlist_for_each(&p->children, c, list)
- *                     printf(" -> %s\n", c->name);
- *     }
- */
-#define tlist_check(h, abortstr) \
-       ccan_list_check(&(h)->raw, (abortstr))
-
-/**
- * tlist_init - initialize a tlist
- * @h: the tlist to set to the empty list
- *
- * Example:
- *     ...
- *     struct parent *parent = malloc(sizeof(*parent));
- *
- *     tlist_init(&parent->children);
- *     parent->num_children = 0;
- */
-#define tlist_init(h) ccan_list_head_init(&(h)->raw)
-
-/**
- * tlist_raw - unwrap the typed list and check the type
- * @h: the tlist
- * @expr: the expression to check the type against (not evaluated)
- *
- * This macro usually causes the compiler to emit a warning if the
- * variable is of an unexpected type.  It is used internally where we
- * need to access the raw underlying list.
- */
-#define tlist_raw(h, expr) (&tcon_check((h), canary, (expr))->raw)
-
-/**
- * tlist_add - add an entry at the start of a linked list.
- * @h: the tlist to add the node to
- * @n: the entry to add to the list.
- * @member: the member of n to add to the list.
- *
- * The entry's ccan_list_node does not need to be initialized; it will be
- * overwritten.
- * Example:
- *     struct child *child = malloc(sizeof(*child));
- *
- *     child->name = "marvin";
- *     tlist_add(&parent->children, child, list);
- *     parent->num_children++;
- */
-#define tlist_add(h, n, member) ccan_list_add(tlist_raw((h), (n)), &(n)->member)
-
-/**
- * tlist_add_tail - add an entry at the end of a linked list.
- * @h: the tlist to add the node to
- * @n: the entry to add to the list.
- * @member: the member of n to add to the list.
- *
- * The ccan_list_node does not need to be initialized; it will be overwritten.
- * Example:
- *     tlist_add_tail(&parent->children, child, list);
- *     parent->num_children++;
- */
-#define tlist_add_tail(h, n, member) \
-       ccan_list_add_tail(tlist_raw((h), (n)), &(n)->member)
-
-/**
- * tlist_del_from - delete an entry from a linked list.
- * @h: the tlist @n is in
- * @n: the entry to delete
- * @member: the member of n to remove from the list.
- *
- * This explicitly indicates which list a node is expected to be in,
- * which is better documentation and can catch more bugs.
- *
- * Note that this leaves @n->@member in an undefined state; it
- * can be added to another list, but not deleted again.
- *
- * See also: tlist_del()
- *
- * Example:
- *     tlist_del_from(&parent->children, child, list);
- *     parent->num_children--;
- */
-#define tlist_del_from(h, n, member) \
-       ccan_list_del_from(tlist_raw((h), (n)), &(n)->member)
-
-/**
- * tlist_del - delete an entry from an unknown linked list.
- * @n: the entry to delete from the list.
- * @member: the member of @n which is in the list.
- *
- * Example:
- *     tlist_del(child, list);
- *     parent->num_children--;
- */
-#define tlist_del(n, member) \
-       ccan_list_del(&(n)->member)
-
-/**
- * tlist_empty - is a list empty?
- * @h: the tlist
- *
- * If the list is empty, returns true.
- *
- * Example:
- *     assert(tlist_empty(&parent->children) == (parent->num_children == 0));
- */
-#define tlist_empty(h) ccan_list_empty(&(h)->raw)
-
-/**
- * tlist_top - get the first entry in a list
- * @h: the tlist
- * @member: the ccan_list_node member of the type
- *
- * If the list is empty, returns NULL.
- *
- * Example:
- *     struct child *first;
- *     first = tlist_top(&parent->children, list);
- */
-#define tlist_top(h, member)                                           \
-       ((tcon_type((h), canary))                                       \
-        ccan_list_top_(&(h)->raw,                                              \
-                  (char *)(&(h)->_tcon[0].canary->member) -            \
-                  (char *)((h)->_tcon[0].canary)))
-
-/**
- * tlist_tail - get the last entry in a list
- * @h: the tlist
- * @member: the ccan_list_node member of the type
- *
- * If the list is empty, returns NULL.
- *
- * Example:
- *     struct child *last;
- *     last = tlist_tail(&parent->children, list);
- */
-#define tlist_tail(h, member)                                          \
-       ((tcon_type((h), canary))                                       \
-        ccan_list_tail_(&(h)->raw,                                             \
-                   (char *)(&(h)->_tcon[0].canary->member) -           \
-                   (char *)((h)->_tcon[0].canary)))
-
-/**
- * tlist_for_each - iterate through a list.
- * @h: the tlist
- * @i: an iterator of suitable type for this list.
- * @member: the ccan_list_node member of @i
- *
- * This is a convenient wrapper to iterate @i over the entire list.  It's
- * a for loop, so you can break and continue as normal.
- *
- * Example:
- *     tlist_for_each(&parent->children, child, list)
- *             printf("Name: %s\n", child->name);
- */
-#define tlist_for_each(h, i, member)                                   \
-       ccan_list_for_each(tlist_raw((h), (i)), (i), member)
-
-/**
- * tlist_for_each - iterate through a list backwards.
- * @h: the tlist
- * @i: an iterator of suitable type for this list.
- * @member: the ccan_list_node member of @i
- *
- * This is a convenient wrapper to iterate @i over the entire list.  It's
- * a for loop, so you can break and continue as normal.
- *
- * Example:
- *     tlist_for_each_rev(&parent->children, child, list)
- *             printf("Name: %s\n", child->name);
- */
-#define tlist_for_each_rev(h, i, member)                                       \
-       ccan_list_for_each_rev(tlist_raw((h), (i)), (i), member)
-
-/**
- * tlist_for_each_safe - iterate through a list, maybe during deletion
- * @h: the tlist
- * @i: an iterator of suitable type for this list.
- * @nxt: another iterator to store the next entry.
- * @member: the ccan_list_node member of the structure
- *
- * This is a convenient wrapper to iterate @i over the entire list.  It's
- * a for loop, so you can break and continue as normal.  The extra variable
- * @nxt is used to hold the next element, so you can delete @i from the list.
- *
- * Example:
- *     struct child *next;
- *     tlist_for_each_safe(&parent->children, child, next, list) {
- *             tlist_del(child, list);
- *             parent->num_children--;
- *     }
- */
-#define tlist_for_each_safe(h, i, nxt, member)                         \
-       ccan_list_for_each_safe(tlist_raw((h), (i)), (i), (nxt), member)
-
-#endif /* CCAN_TLIST_H */
diff --git a/lib/ccan/typesafe_cb/LICENSE b/lib/ccan/typesafe_cb/LICENSE
deleted file mode 100644 (file)
index 5522aa5..0000000
+++ /dev/null
@@ -1,508 +0,0 @@
-
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
-       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL.  It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
-                            Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations
-below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-\f
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it
-becomes a de-facto standard.  To achieve this, non-free programs must
-be allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-\f
-                  GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control
-compilation and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-\f
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at least
-    three years, to give the same user the materials specified in
-    Subsection 6a, above, for a charge no more than the cost of
-    performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-\f
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply, and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License
-may add an explicit geographical distribution limitation excluding those
-countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-                            NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-                     END OF TERMS AND CONDITIONS
-\f
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms
-of the ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.
-It is safest to attach them to the start of each source file to most
-effectively convey the exclusion of warranty; and each file should
-have at least the "copyright" line and a pointer to where the full
-notice is found.
-
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or
-your school, if any, to sign a "copyright disclaimer" for the library,
-if necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James
-  Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/lib/ccan/typesafe_cb/_info b/lib/ccan/typesafe_cb/_info
deleted file mode 100644 (file)
index ca0f103..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "config.h"
-
-/**
- * typesafe_cb - macros for safe callbacks.
- *
- * The basis of the typesafe_cb header is typesafe_cb_cast(): a
- * conditional cast macro.   If an expression exactly matches a given
- * type, it is cast to the target type, otherwise it is left alone.
- *
- * This allows us to create functions which take a small number of
- * specific types, rather than being forced to use a void *.  In
- * particular, it is useful for creating typesafe callbacks as the
- * helpers typesafe_cb(), typesafe_cb_preargs() and
- * typesafe_cb_postargs() demonstrate.
- *
- * The standard way of passing arguments to callback functions in C is
- * to use a void pointer, which the callback then casts back to the
- * expected type.  This unfortunately subverts the type checking the
- * compiler would perform if it were a direct call.  Here's an example:
- *
- *     static void my_callback(void *_obj)
- *     {
- *             struct obj *obj = _obj;
- *             ...
- *     }
- *     ...
- *             register_callback(my_callback, &my_obj);
- *
- * If we wanted to use the natural type for my_callback (ie. "void
- * my_callback(struct obj *obj)"), we could make register_callback()
- * take a void * as its first argument, but this would subvert all
- * type checking.  We really want register_callback() to accept only
- * the exactly correct function type to match the argument, or a
- * function which takes a void *.
- *
- * This is where typesafe_cb() comes in: it uses typesafe_cb_cast() to
- * cast the callback function if it matches the argument type:
- *
- *     void _register_callback(void (*cb)(void *arg), void *arg);
- *     #define register_callback(cb, arg)                              \
- *             _register_callback(typesafe_cb(void, void *, (cb), (arg)), \
- *                                (arg))
- *
- * On compilers which don't support the extensions required
- * typesafe_cb_cast() and friend become an unconditional cast, so your
- * code will compile but you won't get type checking.
- *
- * Example:
- *     #include <ccan/typesafe_cb/typesafe_cb.h>
- *     #include <stdlib.h>
- *     #include <stdio.h>
- *
- *     // Generic callback infrastructure.
- *     struct callback {
- *             struct callback *next;
- *             int value;
- *             int (*callback)(int value, void *arg);
- *             void *arg;
- *     };
- *     static struct callback *callbacks;
- *
- *     static void _register_callback(int value, int (*cb)(int, void *),
- *                                    void *arg)
- *     {
- *             struct callback *new = malloc(sizeof(*new));
- *             new->next = callbacks;
- *             new->value = value;
- *             new->callback = cb;
- *             new->arg = arg;
- *             callbacks = new;
- *     }
- *     #define register_callback(value, cb, arg)                       \
- *             _register_callback(value,                               \
- *                                typesafe_cb_preargs(int, void *,     \
- *                                                    (cb), (arg), int),\
- *                                (arg))
- *
- *     static struct callback *find_callback(int value)
- *     {
- *             struct callback *i;
- *
- *             for (i = callbacks; i; i = i->next)
- *                     if (i->value == value)
- *                             return i;
- *             return NULL;
- *     }
- *
- *     // Define several silly callbacks.  Note they don't use void *!
- *     #define DEF_CALLBACK(name, op)                  \
- *             static int name(int val, int *arg)      \
- *             {                                       \
- *                     printf("%s", #op);              \
- *                     return val op *arg;             \
- *             }
- *     DEF_CALLBACK(multiply, *);
- *     DEF_CALLBACK(add, +);
- *     DEF_CALLBACK(divide, /);
- *     DEF_CALLBACK(sub, -);
- *     DEF_CALLBACK(or, |);
- *     DEF_CALLBACK(and, &);
- *     DEF_CALLBACK(xor, ^);
- *     DEF_CALLBACK(assign, =);
- *
- *     // Silly game to find the longest chain of values.
- *     int main(int argc, char *argv[])
- *     {
- *             int i, run = 1, num = argv[1] ? atoi(argv[1]) : 0;
- *
- *             for (i = 1; i < 1024;) {
- *                     // Since run is an int, compiler checks "add" does too.
- *                     register_callback(i++, add, &run);
- *                     register_callback(i++, divide, &run);
- *                     register_callback(i++, sub, &run);
- *                     register_callback(i++, multiply, &run);
- *                     register_callback(i++, or, &run);
- *                     register_callback(i++, and, &run);
- *                     register_callback(i++, xor, &run);
- *                     register_callback(i++, assign, &run);
- *             }
- *
- *             printf("%i ", num);
- *             while (run < 56) {
- *                     struct callback *cb = find_callback(num % i);
- *                     if (!cb) {
- *                             printf("-> STOP\n");
- *                             return 1;
- *                     }
- *                     num = cb->callback(num, cb->arg);
- *                     printf("->%i ", num);
- *                     run++;
- *             }
- *             printf("-> Winner!\n");
- *             return 0;
- *     }
- *
- * License: LGPL (v2.1 or any later version)
- * Author: Rusty Russell <rusty@rustcorp.com.au>
- */
-int main(int argc, char *argv[])
-{
-       if (argc != 2)
-               return 1;
-
-       if (strcmp(argv[1], "depends") == 0) {
-               return 0;
-       }
-
-       return 1;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_fail-cast_if_any.c b/lib/ccan/typesafe_cb/test/compile_fail-cast_if_any.c
deleted file mode 100644 (file)
index dfb5116..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdlib.h>
-
-struct foo {
-       int x;
-};
-
-struct bar {
-       int x;
-};
-
-struct baz {
-       int x;
-};
-
-struct any {
-       int x;
-};
-
-struct other {
-       int x;
-};
-
-static void take_any(struct any *any)
-{
-}
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-       struct other
-#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if cast_if_type is a noop."
-#endif
-#else
-       struct foo
-#endif
-               *arg = NULL;
-       take_any(cast_if_any(struct any *, arg, arg,
-                            struct foo *, struct bar *, struct baz *));
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_fail-cast_if_type-promotable.c b/lib/ccan/typesafe_cb/test/compile_fail-cast_if_type-promotable.c
deleted file mode 100644 (file)
index 11d42f4..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdbool.h>
-
-static void _set_some_value(void *val)
-{
-}
-
-#define set_some_value(expr)                                           \
-       _set_some_value(typesafe_cb_cast(void *, long, (expr)))
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-       bool x = 0;
-#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if typesafe_cb_cast is a noop."
-#endif
-#else
-       long x = 0;
-#endif
-       set_some_value(x);
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_fail-cast_if_type.c b/lib/ccan/typesafe_cb/test/compile_fail-cast_if_type.c
deleted file mode 100644 (file)
index 6107935..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-
-void _set_some_value(void *val);
-
-void _set_some_value(void *val)
-{
-}
-
-#define set_some_value(expr)                                           \
-       _set_some_value(cast_if_type(void *, (expr), (expr), unsigned long))
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-       int x = 0;
-       set_some_value(x);
-#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if cast_if_type is a noop."
-#endif
-#else
-       void *p = 0;
-       set_some_value(p);
-#endif
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb-int.c b/lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb-int.c
deleted file mode 100644 (file)
index c403336..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdlib.h>
-
-void _callback(void (*fn)(void *arg), void *arg);
-void _callback(void (*fn)(void *arg), void *arg)
-{
-       fn(arg);
-}
-
-/* Callback is set up to warn if arg isn't a pointer (since it won't
- * pass cleanly to _callback's second arg. */
-#define callback(fn, arg)                                              \
-       _callback(typesafe_cb(void, (fn), (arg)), (arg))
-
-void my_callback(int something);
-void my_callback(int something)
-{
-}
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-       /* This fails due to arg, not due to cast. */
-       callback(my_callback, 100);
-#endif
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb.c b/lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb.c
deleted file mode 100644 (file)
index 81e36d7..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdlib.h>
-
-static void _register_callback(void (*cb)(void *arg), void *arg)
-{
-}
-
-#define register_callback(cb, arg)                             \
-       _register_callback(typesafe_cb(void, void *, (cb), (arg)), (arg))
-
-static void my_callback(char *p)
-{
-}
-
-int main(int argc, char *argv[])
-{
-       char str[] = "hello world";
-#ifdef FAIL
-       int *p;
-#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if typesafe_cb_cast is a noop."
-#endif
-#else
-       char *p;
-#endif
-       p = NULL;
-
-       /* This should work always. */
-       register_callback(my_callback, str);
-
-       /* This will fail with FAIL defined */
-       register_callback(my_callback, p);
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_cast-multi.c b/lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_cast-multi.c
deleted file mode 100644 (file)
index 62b5f91..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdlib.h>
-
-struct foo {
-       int x;
-};
-
-struct bar {
-       int x;
-};
-
-struct baz {
-       int x;
-};
-
-struct any {
-       int x;
-};
-
-struct other {
-       int x;
-};
-
-static void take_any(struct any *any)
-{
-}
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-       struct other
-#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if typesafe_cb_cast is a noop."
-#endif
-#else
-       struct foo
-#endif
-               *arg = NULL;
-       take_any(typesafe_cb_cast3(struct any *,
-                                  struct foo *, struct bar *, struct baz *,
-                                  arg));
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_cast.c b/lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_cast.c
deleted file mode 100644 (file)
index d2e6f2a..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-
-void _set_some_value(void *val);
-
-void _set_some_value(void *val)
-{
-}
-
-#define set_some_value(expr)                                           \
-       _set_some_value(typesafe_cb_cast(void *, unsigned long, (expr)))
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-       int x = 0;
-       set_some_value(x);
-#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if typesafe_cb_cast is a noop."
-#endif
-#else
-       void *p = 0;
-       set_some_value(p);
-#endif
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_exact.c b/lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_exact.c
deleted file mode 100644 (file)
index 0f61d5d..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdlib.h>
-
-static void _register_callback(void (*cb)(void *arg), const void *arg)
-{
-}
-
-#define register_callback(cb, arg)                             \
-       _register_callback(typesafe_cb_exact(void, (cb), (arg)), (arg))
-
-static void my_callback(const char *p)
-{
-}
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-       char *p;
-#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if cast_if_type is a noop."
-#endif
-#else
-       const char *p;
-#endif
-       p = NULL;
-
-       /* This should work always. */
-       register_callback(my_callback, (const char *)"hello world");
-
-       /* This will fail with FAIL defined */
-       register_callback(my_callback, p);
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_postargs.c b/lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_postargs.c
deleted file mode 100644 (file)
index 7d35308..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdlib.h>
-
-static void _register_callback(void (*cb)(void *arg, int x), void *arg)
-{
-}
-#define register_callback(cb, arg)                             \
-       _register_callback(typesafe_cb_postargs(void, void *, (cb), (arg), int), (arg))
-
-static void my_callback(char *p, int x)
-{
-}
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-       int *p;
-#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if typesafe_cb_cast is a noop."
-#endif
-#else
-       char *p;
-#endif
-       p = NULL;
-       register_callback(my_callback, p);
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_preargs.c b/lib/ccan/typesafe_cb/test/compile_fail-typesafe_cb_preargs.c
deleted file mode 100644 (file)
index bd55c67..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdlib.h>
-
-static void _register_callback(void (*cb)(int x, void *arg), void *arg)
-{
-}
-
-#define register_callback(cb, arg)                             \
-       _register_callback(typesafe_cb_preargs(void, void *, (cb), (arg), int), (arg))
-
-static void my_callback(int x, char *p)
-{
-}
-
-int main(int argc, char *argv[])
-{
-#ifdef FAIL
-       int *p;
-#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
-#error "Unfortunately we don't fail if typesafe_cb_cast is a noop."
-#endif
-#else
-       char *p;
-#endif
-       p = NULL;
-       register_callback(my_callback, p);
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_ok-cast_if_any.c b/lib/ccan/typesafe_cb/test/compile_ok-cast_if_any.c
deleted file mode 100644 (file)
index e8f3c49..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdlib.h>
-
-struct foo {
-       int x;
-};
-
-struct bar {
-       int x;
-};
-
-struct baz {
-       int x;
-};
-
-struct any {
-       int x;
-};
-
-static void take_any(struct any *any)
-{
-}
-
-int main(int argc, char *argv[])
-{
-#if HAVE_TYPEOF
-       /* Otherwise we get unused warnings for these. */
-       struct foo *foo = NULL;
-       struct bar *bar = NULL;
-       struct baz *baz = NULL;
-#endif
-       struct other *arg = NULL;
-
-       take_any(cast_if_any(struct any *, arg, foo,
-                            struct foo *, struct bar *, struct baz *));
-       take_any(cast_if_any(struct any *, arg, bar,
-                            struct foo *, struct bar *, struct baz *));
-       take_any(cast_if_any(struct any *, arg, baz,
-                            struct foo *, struct bar *, struct baz *));
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c b/lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb-NULL.c
deleted file mode 100644 (file)
index 265de8b..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdlib.h>
-
-/* NULL args for callback function should be OK for normal and _def. */
-
-static void _register_callback(void (*cb)(const void *arg), const void *arg)
-{
-}
-
-#define register_callback(cb, arg)                             \
-       _register_callback(typesafe_cb(void, const void *, (cb), (arg)), (arg))
-
-int main(int argc, char *argv[])
-{
-       register_callback(NULL, "hello world");
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb-const.c b/lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb-const.c
deleted file mode 100644 (file)
index 7c2d62e..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdlib.h>
-
-/* const args in callbacks should be OK. */
-
-static void _register_callback(void (*cb)(void *arg), void *arg)
-{
-}
-
-#define register_callback(cb, arg)                             \
-       _register_callback(typesafe_cb(void, (cb), (arg)), (arg))
-
-#define register_callback_def(cb, arg)                         \
-       _register_callback(typesafe_cb_def(void, (cb), (arg)), (arg))
-
-static void _register_callback_pre(void (*cb)(int x, void *arg), void *arg)
-{
-}
-
-#define register_callback_pre(cb, arg)                                 \
-       _register_callback_pre(typesafe_cb_preargs(void, (cb), (arg), int), (arg))
-
-static void _register_callback_post(void (*cb)(void *arg, int x), void *arg)
-{
-}
-
-#define register_callback_post(cb, arg)                                        \
-       _register_callback_post(typesafe_cb_postargs(void, (cb), (arg), int), (arg))
-
-static void my_callback(const char *p)
-{
-}
-
-static void my_callback_pre(int x, /*const*/ char *p)
-{
-}
-
-static void my_callback_post(/*const*/ char *p, int x)
-{
-}
-
-int main(int argc, char *argv[])
-{
-       char p[] = "hello world";
-       register_callback(my_callback, p);
-       register_callback_def(my_callback, p);
-       register_callback_pre(my_callback_pre, p);
-       register_callback_post(my_callback_post, p);
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb-undefined.c b/lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb-undefined.c
deleted file mode 100644 (file)
index aa50bad..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdlib.h>
-
-/* const args in callbacks should be OK. */
-
-static void _register_callback(void (*cb)(void *arg), void *arg)
-{
-}
-
-#define register_callback(cb, arg)                             \
-       _register_callback(typesafe_cb(void, void *, (cb), (arg)), (arg))
-
-static void _register_callback_pre(void (*cb)(int x, void *arg), void *arg)
-{
-}
-
-#define register_callback_pre(cb, arg)                                 \
-       _register_callback_pre(typesafe_cb_preargs(void, void *, (cb), (arg), int), (arg))
-
-static void _register_callback_post(void (*cb)(void *arg, int x), void *arg)
-{
-}
-
-#define register_callback_post(cb, arg)                                        \
-       _register_callback_post(typesafe_cb_postargs(void, void *, (cb), (arg), int), (arg))
-
-struct undefined;
-
-static void my_callback(struct undefined *undef)
-{
-}
-
-static void my_callback_pre(int x, struct undefined *undef)
-{
-}
-
-static void my_callback_post(struct undefined *undef, int x)
-{
-}
-
-int main(int argc, char *argv[])
-{
-       struct undefined *handle = NULL;
-
-       register_callback(my_callback, handle);
-       register_callback_pre(my_callback_pre, handle);
-       register_callback_post(my_callback_post, handle);
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb-vars.c b/lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb-vars.c
deleted file mode 100644 (file)
index f6a2bfe..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdlib.h>
-
-/* const args in callbacks should be OK. */
-
-static void _register_callback(void (*cb)(void *arg), void *arg)
-{
-}
-
-#define register_callback(cb, arg)                             \
-       _register_callback(typesafe_cb(void, void *, (cb), (arg)), (arg))
-
-static void _register_callback_pre(void (*cb)(int x, void *arg), void *arg)
-{
-}
-
-#define register_callback_pre(cb, arg)                                 \
-       _register_callback_pre(typesafe_cb_preargs(void, void *, (cb), (arg), int), (arg))
-
-static void _register_callback_post(void (*cb)(void *arg, int x), void *arg)
-{
-}
-
-#define register_callback_post(cb, arg)                                        \
-       _register_callback_post(typesafe_cb_postargs(void, void *, (cb), (arg), int), (arg))
-
-struct undefined;
-
-static void my_callback(struct undefined *undef)
-{
-}
-
-static void my_callback_pre(int x, struct undefined *undef)
-{
-}
-
-static void my_callback_post(struct undefined *undef, int x)
-{
-}
-
-int main(int argc, char *argv[])
-{
-       struct undefined *handle = NULL;
-       void (*cb)(struct undefined *undef) = my_callback;
-       void (*pre)(int x, struct undefined *undef) = my_callback_pre;
-       void (*post)(struct undefined *undef, int x) = my_callback_post;
-
-       register_callback(cb, handle);
-       register_callback_pre(pre, handle);
-       register_callback_post(post, handle);
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb-volatile.c b/lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb-volatile.c
deleted file mode 100644 (file)
index 3fcb1ff..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdlib.h>
-
-/* volatile args in callbacks should be OK. */
-
-static void _register_callback(void (*cb)(void *arg), void *arg)
-{
-}
-
-#define register_callback(cb, arg)                             \
-       _register_callback(typesafe_cb(void, (cb), (arg)), (arg))
-
-static void _register_callback_pre(void (*cb)(int x, void *arg), void *arg)
-{
-}
-
-#define register_callback_pre(cb, arg)                                 \
-       _register_callback_pre(typesafe_cb_preargs(void, (cb), (arg), int), (arg))
-
-static void _register_callback_post(void (*cb)(void *arg, int x), void *arg)
-{
-}
-
-#define register_callback_post(cb, arg)                                        \
-       _register_callback_post(typesafe_cb_postargs(void, (cb), (arg), int), (arg))
-
-static void my_callback(volatile char *p)
-{
-}
-
-/* FIXME: Can't handle volatile for these */
-static void my_callback_pre(int x, /* volatile */ char *p)
-{
-}
-
-static void my_callback_post(/* volatile */ char *p, int x)
-{
-}
-
-int main(int argc, char *argv[])
-{
-       char p[] = "hello world";
-       register_callback(my_callback, p);
-       register_callback_pre(my_callback_pre, p);
-       register_callback_post(my_callback_post, p);
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb_cast.c b/lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb_cast.c
deleted file mode 100644 (file)
index b7f21dc..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdlib.h>
-
-struct foo {
-       int x;
-};
-
-struct bar {
-       int x;
-};
-
-struct baz {
-       int x;
-};
-
-struct any {
-       int x;
-};
-
-static void take_any(struct any *any)
-{
-}
-
-int main(int argc, char *argv[])
-{
-       /* Otherwise we get unused warnings for these. */
-       struct foo *foo = NULL;
-       struct bar *bar = NULL;
-       struct baz *baz = NULL;
-
-       take_any(typesafe_cb_cast3(struct any *,
-                                  struct foo *, struct bar *, struct baz *,
-                                  foo));
-       take_any(typesafe_cb_cast3(struct any *,
-                                  struct foo *, struct bar *, struct baz *,
-                                  bar));
-       take_any(typesafe_cb_cast3(struct any *,
-                                  struct foo *, struct bar *, struct baz *,
-                                  baz));
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb_def-const.c b/lib/ccan/typesafe_cb/test/compile_ok-typesafe_cb_def-const.c
deleted file mode 100644 (file)
index 01e090f..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <stdlib.h>
-
-/* const args in callbacks should be OK. */
-
-static void _register_callback(void (*cb)(void *arg), void *arg)
-{
-}
-
-#define register_callback(cb, arg)                             \
-       _register_callback(typesafe_cb(void, (cb), (arg)), (arg))
-
-static void _register_callback_pre(void (*cb)(int x, void *arg), void *arg)
-{
-}
-
-#define register_callback_pre(cb, arg)                                 \
-       _register_callback_pre(typesafe_cb_preargs(void, (cb), (arg), int), (arg))
-
-static void _register_callback_post(void (*cb)(void *arg, int x), void *arg)
-{
-}
-
-#define register_callback_post(cb, arg)                                        \
-       _register_callback_post(typesafe_cb_postargs(void, (cb), (arg), int), (arg))
-
-static void my_callback(const char *p)
-{
-}
-
-static void my_callback_pre(int x, /*const*/ char *p)
-{
-}
-
-static void my_callback_post(/*const*/ char *p, int x)
-{
-}
-
-int main(int argc, char *argv[])
-{
-       char p[] = "hello world";
-       register_callback(my_callback, p);
-       register_callback_pre(my_callback_pre, p);
-       register_callback_post(my_callback_post, p);
-       return 0;
-}
diff --git a/lib/ccan/typesafe_cb/test/run.c b/lib/ccan/typesafe_cb/test/run.c
deleted file mode 100644 (file)
index 116e7d1..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <string.h>
-#include <stdint.h>
-#include <ccan/tap/tap.h>
-
-static char dummy = 0;
-
-/* The example usage. */
-static void _set_some_value(void *val)
-{
-       ok1(val == &dummy);
-}
-
-#define set_some_value(expr)                                           \
-       _set_some_value(typesafe_cb_cast(void *, unsigned long, (expr)))
-
-static void _callback_onearg(void (*fn)(void *arg), void *arg)
-{
-       fn(arg);
-}
-
-static void _callback_preargs(void (*fn)(int a, int b, void *arg), void *arg)
-{
-       fn(1, 2, arg);
-}
-
-static void _callback_postargs(void (*fn)(void *arg, int a, int b), void *arg)
-{
-       fn(arg, 1, 2);
-}
-
-#define callback_onearg(cb, arg)                                       \
-       _callback_onearg(typesafe_cb(void, void *, (cb), (arg)), (arg))
-
-#define callback_preargs(cb, arg)                                      \
-       _callback_preargs(typesafe_cb_preargs(void, void *, (cb), (arg), int, int), (arg))
-
-#define callback_postargs(cb, arg)                                     \
-       _callback_postargs(typesafe_cb_postargs(void, void *, (cb), (arg), int, int), (arg))
-
-static void my_callback_onearg(char *p)
-{
-       ok1(strcmp(p, "hello world") == 0);
-}
-
-static void my_callback_preargs(int a, int b, char *p)
-{
-       ok1(a == 1);
-       ok1(b == 2);
-       ok1(strcmp(p, "hello world") == 0);
-}
-
-static void my_callback_postargs(char *p, int a, int b)
-{
-       ok1(a == 1);
-       ok1(b == 2);
-       ok1(strcmp(p, "hello world") == 0);
-}
-
-/* This is simply a compile test; we promised typesafe_cb_cast can be in a
- * static initializer. */
-struct callback_onearg
-{
-       void (*fn)(void *arg);
-       const void *arg;
-};
-
-struct callback_onearg cb_onearg
-= { typesafe_cb(void, void *, my_callback_onearg, (char *)(intptr_t)"hello world"),
-    "hello world" };
-
-struct callback_preargs
-{
-       void (*fn)(int a, int b, void *arg);
-       const void *arg;
-};
-
-struct callback_preargs cb_preargs
-= { typesafe_cb_preargs(void, void *, my_callback_preargs,
-                       (char *)(intptr_t)"hi", int, int), "hi" };
-
-struct callback_postargs
-{
-       void (*fn)(void *arg, int a, int b);
-       const void *arg;
-};
-
-struct callback_postargs cb_postargs
-= { typesafe_cb_postargs(void, void *, my_callback_postargs,
-                        (char *)(intptr_t)"hi", int, int), "hi" };
-
-int main(int argc, char *argv[])
-{
-       void *p = &dummy;
-       unsigned long l = (unsigned long)p;
-       char str[] = "hello world";
-
-       plan_tests(2 + 1 + 3 + 3);
-       set_some_value(p);
-       set_some_value(l);
-
-       callback_onearg(my_callback_onearg, str);
-
-       callback_preargs(my_callback_preargs, str);
-
-       callback_postargs(my_callback_postargs, str);
-
-       return exit_status();
-}
diff --git a/lib/ccan/typesafe_cb/typesafe_cb.h b/lib/ccan/typesafe_cb/typesafe_cb.h
deleted file mode 100644 (file)
index 8843149..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/* Licensed under LGPLv2.1+ - see LICENSE file for details */
-#ifndef CCAN_TYPESAFE_CB_H
-#define CCAN_TYPESAFE_CB_H
-#include "config.h"
-
-#if HAVE_TYPEOF && HAVE_BUILTIN_CHOOSE_EXPR && HAVE_BUILTIN_TYPES_COMPATIBLE_P
-/**
- * typesafe_cb_cast - only cast an expression if it matches a given type
- * @desttype: the type to cast to
- * @oktype: the type we allow
- * @expr: the expression to cast
- *
- * This macro is used to create functions which allow multiple types.
- * The result of this macro is used somewhere that a @desttype type is
- * expected: if @expr is exactly of type @oktype, then it will be
- * cast to @desttype type, otherwise left alone.
- *
- * This macro can be used in static initializers.
- *
- * This is merely useful for warnings: if the compiler does not
- * support the primitives required for typesafe_cb_cast(), it becomes an
- * unconditional cast, and the @oktype argument is not used.  In
- * particular, this means that @oktype can be a type which uses the
- * "typeof": it will not be evaluated if typeof is not supported.
- *
- * Example:
- *     // We can take either an unsigned long or a void *.
- *     void _set_some_value(void *val);
- *     #define set_some_value(e)                       \
- *             _set_some_value(typesafe_cb_cast(void *, (e), unsigned long))
- */
-#define typesafe_cb_cast(desttype, oktype, expr)                       \
-       __builtin_choose_expr(                                          \
-               __builtin_types_compatible_p(__typeof__(0?(expr):(expr)), \
-                                            oktype),                   \
-               (desttype)(expr), (expr))
-#else
-#define typesafe_cb_cast(desttype, oktype, expr) ((desttype)(expr))
-#endif
-
-/**
- * typesafe_cb_cast3 - only cast an expression if it matches given types
- * @desttype: the type to cast to
- * @ok1: the first type we allow
- * @ok2: the second type we allow
- * @ok3: the third type we allow
- * @expr: the expression to cast
- *
- * This is a convenient wrapper for multiple typesafe_cb_cast() calls.
- * You can chain them inside each other (ie. use typesafe_cb_cast()
- * for expr) if you need more than 3 arguments.
- *
- * Example:
- *     // We can take either a long, unsigned long, void * or a const void *.
- *     void _set_some_value(void *val);
- *     #define set_some_value(expr)                                    \
- *             _set_some_value(typesafe_cb_cast3(void *,,              \
- *                                         long, unsigned long, const void *,\
- *                                         (expr)))
- */
-#define typesafe_cb_cast3(desttype, ok1, ok2, ok3, expr)               \
-       typesafe_cb_cast(desttype, ok1,                                 \
-                        typesafe_cb_cast(desttype, ok2,                \
-                                         typesafe_cb_cast(desttype, ok3, \
-                                                          (expr))))
-
-/**
- * typesafe_cb - cast a callback function if it matches the arg
- * @rtype: the return type of the callback function
- * @atype: the (pointer) type which the callback function expects.
- * @fn: the callback function to cast
- * @arg: the (pointer) argument to hand to the callback function.
- *
- * If a callback function takes a single argument, this macro does
- * appropriate casts to a function which takes a single atype argument if the
- * callback provided matches the @arg.
- *
- * It is assumed that @arg is of pointer type: usually @arg is passed
- * or assigned to a void * elsewhere anyway.
- *
- * Example:
- *     void _register_callback(void (*fn)(void *arg), void *arg);
- *     #define register_callback(fn, arg) \
- *             _register_callback(typesafe_cb(void, (fn), void*, (arg)), (arg))
- */
-#define typesafe_cb(rtype, atype, fn, arg)                     \
-       typesafe_cb_cast(rtype (*)(atype),                      \
-                        rtype (*)(__typeof__(arg)),            \
-                        (fn))
-
-/**
- * typesafe_cb_preargs - cast a callback function if it matches the arg
- * @rtype: the return type of the callback function
- * @atype: the (pointer) type which the callback function expects.
- * @fn: the callback function to cast
- * @arg: the (pointer) argument to hand to the callback function.
- *
- * This is a version of typesafe_cb() for callbacks that take other arguments
- * before the @arg.
- *
- * Example:
- *     void _register_callback(void (*fn)(int, void *arg), void *arg);
- *     #define register_callback(fn, arg)                                 \
- *             _register_callback(typesafe_cb_preargs(void, void *,       \
- *                                (fn), (arg), int),                      \
- *                                (arg))
- */
-#define typesafe_cb_preargs(rtype, atype, fn, arg, ...)                        \
-       typesafe_cb_cast(rtype (*)(__VA_ARGS__, atype),                 \
-                        rtype (*)(__VA_ARGS__, __typeof__(arg)),       \
-                        (fn))
-
-/**
- * typesafe_cb_postargs - cast a callback function if it matches the arg
- * @rtype: the return type of the callback function
- * @atype: the (pointer) type which the callback function expects.
- * @fn: the callback function to cast
- * @arg: the (pointer) argument to hand to the callback function.
- *
- * This is a version of typesafe_cb() for callbacks that take other arguments
- * after the @arg.
- *
- * Example:
- *     void _register_callback(void (*fn)(void *arg, int), void *arg);
- *     #define register_callback(fn, arg) \
- *             _register_callback(typesafe_cb_postargs(void, (fn), void *, \
- *                                (arg), int),                             \
- *                                (arg))
- */
-#define typesafe_cb_postargs(rtype, atype, fn, arg, ...)               \
-       typesafe_cb_cast(rtype (*)(atype, __VA_ARGS__),                 \
-                        rtype (*)(__typeof__(arg), __VA_ARGS__),       \
-                        (fn))
-#endif /* CCAN_CAST_IF_TYPE_H */
diff --git a/lib/ccan/wscript b/lib/ccan/wscript
deleted file mode 100644 (file)
index 0e540db..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-#!/usr/bin/env python
-
-import Logs, sys, Options
-
-def configure(conf):
-    conf.DEFINE('HAVE_CCAN', 1)
-    conf.CHECK_HEADERS('err.h')
-    conf.CHECK_HEADERS('byteswap.h')
-    conf.CHECK_FUNCS('bswap_64', link=False, headers="byteswap.h")
-    conf.CHECK_CODE('int __attribute__((cold)) func(int x) { return x; }',
-                    addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
-                    define='HAVE_ATTRIBUTE_COLD')
-    conf.CHECK_CODE('int __attribute__((const)) func(int x) { return x; }',
-                    addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
-                    define='HAVE_ATTRIBUTE_CONST')
-    conf.CHECK_CODE('void __attribute__((noreturn)) func(int x) { exit(x); }',
-                    addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
-                    define='HAVE_ATTRIBUTE_NORETURN')
-    conf.CHECK_CODE('void __attribute__((format(__printf__, 1, 2))) func(const char *fmt, ...) { }',
-                    addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
-                    define='HAVE_ATTRIBUTE_PRINTF')
-    conf.CHECK_CODE('int __attribute__((unused)) func(int x) { return x; }',
-                    addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
-                    define='HAVE_ATTRIBUTE_UNUSED')
-    conf.CHECK_CODE('int __attribute__((used)) func(int x) { return x; }',
-                    addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
-                    define='HAVE_ATTRIBUTE_USED')
-
-    conf.CHECK_CODE('return __builtin_choose_expr(1, 0, "garbage");',
-                    link=True,
-                    define='HAVE_BUILTIN_CHOOSE_EXPR')
-    conf.CHECK_CODE('return __builtin_clz(1) == (sizeof(int)*8 - 1) ? 0 : 1;',
-                    link=True,
-                    define='HAVE_BUILTIN_CLZ')
-    conf.CHECK_CODE('return __builtin_clzl(1) == (sizeof(long)*8 - 1) ? 0 : 1;',
-                    link=True,
-                    define='HAVE_BUILTIN_CLZL')
-    conf.CHECK_CODE('return __builtin_clzll(1) == (sizeof(long long)*8 - 1) ? 0 : 1;',
-                    link=True,
-                    define='HAVE_BUILTIN_CLZLL')
-    conf.CHECK_CODE('return __builtin_constant_p(1) ? 0 : 1;',
-                    link=True,
-                    define='HAVE_BUILTIN_CONSTANT_P')
-    conf.CHECK_CODE('return __builtin_expect(main != 0, 1) ? 0 : 1;',
-                    link=True,
-                    define='HAVE_BUILTIN_EXPECT')
-    conf.CHECK_CODE('return __builtin_popcountl(255L) == 8 ? 0 : 1;',
-                    link=True,
-                    define='HAVE_BUILTIN_POPCOUNTL')
-    conf.CHECK_CODE('return __builtin_types_compatible_p(char *, int) ? 1 : 0;',
-                    link=True,
-                    define='HAVE_BUILTIN_TYPES_COMPATIBLE_P')
-    conf.CHECK_CODE('int *foo = (int[]) { 1, 2, 3, 4 }; return foo[0] ? 0 : 1;',
-                    define='HAVE_COMPOUND_LITERALS')
-    conf.CHECK_CODE('struct foo { unsigned int x; int arr[]; };',
-                    addmain=False, link=False,
-                    define='HAVE_FLEXIBLE_ARRAY_MEMBER')
-    conf.CHECK_CODE("""#include <ctype.h>
-         int main(void) { return isblank(' ') ? 0 : 1; }""",
-                    link=True, addmain=False, add_headers=False,
-                    define='HAVE_ISBLANK')
-    conf.CHECK_CODE('int x = 1; __typeof__(x) i; i = x; return i == x ? 0 : 1;',
-                    link=True,
-                    define='HAVE_TYPEOF')
-    conf.CHECK_CODE('int __attribute__((warn_unused_result)) func(int x) { return x; }',
-                    addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
-                    define='HAVE_WARN_UNUSED_RESULT')
-
-    # backtrace could be in libexecinfo or in libc
-    conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo', checklibc=True, headers='execinfo.h')
-
-    # Only check for FILE_OFFSET_BITS=64 if off_t is normally small:
-    # use raw routines because wrappers include previous _GNU_SOURCE
-    # or _FILE_OFFSET_BITS defines.
-    # The math for these tests is:
-    # array[-1 * !((int)(condition)) ] (condition is true) = array[0] = builds
-    # array[-1 * !((int)(condition)) ] (condition is false) = array[-1] = fails
-    conf.check(fragment="""#include <sys/types.h>
-               int main(void) { static int test_array[1 - 2 * !(((long int)(sizeof(off_t))) < 8)]; }""",
-               msg='Checking for small off_t',
-               define_name='SMALL_OFF_T')
-    # Unreliable return value above, hence use define.
-    if conf.CONFIG_SET('SMALL_OFF_T'):
-        conf.check(fragment="""#include <sys/types.h>
-                  int main(void) { static int test_array[1 - 2 * !(((long int)(sizeof(off_t))) >= 8)]; }""",
-                   msg='Checking for -D_FILE_OFFSET_BITS=64',
-                   ccflags='-D_FILE_OFFSET_BITS=64',
-                   define_name='HAVE_FILE_OFFSET_BITS')
-
-def ccan_module(bld, name, deps=''):
-    bld.SAMBA_SUBSYSTEM('ccan-%s' % name,
-                        source=bld.path.ant_glob('%s/*.c' % name),
-                        allow_warnings=True,
-                        deps=deps)
-    bld.env.CCAN_MODS += 'ccan-%s ' % name
-
-def build(bld):
-    bld.env.CCAN_MODS = ""
-
-    # These have actual C files.
-    ccan_module(bld, 'hash', 'ccan-build_assert')
-    ccan_module(bld, 'ilog', 'ccan-compiler');
-    ccan_module(bld, 'read_write_all')
-    ccan_module(bld, 'str', 'ccan-build_assert')
-    ccan_module(bld, 'tally', 'ccan-build_assert ccan-likely')
-
-    # These are headers only.
-    ccan_module(bld, 'array_size', 'ccan-build_assert')
-    ccan_module(bld, 'asearch','ccan-typesafe_cb ccan-array_size')
-    ccan_module(bld, 'build_assert')
-    ccan_module(bld, 'cast', 'ccan-build_assert')
-    ccan_module(bld, 'check_type', 'ccan-build_assert')
-    ccan_module(bld, 'compiler')
-    ccan_module(bld, 'endian')
-    ccan_module(bld, 'likely', 'ccan-str')
-    ccan_module(bld, 'typesafe_cb')
-    ccan_module(bld, 'err', 'ccan-compiler')
-
-    # Failtest pulls in a lot of stuff, and it's only for unit tests.
-    if bld.env.DEVELOPER_MODE:
-        ccan_module(bld, 'container_of', 'ccan-check_type')
-        ccan_module(bld, 'htable', 'ccan-compiler')
-        ccan_module(bld, 'list', 'ccan-container_of')
-        ccan_module(bld, 'time')
-        ccan_module(bld, 'tcon')
-        ccan_module(bld, 'tlist', 'ccan-list ccan-tcon')
-        ccan_module(bld, 'failtest',
-                    '''
-                    ccan-err ccan-hash ccan-htable ccan-list
-                    ccan-read_write_all ccan-str ccan-time execinfo
-                    ''')
-
-    # This is the complete CCAN collection as one group.
-    bld.SAMBA_LIBRARY('ccan',
-                      source='',
-                      deps=bld.env.CCAN_MODS,
-                      allow_warnings=True,
-                      private_library=True,
-                      grouping_library=True)