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

Side by Side Diff: webrtc/base/common.h

Issue 2684613002: Delete webrtc/base/common.h (Closed)
Patch Set: Added TODO comment. Created 3 years, 10 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/base/BUILD.gn ('k') | webrtc/base/common.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2004 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 #ifndef WEBRTC_BASE_COMMON_H_ // NOLINT
12 #define WEBRTC_BASE_COMMON_H_
13
14 #include "webrtc/base/constructormagic.h"
15
16 #if defined(_MSC_VER)
17 // warning C4355: 'this' : used in base member initializer list
18 #pragma warning(disable:4355)
19 #endif
20
21 //////////////////////////////////////////////////////////////////////
22 // General Utilities
23 //////////////////////////////////////////////////////////////////////
24
25 #ifndef RTC_UNUSED
26 #define RTC_UNUSED(x) RtcUnused(static_cast<const void*>(&x))
27 #define RTC_UNUSED2(x, y) RtcUnused(static_cast<const void*>(&x)); \
28 RtcUnused(static_cast<const void*>(&y))
29 #define RTC_UNUSED3(x, y, z) RtcUnused(static_cast<const void*>(&x)); \
30 RtcUnused(static_cast<const void*>(&y)); \
31 RtcUnused(static_cast<const void*>(&z))
32 #define RTC_UNUSED4(x, y, z, a) RtcUnused(static_cast<const void*>(&x)); \
33 RtcUnused(static_cast<const void*>(&y)); \
34 RtcUnused(static_cast<const void*>(&z)); \
35 RtcUnused(static_cast<const void*>(&a))
36 #define RTC_UNUSED5(x, y, z, a, b) RtcUnused(static_cast<const void*>(&x)); \
37 RtcUnused(static_cast<const void*>(&y)); \
38 RtcUnused(static_cast<const void*>(&z)); \
39 RtcUnused(static_cast<const void*>(&a)); \
40 RtcUnused(static_cast<const void*>(&b))
41 inline void RtcUnused(const void*) {}
42 #endif // RTC_UNUSED
43
44 #if !defined(WEBRTC_WIN)
45
46 #ifndef strnicmp
47 #define strnicmp(x, y, n) strncasecmp(x, y, n)
48 #endif
49
50 #ifndef stricmp
51 #define stricmp(x, y) strcasecmp(x, y)
52 #endif
53
54 #endif // !defined(WEBRTC_WIN)
55
56 /////////////////////////////////////////////////////////////////////////////
57 // Assertions
58 /////////////////////////////////////////////////////////////////////////////
59
60 #ifndef ENABLE_DEBUG
61 #if !defined(NDEBUG)
62 #define ENABLE_DEBUG 1
63 #else
64 #define ENABLE_DEBUG 0
65 #endif
66 #endif // !defined(ENABLE_DEBUG)
67
68 // Even for release builds, allow for the override of LogAssert. Though no
69 // macro is provided, this can still be used for explicit runtime asserts
70 // and allow applications to override the assert behavior.
71
72 namespace rtc {
73
74
75 // If a debugger is attached, triggers a debugger breakpoint. If a debugger is
76 // not attached, forces program termination.
77 void Break();
78
79 // LogAssert writes information about an assertion to the log. It's called by
80 // Assert (and from the ASSERT macro in debug mode) before any other action
81 // is taken (e.g. breaking the debugger, abort()ing, etc.).
82 void LogAssert(const char* function, const char* file, int line,
83 const char* expression);
84
85 typedef void (*AssertLogger)(const char* function,
86 const char* file,
87 int line,
88 const char* expression);
89
90 // Sets a custom assert logger to be used instead of the default LogAssert
91 // behavior. To clear the custom assert logger, pass NULL for |logger| and the
92 // default behavior will be restored. Only one custom assert logger can be set
93 // at a time, so this should generally be set during application startup and
94 // only by one component.
95 void SetCustomAssertLogger(AssertLogger logger);
96
97 bool IsOdd(int n);
98
99 bool IsEven(int n);
100
101 } // namespace rtc
102
103 #if ENABLE_DEBUG
104
105 namespace rtc {
106
107 inline bool Assert(bool result, const char* function, const char* file,
108 int line, const char* expression) {
109 if (!result) {
110 LogAssert(function, file, line, expression);
111 Break();
112 }
113 return result;
114 }
115
116 // Same as Assert above, but does not call Break(). Used in assert macros
117 // that implement their own breaking.
118 inline bool AssertNoBreak(bool result, const char* function, const char* file,
119 int line, const char* expression) {
120 if (!result)
121 LogAssert(function, file, line, expression);
122 return result;
123 }
124
125 } // namespace rtc
126
127 #if defined(_MSC_VER) && _MSC_VER < 1300
128 #define __FUNCTION__ ""
129 #endif
130
131 #ifndef ASSERT
132 #if defined(WIN32)
133 // Using debugbreak() inline on Windows directly in the ASSERT macro, has the
134 // benefit of breaking exactly where the failing expression is and not two
135 // calls up the stack.
136 #define ASSERT(x) \
137 (rtc::AssertNoBreak((x), __FUNCTION__, __FILE__, __LINE__, #x) ? \
138 (void)(1) : __debugbreak())
139 #else
140 #define ASSERT(x) \
141 (void)rtc::Assert((x), __FUNCTION__, __FILE__, __LINE__, #x)
142 #endif
143 #endif
144
145 #ifndef VERIFY
146 #if defined(WIN32)
147 #define VERIFY(x) \
148 (rtc::AssertNoBreak((x), __FUNCTION__, __FILE__, __LINE__, #x) ? \
149 true : (__debugbreak(), false))
150 #else
151 #define VERIFY(x) rtc::Assert((x), __FUNCTION__, __FILE__, __LINE__, #x)
152 #endif
153 #endif
154
155 #else // !ENABLE_DEBUG
156
157 namespace rtc {
158
159 inline bool ImplicitCastToBool(bool result) { return result; }
160
161 } // namespace rtc
162
163 #ifndef ASSERT
164 #define ASSERT(x) (void)0
165 #endif
166
167 #ifndef VERIFY
168 #define VERIFY(x) rtc::ImplicitCastToBool(x)
169 #endif
170
171 #endif // !ENABLE_DEBUG
172
173 #define COMPILE_TIME_ASSERT(expr) char CTA_UNIQUE_NAME[expr]
174 #define CTA_UNIQUE_NAME CTA_MAKE_NAME(__LINE__)
175 #define CTA_MAKE_NAME(line) CTA_MAKE_NAME2(line)
176 #define CTA_MAKE_NAME2(line) constraint_ ## line
177
178 // Forces compiler to inline, even against its better judgement. Use wisely.
179 #if defined(__GNUC__)
180 #define FORCE_INLINE __attribute__ ((__always_inline__))
181 #elif defined(WEBRTC_WIN)
182 #define FORCE_INLINE __forceinline
183 #else
184 #define FORCE_INLINE
185 #endif
186
187 // Annotate a function indicating the caller must examine the return value.
188 // Use like:
189 // int foo() WARN_UNUSED_RESULT;
190 // To explicitly ignore a result, see |ignore_result()| in <base/basictypes.h>.
191 // TODO(ajm): Hack to avoid multiple definitions until the base/ of webrtc and
192 // libjingle are merged.
193 #if !defined(WARN_UNUSED_RESULT)
194 #if defined(__GNUC__) || defined(__clang__)
195 #define WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
196 #else
197 #define WARN_UNUSED_RESULT
198 #endif
199 #endif // WARN_UNUSED_RESULT
200
201 #endif // WEBRTC_BASE_COMMON_H_ // NOLINT
OLDNEW
« no previous file with comments | « webrtc/base/BUILD.gn ('k') | webrtc/base/common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698