diff options
author | perkj@webrtc.org <perkj@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-05-13 08:15:48 +0000 |
---|---|---|
committer | perkj@webrtc.org <perkj@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-05-13 08:15:48 +0000 |
commit | e9a604accd54ab14dbf98f99ccdcf3ae1c54d27c (patch) | |
tree | 184b2b5550237373580acbeb8861c833e6027df9 /webrtc/base/safe_conversions.h | |
parent | 3a5825909d24ec39112a8c882a8060ae745929a7 (diff) | |
download | webrtc-e9a604accd54ab14dbf98f99ccdcf3ae1c54d27c.tar.gz |
Revert 6107 "Adds a modified copy of talk/base to webrtc/base. I..."
This breaks Chromium FYI builds and prevent roll of webrtc/libjingle to Chrome.
http://chromegw.corp.google.com/i/chromium.webrtc.fyi/builders/Win%20Builder/builds/457
> Adds a modified copy of talk/base to webrtc/base. It is the first step in migrating talk/base to webrtc/base.
>
> BUG=N/A
> R=andrew@webrtc.org, wu@webrtc.org
>
> Review URL: https://webrtc-codereview.appspot.com/12199004
TBR=henrike@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/14479004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@6116 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'webrtc/base/safe_conversions.h')
-rw-r--r-- | webrtc/base/safe_conversions.h | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/webrtc/base/safe_conversions.h b/webrtc/base/safe_conversions.h deleted file mode 100644 index f6cb24e412..0000000000 --- a/webrtc/base/safe_conversions.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2014 The WebRTC Project Authors. All rights reserved. - * - * 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. - */ - -// Borrowed from Chromium's src/base/numerics/safe_conversions.h. - -#ifndef WEBRTC_BASE_SAFE_CONVERSIONS_H_ -#define WEBRTC_BASE_SAFE_CONVERSIONS_H_ - -#include <limits> - -#include "webrtc/base/common.h" -#include "webrtc/base/logging.h" -#include "webrtc/base/safe_conversions_impl.h" - -namespace rtc { - -inline void Check(bool condition) { - if (!condition) { - LOG(LS_ERROR) << "CHECK failed."; - Break(); - // The program should have crashed at this point. - } -} - -// Convenience function that returns true if the supplied value is in range -// for the destination type. -template <typename Dst, typename Src> -inline bool IsValueInRangeForNumericType(Src value) { - return internal::RangeCheck<Dst>(value) == internal::TYPE_VALID; -} - -// checked_cast<> is analogous to static_cast<> for numeric types, -// except that it CHECKs that the specified numeric conversion will not -// overflow or underflow. NaN source will always trigger a CHECK. -template <typename Dst, typename Src> -inline Dst checked_cast(Src value) { - Check(IsValueInRangeForNumericType<Dst>(value)); - return static_cast<Dst>(value); -} - -// saturated_cast<> is analogous to static_cast<> for numeric types, except -// that the specified numeric conversion will saturate rather than overflow or -// underflow. NaN assignment to an integral will trigger a CHECK condition. -template <typename Dst, typename Src> -inline Dst saturated_cast(Src value) { - // Optimization for floating point values, which already saturate. - if (std::numeric_limits<Dst>::is_iec559) - return static_cast<Dst>(value); - - switch (internal::RangeCheck<Dst>(value)) { - case internal::TYPE_VALID: - return static_cast<Dst>(value); - - case internal::TYPE_UNDERFLOW: - return std::numeric_limits<Dst>::min(); - - case internal::TYPE_OVERFLOW: - return std::numeric_limits<Dst>::max(); - - // Should fail only on attempting to assign NaN to a saturated integer. - case internal::TYPE_INVALID: - Check(false); - return std::numeric_limits<Dst>::max(); - } - - Check(false); // NOTREACHED(); - return static_cast<Dst>(value); -} - -} // namespace rtc - -#endif // WEBRTC_BASE_SAFE_CONVERSIONS_H_ |