Provide __size_t via <sys/_types.h>

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 on Newlib targets which would trash a
__size_t typedef.  Include <stddef.h> before <sys/_types.h> in
<sys/types.h> and undefine __size_t in <sys/_types.h> as a workaround.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
This commit is contained in:
Sebastian Huber 2016-04-15 13:44:28 +02:00 committed by Corinna Vinschen
parent 40928e19e4
commit 3ad9b2fcba
2 changed files with 17 additions and 2 deletions

View File

@ -119,6 +119,21 @@ typedef _off64_t _fpos64_t;
#endif
#endif
/* Defined by GCC provided <stddef.h> */
#undef __size_t
#ifndef __machine_size_t_defined
#ifdef __SIZE_TYPE__
typedef __SIZE_TYPE__ __size_t;
#else
#if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
typedef int __size_t;
#else
typedef long __size_t;
#endif
#endif
#endif
#ifndef __machine_ssize_t_defined
#ifdef __SIZE_TYPE__
/* If __SIZE_TYPE__ is defined (gcc) we define ssize_t based on size_t.

View File

@ -56,11 +56,11 @@ typedef quad_t * qaddr_t;
#ifndef __need_inttypes
#define _SYS_TYPES_H
/* <stddef.h> must be before <sys/_types.h> for __size_t considerations */
#include <stddef.h>
#include <sys/_types.h>
#include <sys/_stdint.h>
# include <stddef.h>
#if __BSD_VISIBLE
#include <machine/endian.h>
#include <sys/select.h>