I work currently on a better FreeBSD compatibility for Newlib. For RTEMS we use the network, USB, SD/MMC stacks from FreeBSD. It would be nice to use <sys/types.h>, etc. from Newlib directly to compile FreeBSD user and kernel space files.
Various FreeBSD source and header files need a typedef __size_t via <sys/_types.h>. Unfortunately the GCC provided <stddef.h> uses #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \ || defined(__DragonFly__) \ || defined(__FreeBSD_kernel__) /* __size_t is a typedef on FreeBSD 5, must not trash it. */ #elif defined (__VMS__) /* __size_t is also a typedef on VMS. */ #else #define __size_t #endif and therefore defines __size_t to nothing on Newlib targets which would trash a __size_t typedef. There exists no Newlib builtin define which we could add here. As a workaround I include <stddef.h> before <sys/_types.h> in <sys/types.h> and undefine __size_t in <sys/_types.h>. This works fine so far, but breaks if someone includes <stddef.h> after <sys/_types.h> the first time. This patch would address this issue, but I do not know which other issues it generates. gcc/ChangeLog 2016-04-15 Sebastian Huber <sebastian.hu...@embedded-brains.de> * ginclude/stddef.h (__size_t): Define to __SIZE_TYPE__. --- gcc/ginclude/stddef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h index d711530..8c2e22e 100644 --- a/gcc/ginclude/stddef.h +++ b/gcc/ginclude/stddef.h @@ -207,7 +207,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; #elif defined (__VMS__) /* __size_t is also a typedef on VMS. */ #else -#define __size_t +#define __size_t __SIZE_TYPE__ #endif #ifndef __SIZE_TYPE__ #define __SIZE_TYPE__ long unsigned int -- 1.8.4.5