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

Fix MacOS X <12 build issue and the regression from PR1609 #1612

Closed
wants to merge 2 commits into from

Conversation

fasterit
Copy link
Member

Closes #1611

Thank you to Explorer09 and aestriplex for debugging.

Commit 2e62fae includes some housekeeping:
IOKit is available since MacOS X was born, so remove the guarding. Fix the defines to actually work compiling on MacOS X v11.

Comment on lines +171 to 174
// Since macOS 12.0, IOMasterPort is deprecated and replaced by IOMainPort
#if !defined(MAC_OS_VERSION_12_0) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_12_0)
#define IOMainPort IOMasterPort
#endif
Copy link
Member

Choose a reason for hiding this comment

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

I may be missing something, but AFAICS IOMainPort is used nowhere in the remainder of this file, thus this source/define is unused.

Copy link
Member

Choose a reason for hiding this comment

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

Based on no visible usage in the file apart from this macro definition or anywhere else inside the Darwin platform code …

$ grep -C3 IOMasterPort -R darwin/
darwin/Platform.c-   const double nanos_per_sec = 1e9;
darwin/Platform.c-   Platform_nanosecondsPerSchedulerTick = nanos_per_sec / scheduler_ticks_per_sec;
darwin/Platform.c-
darwin/Platform.c:   // Since macOS 12.0, IOMasterPort is deprecated and replaced by IOMainPort
darwin/Platform.c-   #if !defined(MAC_OS_VERSION_12_0) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_12_0)
darwin/Platform.c:      #define IOMainPort IOMasterPort
darwin/Platform.c-   #endif
darwin/Platform.c-
darwin/Platform.c-   return true;

I propose to apply the following cleanup instead:

Suggested change
// Since macOS 12.0, IOMasterPort is deprecated and replaced by IOMainPort
#if !defined(MAC_OS_VERSION_12_0) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_12_0)
#define IOMainPort IOMasterPort
#endif

Can someone with Darwin please check or point the location this gets used (indirectly)?

Copy link
Member Author

Choose a reason for hiding this comment

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

We have
AC_CHECK_DECLS([IOMainPort], [], [], [[#include <IOKit/IOKitLib.h>]])
AC_CHECK_DECLS([IOMasterPort], [], [], [[#include <IOKit/IOKitLib.h>]])
in configure.ac coming from ed7eac5 . I removed the test for iokit_available as that seems to be true for any OS X 10.x and higher. We can probably prune more cruft. Would be good if somebody that actually uses OS X could check.

@fasterit
Copy link
Member Author

Partially committed as 5954fa0

@BenBE BenBE added code quality ♻️ Code quality enhancement build system 🔧 Affects the build system rather then the user experience MacOS 🍏 MacOS / Darwin related issues labels Feb 21, 2025
fasterit pushed a commit to fasterit/htop that referenced this pull request Feb 21, 2025
@fasterit
Copy link
Member Author

#1614 is the "full prune" alternative to the remainder of this PR

fasterit pushed a commit to fasterit/htop that referenced this pull request Feb 21, 2025
@BenBE BenBE closed this in 6f43442 Feb 21, 2025
@BenBE BenBE closed this in #1614 Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system 🔧 Affects the build system rather then the user experience code quality ♻️ Code quality enhancement MacOS 🍏 MacOS / Darwin related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assertion fail in macOS (#1609 regression)
2 participants