From a228fd0f3b24e55a41321d6cffd3c937c56b5872 Mon Sep 17 00:00:00 2001 From: deepikabhavnani Date: Wed, 2 May 2018 11:35:45 -0500 Subject: [PATCH 1/2] Add common define to enable all statistics As part of Device Health requirement, all mbed OS statistics should be enabled with single macro `MBED_ALL_STATS_ENABLED` --- platform/mbed_stats.c | 8 ++++---- platform/mbed_stats.h | 5 +++++ rtos/TARGET_CORTEX/mbed_rtx_conf.h | 6 +++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/platform/mbed_stats.c b/platform/mbed_stats.c index 106394be42..c73e319d4a 100644 --- a/platform/mbed_stats.c +++ b/platform/mbed_stats.c @@ -3,7 +3,7 @@ #include #include "mbed_assert.h" -#if MBED_CONF_RTOS_PRESENT +#ifdef MBED_CONF_RTOS_PRESENT #include "cmsis_os2.h" #endif @@ -13,7 +13,7 @@ void mbed_stats_stack_get(mbed_stats_stack_t *stats) { memset(stats, 0, sizeof(mbed_stats_stack_t)); -#if MBED_STACK_STATS_ENABLED && MBED_CONF_RTOS_PRESENT +#if defined(MBED_STACK_STATS_ENABLED) && defined(MBED_CONF_RTOS_PRESENT) uint32_t thread_n = osThreadGetCount(); unsigned i; osThreadId_t *threads; @@ -41,7 +41,7 @@ size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count) memset(stats, 0, count*sizeof(mbed_stats_stack_t)); size_t i = 0; -#if MBED_STACK_STATS_ENABLED && MBED_CONF_RTOS_PRESENT +#if defined(MBED_STACK_STATS_ENABLED) && defined(MBED_CONF_RTOS_PRESENT) osThreadId_t *threads; threads = malloc(sizeof(osThreadId_t) * count); @@ -65,6 +65,6 @@ size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count) return i; } -#if MBED_STACK_STATS_ENABLED && !MBED_CONF_RTOS_PRESENT +#if defined(MBED_STACK_STATS_ENABLED) && !defined(MBED_CONF_RTOS_PRESENT) #warning Stack statistics are currently not supported without the rtos. #endif diff --git a/platform/mbed_stats.h b/platform/mbed_stats.h index c997baefab..e86507991d 100644 --- a/platform/mbed_stats.h +++ b/platform/mbed_stats.h @@ -29,6 +29,11 @@ extern "C" { #endif +#ifdef MBED_ALL_STATS_ENABLED +#define MBED_STACK_STATS_ENABLED 1 +#define MBED_HEAP_STATS_ENABLED 1 +#endif + /** * struct mbed_stats_heap_t definition */ diff --git a/rtos/TARGET_CORTEX/mbed_rtx_conf.h b/rtos/TARGET_CORTEX/mbed_rtx_conf.h index 91d024a260..f983012ebd 100644 --- a/rtos/TARGET_CORTEX/mbed_rtx_conf.h +++ b/rtos/TARGET_CORTEX/mbed_rtx_conf.h @@ -45,7 +45,11 @@ #error "OS Tickrate must be 1000 for system timing" #endif -#if !defined(OS_STACK_WATERMARK) && (defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED) +#if !defined(OS_STACK_WATERMARK) && defined(MBED_STACK_STATS_ENABLED) +#define OS_STACK_WATERMARK 1 +#endif + +#if !defined(OS_STACK_WATERMARK) && defined(MBED_ALL_STATS_ENABLED) #define OS_STACK_WATERMARK 1 #endif From 52c33b54940db44c23f2610c26b69bc9e2a174cc Mon Sep 17 00:00:00 2001 From: deepikabhavnani Date: Wed, 2 May 2018 14:15:01 -0500 Subject: [PATCH 2/2] Add stats header file to mbed.h All API header files should be part of mbed.h --- mbed.h | 1 + rtos/TARGET_CORTEX/mbed_rtx_conf.h | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/mbed.h b/mbed.h index c7e0bcf4e0..ffa82cc50f 100644 --- a/mbed.h +++ b/mbed.h @@ -92,6 +92,7 @@ #include "platform/DirHandle.h" #include "platform/CriticalSectionLock.h" #include "platform/DeepSleepLock.h" +#include "platform/mbed_stats.h" // mbed Non-hardware components #include "platform/Callback.h" diff --git a/rtos/TARGET_CORTEX/mbed_rtx_conf.h b/rtos/TARGET_CORTEX/mbed_rtx_conf.h index f983012ebd..5d9b49c1b8 100644 --- a/rtos/TARGET_CORTEX/mbed_rtx_conf.h +++ b/rtos/TARGET_CORTEX/mbed_rtx_conf.h @@ -45,11 +45,7 @@ #error "OS Tickrate must be 1000 for system timing" #endif -#if !defined(OS_STACK_WATERMARK) && defined(MBED_STACK_STATS_ENABLED) -#define OS_STACK_WATERMARK 1 -#endif - -#if !defined(OS_STACK_WATERMARK) && defined(MBED_ALL_STATS_ENABLED) +#if !defined(OS_STACK_WATERMARK) && (defined(MBED_STACK_STATS_ENABLED) || defined(MBED_ALL_STATS_ENABLED)) #define OS_STACK_WATERMARK 1 #endif