A version of LWIP, provided for backwards compatibility.

Dependents:   AA_DemoBoard DemoBoard HelloServerDemo DemoBoard_RangeIndicator ... more

Committer:
root@mbed.org
Date:
Tue May 08 15:32:10 2012 +0100
Revision:
0:5e1631496985
initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
root@mbed.org 0:5e1631496985 1 /*
root@mbed.org 0:5e1631496985 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
root@mbed.org 0:5e1631496985 3 * All rights reserved.
root@mbed.org 0:5e1631496985 4 *
root@mbed.org 0:5e1631496985 5 * Redistribution and use in source and binary forms, with or without modification,
root@mbed.org 0:5e1631496985 6 * are permitted provided that the following conditions are met:
root@mbed.org 0:5e1631496985 7 *
root@mbed.org 0:5e1631496985 8 * 1. Redistributions of source code must retain the above copyright notice,
root@mbed.org 0:5e1631496985 9 * this list of conditions and the following disclaimer.
root@mbed.org 0:5e1631496985 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
root@mbed.org 0:5e1631496985 11 * this list of conditions and the following disclaimer in the documentation
root@mbed.org 0:5e1631496985 12 * and/or other materials provided with the distribution.
root@mbed.org 0:5e1631496985 13 * 3. The name of the author may not be used to endorse or promote products
root@mbed.org 0:5e1631496985 14 * derived from this software without specific prior written permission.
root@mbed.org 0:5e1631496985 15 *
root@mbed.org 0:5e1631496985 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
root@mbed.org 0:5e1631496985 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
root@mbed.org 0:5e1631496985 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
root@mbed.org 0:5e1631496985 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
root@mbed.org 0:5e1631496985 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
root@mbed.org 0:5e1631496985 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
root@mbed.org 0:5e1631496985 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
root@mbed.org 0:5e1631496985 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
root@mbed.org 0:5e1631496985 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
root@mbed.org 0:5e1631496985 25 * OF SUCH DAMAGE.
root@mbed.org 0:5e1631496985 26 *
root@mbed.org 0:5e1631496985 27 * This file is part of the lwIP TCP/IP stack.
root@mbed.org 0:5e1631496985 28 *
root@mbed.org 0:5e1631496985 29 * Author: Adam Dunkels <adam@sics.se>
root@mbed.org 0:5e1631496985 30 *
root@mbed.org 0:5e1631496985 31 */
root@mbed.org 0:5e1631496985 32
root@mbed.org 0:5e1631496985 33 #ifndef __LWIP_MEMP_H__
root@mbed.org 0:5e1631496985 34 #define __LWIP_MEMP_H__
root@mbed.org 0:5e1631496985 35
root@mbed.org 0:5e1631496985 36 #include "lwip/opt.h"
root@mbed.org 0:5e1631496985 37
root@mbed.org 0:5e1631496985 38 #ifdef __cplusplus
root@mbed.org 0:5e1631496985 39 extern "C" {
root@mbed.org 0:5e1631496985 40 #endif
root@mbed.org 0:5e1631496985 41
root@mbed.org 0:5e1631496985 42 /* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */
root@mbed.org 0:5e1631496985 43 typedef enum {
root@mbed.org 0:5e1631496985 44 #define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name,
root@mbed.org 0:5e1631496985 45 #include "lwip/memp_std.h"
root@mbed.org 0:5e1631496985 46 MEMP_MAX
root@mbed.org 0:5e1631496985 47 } memp_t;
root@mbed.org 0:5e1631496985 48
root@mbed.org 0:5e1631496985 49 #if MEM_USE_POOLS
root@mbed.org 0:5e1631496985 50 /* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */
root@mbed.org 0:5e1631496985 51 typedef enum {
root@mbed.org 0:5e1631496985 52 /* Get the first (via:
root@mbed.org 0:5e1631496985 53 MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/
root@mbed.org 0:5e1631496985 54 MEMP_POOL_HELPER_FIRST = ((u8_t)
root@mbed.org 0:5e1631496985 55 #define LWIP_MEMPOOL(name,num,size,desc)
root@mbed.org 0:5e1631496985 56 #define LWIP_MALLOC_MEMPOOL_START 1
root@mbed.org 0:5e1631496985 57 #define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0
root@mbed.org 0:5e1631496985 58 #define LWIP_MALLOC_MEMPOOL_END
root@mbed.org 0:5e1631496985 59 #include "lwip/memp_std.h"
root@mbed.org 0:5e1631496985 60 ) ,
root@mbed.org 0:5e1631496985 61 /* Get the last (via:
root@mbed.org 0:5e1631496985 62 MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */
root@mbed.org 0:5e1631496985 63 MEMP_POOL_HELPER_LAST = ((u8_t)
root@mbed.org 0:5e1631496985 64 #define LWIP_MEMPOOL(name,num,size,desc)
root@mbed.org 0:5e1631496985 65 #define LWIP_MALLOC_MEMPOOL_START
root@mbed.org 0:5e1631496985 66 #define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size *
root@mbed.org 0:5e1631496985 67 #define LWIP_MALLOC_MEMPOOL_END 1
root@mbed.org 0:5e1631496985 68 #include "lwip/memp_std.h"
root@mbed.org 0:5e1631496985 69 )
root@mbed.org 0:5e1631496985 70 } memp_pool_helper_t;
root@mbed.org 0:5e1631496985 71
root@mbed.org 0:5e1631496985 72 /* The actual start and stop values are here (cast them over)
root@mbed.org 0:5e1631496985 73 We use this helper type and these defines so we can avoid using const memp_t values */
root@mbed.org 0:5e1631496985 74 #define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST)
root@mbed.org 0:5e1631496985 75 #define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST)
root@mbed.org 0:5e1631496985 76 #endif /* MEM_USE_POOLS */
root@mbed.org 0:5e1631496985 77
root@mbed.org 0:5e1631496985 78 #if MEMP_MEM_MALLOC || MEM_USE_POOLS
root@mbed.org 0:5e1631496985 79 extern const u16_t memp_sizes[MEMP_MAX];
root@mbed.org 0:5e1631496985 80 #endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */
root@mbed.org 0:5e1631496985 81
root@mbed.org 0:5e1631496985 82 #if MEMP_MEM_MALLOC
root@mbed.org 0:5e1631496985 83
root@mbed.org 0:5e1631496985 84 #include "mem.h"
root@mbed.org 0:5e1631496985 85
root@mbed.org 0:5e1631496985 86 #define memp_init()
root@mbed.org 0:5e1631496985 87 #define memp_malloc(type) mem_malloc(memp_sizes[type])
root@mbed.org 0:5e1631496985 88 #define memp_free(type, mem) mem_free(mem)
root@mbed.org 0:5e1631496985 89
root@mbed.org 0:5e1631496985 90 #else /* MEMP_MEM_MALLOC */
root@mbed.org 0:5e1631496985 91
root@mbed.org 0:5e1631496985 92 #if MEM_USE_POOLS
root@mbed.org 0:5e1631496985 93 /** This structure is used to save the pool one element came from. */
root@mbed.org 0:5e1631496985 94 struct memp_malloc_helper
root@mbed.org 0:5e1631496985 95 {
root@mbed.org 0:5e1631496985 96 memp_t poolnr;
root@mbed.org 0:5e1631496985 97 };
root@mbed.org 0:5e1631496985 98 #endif /* MEM_USE_POOLS */
root@mbed.org 0:5e1631496985 99
root@mbed.org 0:5e1631496985 100 void memp_init(void);
root@mbed.org 0:5e1631496985 101
root@mbed.org 0:5e1631496985 102 #if MEMP_OVERFLOW_CHECK
root@mbed.org 0:5e1631496985 103 void *memp_malloc_fn(memp_t type, const char* file, const int line);
root@mbed.org 0:5e1631496985 104 #define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__)
root@mbed.org 0:5e1631496985 105 #else
root@mbed.org 0:5e1631496985 106 void *memp_malloc(memp_t type);
root@mbed.org 0:5e1631496985 107 #endif
root@mbed.org 0:5e1631496985 108 void memp_free(memp_t type, void *mem);
root@mbed.org 0:5e1631496985 109
root@mbed.org 0:5e1631496985 110 #endif /* MEMP_MEM_MALLOC */
root@mbed.org 0:5e1631496985 111
root@mbed.org 0:5e1631496985 112 #ifdef __cplusplus
root@mbed.org 0:5e1631496985 113 }
root@mbed.org 0:5e1631496985 114 #endif
root@mbed.org 0:5e1631496985 115
root@mbed.org 0:5e1631496985 116 #endif /* __LWIP_MEMP_H__ */