[PR #4144] [MERGED] Introduce chromium safe math #25659

Open
opened 2026-01-31 09:10:56 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4144
Author: @miniksa
Created: 1/7/2020
Status: ✅ Merged
Merged: 1/16/2020
Merged by: @undefined

Base: master ← Head: dev/miniksa/math


📝 Commits (8)

  • d6f8470 Bring chromium base numerics into our project. Update NOTICE file as appropriate with license. Register component governance information.
  • 5392961 Add Chromium numerics to all precomps via LibraryIncludes. Add include path to base directory to common pre props.
  • 5464160 Make the entire solution build. Part of the chromium safe math headers conflicts with the min/max definitions provided by minwinbase.h. We usually stomp these out, but some of our projects have more complicated/interesting precomp defines which are hell to detangle (or we would have done it already). To work around, put NOMINMAX at the top of all of these non-unified precomps and reintroduce it at the very bottom for the only two projects that actually make use of it.
  • c4ad1c7 format pass.
  • 79f585a Add maintainer notes.
  • 1984dc7 Merge branch 'master' into dev/miniksa/math
  • da70012 Don't define min/max because 4152 is already in master cleaning up their usages.
  • 735e134 remove duplicate nominmax since 4173 is already merged.

📊 Changes

30 files changed (+3961 additions, -2 deletions)

View changed files

📝 NOTICE.md (+36 -0)
➕ dep/chromium/LICENSE (+27 -0)
➕ dep/chromium/MAINTAINER_README.md (+17 -0)
➕ dep/chromium/base/numerics/BUILD.gn (+28 -0)
➕ dep/chromium/base/numerics/DEPS (+7 -0)
➕ dep/chromium/base/numerics/OWNERS (+5 -0)
➕ dep/chromium/base/numerics/README.md (+409 -0)
➕ dep/chromium/base/numerics/checked_math.h (+393 -0)
➕ dep/chromium/base/numerics/checked_math_impl.h (+567 -0)
➕ dep/chromium/base/numerics/clamped_math.h (+264 -0)
➕ dep/chromium/base/numerics/clamped_math_impl.h (+341 -0)
➕ dep/chromium/base/numerics/math_constants.h (+19 -0)
➕ dep/chromium/base/numerics/ranges.h (+27 -0)
➕ dep/chromium/base/numerics/safe_conversions.h (+358 -0)
➕ dep/chromium/base/numerics/safe_conversions_arm_impl.h (+51 -0)
➕ dep/chromium/base/numerics/safe_conversions_impl.h (+850 -0)
➕ dep/chromium/base/numerics/safe_math.h (+12 -0)
➕ dep/chromium/base/numerics/safe_math_arm_impl.h (+122 -0)
➕ dep/chromium/base/numerics/safe_math_clang_gcc_impl.h (+157 -0)
➕ dep/chromium/base/numerics/safe_math_shared_impl.h (+240 -0)

...and 10 more files

📄 Description

Summary of the Pull Request

PR Checklist

Detailed Description of the Pull Request / Additional comments

  • Can we remove min/max completely or rename it in the two projects where it had to be reintroduced? This is now moved into #4152
  • How many usages of the old safe math are there? 79
  • If not a ton, can we migrate them here or in a follow on PR? This is now moved into #4153

Files with old safe math:

  • TerminalControl: TSFInputControl.cpp
  • TerminalCore: TerminalDispatch.cpp
  • TerminalCore: TerminalSelection.cpp
  • Host: directio.cpp
  • RendererGdi: invalidate.cpp
  • RendererGdi: math.cpp
  • RendererGdi: paint.cpp
  • RendererVt: paint.cpp
  • TerminalAdapter: adaptDispatch.cpp
  • Types: viewport.cpp
  • Types: WindowUiaProviderBase.cpp

Validation Steps Performed


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/4144 **Author:** [@miniksa](https://github.com/miniksa) **Created:** 1/7/2020 **Status:** ✅ Merged **Merged:** 1/16/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/miniksa/math` --- ### 📝 Commits (8) - [`d6f8470`](https://github.com/microsoft/terminal/commit/d6f847090ee3b042b5cab197954af72657741c05) Bring chromium base numerics into our project. Update NOTICE file as appropriate with license. Register component governance information. - [`5392961`](https://github.com/microsoft/terminal/commit/539296104f4837dadc89bcb051620c940fc4152b) Add Chromium numerics to all precomps via LibraryIncludes. Add include path to base directory to common pre props. - [`5464160`](https://github.com/microsoft/terminal/commit/54641605b972d870dcea7009ebaed184c3dc3aa7) Make the entire solution build. Part of the chromium safe math headers conflicts with the min/max definitions provided by minwinbase.h. We usually stomp these out, but some of our projects have more complicated/interesting precomp defines which are hell to detangle (or we would have done it already). To work around, put NOMINMAX at the top of all of these non-unified precomps and reintroduce it at the very bottom for the only two projects that actually make use of it. - [`c4ad1c7`](https://github.com/microsoft/terminal/commit/c4ad1c7656933c8ad93eae59c9e29d8548b9d9d8) format pass. - [`79f585a`](https://github.com/microsoft/terminal/commit/79f585a2775d223d035b59dc800bb64056414f50) Add maintainer notes. - [`1984dc7`](https://github.com/microsoft/terminal/commit/1984dc7cbedfe7e08b74e45e9fb99aa55db21293) Merge branch 'master' into dev/miniksa/math - [`da70012`](https://github.com/microsoft/terminal/commit/da70012333654269237f9389c1a453487e606b24) Don't define min/max because 4152 is already in master cleaning up their usages. - [`735e134`](https://github.com/microsoft/terminal/commit/735e134d2eed4b49df4ceabdd33fc8db345bb5d1) remove duplicate nominmax since 4173 is already merged. ### 📊 Changes **30 files changed** (+3961 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `NOTICE.md` (+36 -0) ➕ `dep/chromium/LICENSE` (+27 -0) ➕ `dep/chromium/MAINTAINER_README.md` (+17 -0) ➕ `dep/chromium/base/numerics/BUILD.gn` (+28 -0) ➕ `dep/chromium/base/numerics/DEPS` (+7 -0) ➕ `dep/chromium/base/numerics/OWNERS` (+5 -0) ➕ `dep/chromium/base/numerics/README.md` (+409 -0) ➕ `dep/chromium/base/numerics/checked_math.h` (+393 -0) ➕ `dep/chromium/base/numerics/checked_math_impl.h` (+567 -0) ➕ `dep/chromium/base/numerics/clamped_math.h` (+264 -0) ➕ `dep/chromium/base/numerics/clamped_math_impl.h` (+341 -0) ➕ `dep/chromium/base/numerics/math_constants.h` (+19 -0) ➕ `dep/chromium/base/numerics/ranges.h` (+27 -0) ➕ `dep/chromium/base/numerics/safe_conversions.h` (+358 -0) ➕ `dep/chromium/base/numerics/safe_conversions_arm_impl.h` (+51 -0) ➕ `dep/chromium/base/numerics/safe_conversions_impl.h` (+850 -0) ➕ `dep/chromium/base/numerics/safe_math.h` (+12 -0) ➕ `dep/chromium/base/numerics/safe_math_arm_impl.h` (+122 -0) ➕ `dep/chromium/base/numerics/safe_math_clang_gcc_impl.h` (+157 -0) ➕ `dep/chromium/base/numerics/safe_math_shared_impl.h` (+240 -0) _...and 10 more files_ </details> ### 📄 Description ## Summary of the Pull Request <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #4013 * [x] I work here. * [x] Existing tests should be OK. Real changes, just adding a lib to use. * [x] Couldn't find any existing docs about intsafe. * [x] Am core contributor. ## Detailed Description of the Pull Request / Additional comments * [x] Can we remove min/max completely or rename it in the two projects where it had to be reintroduced? This is now moved into #4152 * [x] How many usages of the old safe math are there? **79** * [x] If not a ton, can we migrate them here or in a follow on PR? This is now moved into #4153 Files with old safe math: - TerminalControl: TSFInputControl.cpp - TerminalCore: TerminalDispatch.cpp - TerminalCore: TerminalSelection.cpp - Host: directio.cpp - RendererGdi: invalidate.cpp - RendererGdi: math.cpp - RendererGdi: paint.cpp - RendererVt: paint.cpp - TerminalAdapter: adaptDispatch.cpp - Types: viewport.cpp - Types: WindowUiaProviderBase.cpp ## Validation Steps Performed --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:10:56 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25659