Bug 886842 - Add clang trunk builds for ASan. r=froydnj
[gecko.git] / mfbt / NullPtr.h
blob7dcb03d73459983cae8c1268d5932794ff478c5f
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /*
7 * Implements a workaround for compilers which do not support the C++11 nullptr
8 * constant.
9 */
11 #ifndef mozilla_NullPtr_h_
12 #define mozilla_NullPtr_h_
14 #include "mozilla/Compiler.h"
16 #if defined(__clang__)
17 # ifndef __has_extension
18 # define __has_extension __has_feature
19 # endif
20 # if __has_extension(cxx_nullptr)
21 # define MOZ_HAVE_CXX11_NULLPTR
22 # endif
23 #elif defined(__GNUC__)
24 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
25 # if MOZ_GCC_VERSION_AT_LEAST(4, 6, 0)
26 # define MOZ_HAVE_CXX11_NULLPTR
27 # endif
28 # endif
29 #elif _MSC_VER >= 1600
30 # define MOZ_HAVE_CXX11_NULLPTR
31 #endif
33 /**
34 * Use C++11 nullptr if available; otherwise use __null for gcc, or a 0 literal
35 * with the correct size to match the size of a pointer on a given platform.
38 #ifndef MOZ_HAVE_CXX11_NULLPTR
39 # if defined(__GNUC__)
40 # define nullptr __null
41 # elif defined(_WIN64)
42 # define nullptr 0LL
43 # else
44 # define nullptr 0L
45 # endif
46 #endif
48 #endif /* mozilla_NullPtr_h_ */