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

Side by Side Diff: src/base/bits.cc

Issue 1952843002: Create TimeBase for time related classes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/base/bits.h" 5 #include "src/base/bits.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/logging.h" 9 #include "src/base/logging.h"
10 10
(...skipping 30 matching lines...) Expand all
41 if (rhs == -1) return -lhs; 41 if (rhs == -1) return -lhs;
42 return lhs / rhs; 42 return lhs / rhs;
43 } 43 }
44 44
45 45
46 int32_t SignedMod32(int32_t lhs, int32_t rhs) { 46 int32_t SignedMod32(int32_t lhs, int32_t rhs) {
47 if (rhs == 0 || rhs == -1) return 0; 47 if (rhs == 0 || rhs == -1) return 0;
48 return lhs % rhs; 48 return lhs % rhs;
49 } 49 }
50 50
51
52 int64_t FromCheckedNumeric(const CheckedNumeric<int64_t> value) {
53 if (value.IsValid())
54 return value.ValueUnsafe();
55
56 // We could return max/min but we don't really expose what the maximum delta
57 // is. Instead, return max/(-max), which is something that clients can reason
58 // about.
59 // TODO(rvargas) crbug.com/332611: don't use internal values.
60 int64_t limit = std::numeric_limits<int64_t>::max();
61 if (value.validity() == internal::RANGE_UNDERFLOW)
62 limit = -limit;
63 return value.ValueOrDefault(limit);
64 }
65
51 } // namespace bits 66 } // namespace bits
52 } // namespace base 67 } // namespace base
53 } // namespace v8 68 } // namespace v8
OLDNEW
« src/base/bits.h ('K') | « src/base/bits.h ('k') | src/base/platform/time.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698