[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH] Fix selectively included type definitions



The newlib glue code use code originally taken from musl. In musl, the
way to selectively include certain data types from those defined in
types.h is by the use of __NEED_* macros. Newlib uses a different
approach: it provides all definitions as underscored variants via
sys/_types.h, and the header files then typedef them over to the normal
variants as needed, with preprocessor guards around each of them to
provent duplications.

Replace the __NEED macros (which are effectively noops, so none of those
data types ever got properly defined in those headers) with the newlib
_types solution.

Signed-off-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
---
 include/dirent.h       | 19 ++++++++++++++++---
 include/sys/mman.h     | 23 +++++++++++++++++++----
 include/sys/resource.h | 11 +++++++++--
 include/sys/statvfs.h  | 14 +++++++++++---
 4 files changed, 55 insertions(+), 12 deletions(-)

diff --git a/include/dirent.h b/include/dirent.h
index 37589b4..8532930 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -31,10 +31,23 @@
 extern "C" {
 #endif
 
-#define __NEED_ino_t
-#define __NEED_off_t
+#include <sys/_types.h>
+
+#ifndef _INO_T_DECLARED
+typedef __ino_t ino_t;
+#define _INO_T_DECLARED
+#endif
+
+#ifndef _OFF_T_DECLARED
+typedef __off_t off_t;
+#define _OFF_T_DECLARED
+#endif
+
 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
-#define __NEED_size_t
+#ifndef _SIZE_T_DECLARED
+typedef __size_t size_t;
+#define _SIZE_T_DECLARED
+#endif
 #endif
 
 typedef struct __dirstream DIR;
diff --git a/include/sys/mman.h b/include/sys/mman.h
index 7abf57f..147ed5d 100644
--- a/include/sys/mman.h
+++ b/include/sys/mman.h
@@ -30,14 +30,29 @@
 extern "C" {
 #endif
 
+#include <sys/_types.h>
 #include <stddef.h>
 
-#define __NEED_mode_t
-#define __NEED_size_t
-#define __NEED_off_t
+#ifndef _OFF_T_DECLARED
+typedef __off_t off_t;
+#define _OFF_T_DECLARED
+#endif
+
+#ifndef _SIZE_T_DECLARED
+typedef __size_t size_t;
+#define _SIZE_T_DECLARED
+#endif
+
+#ifndef _MODE_T_DECLARED
+typedef __mode_t mode_t;
+#define _MODE_T_DECLARED
+#endif
 
 #if defined(_GNU_SOURCE)
-#define __NEED_ssize_t
+#ifndef _SSIZE_T_DECLARED
+typedef __ssize_t ssize_t;
+#define _SSIZE_T_DECLARED
+#endif
 #endif
 
 #define MAP_FAILED ((void *) -1)
diff --git a/include/sys/resource.h b/include/sys/resource.h
index 5174b65..82eb631 100644
--- a/include/sys/resource.h
+++ b/include/sys/resource.h
@@ -31,12 +31,19 @@
 extern "C" {
 #endif
 
+#include <sys/_types.h>
 #include <sys/time.h>
 
-#define __NEED_id_t
+#ifndef _ID_T_DECLARED
+typedef __id_t id_t;
+#define _ID_T_DECLARED
+#endif
 
 #ifdef _GNU_SOURCE
-#define __NEED_pid_t
+#ifndef _PID_T_DECLARED
+typedef __pid_t pid_t;
+#define _PID_T_DECLARED
+#endif
 #endif
 
 typedef unsigned long long rlim_t;
diff --git a/include/sys/statvfs.h b/include/sys/statvfs.h
index 0357eec..96ef851 100644
--- a/include/sys/statvfs.h
+++ b/include/sys/statvfs.h
@@ -31,10 +31,18 @@
 extern "C" {
 #endif
 
-#define __NEED_fsblkcnt_t
-#define __NEED_fsfilcnt_t
-#include <sys/types.h>
 #include <endian.h>
+#include <sys/_types.h>
+
+#ifndef _FSBLKCNT_T_DECLARED
+typedef __fsblkcnt_t fsblkcnt_t;
+#define _FSBLKCNT_T_DECLARED
+#endif
+
+#ifndef _FSFILCNT_T_DECLARED
+typedef __fsfilcnt_t fsfilcnt_t;
+#define _FSFILCNT_T_DECLARED
+#endif
 
 struct statvfs {
        unsigned long f_bsize, f_frsize;
-- 
2.21.0


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.