mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 782647. Move the nullptr workaround macros to MFBT so that it can be shared. r=waldo
This also changes the header to use compiler detection instead of a configure test. This makes the header more portable because it doesn't require the configure infrastructure.
This commit is contained in:
parent
8f85d6a619
commit
d6345f3cb2
18
configure.in
18
configure.in
@ -754,9 +754,6 @@ if test -n "$_WIN32_MSVC"; then
|
||||
AC_DEFINE(HAVE_IO_H)
|
||||
AC_DEFINE(HAVE_SETBUF)
|
||||
AC_DEFINE(HAVE_ISATTY)
|
||||
if test $_MSC_VER -ge 1600; then
|
||||
AC_DEFINE(HAVE_NULLPTR)
|
||||
fi
|
||||
fi
|
||||
|
||||
fi # COMPILE_ENVIRONMENT
|
||||
@ -2804,21 +2801,6 @@ dnl Note that we assume that mac & win32 have short wchar (see nscore.h)
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl Check for nullptr (bug 626472)
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_MSG_CHECKING(for nullptr)
|
||||
AC_CACHE_VAL(ac_cv_nullptr,
|
||||
[AC_TRY_COMPILE([],
|
||||
[int* foo = nullptr;],
|
||||
[ac_cv_nullptr=true],
|
||||
[ac_cv_nullptr=false])])
|
||||
if test "$ac_cv_nullptr" = true ; then
|
||||
AC_DEFINE(HAVE_NULLPTR)
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
AC_LANG_C
|
||||
|
||||
dnl Check for .hidden assembler directive and visibility attribute.
|
||||
|
@ -6,24 +6,8 @@
|
||||
#ifndef MOZILLA_GFX_TYPES_H_
|
||||
#define MOZILLA_GFX_TYPES_H_
|
||||
|
||||
/**
|
||||
* Use C++11 nullptr if available; otherwise use a C++ typesafe template; and
|
||||
* for C, fall back to longs. See bugs 547964 and 626472.
|
||||
* Copy and paste job from nscore.h, see bug 781943
|
||||
*/
|
||||
#if defined(MOZ_GFX) && !defined(HAVE_NULLPTR)
|
||||
#ifndef __cplusplus
|
||||
# define nullptr ((void*)0)
|
||||
#elif defined(__GNUC__)
|
||||
# define nullptr __null
|
||||
#elif defined(_WIN64)
|
||||
# define nullptr 0LL
|
||||
#else
|
||||
# define nullptr 0L
|
||||
#endif
|
||||
#endif /* defined(MOZ_GFX) && !defined(HAVE_NULLPTR) */
|
||||
|
||||
#include "mozilla/StandardInteger.h"
|
||||
#include "mozilla/NullPtr.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
46
mfbt/NullPtr.h
Normal file
46
mfbt/NullPtr.h
Normal file
@ -0,0 +1,46 @@
|
||||
/* -*- 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_
|
||||
|
||||
#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 (__GNUC__ * 1000 + __GNU_MINOR__) >= 4006
|
||||
# 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_ */
|
@ -21,6 +21,7 @@ EXPORTS_mozilla += \
|
||||
LinkedList.h \
|
||||
MathAlgorithms.h \
|
||||
MSStdInt.h \
|
||||
NullPtr.h \
|
||||
RangedPtr.h \
|
||||
RefPtr.h \
|
||||
Scoped.h \
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include "mozilla/StandardInteger.h"
|
||||
#include "stddef.h"
|
||||
|
||||
#include "mozilla/NullPtr.h"
|
||||
|
||||
/*
|
||||
* This is for functions that are like malloc_usable_size. Such functions are
|
||||
* used for measuring the size of data structures.
|
||||
@ -324,22 +326,6 @@ typedef unsigned long nsrefcnt;
|
||||
typedef uint32_t nsrefcnt;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Use C++11 nullptr if available; otherwise use a C++ typesafe template; and
|
||||
* for C, fall back to longs. See bugs 547964 and 626472.
|
||||
*/
|
||||
#ifndef HAVE_NULLPTR
|
||||
#ifndef __cplusplus
|
||||
# define nullptr ((void*)0)
|
||||
#elif defined(__GNUC__)
|
||||
# define nullptr __null
|
||||
#elif defined(_WIN64)
|
||||
# define nullptr 0LL
|
||||
#else
|
||||
# define nullptr 0L
|
||||
#endif
|
||||
#endif /* defined(HAVE_NULLPTR) */
|
||||
|
||||
#include "nsError.h"
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
Loading…
Reference in New Issue
Block a user