Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | /* Various compiler checks. */ |
michael@0 | 8 | |
michael@0 | 9 | #ifndef mozilla_Compiler_h |
michael@0 | 10 | #define mozilla_Compiler_h |
michael@0 | 11 | |
michael@0 | 12 | #if !defined(__clang__) && defined(__GNUC__) |
michael@0 | 13 | |
michael@0 | 14 | # define MOZ_IS_GCC 1 |
michael@0 | 15 | /* |
michael@0 | 16 | * This macro should simplify gcc version checking. For example, to check |
michael@0 | 17 | * for gcc 4.5.1 or later, check `#if MOZ_GCC_VERSION_AT_LEAST(4, 5, 1)`. |
michael@0 | 18 | */ |
michael@0 | 19 | # define MOZ_GCC_VERSION_AT_LEAST(major, minor, patchlevel) \ |
michael@0 | 20 | ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) \ |
michael@0 | 21 | >= ((major) * 10000 + (minor) * 100 + (patchlevel))) |
michael@0 | 22 | # if !MOZ_GCC_VERSION_AT_LEAST(4, 4, 0) |
michael@0 | 23 | # error "mfbt (and Gecko) require at least gcc 4.4 to build." |
michael@0 | 24 | # endif |
michael@0 | 25 | |
michael@0 | 26 | #else |
michael@0 | 27 | |
michael@0 | 28 | # define MOZ_IS_GCC 0 |
michael@0 | 29 | |
michael@0 | 30 | #endif |
michael@0 | 31 | |
michael@0 | 32 | /* |
michael@0 | 33 | * The situation with standard libraries is a lot worse than with compilers, |
michael@0 | 34 | * particularly as clang and gcc could end up using one of three or so standard |
michael@0 | 35 | * libraries, and they may not be up-to-snuff with newer C++11 versions. To |
michael@0 | 36 | * detect the library, we're going to include cstddef (which is a small header |
michael@0 | 37 | * which will be transitively included by everybody else at some point) to grab |
michael@0 | 38 | * the version macros and deduce macros from there. |
michael@0 | 39 | */ |
michael@0 | 40 | #ifdef __cplusplus |
michael@0 | 41 | # include <cstddef> |
michael@0 | 42 | # ifdef _STLPORT_MAJOR |
michael@0 | 43 | # define MOZ_USING_STLPORT 1 |
michael@0 | 44 | # define MOZ_STLPORT_VERSION_AT_LEAST(major, minor, patch) \ |
michael@0 | 45 | (_STLPORT_VERSION >= ((major) << 8 | (minor) << 4 | (patch))) |
michael@0 | 46 | # elif defined(_LIBCPP_VERSION) |
michael@0 | 47 | /* |
michael@0 | 48 | * libc++, unfortunately, doesn't appear to have useful versioning macros. |
michael@0 | 49 | * Hopefully, the recommendations of N3694 with respect to standard libraries |
michael@0 | 50 | * will get applied instead and we won't need to worry about version numbers |
michael@0 | 51 | * here. |
michael@0 | 52 | */ |
michael@0 | 53 | # define MOZ_USING_LIBCXX 1 |
michael@0 | 54 | # elif defined(__GLIBCXX__) |
michael@0 | 55 | # define MOZ_USING_LIBSTDCXX 1 |
michael@0 | 56 | /* |
michael@0 | 57 | * libstdc++ is also annoying and doesn't give us useful versioning macros |
michael@0 | 58 | * for the library. If we're using gcc, then assume that libstdc++ matches |
michael@0 | 59 | * the compiler version. If we're using clang, we're going to have to fake |
michael@0 | 60 | * major/minor combinations by looking for newly-defined config macros. |
michael@0 | 61 | */ |
michael@0 | 62 | # if MOZ_IS_GCC |
michael@0 | 63 | # define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ |
michael@0 | 64 | MOZ_GCC_VERSION_AT_LEAST(major, minor, patch) |
michael@0 | 65 | # elif defined(_GLIBCXX_THROW_OR_ABORT) |
michael@0 | 66 | # define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ |
michael@0 | 67 | ((major) < 4 || ((major) == 4 && (minor) <= 8)) |
michael@0 | 68 | # elif defined(_GLIBCXX_NOEXCEPT) |
michael@0 | 69 | # define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ |
michael@0 | 70 | ((major) < 4 || ((major) == 4 && (minor) <= 7)) |
michael@0 | 71 | # elif defined(_GLIBCXX_USE_DEPRECATED) |
michael@0 | 72 | # define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ |
michael@0 | 73 | ((major) < 4 || ((major) == 4 && (minor) <= 6)) |
michael@0 | 74 | # elif defined(_GLIBCXX_PSEUDO_VISIBILITY) |
michael@0 | 75 | # define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ |
michael@0 | 76 | ((major) < 4 || ((major) == 4 && (minor) <= 5)) |
michael@0 | 77 | # elif defined(_GLIBCXX_BEGIN_EXTERN_C) |
michael@0 | 78 | # define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ |
michael@0 | 79 | ((major) < 4 || ((major) == 4 && (minor) <= 4)) |
michael@0 | 80 | # elif defined(_GLIBCXX_VISIBILITY_ATTR) |
michael@0 | 81 | # define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ |
michael@0 | 82 | ((major) < 4 || ((major) == 4 && (minor) <= 3)) |
michael@0 | 83 | # elif defined(_GLIBCXX_VISIBILITY) |
michael@0 | 84 | # define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ |
michael@0 | 85 | ((major) < 4 || ((major) == 4 && (minor) <= 2)) |
michael@0 | 86 | # else |
michael@0 | 87 | # error "Your version of libstdc++ is unknown to us and is likely too old." |
michael@0 | 88 | # endif |
michael@0 | 89 | # endif |
michael@0 | 90 | |
michael@0 | 91 | // Flesh out the defines for everyone else |
michael@0 | 92 | # ifndef MOZ_USING_STLPORT |
michael@0 | 93 | # define MOZ_USING_STLPORT 0 |
michael@0 | 94 | # define MOZ_STLPORT_VERSION_AT_LEAST(major, minor, patch) 0 |
michael@0 | 95 | # endif |
michael@0 | 96 | # ifndef MOZ_USING_LIBCXX |
michael@0 | 97 | # define MOZ_USING_LIBCXX 0 |
michael@0 | 98 | # endif |
michael@0 | 99 | # ifndef MOZ_USING_LIBSTDCXX |
michael@0 | 100 | # define MOZ_USING_LIBSTDCXX 0 |
michael@0 | 101 | # define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) 0 |
michael@0 | 102 | # endif |
michael@0 | 103 | #endif /* __cplusplus */ |
michael@0 | 104 | |
michael@0 | 105 | #endif /* mozilla_Compiler_h */ |