From a3848ed0a29283946b7129498d914f532442a95f Mon Sep 17 00:00:00 2001 From: Aurélien Larcher Date: Wed, 29 Mar 2017 01:23:54 +0200 Subject: 8017 Comply with POSIX.1-2008 and C++11 for the definition of NULL Reviewed by: Toomas Soome Reviewed by: Robert Mustacchi Approved by: Dan McDonald --- usr/src/uts/common/sys/null.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'usr/src') diff --git a/usr/src/uts/common/sys/null.h b/usr/src/uts/common/sys/null.h index da580d05c4..251dcfc994 100644 --- a/usr/src/uts/common/sys/null.h +++ b/usr/src/uts/common/sys/null.h @@ -16,13 +16,36 @@ #ifndef _SYS_NULL_H #define _SYS_NULL_H +#include + #ifndef NULL +/* + * POSIX.1-2008 requires that the NULL macro be cast to type void *. + * Historically, this has not been done, so we only enable this in a + * POSIX.1-2008 compilation environment. + */ + +#if defined(_XPG7) && !defined(__cplusplus) +#define NULL ((void *)0) +#else + +/* + * ISO C++ requires that the NULL macro be a constant integral type evaluating + * to zero until C++11, and an integer or pointer literal with value zero from + * C++11 onwards. + */ + +#if defined(__cplusplus) && __cplusplus >= 201103L +#define NULL nullptr +#else #if defined(_LP64) #define NULL 0L #else #define NULL 0 -#endif +#endif /* _LP64 */ +#endif /* C++11 */ +#endif /* _XPG7 */ #endif /* NULL */ -- cgit v1.2.3