blob: 4857908868db02226ff28474eb8ec712aa3d8feb [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:231/*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11// This file contains platform-specific typedefs and defines.
12// Much of it is derived from Chromium's build/build_config.h.
13
14#ifndef WEBRTC_TYPEDEFS_H_
15#define WEBRTC_TYPEDEFS_H_
16
andrew@webrtc.orgb015cbe2012-10-22 18:19:2317// Processor architecture detection. For more info on what's defined, see:
18// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
19// http://www.agner.org/optimize/calling_conventions.pdf
20// or with gcc, run: "echo | gcc -E -dM -"
andrew@webrtc.orgb015cbe2012-10-22 18:19:2321#if defined(_M_X64) || defined(__x86_64__)
22#define WEBRTC_ARCH_X86_FAMILY
23#define WEBRTC_ARCH_X86_64
24#define WEBRTC_ARCH_64_BITS
25#define WEBRTC_ARCH_LITTLE_ENDIAN
andrew@webrtc.orgb015cbe2012-10-22 18:19:2326#elif defined(_M_IX86) || defined(__i386__)
27#define WEBRTC_ARCH_X86_FAMILY
28#define WEBRTC_ARCH_X86
29#define WEBRTC_ARCH_32_BITS
30#define WEBRTC_ARCH_LITTLE_ENDIAN
andrew@webrtc.orgb015cbe2012-10-22 18:19:2331#elif defined(__ARMEL__)
andrew@webrtc.orgd7e90412013-10-22 10:27:2332// TODO(ajm): We'd prefer to control platform defines here, but this is
andrew@webrtc.orgb015cbe2012-10-22 18:19:2333// currently provided by the Android makefiles. Commented to avoid duplicate
34// definition warnings.
35//#define WEBRTC_ARCH_ARM
andrew@webrtc.orgd7e90412013-10-22 10:27:2336// TODO(ajm): Chromium uses the following two defines. Should we switch?
andrew@webrtc.orgb015cbe2012-10-22 18:19:2337//#define WEBRTC_ARCH_ARM_FAMILY
38//#define WEBRTC_ARCH_ARMEL
39#define WEBRTC_ARCH_32_BITS
40#define WEBRTC_ARCH_LITTLE_ENDIAN
andrew@webrtc.orgb015cbe2012-10-22 18:19:2341#elif defined(__MIPSEL__)
42#define WEBRTC_ARCH_32_BITS
43#define WEBRTC_ARCH_LITTLE_ENDIAN
andresp@webrtc.org1af2c142014-02-19 13:55:0244#elif defined(__pnacl__)
45#define WEBRTC_ARCH_32_BITS
46#define WEBRTC_ARCH_LITTLE_ENDIAN
47#define WEBRTC_LITTLE_ENDIAN
andrew@webrtc.orgb015cbe2012-10-22 18:19:2348#else
49#error Please add support for your architecture in typedefs.h
50#endif
51
andrew@webrtc.orgd7e90412013-10-22 10:27:2352#if !(defined(WEBRTC_ARCH_LITTLE_ENDIAN) ^ defined(WEBRTC_ARCH_BIG_ENDIAN))
53#error Define either WEBRTC_ARCH_LITTLE_ENDIAN or WEBRTC_ARCH_BIG_ENDIAN
54#endif
55
andrew@webrtc.orge9d42e62014-02-27 04:12:3456#if (defined(WEBRTC_ARCH_X86_FAMILY) && !defined(__SSE2__)) || \
57 (defined(WEBRTC_ARCH_ARM_V7) && !defined(WEBRTC_ARCH_ARM_NEON))
58#define WEBRTC_CPU_DETECTION
andrew@webrtc.orgb015cbe2012-10-22 18:19:2359#endif
60
61#if !defined(_MSC_VER)
62#include <stdint.h>
63#else
andrew@webrtc.org5350e312014-03-04 20:58:1364// Define C99 equivalent types, since pre-2010 MSVC doesn't provide stdint.h.
andrew@webrtc.orgb015cbe2012-10-22 18:19:2365typedef signed char int8_t;
66typedef signed short int16_t;
67typedef signed int int32_t;
68typedef __int64 int64_t;
69typedef unsigned char uint8_t;
70typedef unsigned short uint16_t;
71typedef unsigned int uint32_t;
72typedef unsigned __int64 uint64_t;
73#endif
74
andrew@webrtc.org13f66d12013-03-25 21:20:3875// Borrowed from Chromium's base/compiler_specific.h.
76// Annotate a virtual method indicating it must be overriding a virtual
77// method in the parent class.
78// Use like:
79// virtual void foo() OVERRIDE;
80#if defined(_MSC_VER)
81#define OVERRIDE override
82#elif defined(__clang__)
pbos@webrtc.orgd7ebd682013-05-08 08:34:3483// Clang defaults to C++03 and warns about using override. Squelch that.
84// Intentionally no push/pop here so all users of OVERRIDE ignore the warning
85// too. This is like passing -Wno-c++11-extensions, except that GCC won't die
86// (because it won't see this pragma).
87#pragma clang diagnostic ignored "-Wc++11-extensions"
andrew@webrtc.org13f66d12013-03-25 21:20:3888#define OVERRIDE override
andrew@webrtc.orgaa9e7682013-12-10 19:20:4689#elif defined(__GNUC__) && __cplusplus >= 201103 && \
90 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700
91// GCC 4.7 supports explicit virtual overrides when C++11 support is enabled.
92#define OVERRIDE override
andrew@webrtc.org13f66d12013-03-25 21:20:3893#else
94#define OVERRIDE
95#endif
96
andrew@webrtc.org221798a2013-10-22 12:50:0097// Annotate a function indicating the caller must examine the return value.
98// Use like:
99// int foo() WARN_UNUSED_RESULT;
andrew@webrtc.org44a8ce52013-10-23 19:11:32100// TODO(ajm): Hack to avoid multiple definitions until the base/ of webrtc and
101// libjingle are merged.
102#if !defined(WARN_UNUSED_RESULT)
andrew@webrtc.org221798a2013-10-22 12:50:00103#if defined(__GNUC__)
104#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
105#else
106#define WARN_UNUSED_RESULT
107#endif
andrew@webrtc.org44a8ce52013-10-23 19:11:32108#endif // WARN_UNUSED_RESULT
andrew@webrtc.org221798a2013-10-22 12:50:00109
andrew@webrtc.orgb015cbe2012-10-22 18:19:23110#endif // WEBRTC_TYPEDEFS_H_