![]() |
|
|||
Warning, cross-references for /kernel/include/lwip/mem.h need to be fixed.
0001 /* 0002 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 0003 * All rights reserved. 0004 * 0005 * Redistribution and use in source and binary forms, with or without modification, 0006 * are permitted provided that the following conditions are met: 0007 * 0008 * 1. Redistributions of source code must retain the above copyright notice, 0009 * this list of conditions and the following disclaimer. 0010 * 2. Redistributions in binary form must reproduce the above copyright notice, 0011 * this list of conditions and the following disclaimer in the documentation 0012 * and/or other materials provided with the distribution. 0013 * 3. The name of the author may not be used to endorse or promote products 0014 * derived from this software without specific prior written permission. 0015 * 0016 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 0017 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 0018 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 0019 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 0020 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 0021 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0022 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0023 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 0024 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 0025 * OF SUCH DAMAGE. 0026 * 0027 * This file is part of the lwIP TCP/IP stack. 0028 * 0029 * Author: Adam Dunkels <adam@sics.se> 0030 * 0031 */ 0032 #ifndef __LWIP_MEM_H__ 0033 #define __LWIP_MEM_H__ 0034 0035 #include "lwip/opt.h" 0036 0037 #ifdef __cplusplus 0038 extern "C" { 0039 #endif 0040 0041 #if MEM_LIBC_MALLOC 0042 0043 #include <stddef.h> 0044 0045 typedef size_t mem_size_t; 0046 0047 /* aliases for C library malloc() */ 0048 #define mem_init() 0049 /* in case C library malloc() needs extra protection, 0050 * allow these defines to be overridden. 0051 */ 0052 #ifndef mem_free 0053 #define mem_free free 0054 #endif 0055 #ifndef mem_malloc 0056 #define mem_malloc malloc 0057 #endif 0058 #ifndef mem_calloc 0059 #define mem_calloc calloc 0060 #endif 0061 #ifndef mem_realloc 0062 static void *mem_realloc(void *mem, mem_size_t size) 0063 { 0064 LWIP_UNUSED_ARG(size); 0065 return mem; 0066 } 0067 #endif 0068 #else /* MEM_LIBC_MALLOC */ 0069 0070 /* MEM_SIZE would have to be aligned, but using 64000 here instead of 0071 * 65535 leaves some room for alignment... 0072 */ 0073 #if MEM_SIZE > 64000l 0074 typedef u32_t mem_size_t; 0075 #else 0076 typedef u16_t mem_size_t; 0077 #endif /* MEM_SIZE > 64000 */ 0078 0079 #if MEM_USE_POOLS 0080 /** mem_init is not used when using pools instead of a heap */ 0081 #define mem_init() 0082 /** mem_realloc is not used when using pools instead of a heap: 0083 we can't free part of a pool element and don't want to copy the rest */ 0084 #define mem_realloc(mem, size) (mem) 0085 #else /* MEM_USE_POOLS */ 0086 /* lwIP alternative malloc */ 0087 void mem_init(void); 0088 void *mem_realloc(void *mem, mem_size_t size); 0089 #endif /* MEM_USE_POOLS */ 0090 void *mem_malloc(mem_size_t size); 0091 void *mem_calloc(mem_size_t count, mem_size_t size); 0092 void mem_free(void *mem); 0093 #endif /* MEM_LIBC_MALLOC */ 0094 0095 #ifndef LWIP_MEM_ALIGN_SIZE 0096 #define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1)) 0097 #endif 0098 0099 #ifndef LWIP_MEM_ALIGN 0100 #define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1))) 0101 #endif 0102 0103 #ifdef __cplusplus 0104 } 0105 #endif 0106 0107 #endif /* __LWIP_MEM_H__ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |