1 /*
2  * Copyright (C) 2015-2017 Alibaba Group Holding Limited
3  */
4 
5 #ifndef K_MM_DEBUG_H
6 #define K_MM_DEBUG_H
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 /** @addtogroup aos_rhino mm
13  *  Memory debug includes buffer over flow check, memory usage statistics, etc.
14  *
15  *  @{
16  */
17 
18 #if (RHINO_CONFIG_MM_DEBUG > 0)
19 
20 #define AOS_UNSIGNED_INT_MSB    (1u << (sizeof(unsigned int) * 8 - 1))
21 
22 extern uint8_t g_mmlk_cnt;
23 
24 /**
25  * Add owner info to the memory buffer.
26  *
27  * @param[in]  addr  pointer to the buffer
28  * @param[in]  allocator   address of the allocator
29  *
30  * @return  NULL
31  */
32 void krhino_owner_attach(void *addr, size_t allocator);
33 
34 /**
35  * Set owner to return address of function.
36  *
37  */
38 #define krhino_owner_return_addr(addr) \
39     krhino_owner_attach(addr, (size_t)__builtin_return_address(0))
40 
41 /**
42  * Show heap information.
43  *
44  * @param[in]  mm status
45  *
46  * @return  RHINO_SUCCESS
47  */
48 uint32_t dumpsys_mm_info_func(uint32_t mm_status);
49 
50 #endif /* RHINO_CONFIG_MM_DEBUG */
51 
52 /** @} */
53 
54 #ifdef __cplusplus
55 }
56 #endif
57 
58 #endif /* K_MM_DEBUG_H */
59 
60