зеркало из https://github.com/mozilla/pjs.git
Bug 712129 - Move MOZ*INLINE macros from Util.h into Attributes.h, where they make more sense. r=luke
--HG-- extra : rebase_source : f62a21c8833c9d5eb7351b18ba14f14d4286b3c0
This commit is contained in:
Родитель
2bfe39573a
Коммит
16b139871d
|
@ -48,6 +48,39 @@
|
||||||
* code that is (only currently) mfbt-incompatible.
|
* code that is (only currently) mfbt-incompatible.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MOZ_INLINE is a macro which expands to tell the compiler that the method
|
||||||
|
* decorated with it should be inlined. This macro is usable from C and C++
|
||||||
|
* code, even though C89 does not support the |inline| keyword. The compiler
|
||||||
|
* may ignore this directive if it chooses.
|
||||||
|
*/
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
# define MOZ_INLINE inline
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
# define MOZ_INLINE __inline
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
# define MOZ_INLINE __inline__
|
||||||
|
#else
|
||||||
|
# define MOZ_INLINE inline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MOZ_ALWAYS_INLINE is a macro which expands to tell the compiler that the
|
||||||
|
* method decorated with it must be inlined, even if the compiler thinks
|
||||||
|
* otherwise. This is only a (much) stronger version of the MOZ_INLINE hint:
|
||||||
|
* compilers are not guaranteed to respect it (although they're much more likely
|
||||||
|
* to do so).
|
||||||
|
*/
|
||||||
|
#if defined(DEBUG)
|
||||||
|
# define MOZ_ALWAYS_INLINE MOZ_INLINE
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
# define MOZ_ALWAYS_INLINE __forceinline
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
# define MOZ_ALWAYS_INLINE __attribute__((always_inline)) MOZ_INLINE
|
||||||
|
#else
|
||||||
|
# define MOZ_ALWAYS_INLINE MOZ_INLINE
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality
|
* g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality
|
||||||
* without warnings (functionality used by the macros below). These modes are
|
* without warnings (functionality used by the macros below). These modes are
|
||||||
|
@ -72,6 +105,9 @@
|
||||||
# define MOZ_HAVE_CXX11_OVERRIDE
|
# define MOZ_HAVE_CXX11_OVERRIDE
|
||||||
# define MOZ_HAVE_CXX11_FINAL final
|
# define MOZ_HAVE_CXX11_FINAL final
|
||||||
# endif
|
# endif
|
||||||
|
# if __has_attribute(noinline)
|
||||||
|
# define MOZ_HAVE_NEVER_INLINE __attribute__((noinline))
|
||||||
|
# endif
|
||||||
# if __has_attribute(noreturn)
|
# if __has_attribute(noreturn)
|
||||||
# define MOZ_HAVE_NORETURN __attribute__((noreturn))
|
# define MOZ_HAVE_NORETURN __attribute__((noreturn))
|
||||||
# endif
|
# endif
|
||||||
|
@ -100,6 +136,7 @@
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
# define MOZ_HAVE_NEVER_INLINE __attribute__((noinline))
|
||||||
# define MOZ_HAVE_NORETURN __attribute__((noreturn))
|
# define MOZ_HAVE_NORETURN __attribute__((noreturn))
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
# if _MSC_VER >= 1400
|
# if _MSC_VER >= 1400
|
||||||
|
@ -107,9 +144,22 @@
|
||||||
/* MSVC currently spells "final" as "sealed". */
|
/* MSVC currently spells "final" as "sealed". */
|
||||||
# define MOZ_HAVE_CXX11_FINAL sealed
|
# define MOZ_HAVE_CXX11_FINAL sealed
|
||||||
# endif
|
# endif
|
||||||
|
# define MOZ_HAVE_NEVER_INLINE __declspec(noinline)
|
||||||
# define MOZ_HAVE_NORETURN __declspec(noreturn)
|
# define MOZ_HAVE_NORETURN __declspec(noreturn)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MOZ_NEVER_INLINE is a macro which expands to tell the compiler that the
|
||||||
|
* method decorated with it must never be inlined, even if the compiler would
|
||||||
|
* otherwise choose to inline the method. Compilers aren't absolutely
|
||||||
|
* guaranteed to support this, but most do.
|
||||||
|
*/
|
||||||
|
#if defined(MOZ_HAVE_NEVER_INLINE)
|
||||||
|
# define MOZ_NEVER_INLINE MOZ_HAVE_NEVER_INLINE
|
||||||
|
#else
|
||||||
|
# define MOZ_NEVER_INLINE /* no support */
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MOZ_NORETURN, specified at the start of a function declaration, indicates
|
* MOZ_NORETURN, specified at the start of a function declaration, indicates
|
||||||
* that the given function does not return. (The function definition does not
|
* that the given function does not return. (The function definition does not
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
|
|
||||||
#include "mozilla/Assertions.h"
|
#include "mozilla/Assertions.h"
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/Util.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helpers for defining and using refcounted objects.
|
* Helpers for defining and using refcounted objects.
|
||||||
|
|
53
mfbt/Util.h
53
mfbt/Util.h
|
@ -44,59 +44,6 @@
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/Types.h"
|
#include "mozilla/Types.h"
|
||||||
|
|
||||||
/*
|
|
||||||
* MOZ_INLINE is a macro which expands to tell the compiler that the method
|
|
||||||
* decorated with it should be inlined. This macro is usable from C and C++
|
|
||||||
* code, even though C89 does not support the |inline| keyword. The compiler
|
|
||||||
* may ignore this directive if it chooses.
|
|
||||||
*/
|
|
||||||
#ifndef MOZ_INLINE
|
|
||||||
# if defined __cplusplus
|
|
||||||
# define MOZ_INLINE inline
|
|
||||||
# elif defined _MSC_VER
|
|
||||||
# define MOZ_INLINE __inline
|
|
||||||
# elif defined __GNUC__
|
|
||||||
# define MOZ_INLINE __inline__
|
|
||||||
# else
|
|
||||||
# define MOZ_INLINE inline
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* MOZ_ALWAYS_INLINE is a macro which expands to tell the compiler that the
|
|
||||||
* method decorated with it must be inlined, even if the compiler thinks
|
|
||||||
* otherwise. This is only a (much) stronger version of the MOZ_INLINE hint:
|
|
||||||
* compilers are not guaranteed to respect it (although they're much more likely
|
|
||||||
* to do so).
|
|
||||||
*/
|
|
||||||
#ifndef MOZ_ALWAYS_INLINE
|
|
||||||
# if defined DEBUG
|
|
||||||
# define MOZ_ALWAYS_INLINE MOZ_INLINE
|
|
||||||
# elif defined _MSC_VER
|
|
||||||
# define MOZ_ALWAYS_INLINE __forceinline
|
|
||||||
# elif defined __GNUC__
|
|
||||||
# define MOZ_ALWAYS_INLINE __attribute__((always_inline)) MOZ_INLINE
|
|
||||||
# else
|
|
||||||
# define MOZ_ALWAYS_INLINE MOZ_INLINE
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* MOZ_NEVER_INLINE is a macro which expands to tell the compiler that the
|
|
||||||
* method decorated with it must never be inlined, even if the compiler would
|
|
||||||
* otherwise choose to inline the method. Compilers aren't absolutely
|
|
||||||
* guaranteed to support this, but most do.
|
|
||||||
*/
|
|
||||||
#ifndef MOZ_NEVER_INLINE
|
|
||||||
# if defined _MSC_VER
|
|
||||||
# define MOZ_NEVER_INLINE __declspec(noinline)
|
|
||||||
# elif defined __GNUC__
|
|
||||||
# define MOZ_NEVER_INLINE __attribute__((noinline))
|
|
||||||
# else
|
|
||||||
# define MOZ_NEVER_INLINE
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче