2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-03-01 21:39:57 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-08-04 01:50:00 +00:00
|
|
|
// This file contains platform-specific typedefs and defines.
|
2012-08-31 23:17:53 +00:00
|
|
|
// Much of it is derived from Chromium's build/build_config.h.
|
2011-08-04 01:50:00 +00:00
|
|
|
|
|
|
|
|
#ifndef WEBRTC_TYPEDEFS_H_
|
|
|
|
|
#define WEBRTC_TYPEDEFS_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-08-04 01:50:00 +00: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 WEBRTC_ARCH_X86_FAMILY
|
|
|
|
|
#define WEBRTC_ARCH_X86_64
|
|
|
|
|
#define WEBRTC_ARCH_64_BITS
|
|
|
|
|
#define WEBRTC_ARCH_LITTLE_ENDIAN
|
2014-04-01 01:19:08 +00:00
|
|
|
#elif defined(__aarch64__)
|
2015-12-18 04:28:42 -08:00
|
|
|
#define WEBRTC_ARCH_ARM_FAMILY
|
2014-03-27 19:48:53 +00:00
|
|
|
#define WEBRTC_ARCH_64_BITS
|
|
|
|
|
#define WEBRTC_ARCH_LITTLE_ENDIAN
|
2011-08-04 01:50:00 +00:00
|
|
|
#elif defined(_M_IX86) || defined(__i386__)
|
|
|
|
|
#define WEBRTC_ARCH_X86_FAMILY
|
|
|
|
|
#define WEBRTC_ARCH_X86
|
|
|
|
|
#define WEBRTC_ARCH_32_BITS
|
|
|
|
|
#define WEBRTC_ARCH_LITTLE_ENDIAN
|
|
|
|
|
#elif defined(__ARMEL__)
|
2015-12-18 04:28:42 -08:00
|
|
|
#define WEBRTC_ARCH_ARM_FAMILY
|
2011-08-04 01:50:00 +00:00
|
|
|
#define WEBRTC_ARCH_32_BITS
|
|
|
|
|
#define WEBRTC_ARCH_LITTLE_ENDIAN
|
2012-06-27 22:24:43 +00:00
|
|
|
#elif defined(__MIPSEL__)
|
2016-06-23 03:52:28 -07:00
|
|
|
#define WEBRTC_ARCH_MIPS_FAMILY
|
2015-12-18 04:28:42 -08:00
|
|
|
#if defined(__LP64__)
|
2016-06-23 03:52:28 -07:00
|
|
|
#define WEBRTC_ARCH_64_BITS
|
2015-12-18 04:28:42 -08:00
|
|
|
#else
|
2012-06-27 22:24:43 +00:00
|
|
|
#define WEBRTC_ARCH_32_BITS
|
2016-06-23 03:52:28 -07:00
|
|
|
#endif
|
2012-06-27 22:24:43 +00:00
|
|
|
#define WEBRTC_ARCH_LITTLE_ENDIAN
|
2014-02-19 13:55:02 +00:00
|
|
|
#elif defined(__pnacl__)
|
|
|
|
|
#define WEBRTC_ARCH_32_BITS
|
|
|
|
|
#define WEBRTC_ARCH_LITTLE_ENDIAN
|
2011-08-04 01:50:00 +00:00
|
|
|
#else
|
|
|
|
|
#error Please add support for your architecture in typedefs.h
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-10-22 10:27:23 +00:00
|
|
|
#if !(defined(WEBRTC_ARCH_LITTLE_ENDIAN) ^ defined(WEBRTC_ARCH_BIG_ENDIAN))
|
|
|
|
|
#error Define either WEBRTC_ARCH_LITTLE_ENDIAN or WEBRTC_ARCH_BIG_ENDIAN
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-05-19 22:20:17 -07:00
|
|
|
// TODO(zhongwei.yao): WEBRTC_CPU_DETECTION is only used in one place; we should
|
|
|
|
|
// probably just remove it.
|
2016-05-17 10:56:40 -07:00
|
|
|
#if (defined(WEBRTC_ARCH_X86_FAMILY) && !defined(__SSE2__))
|
2014-02-27 04:12:34 +00:00
|
|
|
#define WEBRTC_CPU_DETECTION
|
2011-08-04 01:50:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
2012-03-01 21:39:57 +00:00
|
|
|
#include <stdint.h>
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-10-22 12:50:00 +00:00
|
|
|
// Annotate a function indicating the caller must examine the return value.
|
|
|
|
|
// Use like:
|
|
|
|
|
// int foo() WARN_UNUSED_RESULT;
|
2015-12-12 05:47:19 -08:00
|
|
|
// To explicitly ignore a result, see |ignore_result()| in <base/macros.h>.
|
2013-10-23 19:11:32 +00:00
|
|
|
// TODO(ajm): Hack to avoid multiple definitions until the base/ of webrtc and
|
|
|
|
|
// libjingle are merged.
|
|
|
|
|
#if !defined(WARN_UNUSED_RESULT)
|
2015-12-12 05:47:19 -08:00
|
|
|
#if defined(__GNUC__) || defined(__clang__)
|
2016-01-08 04:51:38 -08:00
|
|
|
#define WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
|
2013-10-22 12:50:00 +00:00
|
|
|
#else
|
|
|
|
|
#define WARN_UNUSED_RESULT
|
|
|
|
|
#endif
|
2013-10-23 19:11:32 +00:00
|
|
|
#endif // WARN_UNUSED_RESULT
|
2013-10-22 12:50:00 +00:00
|
|
|
|
2014-08-25 06:26:04 +00:00
|
|
|
// Put after a variable that might not be used, to prevent compiler warnings:
|
2014-11-17 13:47:38 +00:00
|
|
|
// int result ATTRIBUTE_UNUSED = DoSomething();
|
2014-08-25 06:26:04 +00:00
|
|
|
// assert(result == 17);
|
2014-11-17 13:47:38 +00:00
|
|
|
#ifndef ATTRIBUTE_UNUSED
|
|
|
|
|
#if defined(__GNUC__) || defined(__clang__)
|
2016-01-08 04:51:38 -08:00
|
|
|
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
2014-08-25 06:26:04 +00:00
|
|
|
#else
|
2014-11-17 13:47:38 +00:00
|
|
|
#define ATTRIBUTE_UNUSED
|
2014-08-25 06:26:04 +00:00
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-01-28 18:37:58 +00:00
|
|
|
// Macro to be used for switch-case fallthrough (required for enabling
|
|
|
|
|
// -Wimplicit-fallthrough warning on Clang).
|
|
|
|
|
#ifndef FALLTHROUGH
|
|
|
|
|
#if defined(__clang__)
|
|
|
|
|
#define FALLTHROUGH() [[clang::fallthrough]]
|
|
|
|
|
#else
|
|
|
|
|
#define FALLTHROUGH() do { } while (0)
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-01-30 00:54:19 -08:00
|
|
|
#ifndef NO_RETURN
|
Add CHECK and friends from Chromium.
Replace FATAL_ERROR_IF with the more familiar (to Chromium developers)
CHECK and DCHECK. The full Chromium implementation is fairly elaborate
but I copied enough to get us most of the benefits. I believe the main
missing component is a more advanced stack dump. For this bit I relied
on the V8 implementation.
There are a few minor modifications from the Chromium original:
- The FatalMessage class is specialized for logging fatal error
messages and aborting. Chromium uses the general LogMessage class,
which we could consider moving towards in the future.
- NOTIMPLEMENTED() and NOTREACHED() have been removed, partly because
I don't want to rely on our logging.h until base/ and system_wrappers/
are consolidated.
- FATAL() replaces LOG(FATAL).
Minor modifications from V8's stack dump:
- If parsing of a stack trace symbol fails, just print the unparsed
symbol. (I noticed this happened on Mac.)
- Use __GLIBCXX__ and __UCLIBC__. This is from examining the backtrace
use in Chromium.
UNREACHABLE() has been removed because its behavior is different than
Chromium's NOTREACHED(), which is bound to cause confusion. The few uses
were replaced with FATAL(), matching the previous behavior.
Add a NO_RETURN macro, allowing us to remove unreachable return
statements following a CHECK/FATAL.
TESTED=the addition of dummy CHECK, DCHECK, CHECK_EQ and FATAL did the
did the right things. Stack traces work on Mac, but I don't get symbols
on Linux.
R=henrik.lundin@webrtc.org, kwiberg@webrtc.org, tommi@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/22449004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7003 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-08-28 16:28:26 +00:00
|
|
|
// Annotate a function that will not return control flow to the caller.
|
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
|
#define NO_RETURN __declspec(noreturn)
|
|
|
|
|
#elif defined(__GNUC__)
|
2016-01-08 04:51:38 -08:00
|
|
|
#define NO_RETURN __attribute__ ((__noreturn__))
|
Add CHECK and friends from Chromium.
Replace FATAL_ERROR_IF with the more familiar (to Chromium developers)
CHECK and DCHECK. The full Chromium implementation is fairly elaborate
but I copied enough to get us most of the benefits. I believe the main
missing component is a more advanced stack dump. For this bit I relied
on the V8 implementation.
There are a few minor modifications from the Chromium original:
- The FatalMessage class is specialized for logging fatal error
messages and aborting. Chromium uses the general LogMessage class,
which we could consider moving towards in the future.
- NOTIMPLEMENTED() and NOTREACHED() have been removed, partly because
I don't want to rely on our logging.h until base/ and system_wrappers/
are consolidated.
- FATAL() replaces LOG(FATAL).
Minor modifications from V8's stack dump:
- If parsing of a stack trace symbol fails, just print the unparsed
symbol. (I noticed this happened on Mac.)
- Use __GLIBCXX__ and __UCLIBC__. This is from examining the backtrace
use in Chromium.
UNREACHABLE() has been removed because its behavior is different than
Chromium's NOTREACHED(), which is bound to cause confusion. The few uses
were replaced with FATAL(), matching the previous behavior.
Add a NO_RETURN macro, allowing us to remove unreachable return
statements following a CHECK/FATAL.
TESTED=the addition of dummy CHECK, DCHECK, CHECK_EQ and FATAL did the
did the right things. Stack traces work on Mac, but I don't get symbols
on Linux.
R=henrik.lundin@webrtc.org, kwiberg@webrtc.org, tommi@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/22449004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7003 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-08-28 16:28:26 +00:00
|
|
|
#else
|
|
|
|
|
#define NO_RETURN
|
|
|
|
|
#endif
|
2017-01-30 00:54:19 -08:00
|
|
|
#endif
|
Add CHECK and friends from Chromium.
Replace FATAL_ERROR_IF with the more familiar (to Chromium developers)
CHECK and DCHECK. The full Chromium implementation is fairly elaborate
but I copied enough to get us most of the benefits. I believe the main
missing component is a more advanced stack dump. For this bit I relied
on the V8 implementation.
There are a few minor modifications from the Chromium original:
- The FatalMessage class is specialized for logging fatal error
messages and aborting. Chromium uses the general LogMessage class,
which we could consider moving towards in the future.
- NOTIMPLEMENTED() and NOTREACHED() have been removed, partly because
I don't want to rely on our logging.h until base/ and system_wrappers/
are consolidated.
- FATAL() replaces LOG(FATAL).
Minor modifications from V8's stack dump:
- If parsing of a stack trace symbol fails, just print the unparsed
symbol. (I noticed this happened on Mac.)
- Use __GLIBCXX__ and __UCLIBC__. This is from examining the backtrace
use in Chromium.
UNREACHABLE() has been removed because its behavior is different than
Chromium's NOTREACHED(), which is bound to cause confusion. The few uses
were replaced with FATAL(), matching the previous behavior.
Add a NO_RETURN macro, allowing us to remove unreachable return
statements following a CHECK/FATAL.
TESTED=the addition of dummy CHECK, DCHECK, CHECK_EQ and FATAL did the
did the right things. Stack traces work on Mac, but I don't get symbols
on Linux.
R=henrik.lundin@webrtc.org, kwiberg@webrtc.org, tommi@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/22449004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7003 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-08-28 16:28:26 +00:00
|
|
|
|
2011-08-04 01:50:00 +00:00
|
|
|
#endif // WEBRTC_TYPEDEFS_H_
|