Committer:
ganlikun
Date:
Mon Oct 24 15:19:39 2022 +0000
Revision:
0:06036f8bee2d
11

Who changed what in which revision?

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