Bug 833254 - Fix MFBT's gcc version checks. r=waldo

This commit is contained in:
Chris Peterson 2013-01-21 19:42:15 -08:00
Родитель 7823655184
Коммит e171e76319
6 изменённых файлов: 38 добавлений и 28 удалений

Просмотреть файл

@ -9,6 +9,7 @@
#define mozilla_Assertions_h_ #define mozilla_Assertions_h_
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/Compiler.h"
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
@ -312,7 +313,7 @@ MOZ_ReportAssertionFailure(const char* s, const char* file, int ln)
* that, call a noreturn function; abort() will do nicely. Qualify the call * that, call a noreturn function; abort() will do nicely. Qualify the call
* in C++ in case there's another abort() visible in local scope. * in C++ in case there's another abort() visible in local scope.
*/ */
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) # if MOZ_GCC_VERSION_AT_LEAST(4, 5, 0)
# define MOZ_NOT_REACHED_MARKER() __builtin_unreachable() # define MOZ_NOT_REACHED_MARKER() __builtin_unreachable()
# else # else
# ifdef __cplusplus # ifdef __cplusplus

Просмотреть файл

@ -8,10 +8,7 @@
#ifndef mozilla_Attributes_h_ #ifndef mozilla_Attributes_h_
#define mozilla_Attributes_h_ #define mozilla_Attributes_h_
/* #include "mozilla/Compiler.h"
* This header does not include any other headers so that it can be included by
* code that is (only currently) mfbt-incompatible.
*/
/* /*
* MOZ_INLINE is a macro which expands to tell the compiler that the method * MOZ_INLINE is a macro which expands to tell the compiler that the method
@ -81,28 +78,18 @@
# endif # endif
#elif defined(__GNUC__) #elif defined(__GNUC__)
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
# if __GNUC__ > 4 # if MOZ_GCC_VERSION_AT_LEAST(4, 7, 0)
# define MOZ_HAVE_CXX11_DELETE
# define MOZ_HAVE_CXX11_OVERRIDE # define MOZ_HAVE_CXX11_OVERRIDE
# define MOZ_HAVE_CXX11_FINAL final # define MOZ_HAVE_CXX11_FINAL final
# elif __GNUC__ == 4
# if __GNUC_MINOR__ >= 7
# define MOZ_HAVE_CXX11_OVERRIDE
# define MOZ_HAVE_CXX11_FINAL final
# endif
# if __GNUC_MINOR__ >= 6
# define MOZ_HAVE_CXX11_CONSTEXPR
# endif
# define MOZ_HAVE_CXX11_DELETE
# endif # endif
# if MOZ_GCC_VERSION_AT_LEAST(4, 6, 0)
# define MOZ_HAVE_CXX11_CONSTEXPR
# endif
# define MOZ_HAVE_CXX11_DELETE
# else # else
/* __final is a non-C++11 GCC synonym for 'final', per GCC r176655. */ /* __final is a non-C++11 GCC synonym for 'final', per GCC r176655. */
# if __GNUC__ > 4 # if MOZ_GCC_VERSION_AT_LEAST(4, 7, 0)
# define MOZ_HAVE_CXX11_FINAL __final # define MOZ_HAVE_CXX11_FINAL __final
# elif __GNUC__ == 4
# if __GNUC_MINOR__ >= 7
# define MOZ_HAVE_CXX11_FINAL __final
# endif
# endif # endif
# endif # endif
# define MOZ_HAVE_NEVER_INLINE __attribute__((noinline)) # define MOZ_HAVE_NEVER_INLINE __attribute__((noinline))

24
mfbt/Compiler.h Normal file
Просмотреть файл

@ -0,0 +1,24 @@
/* -*- 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/. */
/* Various compiler checks. */
#ifndef mozilla_Compiler_h_
#define mozilla_Compiler_h_
#if !defined(__clang__) && defined(__GNUC__)
/*
* This macro should simplify gcc version checking. For example, to check
* for gcc 4.5.1 or later, check `#ifdef MOZ_GCC_VERSION_AT_LEAST(4, 5, 1)`.
*/
# define MOZ_GCC_VERSION_AT_LEAST(major, minor, patchlevel) \
((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) \
>= ((major) * 10000 + (minor) * 100 + (patchlevel)))
#if !MOZ_GCC_VERSION_AT_LEAST(4, 4, 0)
# error "mfbt (and Gecko) require at least gcc 4.4 to build."
#endif
#endif
#endif /* mozilla_Compiler_h_ */

Просмотреть файл

@ -11,6 +11,8 @@
#ifndef mozilla_NullPtr_h_ #ifndef mozilla_NullPtr_h_
#define mozilla_NullPtr_h_ #define mozilla_NullPtr_h_
#include "mozilla/Compiler.h"
#if defined(__clang__) #if defined(__clang__)
# ifndef __has_extension # ifndef __has_extension
# define __has_extension __has_feature # define __has_extension __has_feature
@ -20,7 +22,7 @@
# endif # endif
#elif defined(__GNUC__) #elif defined(__GNUC__)
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
# if (__GNUC__ * 1000 + __GNUC_MINOR__) >= 4006 # if MOZ_GCC_VERSION_AT_LEAST(4, 6, 0)
# define MOZ_HAVE_CXX11_NULLPTR # define MOZ_HAVE_CXX11_NULLPTR
# endif # endif
# endif # endif

Просмотреть файл

@ -27,14 +27,9 @@
# endif # endif
#elif defined(__GNUC__) #elif defined(__GNUC__)
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
# if __GNUC__ > 4 # if MOZ_GCC_VERSION_AT_LEAST(4, 5, 1)
# define MOZ_HAVE_CXX11_ENUM_TYPE # define MOZ_HAVE_CXX11_ENUM_TYPE
# define MOZ_HAVE_CXX11_STRONG_ENUMS # define MOZ_HAVE_CXX11_STRONG_ENUMS
# elif __GNUC__ == 4
# if __GNUC_MINOR__ >= 5
# define MOZ_HAVE_CXX11_ENUM_TYPE
# define MOZ_HAVE_CXX11_STRONG_ENUMS
# endif
# endif # endif
# endif # endif
#elif defined(_MSC_VER) #elif defined(_MSC_VER)

Просмотреть файл

@ -14,6 +14,7 @@ EXPORTS_mozilla += \
BloomFilter.h \ BloomFilter.h \
Char16.h \ Char16.h \
CheckedInt.h \ CheckedInt.h \
Compiler.h \
Constants.h \ Constants.h \
DebugOnly.h \ DebugOnly.h \
EnumSet.h \ EnumSet.h \