blob: 80f697251f00c0ad1b4bd6b46ceebef1d681719d [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*******************************************************************************
2* °æÈ¨ËùÓÐ (C)2014, ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
3*
4* ÎļþÃû³Æ: oss_pool.h
5* Îļþ±êʶ: oss_pool.h
6* ÄÚÈÝÕªÒª: ossÖ§³Å²ãÄÚ´æ³Ø¹ÜÀíÄ£¿éÍ·Îļþ
7* ʹÓ÷½·¨: #include "oss_api.h"
8*
9* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ Ð޸ıê¼Ç ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
10* ------------------------------------------------------------------------------
11* 2014/08/25 V1.0 Create ÁõÑÇÄÏ ´´½¨
12*
13*******************************************************************************/
14
15#ifndef _OSS_POOL_H
16#define _OSS_POOL_H
17
18/*******************************************************************************
19* Í·Îļþ *
20*******************************************************************************/
21
22/*******************************************************************************
23* ºê¶¨Òå *
24*******************************************************************************/
25#if defined(_DEBUG) && !defined(_USE_OSS_MIN)
26# define POOL_DEBUG
27# define POOL_LEAK_CHECK
28# define POOL_INIT_CHECK
29#endif
30
31#ifdef POOL_DEBUG
32# define palloc(size) pool_alloc(size, __FILE__, __LINE__)
33# define pfree(ptr) pool_free(ptr, __FILE__, __LINE__)
34# define prealloc(ptr, size) pool_realloc(ptr, size, __FILE__, __LINE__)
35# define psize(ptr) pool_node_size(ptr, __FILE__, __LINE__)
36#else
37# define palloc(size) pool_alloc(size, NULL, 0x00)
38# define pfree(ptr) pool_free(ptr, NULL, 0x00)
39# define prealloc(ptr, size) pool_realloc(ptr, size, NULL, 0x00)
40# define psize(ptr) pool_node_size(ptr, NULL, 0x00)
41#endif
42
43#define POOL_INDEX_0_NUM (4096) /* the number of index 0 pool node */
44#define POOL_INDEX_0_SIZE (4) /* the size of index 0 pool node */
45
46#define POOL_INDEX_1_NUM (4096) /* the number of index 1 pool node */
47#define POOL_INDEX_1_SIZE (8) /* the size of index 1 pool node */
48
49#define POOL_INDEX_2_NUM (256) /* the number of index 2 pool node */
50#define POOL_INDEX_2_SIZE (16) /* the size of index 2 pool node */
51
52#define POOL_INDEX_3_NUM (2048) /* the number of index 3 pool node */
53#define POOL_INDEX_3_SIZE (32) /* the size of index 3 pool node */
54
55#define POOL_INDEX_4_NUM (3072) /* the number of index 4 pool node */
56#define POOL_INDEX_4_SIZE (64) /* the size of index 4 pool node */
57
58#define POOL_INDEX_5_NUM (512) /* the number of index 5 pool node */
59#define POOL_INDEX_5_SIZE (128) /* the size of index 5 pool node */
60
61#define POOL_INDEX_6_NUM (512) /* the number of index 6 pool node */
62#define POOL_INDEX_6_SIZE (256) /* the size of index 6 pool node */
63
64#define POOL_INDEX_7_NUM (300) /* the number of index 7 pool node */
65#define POOL_INDEX_7_SIZE (512) /* the size of index 7 pool node */
66
67#define POOL_INDEX_8_NUM (300) /* the number of index 8 pool node */
68#define POOL_INDEX_8_SIZE (1024) /* the size of index 8 pool node */
69
70#define POOL_INDEX_9_NUM (100) /* the number of index 9 pool node */
71#define POOL_INDEX_9_SIZE (2048) /* the size of index 9 pool node */
72
73#define POOL_INDEX_10_NUM (21) /* the number of index 10 pool node */
74#define POOL_INDEX_10_SIZE (4096) /* the size of index 10 pool node */
75
76#define POOL_INDEX_11_NUM (60) /* the number of index 11 pool node */
77#define POOL_INDEX_11_SIZE (8192) /* the size of index 11 pool node */
78
79#define POOL_INDEX_12_NUM (15) /* the number of index 12 pool node */
80#define POOL_INDEX_12_SIZE (16384) /* the size of index 12 pool node */
81
82#define POOL_INDEX_13_NUM (5) /* the number of index 13 pool node */
83#define POOL_INDEX_13_SIZE (32768) /* the size of index 13 pool node */
84
85#define POOL_INDEX_14_NUM (5) /* the number of index 14 pool node */
86#define POOL_INDEX_14_SIZE (65536) /* the size of index 14 pool node */
87
88#define POOL_INDEX_15_NUM (1) /* the number of index 15 pool node */
89#define POOL_INDEX_15_SIZE (131072) /* the size of index 15 pool node */
90
91#define POOL_LEAK_CHECK_TIMEOUT (100)
92
93#define POOL_ALLOC_STATISTIC_NUM (8)
94
95#define POOL_MBOX_ITEM_COUNT (3000) /* the total available items(msgs) for system */
96
97
98/*******************************************************************************
99* Êý¾ÝÀàÐͶ¨Òå *
100*******************************************************************************/
101
102/*******************************************************************************
103* È«¾Ö±äÁ¿ÉùÃ÷ *
104*******************************************************************************/
105
106/*******************************************************************************
107* È«¾Öº¯ÊýÉùÃ÷ *
108*******************************************************************************/
109void pool_init(void);
110__tcm_call_func void *pool_alloc(unsigned long size, const char *file, unsigned long line);
111__tcm_call_func void pool_free(void *ptr, const char *file, unsigned long line);
112void *pool_realloc(void *old_ptr, unsigned long new_size, const char *file, unsigned long line);
113unsigned long pool_node_size(void *ptr, const char *file, unsigned long line);
114void pool_print_leak(unsigned long timeout);
115void pool_print_alloc_fail(void);
116void pool_print_alloc_statistic(void);
117void pool_print_free(void);
118void pool_trace_leak_start(void);
119void pool_trace_leak_end(unsigned long timeout);
120
121#endif // #ifndef _OSS_POOL_H
122