Free (GPLv2) TCP/IP stack developed by TASS Belgium
Dependents: lpc1768-picotcp-demo ZeroMQ_PicoTCP_Publisher_demo TCPSocket_HelloWorld_PicoTCP Pico_TCP_UDP_Test ... more
PicoTCP. Copyright (c) 2013 TASS Belgium NV.
Released under the GNU General Public License, version 2.
Different licensing models may exist, at the sole discretion of the Copyright holders.
Official homepage: http://www.picotcp.com
Bug tracker: https://github.com/tass-belgium/picotcp/issues
Development steps:
initial integration with mbed RTOSgeneric mbed Ethernet driverhigh performance NXP LPC1768 specific Ethernet driverMulti-threading support for mbed RTOSBerkeley sockets and integration with the New Socket APIFork of the apps running on top of the New Socket APIScheduling optimizations- Debugging/benchmarking/testing
Demo application (measuring TCP sender performance):
Import programlpc1768-picotcp-demo
A PicoTCP demo app testing the ethernet throughput on the lpc1768 mbed board.
include/heap.h@155:a70f34550c34, 2016-01-28 (annotated)
- Committer:
- tass
- Date:
- Thu Jan 28 15:12:00 2016 +0100
- Revision:
- 155:a70f34550c34
- Parent:
- 152:a3d286bf94e5
Adding TCP flag for FIN.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tass | 68:0847e35d08a6 | 1 | /********************************************************************* |
tass | 152:a3d286bf94e5 | 2 | PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved. |
TASS Belgium NV |
131:4758606c9316 | 3 | See LICENSE and COPYING for usage. |
tass | 68:0847e35d08a6 | 4 | |
TASS Belgium NV |
131:4758606c9316 | 5 | *********************************************************************/ |
tass | 68:0847e35d08a6 | 6 | |
tass | 68:0847e35d08a6 | 7 | #define DECLARE_HEAP(type, orderby) \ |
TASS Belgium NV |
131:4758606c9316 | 8 | struct heap_ ## type { \ |
TASS Belgium NV |
131:4758606c9316 | 9 | uint32_t size; \ |
TASS Belgium NV |
131:4758606c9316 | 10 | uint32_t n; \ |
TASS Belgium NV |
131:4758606c9316 | 11 | type *top; \ |
TASS Belgium NV |
131:4758606c9316 | 12 | }; \ |
TASS Belgium NV |
131:4758606c9316 | 13 | typedef struct heap_ ## type heap_ ## type; \ |
TASS Belgium NV |
131:4758606c9316 | 14 | static inline int heap_insert(struct heap_ ## type *heap, type * el) \ |
TASS Belgium NV |
131:4758606c9316 | 15 | { \ |
TASS Belgium NV |
131:4758606c9316 | 16 | uint32_t i; \ |
TASS Belgium NV |
131:4758606c9316 | 17 | type *newTop; \ |
TASS Belgium NV |
131:4758606c9316 | 18 | if (++heap->n >= heap->size) { \ |
tass picotcp@tass.be | 149:5f4cb161cec3 | 19 | newTop = PICO_ZALLOC((heap->n + 1) * sizeof(type)); \ |
tass | 152:a3d286bf94e5 | 20 | if(!newTop) { \ |
tass | 152:a3d286bf94e5 | 21 | heap->n--; \ |
TASS Belgium NV |
131:4758606c9316 | 22 | return -1; \ |
tass | 152:a3d286bf94e5 | 23 | } \ |
TASS Belgium NV |
131:4758606c9316 | 24 | if (heap->top) { \ |
TASS Belgium NV |
131:4758606c9316 | 25 | memcpy(newTop, heap->top, heap->n * sizeof(type)); \ |
tass picotcp@tass.be | 149:5f4cb161cec3 | 26 | PICO_FREE(heap->top); \ |
TASS Belgium NV |
131:4758606c9316 | 27 | } \ |
TASS Belgium NV |
131:4758606c9316 | 28 | heap->top = newTop; \ |
TASS Belgium NV |
131:4758606c9316 | 29 | heap->size++; \ |
TASS Belgium NV |
131:4758606c9316 | 30 | } \ |
TASS Belgium NV |
131:4758606c9316 | 31 | if (heap->n == 1) { \ |
TASS Belgium NV |
131:4758606c9316 | 32 | memcpy(&heap->top[1], el, sizeof(type)); \ |
TASS Belgium NV |
131:4758606c9316 | 33 | return 0; \ |
TASS Belgium NV |
131:4758606c9316 | 34 | } \ |
TASS Belgium NV |
131:4758606c9316 | 35 | for (i = heap->n; ((i > 1) && (heap->top[i / 2].orderby > el->orderby)); i /= 2) { \ |
TASS Belgium NV |
131:4758606c9316 | 36 | memcpy(&heap->top[i], &heap->top[i / 2], sizeof(type)); \ |
TASS Belgium NV |
131:4758606c9316 | 37 | } \ |
TASS Belgium NV |
131:4758606c9316 | 38 | memcpy(&heap->top[i], el, sizeof(type)); \ |
TASS Belgium NV |
131:4758606c9316 | 39 | return 0; \ |
tass | 68:0847e35d08a6 | 40 | } \ |
TASS Belgium NV |
131:4758606c9316 | 41 | static inline int heap_peek(struct heap_ ## type *heap, type * first) \ |
TASS Belgium NV |
131:4758606c9316 | 42 | { \ |
TASS Belgium NV |
131:4758606c9316 | 43 | type *last; \ |
TASS Belgium NV |
131:4758606c9316 | 44 | uint32_t i, child; \ |
TASS Belgium NV |
131:4758606c9316 | 45 | if(heap->n == 0) { \ |
TASS Belgium NV |
131:4758606c9316 | 46 | return -1; \ |
TASS Belgium NV |
131:4758606c9316 | 47 | } \ |
TASS Belgium NV |
131:4758606c9316 | 48 | memcpy(first, &heap->top[1], sizeof(type)); \ |
TASS Belgium NV |
131:4758606c9316 | 49 | last = &heap->top[heap->n--]; \ |
tass picotcp@tass.be | 149:5f4cb161cec3 | 50 | for(i = 1; (i * 2u) <= heap->n; i = child) { \ |
tass picotcp@tass.be | 149:5f4cb161cec3 | 51 | child = 2u * i; \ |
TASS Belgium NV |
131:4758606c9316 | 52 | if ((child != heap->n) && \ |
TASS Belgium NV |
131:4758606c9316 | 53 | (heap->top[child + 1]).orderby \ |
TASS Belgium NV |
131:4758606c9316 | 54 | < (heap->top[child]).orderby) \ |
TASS Belgium NV |
131:4758606c9316 | 55 | child++; \ |
TASS Belgium NV |
131:4758606c9316 | 56 | if (last->orderby > \ |
TASS Belgium NV |
131:4758606c9316 | 57 | heap->top[child].orderby) \ |
TASS Belgium NV |
131:4758606c9316 | 58 | memcpy(&heap->top[i], &heap->top[child], \ |
TASS Belgium NV |
131:4758606c9316 | 59 | sizeof(type)); \ |
TASS Belgium NV |
131:4758606c9316 | 60 | else \ |
TASS Belgium NV |
131:4758606c9316 | 61 | break; \ |
TASS Belgium NV |
131:4758606c9316 | 62 | } \ |
TASS Belgium NV |
131:4758606c9316 | 63 | memcpy(&heap->top[i], last, sizeof(type)); \ |
TASS Belgium NV |
131:4758606c9316 | 64 | return 0; \ |
TASS Belgium NV |
131:4758606c9316 | 65 | } \ |
TASS Belgium NV |
131:4758606c9316 | 66 | static inline type *heap_first(heap_ ## type * heap) \ |
TASS Belgium NV |
131:4758606c9316 | 67 | { \ |
TASS Belgium NV |
131:4758606c9316 | 68 | if (heap->n == 0) \ |
TASS Belgium NV |
131:4758606c9316 | 69 | return NULL; \ |
TASS Belgium NV |
131:4758606c9316 | 70 | return &heap->top[1]; \ |
TASS Belgium NV |
131:4758606c9316 | 71 | } \ |
TASS Belgium NV |
131:4758606c9316 | 72 | static inline heap_ ## type *heap_init(void) \ |
TASS Belgium NV |
131:4758606c9316 | 73 | { \ |
tass picotcp@tass.be | 149:5f4cb161cec3 | 74 | heap_ ## type * p = (heap_ ## type *)PICO_ZALLOC(sizeof(heap_ ## type)); \ |
TASS Belgium NV |
131:4758606c9316 | 75 | return p; \ |
TASS Belgium NV |
131:4758606c9316 | 76 | } \ |
tass picotcp@tass.be | 134:cc4e6d2654d9 | 77 | /*static inline void heap_destroy(heap_ ## type * h) \ |
tass picotcp@tass.be | 137:a1c8bfa9d691 | 78 | { \ |
tass picotcp@tass.be | 149:5f4cb161cec3 | 79 | PICO_FREE(h->top); \ |
tass picotcp@tass.be | 149:5f4cb161cec3 | 80 | PICO_FREE(h); \ |
tass picotcp@tass.be | 137:a1c8bfa9d691 | 81 | } \*/ |
tass | 68:0847e35d08a6 | 82 | |
tass | 68:0847e35d08a6 | 83 |