xref: /illumos-gate/usr/src/uts/common/sys/null.h (revision 6446bd46ed1b4e9f69da153665f82181ccaedad5)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2014-2016 PALO, Richard.
14  */
15 
16 #ifndef _SYS_NULL_H
17 #define	_SYS_NULL_H
18 
19 #include <sys/feature_tests.h>
20 
21 #ifndef	NULL
22 
23 /*
24  * POSIX.1-2008 requires that the NULL macro be cast to type void *.
25  */
26 
27 #if !defined(__cplusplus)
28 #define	NULL	((void *)0)
29 #else
30 
31 /*
32  * ISO C++ requires that the NULL macro be a constant integral type evaluating
33  * to zero until C++11, and an integer or pointer literal with value zero from
34  * C++11 onwards.
35  */
36 
37 #if __cplusplus >= 201103L
38 #define	NULL	nullptr
39 #else
40 #if defined(_LP64)
41 #define	NULL	0L
42 #else
43 #define	NULL	0
44 #endif	/* _LP64 */
45 #endif	/* C++11 */
46 #endif	/* !__cplusplus */
47 
48 #endif	/* NULL */
49 
50 #endif	/* _SYS_NULL_H */
51