Minor fixes for RTT v2

S Roderick <[email protected]> Tue, 25 Feb 2014 13:30:16 -0500
Newsgroups gmane.science.robotics.orocos.devel
Message-ID <[email protected]>
3 small patches attached

TaskContext::getName() is not const, which causes warnings/errors with certain compilers when using the function with a const TaskContext object. The underlying call is a const, and so this seems to be an oversight. All RTT tests pass with this fix to simply make the function constant.



The default TLSF memory pool is not exposed, and so statistics aren't available on it. This adds two small new functions that provide statistiscs on the default memory pool, without actually exposing the pool



Fix minor compiler warning from gcc 4.7.3 on Mint 15



Let me know if anyone has questions or issues
S

-- 
Orocos-Dev mailing list
[email protected]
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev
0001-Make-TaskContext-getName-a-const-function.patch (application/octet-stream, 1 KB)
From b00ff3b7662a152ea5440d6faafe57266faf988c Mon Sep 17 00:00:00 2001
From: Stephen Roderick <[email protected]>
Date: Tue, 25 Feb 2014 08:35:59 -0500
Subject: [PATCH 1/3] Make TaskContext::getName() a const function

THe undelrying function that it calls in Service is a const function,
and the TaskContext version does not modify anything. Without the const
some compilers will error out, or produce warnings, when trying to
get the name of a const TaskContext object, which is wrong.
---
 rtt/TaskContext.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rtt/TaskContext.hpp b/rtt/TaskContext.hpp
index 3b8a462..c2fed13 100644
--- a/rtt/TaskContext.hpp
+++ b/rtt/TaskContext.hpp
@@ -125,7 +125,7 @@ namespace RTT
         /**
          * Returns the name of this TaskContext.
          */
-        virtual const std::string& getName() { return tcservice->getName(); }
+        virtual const std::string& getName() const { return tcservice->getName(); }
 
         /**
          * Sets the activity of this TaskContext. The
-- 
1.8.2.3
0002-tlsf-Add-default-memory-pool-statistic-functions.patch (application/octet-stream, 2.2 KB)
From 4bdc6a0ad3a0765bacab0d1104eb733eee03ca7d Mon Sep 17 00:00:00 2001
From: Stephen Roderick <[email protected]>
Date: Tue, 25 Feb 2014 09:43:43 -0500
Subject: [PATCH 2/3] tlsf: Add default memory pool statistic functions

Without these statistics on the default memory pool are not
available, as the pointer to the default memory pool ("mp")
is not externally exposed.
---
 rtt/os/tlsf/tlsf.c | 24 ++++++++++++++++++++++++
 rtt/os/tlsf/tlsf.h |  2 ++
 2 files changed, 26 insertions(+)

diff --git a/rtt/os/tlsf/tlsf.c b/rtt/os/tlsf/tlsf.c
index f5926b0..0fc5286 100644
--- a/rtt/os/tlsf/tlsf.c
+++ b/rtt/os/tlsf/tlsf.c
@@ -586,6 +586,18 @@ size_t get_used_size(void *mem_pool)
 }
 
 /******************************************************************/
+// use default memory pool
+size_t get_used_size_mp()
+{
+/******************************************************************/
+#if TLSF_STATISTIC
+    return (mp ? ((tlsf_t *) mp)->used_size : 0);
+#else
+    return 0;
+#endif
+}
+
+/******************************************************************/
 size_t get_max_size(void *mem_pool)
 {
 /******************************************************************/
@@ -597,6 +609,18 @@ size_t get_max_size(void *mem_pool)
 }
 
 /******************************************************************/
+// use default memory pool
+size_t get_max_size_mp()
+{
+/******************************************************************/
+#if TLSF_STATISTIC
+    return (mp ? ((tlsf_t *) mp)->max_size : 0);
+#else
+    return 0;
+#endif
+}
+
+/******************************************************************/
 void destroy_memory_pool(void *mem_pool)
 {
 /******************************************************************/
diff --git a/rtt/os/tlsf/tlsf.h b/rtt/os/tlsf/tlsf.h
index f58a914..a31f232 100644
--- a/rtt/os/tlsf/tlsf.h
+++ b/rtt/os/tlsf/tlsf.h
@@ -35,7 +35,9 @@ extern "C" {
 #ifdef ORO_MEMORY_POOL
 extern size_t init_memory_pool(size_t, void *);
 extern size_t get_used_size(void *);
+extern size_t get_used_size_mp();
 extern size_t get_max_size(void *);
+extern size_t get_max_size_mp();
 extern void destroy_memory_pool(void *);
 extern size_t add_new_area(void *, size_t, void *);
 extern void *malloc_ex(size_t, void *);
-- 
1.8.2.3
0003-tests-Avoid-compiler-warning.patch (application/octet-stream, 820 B)
From b04b5803dbe270f5666e9640558942b345906e16 Mon Sep 17 00:00:00 2001
From: Stephen Roderick <[email protected]>
Date: Tue, 25 Feb 2014 09:52:23 -0500
Subject: [PATCH 3/3] tests: Avoid compiler warning

---
 tests/test-runner.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/test-runner.cpp b/tests/test-runner.cpp
index 8c3a406..045ae82 100644
--- a/tests/test-runner.cpp
+++ b/tests/test-runner.cpp
@@ -80,6 +80,7 @@ boost::unit_test::test_suite* init_unit_test_suite(int argc, char** const argv)
 	assert(0 != rtMem);
 	freeMem		= init_memory_pool(BUILD_TEST_RT_MEM_POOL_SIZE, rtMem);
 	assert((size_t)-1 != freeMem); // increase MEMORY_SIZE above most likely, as TLSF has a several kilobyte overhead
+    (void)freeMem;          // avoid compiler warning
 #endif
 	__os_init(argc, argv);
 
-- 
1.8.2.3