From 20c3aaa44893e763fe40fc74c336ad8b116b4dc3 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Mon, 7 Nov 2016 19:49:09 +0100 Subject: [PATCH] sys: Fix pthread includes to support avr-libs Missing malloc.h and clock_id_t were causing issues to build. It was tested with this configuration: - linux ubuntu 14.04.5 - arduino-mega2560 board - avr-libc-1.8.0-4.1 This change was needed to build iotivity example Bug: https://github.com/RIOT-OS/RIOT/issues/6241 Change-Id: I82ce246093b3467dfe9746f999bcc9335dbb65f6 Signed-off-by: Philippe Coval --- sys/posix/pthread/include/pthread.h | 4 ++++ sys/posix/pthread/include/pthread_cond.h | 2 +- sys/posix/pthread/pthread.c | 5 ++++- sys/posix/pthread/pthread_tls.c | 6 ++++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/sys/posix/pthread/include/pthread.h b/sys/posix/pthread/include/pthread.h index 183e9ecb69..df5d5d6092 100644 --- a/sys/posix/pthread/include/pthread.h +++ b/sys/posix/pthread/include/pthread.h @@ -22,6 +22,10 @@ #include +#ifndef __WITH_AVRLIBC__ +#define HAVE_MALLOC_H 1 +#endif + #include "mutex.h" #include "sched.h" diff --git a/sys/posix/pthread/include/pthread_cond.h b/sys/posix/pthread/include/pthread_cond.h index ebbd54f731..5d34d50554 100644 --- a/sys/posix/pthread/include/pthread_cond.h +++ b/sys/posix/pthread/include/pthread_cond.h @@ -25,7 +25,7 @@ # include "msp430_types.h" #endif -#if defined(__MACH__) +#if defined(__MACH__) || defined(__WITH_AVRLIBC__) typedef int clockid_t; #endif diff --git a/sys/posix/pthread/pthread.c b/sys/posix/pthread/pthread.c index dd7cbdf5a7..64d72ec261 100644 --- a/sys/posix/pthread/pthread.c +++ b/sys/posix/pthread/pthread.c @@ -19,7 +19,6 @@ * @} */ -#include #include #include #include @@ -34,6 +33,10 @@ #include "pthread.h" +#ifdef HAVE_MALLOC_H +#include +#endif + #define ENABLE_DEBUG (0) #if ENABLE_DEBUG diff --git a/sys/posix/pthread/pthread_tls.c b/sys/posix/pthread/pthread_tls.c index 028d132074..dbd272f3c8 100644 --- a/sys/posix/pthread/pthread_tls.c +++ b/sys/posix/pthread/pthread_tls.c @@ -16,10 +16,12 @@ * @} */ -#include - #include "pthread.h" +#ifdef HAVE_MALLOC_H +#include +#endif + #define ENABLE_DEBUG (0) #include "debug.h"