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

[Minios-devel] [UNIKRAFT PATCH 3/5] lib/nolibc: add NULL to shareddefs.h



NULL is to be defined in several header files. By putting it in
shareddefs.h, we can subsequently disentangle the cross-including of the
standard header files.

This also changes the definition of NULL for C++ code, in which void* is
not special and doesn't support implicit casting.

Signed-off-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
---
 lib/nolibc/include/nolibc-internal/shareddefs.h | 9 +++++++++
 lib/nolibc/include/stddef.h                     | 5 +----
 lib/nolibc/include/stdio.h                      | 1 +
 lib/nolibc/include/unistd.h                     | 1 +
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/nolibc/include/nolibc-internal/shareddefs.h 
b/lib/nolibc/include/nolibc-internal/shareddefs.h
index 9fccc15..6503ab1 100644
--- a/lib/nolibc/include/nolibc-internal/shareddefs.h
+++ b/lib/nolibc/include/nolibc-internal/shareddefs.h
@@ -41,6 +41,15 @@
 
 #include <uk/arch/types.h>
 
+#if (defined __NEED_NULL && !defined __DEFINED_NULL)
+#ifdef __cplusplus
+#define NULL 0L
+#else
+#define NULL ((void *) 0)
+#endif
+#define __DEFINED__NULL
+#endif
+
 #if (defined __NEED_size_t && !defined __DEFINED_size_t)
 typedef __sz size_t;
 #define __DEFINED_size_t
diff --git a/lib/nolibc/include/stddef.h b/lib/nolibc/include/stddef.h
index a7c600f..dae059b 100644
--- a/lib/nolibc/include/stddef.h
+++ b/lib/nolibc/include/stddef.h
@@ -44,10 +44,7 @@ extern "C" {
 
 typedef __sptr ptrdiff_t;
 
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
+#define __NEED_NULL
 #define __NEED_size_t
 #include <nolibc-internal/shareddefs.h>
 
diff --git a/lib/nolibc/include/stdio.h b/lib/nolibc/include/stdio.h
index 0dc59aa..a0f552b 100644
--- a/lib/nolibc/include/stdio.h
+++ b/lib/nolibc/include/stdio.h
@@ -42,6 +42,7 @@
 extern "C" {
 #endif
 
+#define __NEED_NULL
 #define __NEED_size_t
 #include <nolibc-internal/shareddefs.h>
 
diff --git a/lib/nolibc/include/unistd.h b/lib/nolibc/include/unistd.h
index 92d8351..dadfd4a 100644
--- a/lib/nolibc/include/unistd.h
+++ b/lib/nolibc/include/unistd.h
@@ -41,6 +41,7 @@
 extern "C" {
 #endif
 
+#define __NEED_NULL
 #define __NEED_ssize_t
 #include <nolibc-internal/shareddefs.h>
 
-- 
2.18.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®.