--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * jset - set of pointers (based on libJudy)
+ *
+ * This provides a convenient wrapper for using Judy bitsets; using
+ * pointers (or unsigned longs) as the index, Judy arrays provide an
+ * efficient bit array or bit map of variable size.
+ *
+ * jset.h contains typesafe wrappers for this usage.
+ *
+ * Example:
+ * // Simple analysis of one-byte mallocs.
+ * #include <ccan/jset/jset.h>
+ * #include <stdlib.h>
+ * #include <stdio.h>
+ * #include <err.h>
+ *
+ * struct jset_char {
+ * JSET_MEMBERS(char *);
+ * };
+ *
+ * int main(int argc, char *argv[])
+ * {
+ * unsigned int i, runs, reuse;
+ * size_t mindist = -1;
+ * struct jset_char *set = jset_new(struct jset_char);
+ * char *p, *prev;
+ *
+ * runs = (argc == 1 ? 1000 : atoi(argv[1]));
+ * if (!runs)
+ * errx(1, "Invalid number of allocations '%s'", argv[1]);
+ *
+ * for (i = 0; i < runs; i++)
+ * if (!jset_set(set, malloc(1)))
+ * errx(1, "same pointer allocated twice!");
+ *
+ * // Calculate minimum distance
+ * prev = jset_first(set)+1;
+ * for (p = jset_first(set); p; prev = p, p = jset_next(set,p))
+ * if (p - prev < mindist)
+ * mindist = p - prev;
+ *
+ * // Free them all, see how many we reallocate.
+ * for (p = jset_first(set); p; p = jset_next(set, p))
+ * free(p);
+ * for (reuse = 0, i = 0; i < runs; i++)
+ * reuse += jset_test(set, malloc(1));
+ *
+ * printf("Allocation density (bytes): %zu\n"
+ * "Minimum inter-pointer distance: %zu\n"
+ * "Reuse rate: %.0f%%\n",
+ * (jset_last(set) - jset_first(set)) / runs,
+ * mindist,
+ * 100.0 * reuse / runs);
+ * 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/build_assert\n");
+ printf("ccan/compiler\n");
+ printf("ccan/tcon\n");
+ printf("Judy\n");
+ return 0;
+ }
+
+ if (strcmp(argv[1], "libs") == 0) {
+ printf("Judy\n");
+ return 0;
+ }
+
+ return 1;
+}