Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: webrtc/typedefs.h

Issue 3007253002: Remove typedefs.h from webrtc/ root (part 1)
Patch Set: backwards compatible FALLTHROUGH #define Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/rtc_base/httpbase.cc ('k') | webrtc/video/rtp_video_stream_receiver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 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_ 11 #ifndef WEBRTC_TYPEDEFS_H_
15 #define WEBRTC_TYPEDEFS_H_ 12 #define WEBRTC_TYPEDEFS_H_
16 13
17 // Processor architecture detection. For more info on what's defined, see: 14 // TODO(solenberg): Delete this file once downstream projects have been updated.
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 -"
21 #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
26 #elif defined(__aarch64__)
27 #define WEBRTC_ARCH_ARM_FAMILY
28 #define WEBRTC_ARCH_64_BITS
29 #define WEBRTC_ARCH_LITTLE_ENDIAN
30 #elif defined(_M_IX86) || defined(__i386__)
31 #define WEBRTC_ARCH_X86_FAMILY
32 #define WEBRTC_ARCH_X86
33 #define WEBRTC_ARCH_32_BITS
34 #define WEBRTC_ARCH_LITTLE_ENDIAN
35 #elif defined(__ARMEL__)
36 #define WEBRTC_ARCH_ARM_FAMILY
37 #define WEBRTC_ARCH_32_BITS
38 #define WEBRTC_ARCH_LITTLE_ENDIAN
39 #elif defined(__MIPSEL__)
40 #define WEBRTC_ARCH_MIPS_FAMILY
41 #if defined(__LP64__)
42 #define WEBRTC_ARCH_64_BITS
43 #else
44 #define WEBRTC_ARCH_32_BITS
45 #endif
46 #define WEBRTC_ARCH_LITTLE_ENDIAN
47 #elif defined(__pnacl__)
48 #define WEBRTC_ARCH_32_BITS
49 #define WEBRTC_ARCH_LITTLE_ENDIAN
50 #else
51 #error Please add support for your architecture in typedefs.h
52 #endif
53
54 #if !(defined(WEBRTC_ARCH_LITTLE_ENDIAN) ^ defined(WEBRTC_ARCH_BIG_ENDIAN))
55 #error Define either WEBRTC_ARCH_LITTLE_ENDIAN or WEBRTC_ARCH_BIG_ENDIAN
56 #endif
57
58 // TODO(zhongwei.yao): WEBRTC_CPU_DETECTION is only used in one place; we should
59 // probably just remove it.
60 #if (defined(WEBRTC_ARCH_X86_FAMILY) && !defined(__SSE2__))
61 #define WEBRTC_CPU_DETECTION
62 #endif
63 15
64 #include <stdint.h> 16 #include <stdint.h>
65 17
66 // Annotate a function indicating the caller must examine the return value. 18 #include "webrtc/rtc_base/arch.h"
67 // Use like: 19 #include "webrtc/rtc_base/annotations.h"
68 // int foo() RTC_WARN_UNUSED_RESULT;
69 // To explicitly ignore a result, cast to void.
70 // TODO(kwiberg): Remove when we can use [[nodiscard]] from C++17.
71 #if defined(__clang__)
72 #define RTC_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
73 #elif defined(__GNUC__)
74 // gcc has a __warn_unused_result__ attribute, but you can't quiet it by
75 // casting to void, so we don't use it.
76 #define RTC_WARN_UNUSED_RESULT
77 #else
78 #define RTC_WARN_UNUSED_RESULT
79 #endif
80
81 // Put after a variable that might not be used, to prevent compiler warnings:
82 // int result ATTRIBUTE_UNUSED = DoSomething();
83 // assert(result == 17);
84 // Deprecated since it only works with GCC & clang. See RTC_UNUSED below.
85 // TODO(terelius): Remove.
86 #ifndef ATTRIBUTE_UNUSED
87 #if defined(__GNUC__) || defined(__clang__)
88 #define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
89 #else
90 #define ATTRIBUTE_UNUSED
91 #endif
92 #endif
93
94 // Macro to be used for switch-case fallthrough (required for enabling
95 // -Wimplicit-fallthrough warning on Clang).
96 #ifndef FALLTHROUGH
97 #if defined(__clang__)
98 #define FALLTHROUGH() [[clang::fallthrough]]
99 #else
100 #define FALLTHROUGH() do { } while (0)
101 #endif
102 #endif
103
104 #ifndef NO_RETURN
105 // Annotate a function that will not return control flow to the caller.
106 #if defined(_MSC_VER)
107 #define NO_RETURN __declspec(noreturn)
108 #elif defined(__GNUC__)
109 #define NO_RETURN __attribute__ ((__noreturn__))
110 #else
111 #define NO_RETURN
112 #endif
113 #endif
114
115 // Prevent the compiler from warning about an unused variable. For example:
116 // int result = DoSomething();
117 // assert(result == 17);
118 // RTC_UNUSED(result);
119 // Note: In most cases it is better to remove the unused variable rather than
120 // suppressing the compiler warning.
121 #ifndef RTC_UNUSED
122 #define RTC_UNUSED(x) static_cast<void>(x)
123 #endif // RTC_UNUSED
124 20
125 #endif // WEBRTC_TYPEDEFS_H_ 21 #endif // WEBRTC_TYPEDEFS_H_
OLDNEW
« no previous file with comments | « webrtc/rtc_base/httpbase.cc ('k') | webrtc/video/rtp_video_stream_receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698