Counter

Dependencies:   EthernetInterface NTPClient SDFileSystem TextLCD WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip FATFileSystem

Committer:
Tuxitheone
Date:
Mon Feb 29 18:59:15 2016 +0000
Revision:
0:ecaf3e593122
TankCounter

Who changed what in which revision?

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