xref: /illumos-gate/usr/src/uts/common/sys/null.h (revision dfecc466)
14870e0a7SRichard PALO /*
24870e0a7SRichard PALO  * This file and its contents are supplied under the terms of the
34870e0a7SRichard PALO  * Common Development and Distribution License ("CDDL"), version 1.0.
44870e0a7SRichard PALO  * You may only use this file in accordance with the terms of version
54870e0a7SRichard PALO  * 1.0 of the CDDL.
64870e0a7SRichard PALO  *
74870e0a7SRichard PALO  * A full copy of the text of the CDDL should have accompanied this
84870e0a7SRichard PALO  * source.  A copy of the CDDL is also available via the Internet at
94870e0a7SRichard PALO  * http://www.illumos.org/license/CDDL.
104870e0a7SRichard PALO  */
114870e0a7SRichard PALO 
124870e0a7SRichard PALO /*
134870e0a7SRichard PALO  * Copyright 2014-2016 PALO, Richard.
144870e0a7SRichard PALO  */
154870e0a7SRichard PALO 
164870e0a7SRichard PALO #ifndef _SYS_NULL_H
174870e0a7SRichard PALO #define	_SYS_NULL_H
184870e0a7SRichard PALO 
19a3848ed0SAurélien Larcher #include <sys/feature_tests.h>
20a3848ed0SAurélien Larcher 
214870e0a7SRichard PALO #ifndef	NULL
224870e0a7SRichard PALO 
23*75f3d687SToomas Soome /*
24*75f3d687SToomas Soome  * POSIX.1-2008 requires that the NULL macro be cast to type void *.
25*75f3d687SToomas Soome  */
26*75f3d687SToomas Soome 
27*75f3d687SToomas Soome #if !defined(__cplusplus)
28*75f3d687SToomas Soome #define	NULL	((void *)0)
29*75f3d687SToomas Soome #else
30*75f3d687SToomas Soome 
31*75f3d687SToomas Soome /*
32*75f3d687SToomas Soome  * ISO C++ requires that the NULL macro be a constant integral type evaluating
33*75f3d687SToomas Soome  * to zero until C++11, and an integer or pointer literal with value zero from
34*75f3d687SToomas Soome  * C++11 onwards.
35*75f3d687SToomas Soome  */
36*75f3d687SToomas Soome 
37*75f3d687SToomas Soome #if __cplusplus >= 201103L
38*75f3d687SToomas Soome #define	NULL	nullptr
39*75f3d687SToomas Soome #else
40*75f3d687SToomas Soome #if defined(_LP64)
41*75f3d687SToomas Soome #define	NULL	0L
42*75f3d687SToomas Soome #else
43*75f3d687SToomas Soome #define	NULL	0
44*75f3d687SToomas Soome #endif	/* _LP64 */
45*75f3d687SToomas Soome #endif	/* C++11 */
46*75f3d687SToomas Soome #endif	/* !__cplusplus */
474870e0a7SRichard PALO 
484870e0a7SRichard PALO #endif	/* NULL */
494870e0a7SRichard PALO 
504870e0a7SRichard PALO #endif	/* _SYS_NULL_H */
51