Commit d379e0ae authored by Rusty Russell's avatar Rusty Russell

alloc: move into antithread/alloc.

Our first nested module; easy because noone else relies on it.
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 8fc1b230
...@@ -4,7 +4,6 @@ TAGS ...@@ -4,7 +4,6 @@ TAGS
*.o *.o
libccan.a libccan.a
config.h config.h
ccan/*-Makefile
*~ *~
tools/ccan_depends tools/ccan_depends
tools/doc_extract tools/doc_extract
......
...@@ -55,6 +55,10 @@ summary-check-%: tools/ccanlint/ccanlint $(OBJFILES) ...@@ -55,6 +55,10 @@ summary-check-%: tools/ccanlint/ccanlint $(OBJFILES)
summary-fastcheck-%: tools/ccanlint/ccanlint $(OBJFILES) summary-fastcheck-%: tools/ccanlint/ccanlint $(OBJFILES)
tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage -s ccan/$* tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage -s ccan/$*
# FIXME: Horrible hacks because % doesn't match /
summary-fastcheck-antithread/%: tools/ccanlint/ccanlint $(OBJFILES)
tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage -s ccan/antithread/$*
ccan/%/info: ccan/%/_info ccan/%/info: ccan/%/_info
$(CC) $(CCAN_CFLAGS) -o $@ -x c $< $(CC) $(CCAN_CFLAGS) -o $@ -x c $<
......
...@@ -25,8 +25,8 @@ MODS_NORMAL_NO_SRC := alignof \ ...@@ -25,8 +25,8 @@ MODS_NORMAL_NO_SRC := alignof \
typesafe_cb typesafe_cb
# No external dependencies, with C code: # No external dependencies, with C code:
MODS_NORMAL_WITH_SRC := alloc \ MODS_NORMAL_WITH_SRC := antithread \
antithread \ antithread/alloc \
asort \ asort \
asprintf \ asprintf \
autodata \ autodata \
......
../../licenses/LGPL-2.1
\ No newline at end of file
...@@ -90,7 +90,7 @@ int main(int argc, char *argv[]) ...@@ -90,7 +90,7 @@ int main(int argc, char *argv[])
return 1; return 1;
if (strcmp(argv[1], "depends") == 0) { if (strcmp(argv[1], "depends") == 0) {
printf("ccan/alloc\n"); printf("ccan/antithread/alloc\n");
printf("ccan/err\n"); printf("ccan/err\n");
printf("ccan/list\n"); printf("ccan/list\n");
printf("ccan/noerr\n"); printf("ccan/noerr\n");
......
../../../licenses/LGPL-2.1
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "config.h" #include "config.h"
/** /**
* alloc - memory allocator routines * antithread/alloc - memory allocator routines
* *
* The alloc module implements a simple allocator which you can use to * The alloc module implements a simple allocator which you can use to
* dynamically allocate space within a region of memory. This can be useful * dynamically allocate space within a region of memory. This can be useful
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* #include <fcntl.h> * #include <fcntl.h>
* #include <string.h> * #include <string.h>
* #include <stdlib.h> * #include <stdlib.h>
* #include <ccan/alloc/alloc.h> * #include <ccan/antithread/alloc/alloc.h>
* *
* static void usage(const char *name) * static void usage(const char *name)
* { * {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
http://samba.org/~tridge/junkcode/alloc_mmap/ http://samba.org/~tridge/junkcode/alloc_mmap/
Copyright (C) Andrew Tridgell 2007 Copyright (C) Andrew Tridgell 2007
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
...@@ -362,7 +362,7 @@ void alloc_init(void *pool, unsigned long poolsize) ...@@ -362,7 +362,7 @@ void alloc_init(void *pool, unsigned long poolsize)
/* We rely on page numbers fitting in 16 bit. */ /* We rely on page numbers fitting in 16 bit. */
BUILD_ASSERT(MAX_SMALL_PAGES < 65536); BUILD_ASSERT(MAX_SMALL_PAGES < 65536);
sp_bits = small_page_bits(poolsize); sp_bits = small_page_bits(poolsize);
lp_bits = sp_bits + BITS_FROM_SMALL_TO_LARGE_PAGE; lp_bits = sp_bits + BITS_FROM_SMALL_TO_LARGE_PAGE;
...@@ -776,7 +776,7 @@ void alloc_free(void *pool, unsigned long poolsize, void *free) ...@@ -776,7 +776,7 @@ void alloc_free(void *pool, unsigned long poolsize, void *free)
tiny_alloc_free(pool, poolsize, free); tiny_alloc_free(pool, poolsize, free);
return; return;
} }
/* Get page header. */ /* Get page header. */
sp_bits = small_page_bits(poolsize); sp_bits = small_page_bits(poolsize);
pgnum = offset >> sp_bits; pgnum = offset >> sp_bits;
...@@ -1097,7 +1097,7 @@ bool alloc_check(void *pool, unsigned long poolsize) ...@@ -1097,7 +1097,7 @@ bool alloc_check(void *pool, unsigned long poolsize)
prev = i; prev = i;
} }
/* Make sure every page accounted for. */ /* Make sure every page accounted for. */
for (i = 0; i < poolsize >> sp_bits; i++) { for (i = 0; i < poolsize >> sp_bits; i++) {
if (!test_bit(pages, i)) if (!test_bit(pages, i))
...@@ -1200,7 +1200,7 @@ void alloc_visualize(FILE *out, void *pool, unsigned long poolsize) ...@@ -1200,7 +1200,7 @@ void alloc_visualize(FILE *out, void *pool, unsigned long poolsize)
tiny_alloc_visualize(out, pool, poolsize); tiny_alloc_visualize(out, pool, poolsize);
return; return;
} }
sp_bits = small_page_bits(poolsize); sp_bits = small_page_bits(poolsize);
lp_bits = sp_bits + BITS_FROM_SMALL_TO_LARGE_PAGE; lp_bits = sp_bits + BITS_FROM_SMALL_TO_LARGE_PAGE;
......
/* Example allocation which caused corruption. */ /* Example allocation which caused corruption. */
#include <ccan/alloc/alloc.c> #include <ccan/antithread/alloc/alloc.c>
#include <ccan/alloc/bitops.c> #include <ccan/antithread/alloc/bitops.c>
#include <ccan/alloc/tiny.c> #include <ccan/antithread/alloc/tiny.c>
#include <ccan/tap/tap.h> #include <ccan/tap/tap.h>
#include <stdlib.h> #include <stdlib.h>
......
#include <ccan/alloc/alloc.h> #include <ccan/antithread/alloc/alloc.h>
#include <ccan/tap/tap.h> #include <ccan/tap/tap.h>
#include <ccan/alloc/alloc.c> #include <ccan/antithread/alloc/alloc.c>
#include <ccan/alloc/bitops.c> #include <ccan/antithread/alloc/bitops.c>
#include <ccan/alloc/tiny.c> #include <ccan/antithread/alloc/tiny.c>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include <err.h> #include <err.h>
......
#include <ccan/tap/tap.h> #include <ccan/tap/tap.h>
#include "config.h" #include "config.h"
#include <ccan/alloc/tiny.c> #include <ccan/antithread/alloc/tiny.c>
#include <ccan/alloc/bitops.c> #include <ccan/antithread/alloc/bitops.c>
#include <stdlib.h> #include <stdlib.h>
#include <err.h> #include <err.h>
......
#include <ccan/alloc/alloc.h> #include <ccan/antithread/alloc/alloc.h>
#include <ccan/tap/tap.h> #include <ccan/tap/tap.h>
#include <ccan/alloc/alloc.c> #include <ccan/antithread/alloc/alloc.c>
#include <ccan/alloc/bitops.c> #include <ccan/antithread/alloc/bitops.c>
#include <ccan/alloc/tiny.c> #include <ccan/antithread/alloc/tiny.c>
#include <stdlib.h> #include <stdlib.h>
#include <err.h> #include <err.h>
...@@ -22,9 +22,9 @@ static bool unique(void *p[], unsigned int num) ...@@ -22,9 +22,9 @@ static bool unique(void *p[], unsigned int num)
if (p[i] == p[i-1]) if (p[i] == p[i-1])
return false; return false;
return true; return true;
} }
static bool free_every_second_one(void *mem, unsigned int num, static bool free_every_second_one(void *mem, unsigned int num,
unsigned long pool_size, void *p[]) unsigned long pool_size, void *p[])
{ {
unsigned int i; unsigned int i;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <ccan/noerr/noerr.h> #include <ccan/noerr/noerr.h>
#include <ccan/talloc/talloc.h> #include <ccan/talloc/talloc.h>
#include <ccan/read_write_all/read_write_all.h> #include <ccan/read_write_all/read_write_all.h>
#include <ccan/alloc/alloc.h> #include <ccan/antithread/alloc/alloc.h>
#include <ccan/list/list.h> #include <ccan/list/list.h>
/* FIXME: Valgrind support should be possible for some cases. Tricky /* FIXME: Valgrind support should be possible for some cases. Tricky
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment