diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-12-11 22:24:18 +0000 |
---|---|---|
committer | <> | 2014-07-24 09:30:59 +0000 |
commit | 59e2936f588aa945e8dcd6c737523c299067e9d0 (patch) | |
tree | 97e74980cc54baa19de5faa11f5a50a0121a48ea /mfbt/NullPtr.h | |
download | mozjs24-master.tar.gz |
Imported from /home/lorry/working-area/delta_mozilla_mozjs24/mozjs-24.2.0.tar.bz2.HEADmozjs-24.2.0master
Diffstat (limited to 'mfbt/NullPtr.h')
-rw-r--r-- | mfbt/NullPtr.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/mfbt/NullPtr.h b/mfbt/NullPtr.h new file mode 100644 index 0000000..7dcb03d --- /dev/null +++ b/mfbt/NullPtr.h @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Implements a workaround for compilers which do not support the C++11 nullptr + * constant. + */ + +#ifndef mozilla_NullPtr_h_ +#define mozilla_NullPtr_h_ + +#include "mozilla/Compiler.h" + +#if defined(__clang__) +# ifndef __has_extension +# define __has_extension __has_feature +# endif +# if __has_extension(cxx_nullptr) +# define MOZ_HAVE_CXX11_NULLPTR +# endif +#elif defined(__GNUC__) +# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# if MOZ_GCC_VERSION_AT_LEAST(4, 6, 0) +# define MOZ_HAVE_CXX11_NULLPTR +# endif +# endif +#elif _MSC_VER >= 1600 +# define MOZ_HAVE_CXX11_NULLPTR +#endif + +/** + * Use C++11 nullptr if available; otherwise use __null for gcc, or a 0 literal + * with the correct size to match the size of a pointer on a given platform. + */ + +#ifndef MOZ_HAVE_CXX11_NULLPTR +# if defined(__GNUC__) +# define nullptr __null +# elif defined(_WIN64) +# define nullptr 0LL +# else +# define nullptr 0L +# endif +#endif + +#endif /* mozilla_NullPtr_h_ */ |