Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysinfo.cc: Always abort on GetNumCPUs failure #1756

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

thesamesam
Copy link
Contributor

Defines a wrapper function, CheckNumCPUs, which enforces that GetNumCPUs never returns fewer than one CPU. There is no reasonable way to continue if we are unable to identify the number of CPUs.

This is a followup to #1753.

src/sysinfo.cc Outdated Show resolved Hide resolved
src/sysinfo.cc Outdated
if (GetSysctl("hw.ncpu", &num_cpu)) return num_cpu;
fprintf(stderr, "Err: %s\n", strerror(errno));
std::exit(EXIT_FAILURE);
if (GetSysctl("hw.ncpu", &num_cpu)) return CheckNumCPUs(num_cpu);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Stale?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry!

Defines a wrapper function, CheckNumCPUs, which enforces that GetNumCPUs
never returns fewer than one CPU.  There is no reasonable way to
continue if we are unable to identify the number of CPUs.

Signed-off-by: Sam James <sam@gentoo.org>
Copy link
Collaborator

@LebedevRI LebedevRI left a comment

Choose a reason for hiding this comment

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

Cool, thank you!

@LebedevRI LebedevRI merged commit 7f7c96a into google:main Feb 14, 2024
79 of 80 checks passed
@LebedevRI
Copy link
Collaborator

@thesamesam thank you!

@thesamesam
Copy link
Contributor Author

Many thanks!

@thesamesam thesamesam deleted the alpha branch February 14, 2024 17:43
matoro added a commit to matoro/gentoo that referenced this pull request Mar 12, 2024
Accepted upstream already.

See: google/benchmark#1753
See: google/benchmark#1756
Bug: https://bugs.gentoo.org/922877
Signed-off-by: Matoro Mahri <matoro_gentoo@matoro.tk>
gentoo-bot pushed a commit to gentoo/gentoo that referenced this pull request Mar 21, 2024
Accepted upstream already.

See: google/benchmark#1753
See: google/benchmark#1756
Bug: https://bugs.gentoo.org/922877
Signed-off-by: Matoro Mahri <matoro_gentoo@matoro.tk>
Closes: #35729
Signed-off-by: Sam James <sam@gentoo.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants