Skip to content

MacOS: fix CPU detection, OS version and bitness#125

Open
barracuda156 wants to merge 3 commits intolfreist:mainfrom
barracuda156:macppc
Open

MacOS: fix CPU detection, OS version and bitness#125
barracuda156 wants to merge 3 commits intolfreist:mainfrom
barracuda156:macppc

Conversation

@barracuda156
Copy link
Contributor

@lfreist @Shieldine Hopefully this fixes a part of current issues. RAM detection is still broken.

10.6 PowerPC:

hwinfo

14.7 arm64:

sonoma

_kernel = utils::getSysctlString("kern.ostype", "<unknown name> ");
_kernel.pop_back();
_kernel = _kernel + " " + utils::getSysctlString("kern.osrelease", "<unknown version> ");
_kernel.pop_back();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep those pop_back()s. I put them in specifically to remove the non-printable character that Sysctlstring returns.

Not all terminals show this, but my CLion run does (just did it for the kernel as an example. All other sysctl calls also return this non-printables):

image

Copy link
Contributor Author

@barracuda156 barracuda156 Jul 3, 2025

Choose a reason for hiding this comment

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

Hmm, they seem to have broken output on Sonoma for me. I will try putting them back and see if the same error shows up.

P. S. Is this behavior of sysctl documented or is it a bug? I do not think this should happen or this normally happens.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably the null terminator. This is C-specific - all char arrays must end with a null-terminator

Since the getSysctlString() function simply reads the whole thing, that terminator stays. I guess we could think about just reading the length of the buffer -1 in the function itself instead of manually popping that character.

Copy link
Contributor

Choose a reason for hiding this comment

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

Im not certain about this though. It's a guess

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.

2 participants