[SERVER-43032] simplify platform/overflow_arithmetic.h Created: 25/Aug/19 Updated: 29/Oct/23 Resolved: 04/Sep/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 4.3 Desired |
| Fix Version/s: | 4.3.1 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Billy Donahue | Assignee: | Billy Donahue |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Sprint: | Dev Tools 2019-08-26, Dev Tools 2019-09-09 | ||||||||
| Participants: | |||||||||
| Description |
|
This header provides overflow-protected versions of multiply, add, and subtract over int64_t and uint64_t types. There are a few problems though. 1) The overload set provided for MSVC is different than the one for GCC/Clang. 2) The names are redundant: E.g.: mongoUnsignedMultiplyOverflow64(...) The "mongo" is already the namespace in which the function appears. All that's needed is something to mean "Multiply" and something to mean "Overflow". 3) Twisty little overloads all different.... The noise in the names makes it hard to tell what's going on, and there are so many overloads that it's hard to get an overall picture of the API. Suggestion: I'm going to make 3 function templates in namespace mongo::overload: `mul`, `add`, `sub`. These match the names in the gcc builtins for these ops. We'll just have the output parameter determine the domain type for the operation. Much easier that way:
|
| Comments |
| Comment by Githook User [ 04/Sep/19 ] |
|
Author: {'name': 'Billy Donahue', 'username': 'BillyDonahue', 'email': 'billy.donahue@mongodb.com'}Message: |
| Comment by Githook User [ 04/Sep/19 ] |
|
Author: {'name': 'Billy Donahue', 'username': 'BillyDonahue', 'email': 'billy.donahue@mongodb.com'}Message: |
| Comment by Billy Donahue [ 28/Aug/19 ] |
|
update for the unit test CR https://mongodbcr.appspot.com/495150001 |
| Comment by Githook User [ 28/Aug/19 ] |
|
Author: {'email': 'billy.donahue@mongodb.com', 'name': 'Billy Donahue', 'username': 'BillyDonahue'}Message: |
| Comment by Billy Donahue [ 25/Aug/19 ] |