Version of http://mbed.org/cookbook/NetServicesTribute with setting set the same for LPC2368

Dependents:   UDPSocketExample 24LCxx_I2CApp WeatherPlatform_pachube HvZServerLib ... more

Committer:
simon
Date:
Tue Nov 23 14:15:36 2010 +0000
Revision:
0:350011bf8be7
Experimental version for testing UDP

Who changed what in which revision?

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