diff options
author | Aurélien Larcher <aurelien.larcher@gmail.com> | 2017-03-29 01:23:54 +0200 |
---|---|---|
committer | Dan McDonald <danmcd@omniti.com> | 2017-04-25 16:46:34 -0400 |
commit | a3848ed0a29283946b7129498d914f532442a95f (patch) | |
tree | 0aaefcc8135e42e1effd07e9f209d583820cc3c9 /usr/src | |
parent | 5f368aef86387d6ef4eda84030ae9b402313ee4c (diff) | |
download | illumos-gate-a3848ed0a29283946b7129498d914f532442a95f.tar.gz |
8017 Comply with POSIX.1-2008 and C++11 for the definition of NULL
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Dan McDonald <danmcd@omniti.com>
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/uts/common/sys/null.h | 25 |
1 files changed, 24 insertions, 1 deletions
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 <sys/feature_tests.h> + #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 */ |