2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following disclaimer
|
|
|
|
// in the documentation and/or other materials provided with the
|
|
|
|
// distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
|
|
// Framework nor the names of its contributors may be used to endorse
|
|
|
|
// or promote products derived from this software without specific prior
|
|
|
|
// written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2014-07-11 22:10:05 +02:00
|
|
|
#ifndef CEF_INCLUDE_BASE_CEF_BUILD_H_
|
|
|
|
#define CEF_INCLUDE_BASE_CEF_BUILD_H_
|
2012-04-03 03:34:16 +02:00
|
|
|
#pragma once
|
|
|
|
|
2016-03-16 03:55:59 +01:00
|
|
|
#if defined(USING_CHROMIUM_INCLUDES)
|
2014-07-11 22:10:05 +02:00
|
|
|
// When building CEF include the Chromium header directly.
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "base/compiler_specific.h"
|
2016-03-16 03:55:59 +01:00
|
|
|
#else // !USING_CHROMIUM_INCLUDES
|
2014-07-11 22:10:05 +02:00
|
|
|
// The following is substantially similar to the Chromium implementation.
|
|
|
|
// If the Chromium implementation diverges the below implementation should be
|
|
|
|
// updated to match.
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
#if defined(_WIN32)
|
|
|
|
#ifndef OS_WIN
|
|
|
|
#define OS_WIN 1
|
|
|
|
#endif
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
#ifndef OS_MACOSX
|
|
|
|
#define OS_MACOSX 1
|
|
|
|
#endif
|
|
|
|
#elif defined(__linux__)
|
|
|
|
#ifndef OS_LINUX
|
|
|
|
#define OS_LINUX 1
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#error Please add support for your platform in cef_build.h
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// For access to standard POSIXish features, use OS_POSIX instead of a
|
|
|
|
// more specific macro.
|
|
|
|
#if defined(OS_MACOSX) || defined(OS_LINUX)
|
|
|
|
#ifndef OS_POSIX
|
|
|
|
#define OS_POSIX 1
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Compiler detection.
|
|
|
|
#if defined(__GNUC__)
|
|
|
|
#ifndef COMPILER_GCC
|
|
|
|
#define COMPILER_GCC 1
|
|
|
|
#endif
|
|
|
|
#elif defined(_MSC_VER)
|
|
|
|
#ifndef COMPILER_MSVC
|
|
|
|
#define COMPILER_MSVC 1
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#error Please add support for your compiler in cef_build.h
|
|
|
|
#endif
|
|
|
|
|
2014-07-15 00:18:51 +02:00
|
|
|
// Processor architecture detection. For more info on what's defined, see:
|
|
|
|
// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
|
|
|
|
// http://www.agner.org/optimize/calling_conventions.pdf
|
|
|
|
// or with gcc, run: "echo | gcc -E -dM -"
|
|
|
|
#if defined(_M_X64) || defined(__x86_64__)
|
|
|
|
#define ARCH_CPU_X86_FAMILY 1
|
|
|
|
#define ARCH_CPU_X86_64 1
|
|
|
|
#define ARCH_CPU_64_BITS 1
|
|
|
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
|
|
|
#elif defined(_M_IX86) || defined(__i386__)
|
|
|
|
#define ARCH_CPU_X86_FAMILY 1
|
|
|
|
#define ARCH_CPU_X86 1
|
|
|
|
#define ARCH_CPU_32_BITS 1
|
|
|
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
|
|
|
#elif defined(__ARMEL__)
|
|
|
|
#define ARCH_CPU_ARM_FAMILY 1
|
|
|
|
#define ARCH_CPU_ARMEL 1
|
|
|
|
#define ARCH_CPU_32_BITS 1
|
|
|
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
|
|
|
#elif defined(__aarch64__)
|
|
|
|
#define ARCH_CPU_ARM_FAMILY 1
|
|
|
|
#define ARCH_CPU_ARM64 1
|
|
|
|
#define ARCH_CPU_64_BITS 1
|
|
|
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
|
|
|
#elif defined(__pnacl__)
|
|
|
|
#define ARCH_CPU_32_BITS 1
|
|
|
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
|
|
|
#elif defined(__MIPSEL__)
|
|
|
|
#define ARCH_CPU_MIPS_FAMILY 1
|
|
|
|
#define ARCH_CPU_MIPSEL 1
|
|
|
|
#define ARCH_CPU_32_BITS 1
|
|
|
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
|
|
|
#else
|
2014-07-16 00:07:25 +02:00
|
|
|
#error Please add support for your architecture in cef_build.h
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Type detection for wchar_t.
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
#define WCHAR_T_IS_UTF16
|
2017-05-17 11:29:28 +02:00
|
|
|
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
|
2014-07-16 00:07:25 +02:00
|
|
|
(__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
|
|
|
|
#define WCHAR_T_IS_UTF32
|
2017-05-17 11:29:28 +02:00
|
|
|
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
|
2014-07-16 00:07:25 +02:00
|
|
|
(__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
|
|
|
|
// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
|
|
|
|
// compile in this mode (in particular, Chrome doesn't). This is intended for
|
|
|
|
// other projects using base who manage their own dependencies and make sure
|
|
|
|
// short wchar works for them.
|
|
|
|
#define WCHAR_T_IS_UTF16
|
|
|
|
#else
|
|
|
|
#error Please add support for your compiler in cef_build.h
|
2014-07-15 00:18:51 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Annotate a function indicating the caller must examine the return value.
|
|
|
|
// Use like:
|
|
|
|
// int foo() WARN_UNUSED_RESULT;
|
2016-01-06 20:20:54 +01:00
|
|
|
// To explicitly ignore a result, see |ignore_result()| in <base/macros.h>.
|
2014-08-14 15:23:47 +02:00
|
|
|
#ifndef WARN_UNUSED_RESULT
|
2014-07-15 00:18:51 +02:00
|
|
|
#if defined(COMPILER_GCC)
|
|
|
|
#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
|
|
|
#else
|
|
|
|
#define WARN_UNUSED_RESULT
|
|
|
|
#endif
|
2014-08-14 15:23:47 +02:00
|
|
|
#endif // WARN_UNUSED_RESULT
|
2014-07-15 00:18:51 +02:00
|
|
|
|
2015-01-08 03:42:59 +01:00
|
|
|
// Annotate a typedef or function indicating it's ok if it's not used.
|
|
|
|
// Use like:
|
|
|
|
// typedef Foo Bar ALLOW_UNUSED_TYPE;
|
|
|
|
#ifndef ALLOW_UNUSED_TYPE
|
|
|
|
#if defined(COMPILER_GCC)
|
|
|
|
#define ALLOW_UNUSED_TYPE __attribute__((unused))
|
|
|
|
#else
|
|
|
|
#define ALLOW_UNUSED_TYPE
|
|
|
|
#endif
|
|
|
|
#endif // ALLOW_UNUSED_TYPE
|
|
|
|
|
2014-07-15 00:18:51 +02:00
|
|
|
// Annotate a variable indicating it's ok if the variable is not used.
|
|
|
|
// (Typically used to silence a compiler warning when the assignment
|
|
|
|
// is important for some other reason.)
|
|
|
|
// Use like:
|
2015-01-08 03:42:59 +01:00
|
|
|
// int x = ...;
|
|
|
|
// ALLOW_UNUSED_LOCAL(x);
|
|
|
|
#ifndef ALLOW_UNUSED_LOCAL
|
|
|
|
#define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0
|
2014-07-15 00:18:51 +02:00
|
|
|
#endif
|
|
|
|
|
2018-07-12 19:55:56 +02:00
|
|
|
// Sanitizers annotations.
|
|
|
|
#if defined(__has_attribute)
|
|
|
|
#if __has_attribute(no_sanitize)
|
|
|
|
#define NO_SANITIZE(what) __attribute__((no_sanitize(what)))
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if !defined(NO_SANITIZE)
|
|
|
|
#define NO_SANITIZE(what)
|
|
|
|
#endif
|
|
|
|
|
2016-03-16 03:55:59 +01:00
|
|
|
#endif // !USING_CHROMIUM_INCLUDES
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2015-08-18 00:44:17 +02:00
|
|
|
// Annotate a virtual method indicating it must be overriding a virtual method
|
|
|
|
// in the parent class.
|
|
|
|
// Use like:
|
|
|
|
// void foo() OVERRIDE;
|
|
|
|
// NOTE: This define should only be used in classes exposed to the client since
|
|
|
|
// C++11 support may not be enabled in client applications. CEF internal classes
|
|
|
|
// should use the `override` keyword directly.
|
|
|
|
#ifndef OVERRIDE
|
2015-11-13 17:19:24 +01:00
|
|
|
#if defined(__clang__)
|
|
|
|
#define OVERRIDE override
|
|
|
|
#elif defined(COMPILER_MSVC) && _MSC_VER >= 1600
|
|
|
|
// Visual Studio 2010 and later support override.
|
2015-08-18 00:44:17 +02:00
|
|
|
#define OVERRIDE override
|
|
|
|
#elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \
|
2017-05-17 11:29:28 +02:00
|
|
|
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700
|
2015-08-18 00:44:17 +02:00
|
|
|
// GCC 4.7 supports explicit virtual overrides when C++11 support is enabled.
|
|
|
|
#define OVERRIDE override
|
|
|
|
#else
|
|
|
|
#define OVERRIDE
|
|
|
|
#endif
|
|
|
|
#endif // OVERRIDE
|
|
|
|
|
2017-02-07 22:25:11 +01:00
|
|
|
// Check for C++11 template alias support which was added in VS2013 and GCC4.7.
|
|
|
|
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf
|
2017-05-17 11:29:28 +02:00
|
|
|
#if __cplusplus > 199711L || (defined(_MSC_VER) && _MSC_VER >= 1800) || \
|
|
|
|
(defined(__GNUC__) && \
|
|
|
|
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40700))
|
2017-02-07 22:25:11 +01:00
|
|
|
#define HAS_CPP11_TEMPLATE_ALIAS_SUPPORT
|
|
|
|
#endif
|
|
|
|
|
2014-07-11 22:10:05 +02:00
|
|
|
#endif // CEF_INCLUDE_BASE_CEF_BUILD_H_
|