00

Committer:
ganlikun
Date:
Sun Jun 12 14:02:44 2022 +0000
Revision:
0:13413ea9a877
00

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ganlikun 0:13413ea9a877 1
ganlikun 0:13413ea9a877 2 /** \addtogroup platform */
ganlikun 0:13413ea9a877 3 /** @{*/
ganlikun 0:13413ea9a877 4 /* mbed Microcontroller Library
ganlikun 0:13413ea9a877 5 * Copyright (c) 2016-2016 ARM Limited
ganlikun 0:13413ea9a877 6 *
ganlikun 0:13413ea9a877 7 * Licensed under the Apache License, Version 2.0 (the "License");
ganlikun 0:13413ea9a877 8 * you may not use this file except in compliance with the License.
ganlikun 0:13413ea9a877 9 * You may obtain a copy of the License at
ganlikun 0:13413ea9a877 10 *
ganlikun 0:13413ea9a877 11 * http://www.apache.org/licenses/LICENSE-2.0
ganlikun 0:13413ea9a877 12 *
ganlikun 0:13413ea9a877 13 * Unless required by applicable law or agreed to in writing, software
ganlikun 0:13413ea9a877 14 * distributed under the License is distributed on an "AS IS" BASIS,
ganlikun 0:13413ea9a877 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ganlikun 0:13413ea9a877 16 * See the License for the specific language governing permissions and
ganlikun 0:13413ea9a877 17 * limitations under the License.
ganlikun 0:13413ea9a877 18 */
ganlikun 0:13413ea9a877 19 #ifndef MBED_STATS_H
ganlikun 0:13413ea9a877 20 #define MBED_STATS_H
ganlikun 0:13413ea9a877 21 #include <stdint.h>
ganlikun 0:13413ea9a877 22 #include <stddef.h>
ganlikun 0:13413ea9a877 23
ganlikun 0:13413ea9a877 24 #ifdef __cplusplus
ganlikun 0:13413ea9a877 25 extern "C" {
ganlikun 0:13413ea9a877 26 #endif
ganlikun 0:13413ea9a877 27
ganlikun 0:13413ea9a877 28 typedef struct {
ganlikun 0:13413ea9a877 29 uint32_t current_size; /**< Bytes allocated currently. */
ganlikun 0:13413ea9a877 30 uint32_t max_size; /**< Max bytes allocated at a given time. */
ganlikun 0:13413ea9a877 31 uint32_t total_size; /**< Cumulative sum of bytes ever allocated. */
ganlikun 0:13413ea9a877 32 uint32_t reserved_size; /**< Current number of bytes allocated for the heap. */
ganlikun 0:13413ea9a877 33 uint32_t alloc_cnt; /**< Current number of allocations. */
ganlikun 0:13413ea9a877 34 uint32_t alloc_fail_cnt; /**< Number of failed allocations. */
ganlikun 0:13413ea9a877 35 } mbed_stats_heap_t;
ganlikun 0:13413ea9a877 36
ganlikun 0:13413ea9a877 37 /**
ganlikun 0:13413ea9a877 38 * Fill the passed in heap stat structure with heap stats.
ganlikun 0:13413ea9a877 39 *
ganlikun 0:13413ea9a877 40 * @param stats A pointer to the mbed_stats_heap_t structure to fill
ganlikun 0:13413ea9a877 41 */
ganlikun 0:13413ea9a877 42 void mbed_stats_heap_get(mbed_stats_heap_t *stats);
ganlikun 0:13413ea9a877 43
ganlikun 0:13413ea9a877 44 typedef struct {
ganlikun 0:13413ea9a877 45 uint32_t thread_id; /**< Identifier for thread that owns the stack or 0 if multiple threads. */
ganlikun 0:13413ea9a877 46 uint32_t max_size; /**< Maximum number of bytes used on the stack. */
ganlikun 0:13413ea9a877 47 uint32_t reserved_size; /**< Current number of bytes allocated for the stack. */
ganlikun 0:13413ea9a877 48 uint32_t stack_cnt; /**< Number of stacks stats accumulated in the structure. */
ganlikun 0:13413ea9a877 49 } mbed_stats_stack_t;
ganlikun 0:13413ea9a877 50
ganlikun 0:13413ea9a877 51 /**
ganlikun 0:13413ea9a877 52 * Fill the passed in structure with stack stats accumulated for all threads. The thread_id will be 0
ganlikun 0:13413ea9a877 53 * and stack_cnt will represent number of threads.
ganlikun 0:13413ea9a877 54 *
ganlikun 0:13413ea9a877 55 * @param stats A pointer to the mbed_stats_stack_t structure to fill
ganlikun 0:13413ea9a877 56 */
ganlikun 0:13413ea9a877 57 void mbed_stats_stack_get(mbed_stats_stack_t *stats);
ganlikun 0:13413ea9a877 58
ganlikun 0:13413ea9a877 59 /**
ganlikun 0:13413ea9a877 60 * Fill the passed array of stat structures with the stack stats for each available thread.
ganlikun 0:13413ea9a877 61 *
ganlikun 0:13413ea9a877 62 * @param stats A pointer to an array of mbed_stats_stack_t structures to fill
ganlikun 0:13413ea9a877 63 * @param count The number of mbed_stats_stack_t structures in the provided array
ganlikun 0:13413ea9a877 64 * @return The number of mbed_stats_stack_t structures that have been filled,
ganlikun 0:13413ea9a877 65 * this is equal to the number of stacks on the system.
ganlikun 0:13413ea9a877 66 */
ganlikun 0:13413ea9a877 67 size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count);
ganlikun 0:13413ea9a877 68
ganlikun 0:13413ea9a877 69 #ifdef __cplusplus
ganlikun 0:13413ea9a877 70 }
ganlikun 0:13413ea9a877 71 #endif
ganlikun 0:13413ea9a877 72
ganlikun 0:13413ea9a877 73 #endif
ganlikun 0:13413ea9a877 74
ganlikun 0:13413ea9a877 75 /** @}*/
ganlikun 0:13413ea9a877 76