ソースの整理中ですが、利用はできます。

Dependencies:   EthernetInterface HttpServer TextLCD mbed-rpc mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
yueee_yt
Date:
Wed Mar 12 04:19:54 2014 +0000
Revision:
0:7766f6712673
???????????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yueee_yt 0:7766f6712673 1 /*
yueee_yt 0:7766f6712673 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
yueee_yt 0:7766f6712673 3 * All rights reserved.
yueee_yt 0:7766f6712673 4 *
yueee_yt 0:7766f6712673 5 * Redistribution and use in source and binary forms, with or without modification,
yueee_yt 0:7766f6712673 6 * are permitted provided that the following conditions are met:
yueee_yt 0:7766f6712673 7 *
yueee_yt 0:7766f6712673 8 * 1. Redistributions of source code must retain the above copyright notice,
yueee_yt 0:7766f6712673 9 * this list of conditions and the following disclaimer.
yueee_yt 0:7766f6712673 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
yueee_yt 0:7766f6712673 11 * this list of conditions and the following disclaimer in the documentation
yueee_yt 0:7766f6712673 12 * and/or other materials provided with the distribution.
yueee_yt 0:7766f6712673 13 * 3. The name of the author may not be used to endorse or promote products
yueee_yt 0:7766f6712673 14 * derived from this software without specific prior written permission.
yueee_yt 0:7766f6712673 15 *
yueee_yt 0:7766f6712673 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
yueee_yt 0:7766f6712673 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
yueee_yt 0:7766f6712673 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
yueee_yt 0:7766f6712673 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
yueee_yt 0:7766f6712673 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
yueee_yt 0:7766f6712673 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
yueee_yt 0:7766f6712673 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
yueee_yt 0:7766f6712673 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
yueee_yt 0:7766f6712673 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
yueee_yt 0:7766f6712673 25 * OF SUCH DAMAGE.
yueee_yt 0:7766f6712673 26 *
yueee_yt 0:7766f6712673 27 * This file is part of the lwIP TCP/IP stack.
yueee_yt 0:7766f6712673 28 *
yueee_yt 0:7766f6712673 29 * Author: Adam Dunkels <adam@sics.se>
yueee_yt 0:7766f6712673 30 *
yueee_yt 0:7766f6712673 31 */
yueee_yt 0:7766f6712673 32 #ifndef __LWIP_MEM_H__
yueee_yt 0:7766f6712673 33 #define __LWIP_MEM_H__
yueee_yt 0:7766f6712673 34
yueee_yt 0:7766f6712673 35 #include "lwip/opt.h"
yueee_yt 0:7766f6712673 36
yueee_yt 0:7766f6712673 37 #ifdef __cplusplus
yueee_yt 0:7766f6712673 38 extern "C" {
yueee_yt 0:7766f6712673 39 #endif
yueee_yt 0:7766f6712673 40
yueee_yt 0:7766f6712673 41 #if MEM_LIBC_MALLOC
yueee_yt 0:7766f6712673 42
yueee_yt 0:7766f6712673 43 #include <stddef.h> /* for size_t */
yueee_yt 0:7766f6712673 44
yueee_yt 0:7766f6712673 45 typedef size_t mem_size_t;
yueee_yt 0:7766f6712673 46
yueee_yt 0:7766f6712673 47 /* aliases for C library malloc() */
yueee_yt 0:7766f6712673 48 #define mem_init()
yueee_yt 0:7766f6712673 49 /* in case C library malloc() needs extra protection,
yueee_yt 0:7766f6712673 50 * allow these defines to be overridden.
yueee_yt 0:7766f6712673 51 */
yueee_yt 0:7766f6712673 52 #ifndef mem_free
yueee_yt 0:7766f6712673 53 #define mem_free free
yueee_yt 0:7766f6712673 54 #endif
yueee_yt 0:7766f6712673 55 #ifndef mem_malloc
yueee_yt 0:7766f6712673 56 #define mem_malloc malloc
yueee_yt 0:7766f6712673 57 #endif
yueee_yt 0:7766f6712673 58 #ifndef mem_calloc
yueee_yt 0:7766f6712673 59 #define mem_calloc calloc
yueee_yt 0:7766f6712673 60 #endif
yueee_yt 0:7766f6712673 61 /* Since there is no C library allocation function to shrink memory without
yueee_yt 0:7766f6712673 62 moving it, define this to nothing. */
yueee_yt 0:7766f6712673 63 #ifndef mem_trim
yueee_yt 0:7766f6712673 64 #define mem_trim(mem, size) (mem)
yueee_yt 0:7766f6712673 65 #endif
yueee_yt 0:7766f6712673 66 #else /* MEM_LIBC_MALLOC */
yueee_yt 0:7766f6712673 67
yueee_yt 0:7766f6712673 68 /* MEM_SIZE would have to be aligned, but using 64000 here instead of
yueee_yt 0:7766f6712673 69 * 65535 leaves some room for alignment...
yueee_yt 0:7766f6712673 70 */
yueee_yt 0:7766f6712673 71 #if MEM_SIZE > 64000L
yueee_yt 0:7766f6712673 72 typedef u32_t mem_size_t;
yueee_yt 0:7766f6712673 73 #define MEM_SIZE_F U32_F
yueee_yt 0:7766f6712673 74 #else
yueee_yt 0:7766f6712673 75 typedef u16_t mem_size_t;
yueee_yt 0:7766f6712673 76 #define MEM_SIZE_F U16_F
yueee_yt 0:7766f6712673 77 #endif /* MEM_SIZE > 64000 */
yueee_yt 0:7766f6712673 78
yueee_yt 0:7766f6712673 79 #if MEM_USE_POOLS
yueee_yt 0:7766f6712673 80 /** mem_init is not used when using pools instead of a heap */
yueee_yt 0:7766f6712673 81 #define mem_init()
yueee_yt 0:7766f6712673 82 /** mem_trim is not used when using pools instead of a heap:
yueee_yt 0:7766f6712673 83 we can't free part of a pool element and don't want to copy the rest */
yueee_yt 0:7766f6712673 84 #define mem_trim(mem, size) (mem)
yueee_yt 0:7766f6712673 85 #else /* MEM_USE_POOLS */
yueee_yt 0:7766f6712673 86 /* lwIP alternative malloc */
yueee_yt 0:7766f6712673 87 void mem_init(void);
yueee_yt 0:7766f6712673 88 void *mem_trim(void *mem, mem_size_t size);
yueee_yt 0:7766f6712673 89 #endif /* MEM_USE_POOLS */
yueee_yt 0:7766f6712673 90 void *mem_malloc(mem_size_t size);
yueee_yt 0:7766f6712673 91 void *mem_calloc(mem_size_t count, mem_size_t size);
yueee_yt 0:7766f6712673 92 void mem_free(void *mem);
yueee_yt 0:7766f6712673 93 #endif /* MEM_LIBC_MALLOC */
yueee_yt 0:7766f6712673 94
yueee_yt 0:7766f6712673 95 /** Calculate memory size for an aligned buffer - returns the next highest
yueee_yt 0:7766f6712673 96 * multiple of MEM_ALIGNMENT (e.g. LWIP_MEM_ALIGN_SIZE(3) and
yueee_yt 0:7766f6712673 97 * LWIP_MEM_ALIGN_SIZE(4) will both yield 4 for MEM_ALIGNMENT == 4).
yueee_yt 0:7766f6712673 98 */
yueee_yt 0:7766f6712673 99 #ifndef LWIP_MEM_ALIGN_SIZE
yueee_yt 0:7766f6712673 100 #define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1))
yueee_yt 0:7766f6712673 101 #endif
yueee_yt 0:7766f6712673 102
yueee_yt 0:7766f6712673 103 /** Calculate safe memory size for an aligned buffer when using an unaligned
yueee_yt 0:7766f6712673 104 * type as storage. This includes a safety-margin on (MEM_ALIGNMENT - 1) at the
yueee_yt 0:7766f6712673 105 * start (e.g. if buffer is u8_t[] and actual data will be u32_t*)
yueee_yt 0:7766f6712673 106 */
yueee_yt 0:7766f6712673 107 #ifndef LWIP_MEM_ALIGN_BUFFER
yueee_yt 0:7766f6712673 108 #define LWIP_MEM_ALIGN_BUFFER(size) (((size) + MEM_ALIGNMENT - 1))
yueee_yt 0:7766f6712673 109 #endif
yueee_yt 0:7766f6712673 110
yueee_yt 0:7766f6712673 111 /** Align a memory pointer to the alignment defined by MEM_ALIGNMENT
yueee_yt 0:7766f6712673 112 * so that ADDR % MEM_ALIGNMENT == 0
yueee_yt 0:7766f6712673 113 */
yueee_yt 0:7766f6712673 114 #ifndef LWIP_MEM_ALIGN
yueee_yt 0:7766f6712673 115 #define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1)))
yueee_yt 0:7766f6712673 116 #endif
yueee_yt 0:7766f6712673 117
yueee_yt 0:7766f6712673 118 #ifdef __cplusplus
yueee_yt 0:7766f6712673 119 }
yueee_yt 0:7766f6712673 120 #endif
yueee_yt 0:7766f6712673 121
yueee_yt 0:7766f6712673 122 #endif /* __LWIP_MEM_H__ */