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 #ifndef __LWIP_MEM_H__
simon 0:350011bf8be7 33 #define __LWIP_MEM_H__
simon 0:350011bf8be7 34
simon 0:350011bf8be7 35 #include "lwip/opt.h"
simon 0:350011bf8be7 36
simon 0:350011bf8be7 37 #ifdef __cplusplus
simon 0:350011bf8be7 38 extern "C" {
simon 0:350011bf8be7 39 #endif
simon 0:350011bf8be7 40
simon 0:350011bf8be7 41 #if MEM_LIBC_MALLOC
simon 0:350011bf8be7 42
simon 0:350011bf8be7 43 #include <stddef.h> /* for size_t */
simon 0:350011bf8be7 44
simon 0:350011bf8be7 45 typedef size_t mem_size_t;
simon 0:350011bf8be7 46
simon 0:350011bf8be7 47 /* aliases for C library malloc() */
simon 0:350011bf8be7 48 #define mem_init()
simon 0:350011bf8be7 49 /* in case C library malloc() needs extra protection,
simon 0:350011bf8be7 50 * allow these defines to be overridden.
simon 0:350011bf8be7 51 */
simon 0:350011bf8be7 52 #ifndef mem_free
simon 0:350011bf8be7 53 #define mem_free free
simon 0:350011bf8be7 54 #endif
simon 0:350011bf8be7 55 #ifndef mem_malloc
simon 0:350011bf8be7 56 #define mem_malloc malloc
simon 0:350011bf8be7 57 #endif
simon 0:350011bf8be7 58 #ifndef mem_calloc
simon 0:350011bf8be7 59 #define mem_calloc calloc
simon 0:350011bf8be7 60 #endif
simon 0:350011bf8be7 61 /* Since there is no C library allocation function to shrink memory without
simon 0:350011bf8be7 62 moving it, define this to nothing. */
simon 0:350011bf8be7 63 #ifndef mem_trim
simon 0:350011bf8be7 64 #define mem_trim(mem, size) (mem)
simon 0:350011bf8be7 65 #endif
simon 0:350011bf8be7 66 #else /* MEM_LIBC_MALLOC */
simon 0:350011bf8be7 67
simon 0:350011bf8be7 68 /* MEM_SIZE would have to be aligned, but using 64000 here instead of
simon 0:350011bf8be7 69 * 65535 leaves some room for alignment...
simon 0:350011bf8be7 70 */
simon 0:350011bf8be7 71 #if MEM_SIZE > 64000l
simon 0:350011bf8be7 72 typedef u32_t mem_size_t;
simon 0:350011bf8be7 73 #define MEM_SIZE_F U32_F
simon 0:350011bf8be7 74 #else
simon 0:350011bf8be7 75 typedef u16_t mem_size_t;
simon 0:350011bf8be7 76 #define MEM_SIZE_F U16_F
simon 0:350011bf8be7 77 #endif /* MEM_SIZE > 64000 */
simon 0:350011bf8be7 78
simon 0:350011bf8be7 79 #if MEM_USE_POOLS
simon 0:350011bf8be7 80 /** mem_init is not used when using pools instead of a heap */
simon 0:350011bf8be7 81 #define mem_init()
simon 0:350011bf8be7 82 /** mem_trim is not used when using pools instead of a heap:
simon 0:350011bf8be7 83 we can't free part of a pool element and don't want to copy the rest */
simon 0:350011bf8be7 84 #define mem_trim(mem, size) (mem)
simon 0:350011bf8be7 85 #else /* MEM_USE_POOLS */
simon 0:350011bf8be7 86 /* lwIP alternative malloc */
simon 0:350011bf8be7 87 void mem_init(void);
simon 0:350011bf8be7 88 void *mem_trim(void *mem, mem_size_t size);
simon 0:350011bf8be7 89 #endif /* MEM_USE_POOLS */
simon 0:350011bf8be7 90 void *mem_malloc(mem_size_t size);
simon 0:350011bf8be7 91 void *mem_calloc(mem_size_t count, mem_size_t size);
simon 0:350011bf8be7 92 void mem_free(void *mem);
simon 0:350011bf8be7 93 #endif /* MEM_LIBC_MALLOC */
simon 0:350011bf8be7 94
simon 0:350011bf8be7 95 /** Calculate memory size for an aligned buffer - returns the next highest
simon 0:350011bf8be7 96 * multiple of MEM_ALIGNMENT (e.g. LWIP_MEM_ALIGN_SIZE(3) and
simon 0:350011bf8be7 97 * LWIP_MEM_ALIGN_SIZE(4) will both yield 4 for MEM_ALIGNMENT == 4).
simon 0:350011bf8be7 98 */
simon 0:350011bf8be7 99 #ifndef LWIP_MEM_ALIGN_SIZE
simon 0:350011bf8be7 100 #define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1))
simon 0:350011bf8be7 101 #endif
simon 0:350011bf8be7 102
simon 0:350011bf8be7 103 /** Calculate safe memory size for an aligned buffer when using an unaligned
simon 0:350011bf8be7 104 * type as storage. This includes a safety-margin on (MEM_ALIGNMENT - 1) at the
simon 0:350011bf8be7 105 * start (e.g. if buffer is u8_t[] and actual data will be u32_t*)
simon 0:350011bf8be7 106 */
simon 0:350011bf8be7 107 #ifndef LWIP_MEM_ALIGN_BUFFER
simon 0:350011bf8be7 108 #define LWIP_MEM_ALIGN_BUFFER(size) (((size) + MEM_ALIGNMENT - 1))
simon 0:350011bf8be7 109 #endif
simon 0:350011bf8be7 110
simon 0:350011bf8be7 111 /** Align a memory pointer to the alignment defined by MEM_ALIGNMENT
simon 0:350011bf8be7 112 * so that ADDR % MEM_ALIGNMENT == 0
simon 0:350011bf8be7 113 */
simon 0:350011bf8be7 114 #ifndef LWIP_MEM_ALIGN
simon 0:350011bf8be7 115 #define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1)))
simon 0:350011bf8be7 116 #endif
simon 0:350011bf8be7 117
simon 0:350011bf8be7 118 #ifdef __cplusplus
simon 0:350011bf8be7 119 }
simon 0:350011bf8be7 120 #endif
simon 0:350011bf8be7 121
simon 0:350011bf8be7 122 #endif /* __LWIP_MEM_H__ */