blob: 472c74b088bf771bc12ba0908964a840a5a17846 [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +00001/*
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:23 +000017// For access to standard POSIXish features, use WEBRTC_POSIX instead of a
18// more specific macro.
19#if defined(WEBRTC_MAC) || defined(WEBRTC_LINUX) || \
20 defined(WEBRTC_ANDROID)
21#define WEBRTC_POSIX
22#endif
23
24// Processor architecture detection. For more info on what's defined, see:
25// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
26// http://www.agner.org/optimize/calling_conventions.pdf
27// or with gcc, run: "echo | gcc -E -dM -"
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000028#if defined(_M_X64) || defined(__x86_64__)
29#define WEBRTC_ARCH_X86_FAMILY
30#define WEBRTC_ARCH_X86_64
31#define WEBRTC_ARCH_64_BITS
32#define WEBRTC_ARCH_LITTLE_ENDIAN
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000033#elif defined(_M_IX86) || defined(__i386__)
34#define WEBRTC_ARCH_X86_FAMILY
35#define WEBRTC_ARCH_X86
36#define WEBRTC_ARCH_32_BITS
37#define WEBRTC_ARCH_LITTLE_ENDIAN
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000038#elif defined(__ARMEL__)
andrew@webrtc.orgd7e90412013-10-22 10:27:23 +000039// TODO(ajm): We'd prefer to control platform defines here, but this is
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000040// currently provided by the Android makefiles. Commented to avoid duplicate
41// definition warnings.
42//#define WEBRTC_ARCH_ARM
andrew@webrtc.orgd7e90412013-10-22 10:27:23 +000043// TODO(ajm): Chromium uses the following two defines. Should we switch?
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000044//#define WEBRTC_ARCH_ARM_FAMILY
45//#define WEBRTC_ARCH_ARMEL
46#define WEBRTC_ARCH_32_BITS
47#define WEBRTC_ARCH_LITTLE_ENDIAN
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000048#elif defined(__MIPSEL__)
49#define WEBRTC_ARCH_32_BITS
50#define WEBRTC_ARCH_LITTLE_ENDIAN
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000051#else
52#error Please add support for your architecture in typedefs.h
53#endif
54
andrew@webrtc.orgd7e90412013-10-22 10:27:23 +000055#if !(defined(WEBRTC_ARCH_LITTLE_ENDIAN) ^ defined(WEBRTC_ARCH_BIG_ENDIAN))
56#error Define either WEBRTC_ARCH_LITTLE_ENDIAN or WEBRTC_ARCH_BIG_ENDIAN
57#endif
58
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000059#if defined(__SSE2__) || defined(_MSC_VER)
60#define WEBRTC_USE_SSE2
61#endif
62
63#if !defined(_MSC_VER)
64#include <stdint.h>
65#else
66// Define C99 equivalent types, since MSVC doesn't provide stdint.h.
67typedef signed char int8_t;
68typedef signed short int16_t;
69typedef signed int int32_t;
70typedef __int64 int64_t;
71typedef unsigned char uint8_t;
72typedef unsigned short uint16_t;
73typedef unsigned int uint32_t;
74typedef unsigned __int64 uint64_t;
75#endif
76
andrew@webrtc.org13f66d12013-03-25 21:20:38 +000077// Borrowed from Chromium's base/compiler_specific.h.
78// Annotate a virtual method indicating it must be overriding a virtual
79// method in the parent class.
80// Use like:
81// virtual void foo() OVERRIDE;
82#if defined(_MSC_VER)
83#define OVERRIDE override
84#elif defined(__clang__)
pbos@webrtc.orgd7ebd682013-05-08 08:34:34 +000085// Clang defaults to C++03 and warns about using override. Squelch that.
86// Intentionally no push/pop here so all users of OVERRIDE ignore the warning
87// too. This is like passing -Wno-c++11-extensions, except that GCC won't die
88// (because it won't see this pragma).
89#pragma clang diagnostic ignored "-Wc++11-extensions"
andrew@webrtc.org13f66d12013-03-25 21:20:38 +000090#define OVERRIDE override
andrew@webrtc.orgaa9e7682013-12-10 19:20:46 +000091#elif defined(__GNUC__) && __cplusplus >= 201103 && \
92 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700
93// GCC 4.7 supports explicit virtual overrides when C++11 support is enabled.
94#define OVERRIDE override
andrew@webrtc.org13f66d12013-03-25 21:20:38 +000095#else
96#define OVERRIDE
97#endif
98
andrew@webrtc.org221798a2013-10-22 12:50:00 +000099// Annotate a function indicating the caller must examine the return value.
100// Use like:
101// int foo() WARN_UNUSED_RESULT;
andrew@webrtc.org44a8ce52013-10-23 19:11:32 +0000102// TODO(ajm): Hack to avoid multiple definitions until the base/ of webrtc and
103// libjingle are merged.
104#if !defined(WARN_UNUSED_RESULT)
andrew@webrtc.org221798a2013-10-22 12:50:00 +0000105#if defined(__GNUC__)
106#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
107#else
108#define WARN_UNUSED_RESULT
109#endif
andrew@webrtc.org44a8ce52013-10-23 19:11:32 +0000110#endif // WARN_UNUSED_RESULT
andrew@webrtc.org221798a2013-10-22 12:50:00 +0000111
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +0000112#endif // WEBRTC_TYPEDEFS_H_