| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 The Native Client Authors. All rights reserved. | 2 * Copyright 2010 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 // | 7 // |
| 8 // checked_cast.h | 8 // checked_cast.h |
| 9 // | 9 // |
| 10 // A template system, intended to be a drop-in replacement for static_cast<>, | 10 // A template system, intended to be a drop-in replacement for static_cast<>, |
| 11 // which performs compile-time and (if necessary) runtime evaluation of | 11 // which performs compile-time and (if necessary) runtime evaluation of |
| 12 // integral type casts to detect and handle arithmetic overflow errors. | 12 // integral type casts to detect and handle arithmetic overflow errors. |
| 13 // | 13 // |
| 14 #ifndef NATIVE_CLIENT_SRC_INCLUDE_CHECKED_CAST_H_ | 14 #ifndef NATIVE_CLIENT_SRC_INCLUDE_CHECKED_CAST_H_ |
| 15 #define NATIVE_CLIENT_SRC_INCLUDE_CHECKED_CAST_H_ 1 | 15 #define NATIVE_CLIENT_SRC_INCLUDE_CHECKED_CAST_H_ 1 |
| 16 | 16 |
| 17 #include "native_client/src/include/nacl_defines.h" |
| 18 |
| 17 // Windows defines std::min and std::max in a different header | 19 // Windows defines std::min and std::max in a different header |
| 18 // than gcc prior to Visual Studio 2013. | 20 // than gcc prior to Visual Studio 2013. |
| 19 #if NACL_WINDOWS | 21 #if NACL_WINDOWS |
| 20 #include <xutility> | 22 #include <xutility> |
| 21 #endif | 23 #endif |
| 22 | 24 |
| 23 #include <algorithm> | 25 #include <algorithm> |
| 24 #include <limits> | 26 #include <limits> |
| 25 | 27 |
| 26 // TODO(ilewis): remove reference to base as soon as we can get COMPILE_ASSERT | 28 // TODO(ilewis): remove reference to base as soon as we can get COMPILE_ASSERT |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 ::TruncationPolicyAbort<target_t, source_t> | 444 ::TruncationPolicyAbort<target_t, source_t> |
| 443 ::OnTruncate(const source_t&) { | 445 ::OnTruncate(const source_t&) { |
| 444 NaClLog(LOG_FATAL, "Arithmetic overflow"); | 446 NaClLog(LOG_FATAL, "Arithmetic overflow"); |
| 445 | 447 |
| 446 // Unreachable, assuming that LOG_FATAL really is fatal | 448 // Unreachable, assuming that LOG_FATAL really is fatal |
| 447 return 0; | 449 return 0; |
| 448 } | 450 } |
| 449 | 451 |
| 450 | 452 |
| 451 #endif /* NATIVE_CLIENT_SRC_INCLUDE_CHECKED_CAST_H_ */ | 453 #endif /* NATIVE_CLIENT_SRC_INCLUDE_CHECKED_CAST_H_ */ |
| OLD | NEW |