[1/2] Avoid cyclic header dependencies

Message ID 20190515065542.14146-1-sebastian.huber@embedded-brains.de
State New
Headers show
Series
  • [1/2] Avoid cyclic header dependencies
Related show

Commit Message

Sebastian Huber May 15, 2019, 6:55 a.m.
RTEMS uses a considerable part of FreeBSD kernel and user space sources.
These sources are compiled with a __FreeBSD__ define.  On 2018-06-26
Gerald Pfeifer changed the GCC provided <stddef.h> so that it includes
<sys/_types.h> if __FreeBSD__ is defined.  The Newlib <sys/_types.h>
included <sys/lock.h> which includes <sys/cdefs.h> on RTEMS which
includes <stddef.h>.  To get rid of this cyclic dependency move the
optional _flock_t definition to <sys/reent.h>.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>

---
 newlib/libc/include/sys/_types.h     | 5 -----
 newlib/libc/include/sys/reent.h      | 5 +++++
 newlib/libc/sys/linux/sys/_types.h   | 1 +
 newlib/libc/sys/phoenix/sys/_types.h | 1 +
 4 files changed, 7 insertions(+), 5 deletions(-)

-- 
2.16.4

Comments

Sebastian Huber May 16, 2019, 12:14 p.m. | #1
On 15/05/2019 08:55, Sebastian Huber wrote:
>   newlib/libc/sys/linux/sys/_types.h   | 1 +

>   newlib/libc/sys/phoenix/sys/_types.h | 1 +


It seems the changes in these files are unnecessary since they user 
their own <sys/types.h>. I will send a v2 of the patch set.

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

Patch

diff --git a/newlib/libc/include/sys/_types.h b/newlib/libc/include/sys/_types.h
index fc10531d5..90383b083 100644
--- a/newlib/libc/include/sys/_types.h
+++ b/newlib/libc/include/sys/_types.h
@@ -22,7 +22,6 @@ 
 #include <newlib.h>
 #include <sys/config.h>
 #include <machine/_types.h>
-#include <sys/lock.h>
 
 #ifndef __machine_blkcnt_t_defined
 typedef long __blkcnt_t;
@@ -171,10 +170,6 @@  typedef struct
 } _mbstate_t;
 #endif
 
-#ifndef __machine_flock_t_defined
-typedef _LOCK_RECURSIVE_T _flock_t;
-#endif
-
 #ifndef __machine_iconv_t_defined
 /* Iconv descriptor type */
 typedef void *_iconv_t;
diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/reent.h
index 6e55e1c1f..7f8124deb 100644
--- a/newlib/libc/include/sys/reent.h
+++ b/newlib/libc/include/sys/reent.h
@@ -30,6 +30,11 @@  typedef unsigned __Long __ULong;
 #include <sys/types.h>
 #endif
 
+#ifndef __machine_flock_t_defined
+#include <sys/lock.h>
+typedef _LOCK_RECURSIVE_T _flock_t;
+#endif
+
 #ifndef __Long
 #define __Long __int32_t
 typedef __uint32_t __ULong;
diff --git a/newlib/libc/sys/linux/sys/_types.h b/newlib/libc/sys/linux/sys/_types.h
index 2fd140520..8d8edd1c3 100644
--- a/newlib/libc/sys/linux/sys/_types.h
+++ b/newlib/libc/sys/linux/sys/_types.h
@@ -50,6 +50,7 @@  typedef struct
 } __flock_mutex_t;
 
 typedef struct { __flock_mutex_t mutex; } _flock_t;
+#define	__machine_flock_t_defined
 
 #define	_CLOCK_T_	unsigned long		/* clock() */
 #define	_TIME_T_	long			/* time() */
diff --git a/newlib/libc/sys/phoenix/sys/_types.h b/newlib/libc/sys/phoenix/sys/_types.h
index 39a3c5288..d19de73ca 100644
--- a/newlib/libc/sys/phoenix/sys/_types.h
+++ b/newlib/libc/sys/phoenix/sys/_types.h
@@ -68,5 +68,6 @@  typedef struct {
 typedef struct {
 	__flock_mutex_t mutex;
 } _flock_t;
+#define	__machine_flock_t_defined
 
 #endif