From 866c713a7e8b316668dffb71350181c571ec0075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Fri, 26 Sep 2014 13:59:37 +0200 Subject: [PATCH 1/2] native: -DNATIVE_INCLUDES if using NATIVEINCLUDES It can be useful to know if the current compilation builds the native board module, because e.g. then we must not include `sys/types.h`. This diff adds `-DNATIVE_INCLUDES` to the make variable `NATIVEINCLUDES`. --- boards/native/Makefile.include | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include index 50702b83a..498fa82c5 100644 --- a/boards/native/Makefile.include +++ b/boards/native/Makefile.include @@ -1,6 +1,7 @@ include $(RIOTBOARD)/$(BOARD)/Makefile.dep -export NATIVEINCLUDES = -I$(RIOTBOARD)/$(BOARD)/include/ +export NATIVEINCLUDES += -DNATIVE_INCLUDES +export NATIVEINCLUDES += -I$(RIOTBOARD)/$(BOARD)/include/ export NATIVEINCLUDES += -I$(RIOTBASE)/core/include/ export NATIVEINCLUDES += -I$(RIOTBASE)/drivers/include/ From 4e50d74272b092c1f2df711f374c4c18f682fe75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Fri, 26 Sep 2014 14:04:30 +0200 Subject: [PATCH 2/2] core: Provide ssize_t in a common place Now you can include `kernel_types.h` if you need the `ssize_t`, without facing problems due to the terrible MSP toolchain. --- core/include/kernel_types.h | 18 ++++++++++++++++++ cpu/atmega_common/include/sys/types.h | 1 - cpu/msp430-common/include/msp430_types.h | 6 +++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/core/include/kernel_types.h b/core/include/kernel_types.h index b0fafc9b8..94ea4c9cf 100644 --- a/core/include/kernel_types.h +++ b/core/include/kernel_types.h @@ -11,6 +11,24 @@ #include #include +#include + +#ifndef NATIVE_INCLUDES +# include +# include + +# ifndef SSIZE_MAX +# ifdef _POSIX_SSIZE_MAX +# define SSIZE_MAX _POSIX_SSIZE_MAX +# else +# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) +# endif +# endif + +# if defined (MODULE_MSP430_COMMON) || defined (MODULE_ATMEGA_COMMON) + typedef signed ssize_t; +# endif +#endif /** * @def MAXTHREADS diff --git a/cpu/atmega_common/include/sys/types.h b/cpu/atmega_common/include/sys/types.h index dbd94e301..34f727d48 100644 --- a/cpu/atmega_common/include/sys/types.h +++ b/cpu/atmega_common/include/sys/types.h @@ -10,4 +10,3 @@ #include typedef int16_t suseconds_t; -typedef size_t ssize_t; diff --git a/cpu/msp430-common/include/msp430_types.h b/cpu/msp430-common/include/msp430_types.h index f5673601b..839bfd5cb 100644 --- a/cpu/msp430-common/include/msp430_types.h +++ b/cpu/msp430-common/include/msp430_types.h @@ -12,6 +12,9 @@ #include #include +/** defining signed type for size_t */ +#include "kernel_types.h" + #ifndef EINVAL /** * @brief defines EINVAL if MSP430 toolchain is too old to provide it itself @@ -28,9 +31,6 @@ #define EOVERFLOW (65) #endif -/** defining signed type for size_t */ -typedef _ssize_t ssize_t; - typedef unsigned long time_t; struct timespec {