UbixOS V2
2.0
memp.h
Go to the documentation of this file.
1
6
/*
7
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
8
* All rights reserved.
9
*
10
* Redistribution and use in source and binary forms, with or without modification,
11
* are permitted provided that the following conditions are met:
12
*
13
* 1. Redistributions of source code must retain the above copyright notice,
14
* this list of conditions and the following disclaimer.
15
* 2. Redistributions in binary form must reproduce the above copyright notice,
16
* this list of conditions and the following disclaimer in the documentation
17
* and/or other materials provided with the distribution.
18
* 3. The name of the author may not be used to endorse or promote products
19
* derived from this software without specific prior written permission.
20
*
21
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30
* OF SUCH DAMAGE.
31
*
32
* This file is part of the lwIP TCP/IP stack.
33
*
34
* Author: Adam Dunkels <adam@sics.se>
35
*
36
*/
37
38
#ifndef LWIP_HDR_MEMP_H
39
#define LWIP_HDR_MEMP_H
40
41
#include <
net/opt.h
>
42
43
#ifdef __cplusplus
44
extern
"C"
{
45
#endif
46
47
/* run once with empty definition to handle all custom includes in lwippools.h */
48
#define LWIP_MEMPOOL(name,num,size,desc)
49
#include <
net/priv/memp_std.h
>
50
52
typedef
enum
{
53
#define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name,
54
#include <
net/priv/memp_std.h
>
55
MEMP_MAX
56
}
memp_t
;
57
58
#include <
net/priv/memp_priv.h
>
59
#include <
net/stats.h
>
60
61
extern
const
struct
memp_desc
*
const
memp_pools
[
MEMP_MAX
];
62
67
#define LWIP_MEMPOOL_PROTOTYPE(name) extern const struct memp_desc memp_ ## name
68
69
#if MEMP_MEM_MALLOC
70
71
#define LWIP_MEMPOOL_DECLARE(name,num,size,desc) \
72
LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(memp_stats_ ## name) \
73
const struct memp_desc memp_ ## name = { \
74
DECLARE_LWIP_MEMPOOL_DESC(desc) \
75
LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(memp_stats_ ## name) \
76
LWIP_MEM_ALIGN_SIZE(size) \
77
};
78
79
#else
/* MEMP_MEM_MALLOC */
80
95
#define LWIP_MEMPOOL_DECLARE(name,num,size,desc) \
96
LWIP_DECLARE_MEMORY_ALIGNED(memp_memory_ ## name ## _base, ((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))); \
97
\
98
LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(memp_stats_ ## name) \
99
\
100
static struct memp *memp_tab_ ## name; \
101
\
102
const struct memp_desc memp_ ## name = { \
103
DECLARE_LWIP_MEMPOOL_DESC(desc) \
104
LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(memp_stats_ ## name) \
105
LWIP_MEM_ALIGN_SIZE(size), \
106
(num), \
107
memp_memory_ ## name ## _base, \
108
&memp_tab_ ## name \
109
};
110
111
#endif
/* MEMP_MEM_MALLOC */
112
117
#define LWIP_MEMPOOL_INIT(name) memp_init_pool(&memp_ ## name)
118
122
#define LWIP_MEMPOOL_ALLOC(name) memp_malloc_pool(&memp_ ## name)
123
127
#define LWIP_MEMPOOL_FREE(name, x) memp_free_pool(&memp_ ## name, (x))
128
129
#if MEM_USE_POOLS
130
132
struct
memp_malloc_helper
133
{
134
memp_t
poolnr;
135
#if MEMP_OVERFLOW_CHECK || (LWIP_STATS && MEM_STATS)
136
u16_t
size;
137
#endif
/* MEMP_OVERFLOW_CHECK || (LWIP_STATS && MEM_STATS) */
138
};
139
#endif
/* MEM_USE_POOLS */
140
141
void
memp_init
(
void
);
142
143
#if MEMP_OVERFLOW_CHECK
144
void
*memp_malloc_fn(
memp_t
type,
const
char
*
file
,
const
int
line);
145
#define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__)
146
#else
147
void
*
memp_malloc
(
memp_t
type);
148
#endif
149
void
memp_free
(
memp_t
type,
void
*
mem
);
150
151
#ifdef __cplusplus
152
}
153
#endif
154
155
#endif
/* LWIP_HDR_MEMP_H */
memp_desc
Definition:
memp_priv.h:130
opt.h
mem
Definition:
mem.c:264
u16_t
uint16_t u16_t
Definition:
arch.h:124
MEMP_MAX
Definition:
memp.h:55
file
Definition:
descrip.h:67
memp_malloc
void * memp_malloc(memp_t type)
Definition:
memp.c:385
memp_free
void memp_free(memp_t type, void *mem)
Definition:
memp.c:469
memp_init
void memp_init(void)
Definition:
memp.c:271
stats.h
memp_priv.h
memp_std.h
memp_pools
const struct memp_desc *const memp_pools[MEMP_MAX]
Definition:
memp.c:81
memp_t
memp_t
Definition:
memp.h:52
C:
Dev
git
UbixOS
sys
include
net
memp.h
Generated by
1.8.16