[rtems commit] score: Introduce <rtems/score/heapinfo.h>

Sebastian Huber sebh at rtems.org
Mon Nov 26 11:31:35 UTC 2018


Module:    rtems
Branch:    master
Commit:    eaa5ea84eaf1b3dab72d7a7a6578f0dc59e55396
Changeset: http://git.rtems.org/rtems/commit/?id=eaa5ea84eaf1b3dab72d7a7a6578f0dc59e55396

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Nov 20 16:22:56 2018 +0100

score: Introduce <rtems/score/heapinfo.h>

Move Heap_Information_block to separate header file to hide heap
implementation details from <rtems.h>.

Update #3598.

---

 cpukit/headers.am                     |   1 +
 cpukit/include/rtems/rtems/types.h    |   2 +-
 cpukit/include/rtems/score/heap.h     | 119 +------------------------
 cpukit/include/rtems/score/heapinfo.h | 158 ++++++++++++++++++++++++++++++++++
 testsuites/libtests/stackchk/blow.c   |   1 +
 5 files changed, 162 insertions(+), 119 deletions(-)

diff --git a/cpukit/headers.am b/cpukit/headers.am
index d74fe78..1dbd154 100644
--- a/cpukit/headers.am
+++ b/cpukit/headers.am
@@ -318,6 +318,7 @@ include_rtems_score_HEADERS += include/rtems/score/cpustdatomic.h
 include_rtems_score_HEADERS += include/rtems/score/freechain.h
 include_rtems_score_HEADERS += include/rtems/score/heap.h
 include_rtems_score_HEADERS += include/rtems/score/heapimpl.h
+include_rtems_score_HEADERS += include/rtems/score/heapinfo.h
 include_rtems_score_HEADERS += include/rtems/score/interr.h
 include_rtems_score_HEADERS += include/rtems/score/io.h
 include_rtems_score_HEADERS += include/rtems/score/isr.h
diff --git a/cpukit/include/rtems/rtems/types.h b/cpukit/include/rtems/rtems/types.h
index 9222f25..0eae24b 100644
--- a/cpukit/include/rtems/rtems/types.h
+++ b/cpukit/include/rtems/rtems/types.h
@@ -26,7 +26,7 @@
 #include <sys/_timespec.h>
 #include <sys/_timeval.h>
 #include <stdint.h>
-#include <rtems/score/heap.h>
+#include <rtems/score/heapinfo.h>
 #include <rtems/score/object.h>
 #include <rtems/score/watchdogticks.h>
 #include <rtems/rtems/modes.h>
diff --git a/cpukit/include/rtems/score/heap.h b/cpukit/include/rtems/score/heap.h
index a69d890..a9d75e7 100644
--- a/cpukit/include/rtems/score/heap.h
+++ b/cpukit/include/rtems/score/heap.h
@@ -19,6 +19,7 @@
 #define _RTEMS_SCORE_HEAP_H
 
 #include <rtems/score/cpu.h>
+#include <rtems/score/heapinfo.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -249,95 +250,6 @@ struct Heap_Block {
 };
 
 /**
- * @brief Run-time heap statistics.
- *
- * The value @a searches / @a allocs gives the mean number of searches per
- * allocation, while @a max_search gives maximum number of searches ever
- * performed on a single allocation call.
- */
-typedef struct {
-  /**
-   * @brief Lifetime number of bytes allocated from this heap.
-   *
-   * This value is an integral multiple of the page size.
-   */
-  uint64_t lifetime_allocated;
-
-  /**
-   * @brief Lifetime number of bytes freed to this heap.
-   *
-   * This value is an integral multiple of the page size.
-   */
-  uint64_t lifetime_freed;
-
-  /**
-   * @brief Size of the allocatable area in bytes.
-   *
-   * This value is an integral multiple of the page size.
-   */
-  uintptr_t size;
-
-  /**
-   * @brief Current free size in bytes.
-   *
-   * This value is an integral multiple of the page size.
-   */
-  uintptr_t free_size;
-
-  /**
-   * @brief Minimum free size ever in bytes.
-   *
-   * This value is an integral multiple of the page size.
-   */
-  uintptr_t min_free_size;
-
-  /**
-   * @brief Current number of free blocks.
-   */
-  uint32_t free_blocks;
-
-  /**
-   * @brief Maximum number of free blocks ever.
-   */
-  uint32_t max_free_blocks;
-
-  /**
-   * @brief Current number of used blocks.
-   */
-  uint32_t used_blocks;
-
-  /**
-   * @brief Maximum number of blocks searched ever.
-   */
-  uint32_t max_search;
-
-  /**
-   * @brief Total number of searches.
-   */
-  uint32_t searches;
-
-  /**
-   * @brief Total number of successful allocations.
-   */
-  uint32_t allocs;
-
-  /**
-   * @brief Total number of failed allocations.
-   */
-  uint32_t failed_allocs;
-
-  /**
-   * @brief Total number of successful frees.
-   */
-  uint32_t frees;
-
-  /**
-   * @brief Total number of successful resizes.
-   */
-  uint32_t resizes;
-} Heap_Statistics;
-
-/**
  * @brief Control block used to manage a heap.
  */
 struct Heap_Control {
@@ -355,35 +267,6 @@ struct Heap_Control {
 };
 
 /**
- * @brief Information about blocks.
- */
-typedef struct {
-  /**
-   * @brief Number of blocks of this type.
-   */
-  uintptr_t number;
-
-  /**
-   * @brief Largest block of this type.
-   */
-  uintptr_t largest;
-
-  /**
-   * @brief Total size of the blocks of this type.
-   */
-  uintptr_t total;
-} Heap_Information;
-
-/**
- * @brief Information block returned by _Heap_Get_information().
- */
-typedef struct {
-  Heap_Information Free;
-  Heap_Information Used;
-  Heap_Statistics Stats;
-} Heap_Information_block;
-
-/**
  * @brief Heap area structure for table based heap initialization and
  * extension.
  *
diff --git a/cpukit/include/rtems/score/heapinfo.h b/cpukit/include/rtems/score/heapinfo.h
new file mode 100644
index 0000000..1f84387
--- /dev/null
+++ b/cpukit/include/rtems/score/heapinfo.h
@@ -0,0 +1,158 @@
+/**
+ * @file
+ *
+ * @ingroup ScoreHeap
+ *
+ * @brief Heap Handler Information API
+ */
+
+/*
+ *  COPYRIGHT (c) 1989-2006.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_SCORE_HEAPINFO_H
+#define _RTEMS_SCORE_HEAPINFO_H
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup ScoreHeap
+ *
+ * @{
+ */
+
+/**
+ * @brief Run-time heap statistics.
+ *
+ * The value @a searches / @a allocs gives the mean number of searches per
+ * allocation, while @a max_search gives maximum number of searches ever
+ * performed on a single allocation call.
+ */
+typedef struct {
+  /**
+   * @brief Lifetime number of bytes allocated from this heap.
+   *
+   * This value is an integral multiple of the page size.
+   */
+  uint64_t lifetime_allocated;
+
+  /**
+   * @brief Lifetime number of bytes freed to this heap.
+   *
+   * This value is an integral multiple of the page size.
+   */
+  uint64_t lifetime_freed;
+
+  /**
+   * @brief Size of the allocatable area in bytes.
+   *
+   * This value is an integral multiple of the page size.
+   */
+  uintptr_t size;
+
+  /**
+   * @brief Current free size in bytes.
+   *
+   * This value is an integral multiple of the page size.
+   */
+  uintptr_t free_size;
+
+  /**
+   * @brief Minimum free size ever in bytes.
+   *
+   * This value is an integral multiple of the page size.
+   */
+  uintptr_t min_free_size;
+
+  /**
+   * @brief Current number of free blocks.
+   */
+  uint32_t free_blocks;
+
+  /**
+   * @brief Maximum number of free blocks ever.
+   */
+  uint32_t max_free_blocks;
+
+  /**
+   * @brief Current number of used blocks.
+   */
+  uint32_t used_blocks;
+
+  /**
+   * @brief Maximum number of blocks searched ever.
+   */
+  uint32_t max_search;
+
+  /**
+   * @brief Total number of searches.
+   */
+  uint32_t searches;
+
+  /**
+   * @brief Total number of successful allocations.
+   */
+  uint32_t allocs;
+
+  /**
+   * @brief Total number of failed allocations.
+   */
+  uint32_t failed_allocs;
+
+  /**
+   * @brief Total number of successful frees.
+   */
+  uint32_t frees;
+
+  /**
+   * @brief Total number of successful resizes.
+   */
+  uint32_t resizes;
+} Heap_Statistics;
+
+/**
+ * @brief Information about blocks.
+ */
+typedef struct {
+  /**
+   * @brief Number of blocks of this type.
+   */
+  uintptr_t number;
+
+  /**
+   * @brief Largest block of this type.
+   */
+  uintptr_t largest;
+
+  /**
+   * @brief Total size of the blocks of this type.
+   */
+  uintptr_t total;
+} Heap_Information;
+
+/**
+ * @brief Information block returned by _Heap_Get_information().
+ */
+typedef struct {
+  Heap_Information Free;
+  Heap_Information Used;
+  Heap_Statistics Stats;
+} Heap_Information_block;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/testsuites/libtests/stackchk/blow.c b/testsuites/libtests/stackchk/blow.c
index e424568..15ce0ab 100644
--- a/testsuites/libtests/stackchk/blow.c
+++ b/testsuites/libtests/stackchk/blow.c
@@ -17,6 +17,7 @@
 
 #include <rtems.h>
 #include <rtems/stackchk.h>
+#include <rtems/score/heap.h>
 #include <rtems/score/percpu.h>
 
 /* forward declarations to avoid warnings */



More information about the vc mailing list