Skip to content

Proper uint64 decrement#852

Merged
chombium merged 1 commit intocloudfoundry:mainfrom
jorbaum:proper-uint64-decrement
Sep 30, 2025
Merged

Proper uint64 decrement#852
chombium merged 1 commit intocloudfoundry:mainfrom
jorbaum:proper-uint64-decrement

Conversation

@jorbaum
Copy link
Copy Markdown
Contributor

@jorbaum jorbaum commented Sep 22, 2025

Description

This decrements the uint64 var in Gauge as per go.dev documentation, see https://pkg.go.dev/sync/atomic#AddUint64 .

Without this change a bunch of unit tests are failing on my ARM-based Mac.

My best guess as to why atomic.AddUint64(&m.value, toUint64(-value, 2)) had worked before is that toUint64(-value, 2) produces the same result as ^uint64(toUint64(value, 2)-1) on some CPU architectures.

Alternative to this change one may also consider the "less error-prone" Uint64.Add function (according to documentation) that has been added to atomic in the meantime.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Testing performed?

  • Unit tests
  • Integration tests
  • Acceptance tests

Checklist:

  • This PR is being made against the main branch, or relevant version branch
  • I have made corresponding changes to the documentation
  • I have added testing for my changes

This decrements the uint64 var like documentation states it, see
https://pkg.go.dev/sync/atomic#AddUint64
Copy link
Copy Markdown
Contributor

@chombium chombium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@github-project-automation github-project-automation Bot moved this from Inbox to Pending Merge | Prioritized in Application Runtime Platform Working Group Sep 30, 2025
@chombium chombium merged commit fbf6da3 into cloudfoundry:main Sep 30, 2025
5 checks passed
@github-project-automation github-project-automation Bot moved this from Pending Merge | Prioritized to Done in Application Runtime Platform Working Group Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants