[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH v2 3/6] 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 1980011..9fb27b1 100644 --- a/lib/nolibc/include/stddef.h +++ b/lib/nolibc/include/stddef.h @@ -44,14 +44,11 @@ extern "C" { typedef __sptr ptrdiff_t; -#ifndef NULL -#define NULL ((void *) 0) -#endif - #ifndef offsetof #define offsetof(t, d) __offsetof(t, d) #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 beaf46e..574756c 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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |