inter-depends
test-depends
lib-depends
+tools/_infotojson/infotojson
ALL=$(patsubst ccan/%/test, %, $(wildcard ccan/*/test))
ALL_DIRS=$(patsubst %, ccan/%, $(ALL))
ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(ALL))
-ALL_LIBS=$(patsubst %, ccan/lib%.a, $(ALL))
+ALL_LIBS=$(patsubst %, ccan/%.o, $(ALL))
-test: $(ALL_DIRS:%=test-%)
+libccan.a: $(ALL_LIBS)
+ $(AR) r $@ $^
+
+check: $(ALL_DIRS:%=test-%)
distclean: clean
rm -f */_info
$(ALL_DEPENDS): %/.depends: tools/ccan_depends
tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
-foo:
- echo $(ALL_LIBS)
-
$(ALL_LIBS):
- $(AR) r $@ $^
+ $(LD) -r -o $@ $^ /dev/null
-test-ccan/%: tools/run_tests ccan/lib%.a
+test-ccan/%: tools/run_tests ccan/%.o
@echo Testing $*...
@if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
ccanlint: tools/ccanlint/ccanlint
clean: tools-clean
- $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'`
+ $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'` `find . -name _info`
$(RM) inter-depends lib-depends test-depends
inter-depends: $(ALL_DEPENDS)
- for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),ccan/lib\1.a,p' < $$f`; done > $@
+ for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),ccan/\1.o,p' < $$f`; done > $@
test-depends: $(ALL_DEPENDS)
for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),test-ccan/\1,p' < $$f`; done > $@
lib-depends: $(foreach D,$(ALL),$(wildcard $D/*.[ch]))
- for c in $(ALL); do echo ccan/lib$$c.a: `ls ccan/$$c/*.c | grep -v /_info.c | sed 's/.c$$/.o/'`; done > $@
+ for c in $(ALL); do echo ccan/$$c.o: `ls ccan/$$c/*.c | grep -v /_info.c | sed 's/.c$$/.o/'`; done > $@
include tools/Makefile
-include inter-depends
if (meta[j / 8] & (1 << (j % 8)))
total++;
- printf(" %u: %u/%u (%u%% density)\n",
+ printf(" %u: %u/%zu (%zu%% density)\n",
uc->size[j], total, SUBPAGE_METAOFF / uc->size[i],
(total * 100) / (SUBPAGE_METAOFF / uc->size[i]));
}
#include <string.h>
#include <stdint.h>
#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
/* use this to force every realloc to change the pointer, to stress test
code that might not cope */
NULL
*/
static void *null_context;
-static void *autofree_context;
+static pid_t *autofree_context;
static void *(*tc_external_alloc)(void *parent, size_t size);
static void (*tc_external_free)(void *ptr, void *parent);
tc->destructor = NULL;
}
+ if (unlikely(tc->flags & TALLOC_FLAG_EXT_ALLOC))
+ oldparent = talloc_parent(ptr);
+
if (tc->parent) {
- oldparent = TC_PTR_FROM_CHUNK(tc->parent);
_TLIST_REMOVE(tc->parent->child, tc);
if (tc->parent->child) {
tc->parent->child->parent = tc->parent;
static void talloc_autofree(void)
{
- _talloc_free(autofree_context);
+ if (autofree_context && *autofree_context == getpid())
+ _talloc_free(autofree_context);
}
/*
*/
void *talloc_autofree_context(void)
{
- if (autofree_context == NULL) {
- autofree_context = _talloc_named_const(NULL, 0, "autofree_context");
+ if (autofree_context == NULL || *autofree_context != getpid()) {
+ autofree_context = talloc(NULL, pid_t);
+ *autofree_context = getpid();
+ talloc_set_name_const(autofree_context, "autofree_context");
+
talloc_set_destructor(autofree_context, talloc_autofree_destructor);
atexit(talloc_autofree);
}
#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type)
/**
- * talloc_zero_array - allocate an array of zeroed types
+ * talloc_array_size - allocate an array of elements of the given size
* @ctx: context to be parent of this allocation, or NULL.
- * @type: the type to be allocated.
+ * @size: the size of each element
* @count: the number of elements to be allocated.
*
- * Just like talloc_array, but zeroes the memory.
+ * Typeless form of talloc_array.
*/
#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__)
char **deps;
for (deps = get_deps(objs, dir); *deps; deps++) {
- char *end;
if (!strstarts(*deps, "ccan/"))
continue;
- end = strrchr(*deps, '/') + 1;
- /* ccan/foo -> ccan/libfoo.a */
- externals = talloc_asprintf_append(externals,
- " ccan/lib%s.a", end);
+ /* ccan/foo -> ccan/foo.o */
+ externals = talloc_asprintf_append(externals, " %s.o", *deps);
}
cmd = talloc_asprintf(name, "gcc " CFLAGS " %s -o %s %s %s%s%s",