From a228fd0f3b24e55a41321d6cffd3c937c56b5872 Mon Sep 17 00:00:00 2001 From: deepikabhavnani Date: Wed, 2 May 2018 11:35:45 -0500 Subject: [PATCH] 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