diff --git a/.gitignore b/.gitignore index 65c9fb83fc..b59731441f 100644 --- a/.gitignore +++ b/.gitignore @@ -187,6 +187,8 @@ uptime-*.json /src/lib/libtor-log-testing.a /src/lib/libtor-malloc.a /src/lib/libtor-malloc-testing.a +/src/lib/libtor-memarea.a +/src/lib/libtor-memarea-testing.a /src/lib/libtor-net.a /src/lib/libtor-net-testing.a /src/lib/libtor-sandbox.a diff --git a/Makefile.am b/Makefile.am index be645194aa..f71c94b773 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,6 +46,7 @@ TOR_UTIL_LIBS = \ src/lib/libtor-container.a \ src/lib/libtor-net.a \ src/lib/libtor-thread.a \ + src/lib/libtor-memarea.a \ src/lib/libtor-log.a \ src/lib/libtor-lock.a \ src/lib/libtor-fdio.a \ @@ -67,6 +68,7 @@ TOR_UTIL_TESTING_LIBS = \ src/lib/libtor-container-testing.a \ src/lib/libtor-net-testing.a \ src/lib/libtor-thread-testing.a \ + src/lib/libtor-memarea-testing.a \ src/lib/libtor-log-testing.a \ src/lib/libtor-lock-testing.a \ src/lib/libtor-fdio-testing.a \ diff --git a/src/common/include.am b/src/common/include.am index 9ed5b30d3a..a2d29be5b5 100644 --- a/src/common/include.am +++ b/src/common/include.am @@ -29,7 +29,6 @@ LIBOR_A_SRC = \ src/common/compat.c \ src/common/compat_time.c \ src/common/conffile.c \ - src/common/memarea.c \ src/common/util.c \ src/common/util_process.c \ src/common/storagedir.c \ @@ -71,7 +70,6 @@ COMMONHEADERS = \ src/common/compat_time.h \ src/common/conffile.h \ src/common/handles.h \ - src/common/memarea.h \ src/common/procmon.h \ src/common/storagedir.h \ src/common/timers.h \ diff --git a/src/include.am b/src/include.am index 0a8af38b02..90fafb482e 100644 --- a/src/include.am +++ b/src/include.am @@ -14,6 +14,7 @@ include src/lib/include.libdonna.am include src/lib/intmath/include.am include src/lib/lock/include.am include src/lib/log/include.am +include src/lib/memarea/include.am include src/lib/malloc/include.am include src/lib/net/include.am include src/lib/sandbox/include.am diff --git a/src/lib/memarea/.may_include b/src/lib/memarea/.may_include new file mode 100644 index 0000000000..c55722284f --- /dev/null +++ b/src/lib/memarea/.may_include @@ -0,0 +1,6 @@ +orconfig.h +lib/arch/*.h +lib/cc/*.h +lib/log/*.h +lib/malloc/*.h +lib/memarea/*.h diff --git a/src/lib/memarea/include.am b/src/lib/memarea/include.am new file mode 100644 index 0000000000..94343dcead --- /dev/null +++ b/src/lib/memarea/include.am @@ -0,0 +1,17 @@ + +noinst_LIBRARIES += src/lib/libtor-memarea.a + +if UNITTESTS_ENABLED +noinst_LIBRARIES += src/lib/libtor-memarea-testing.a +endif + +src_lib_libtor_memarea_a_SOURCES = \ + src/lib/memarea/memarea.c + +src_lib_libtor_memarea_testing_a_SOURCES = \ + $(src_lib_libtor_memarea_a_SOURCES) +src_lib_libtor_memarea_testing_a_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS) +src_lib_libtor_memarea_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS) + +noinst_HEADERS += \ + src/lib/memarea/memarea.h diff --git a/src/common/memarea.c b/src/lib/memarea/memarea.c similarity index 98% rename from src/common/memarea.c rename to src/lib/memarea/memarea.c index 589277ba3d..7fe3825723 100644 --- a/src/common/memarea.c +++ b/src/lib/memarea/memarea.c @@ -7,12 +7,16 @@ */ #include "orconfig.h" -#include +#include "lib/memarea/memarea.h" + #include -#include "common/memarea.h" -#include "common/util.h" -#include "common/compat.h" +#include + +#include "lib/cc/torint.h" +#include "lib/arch/bytes.h" #include "lib/log/torlog.h" +#include "lib/log/util_bug.h" +#include "lib/malloc/util_malloc.h" #ifndef DISABLE_MEMORY_SENTINELS @@ -394,4 +398,3 @@ memarea_assert_ok(memarea_t *area) } #endif /* !defined(DISABLE_MEMORY_SENTINELS) */ - diff --git a/src/common/memarea.h b/src/lib/memarea/memarea.h similarity index 98% rename from src/common/memarea.h rename to src/lib/memarea/memarea.h index 7dc7ec1fed..e52f5a1be7 100644 --- a/src/common/memarea.h +++ b/src/lib/memarea/memarea.h @@ -5,6 +5,8 @@ #ifndef TOR_MEMAREA_H #define TOR_MEMAREA_H +#include + typedef struct memarea_t memarea_t; memarea_t *memarea_new(void); @@ -26,4 +28,3 @@ void memarea_get_stats(memarea_t *area, void memarea_assert_ok(memarea_t *area); #endif /* !defined(TOR_MEMAREA_H) */ - diff --git a/src/rust/build.rs b/src/rust/build.rs index e17f9e5df2..4e401f5275 100644 --- a/src/rust/build.rs +++ b/src/rust/build.rs @@ -155,6 +155,7 @@ pub fn main() { cfg.component("tor-encoding-testing"); cfg.component("tor-net"); cfg.component("tor-thread-testing"); + cfg.component("tor-memarea-testing"); cfg.component("tor-log"); cfg.component("tor-lock"); cfg.component("tor-fdio");