HomePhabricator

util: Add integer left shift helpers

Description

util: Add integer left shift helpers

Summary:
The helpers are used in the following commits to increase the safety of
conversions during cache size calculations.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Co-authored-by: stickies-v <stickies-v@protonmail.com>

Notes:

  • This requires some minor adjustments to work with c++17 (see TODO comments)
  • Due to out of orders backports we need to create the overflow.h file.
  • Fuzzers for checked and saturating adds cannot be included here due to these above mentioned out of order backports. They can be added later with 3 additional lines when implemented.

This is a partial backport of core#31483
https://github.com/bitcoin/bitcoin/pull/31483/commits/c03a2795a8e044d17835bbf03de0c64dc7b41da8
https://github.com/bitcoin/bitcoin/pull/31483/commits/d5e2c4a4097c799433cfc5367c61568fad2c784e
Depends on D18579

Test Plan: ninja all check-all bitcoin-fuzzers

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D18580

Details

Provenance
TheCharlatan <seb.kung@gmail.com>Authored on Jan 9 2025, 10:25
PiRKCommitted on Sep 10 2025, 14:58
PiRKPushed on Sep 10 2025, 14:58
Reviewer
Restricted Project
Differential Revision
D18580: util: Add integer left shift helpers
Parents
rABC9d4cbdd3a5f5: [refactor] init: Simplify coinsdb cache calculation
Branches
Unknown
Tags
Unknown