Nicolas Borla / Mbed OS BBR_1Ebene
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_stats.h Source File

mbed_stats.h

00001 
00002 /** \addtogroup platform */
00003 /** @{*/
00004 /**
00005  * \defgroup platform_stats stats functions
00006  * @{
00007  */
00008 /* mbed Microcontroller Library
00009  * Copyright (c) 2016-2016 ARM Limited
00010  *
00011  * Licensed under the Apache License, Version 2.0 (the "License");
00012  * you may not use this file except in compliance with the License.
00013  * You may obtain a copy of the License at
00014  *
00015  *     http://www.apache.org/licenses/LICENSE-2.0
00016  *
00017  * Unless required by applicable law or agreed to in writing, software
00018  * distributed under the License is distributed on an "AS IS" BASIS,
00019  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020  * See the License for the specific language governing permissions and
00021  * limitations under the License.
00022  */
00023 #ifndef MBED_STATS_H
00024 #define MBED_STATS_H
00025 #include <stdint.h>
00026 #include <stddef.h>
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 #ifdef MBED_ALL_STATS_ENABLED
00033 #define MBED_STACK_STATS_ENABLED    1
00034 #define MBED_HEAP_STATS_ENABLED     1
00035 #endif
00036 
00037 /**
00038  * struct mbed_stats_heap_t definition
00039  */
00040 typedef struct {
00041     uint32_t current_size;      /**< Bytes allocated currently. */
00042     uint32_t max_size;          /**< Max bytes allocated at a given time. */
00043     uint32_t total_size;        /**< Cumulative sum of bytes ever allocated. */
00044     uint32_t reserved_size;     /**< Current number of bytes allocated for the heap. */
00045     uint32_t alloc_cnt;         /**< Current number of allocations. */
00046     uint32_t alloc_fail_cnt;    /**< Number of failed allocations. */
00047 } mbed_stats_heap_t;
00048 
00049 /**
00050  *  Fill the passed in heap stat structure with heap stats.
00051  *
00052  *  @param stats    A pointer to the mbed_stats_heap_t structure to fill
00053  */
00054 void mbed_stats_heap_get(mbed_stats_heap_t *stats);
00055 
00056 /**
00057  * struct mbed_stats_stack_t definition
00058  */
00059 typedef struct {
00060     uint32_t thread_id;         /**< Identifier for thread that owns the stack or 0 if multiple threads. */
00061     uint32_t max_size;          /**< Maximum number of bytes used on the stack. */
00062     uint32_t reserved_size;     /**< Current number of bytes allocated for the stack. */
00063     uint32_t stack_cnt;         /**< Number of stacks stats accumulated in the structure. */
00064 } mbed_stats_stack_t;
00065 
00066 /**
00067  *  Fill the passed in structure with stack stats accumulated for all threads. The thread_id will be 0
00068  *  and stack_cnt will represent number of threads.
00069  *
00070  *  @param stats    A pointer to the mbed_stats_stack_t structure to fill
00071  */
00072 void mbed_stats_stack_get(mbed_stats_stack_t *stats);
00073 
00074 /**
00075  *  Fill the passed array of stat structures with the stack stats for each available thread.
00076  *
00077  *  @param stats    A pointer to an array of mbed_stats_stack_t structures to fill
00078  *  @param count    The number of mbed_stats_stack_t structures in the provided array
00079  *  @return         The number of mbed_stats_stack_t structures that have been filled,
00080  *                  this is equal to the number of stacks on the system.
00081  */
00082 size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count);
00083 
00084 #ifdef __cplusplus
00085 }
00086 #endif
00087 
00088 #endif
00089 
00090 /** @}*/
00091 
00092 /** @}*/