[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Extract memarea into its own library



commit eee86e627b670b153bb5a0f41f9f8dfa4c378884
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu Jun 28 09:25:18 2018 -0400

    Extract memarea into its own library
---
 .gitignore                            |  2 ++
 Makefile.am                           |  2 ++
 src/common/include.am                 |  2 --
 src/include.am                        |  1 +
 src/lib/memarea/.may_include          |  6 ++++++
 src/lib/memarea/include.am            | 17 +++++++++++++++++
 src/{common => lib/memarea}/memarea.c | 13 ++++++++-----
 src/{common => lib/memarea}/memarea.h |  3 ++-
 src/rust/build.rs                     |  1 +
 9 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/.gitignore b/.gitignore
index 65c9fb83f..b59731441 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 be645194a..f71c94b77 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 9ed5b30d3..a2d29be5b 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 0a8af38b0..90fafb482 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 000000000..c55722284
--- /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 000000000..94343dcea
--- /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 589277ba3..7fe382572 100644
--- a/src/common/memarea.c
+++ b/src/lib/memarea/memarea.c
@@ -7,12 +7,16 @@
  */
 
 #include "orconfig.h"
-#include <stddef.h>
+#include "lib/memarea/memarea.h"
+
 #include <stdlib.h>
-#include "common/memarea.h"
-#include "common/util.h"
-#include "common/compat.h"
+#include <string.h>
+
+#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 7dc7ec1fe..e52f5a1be 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 <stddef.h>
+
 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 e17f9e5df..4e401f527 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");



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits