From 525962967873c9188e3eb3a22d7270ca7c9edcd7 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Mon, 7 Dec 2015 21:17:40 +0100 Subject: [PATCH] ccn-lite example: use TLSF --- examples/ccn-lite-relay/Makefile | 5 +++++ examples/ccn-lite-relay/main.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/examples/ccn-lite-relay/Makefile b/examples/ccn-lite-relay/Makefile index cfb71c22dc..3e38084114 100644 --- a/examples/ccn-lite-relay/Makefile +++ b/examples/ccn-lite-relay/Makefile @@ -33,6 +33,11 @@ USEMODULE += xtimer USEMODULE += random USEMODULE += prng_minstd + +ifneq (,$(filter-out native,$(BOARD))) + USEPKG += tlsf +endif + USEPKG += ccn-lite USEMODULE += ccn-lite-utils diff --git a/examples/ccn-lite-relay/main.c b/examples/ccn-lite-relay/main.c index 2d7b098e73..4ff2f12192 100644 --- a/examples/ccn-lite-relay/main.c +++ b/examples/ccn-lite-relay/main.c @@ -20,6 +20,11 @@ #include +/* TODO: currently TLSF has to be disabled for native because of its stricter + * CFLAGS (-pedantic) */ +#ifndef BOARD_NATIVE +# include "tlsf-malloc.h" +#endif #include "msg.h" #include "shell.h" #include "ccn-lite-riot.h" @@ -28,8 +33,17 @@ #define MAIN_QUEUE_SIZE (8) static msg_t _main_msg_queue[MAIN_QUEUE_SIZE]; +#ifndef BOARD_NATIVE + /* some buffer for the heap */ +# define TLSF_BUFFER (10240 / sizeof(uint32_t)) + static uint32_t _tlsf_heap[TLSF_BUFFER]; +#endif + int main(void) { +#ifndef BOARD_NATIVE + tlsf_add_pool(_tlsf_heap, sizeof(_tlsf_heap)); +#endif msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE); puts("Basic CCN-Lite example");