Bug 917642 - [Helix] Please update the helix blobs. r=nhirata
[gecko.git] / mfbt / NullPtr.h
blob35faadc4c309a932a1a0167f126e899eacad54d5
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /*
8 * Implements a workaround for compilers which do not support the C++11 nullptr
9 * constant.
12 #ifndef mozilla_NullPtr_h
13 #define mozilla_NullPtr_h
15 #if defined(__clang__)
16 # ifndef __has_extension
17 # define __has_extension __has_feature
18 # endif
19 # if __has_extension(cxx_nullptr)
20 # define MOZ_HAVE_CXX11_NULLPTR
21 # endif
22 #elif defined(__GNUC__)
23 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
24 # include "mozilla/Compiler.h"
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 */