Cocoa: Use MACH_PORT_NULL for default IOKit port

Looking into the definition of kIOMainPortDefault, the following
description can be found:

When specifying a main port to IOKit functions, the NULL argument
indicates "use the default". This is a synonym for NULL, if you'd
rather use a named constant.

Thus, we do not have to utilize an external symbol for the identifier
of the default main IOKit port, but MACH_PORT_NULL suffice. This
simplifies compatibility between macOS versions as the symbol was
renamed with macOS 12.0.

Fixes #1985
Closes #1994

(cherry picked from commit 544790666b)
This commit is contained in:
Jan Ekström 2021-11-18 22:59:52 +02:00 committed by Camilla Löwy
parent 19543afbfb
commit bec6e7565b
2 changed files with 2 additions and 9 deletions

View File

@ -58,7 +58,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen)
io_service_t service; io_service_t service;
CFDictionaryRef info; CFDictionaryRef info;
if (IOServiceGetMatchingServices(kIOMainPortDefault, if (IOServiceGetMatchingServices(MACH_PORT_NULL,
IOServiceMatching("IODisplayConnect"), IOServiceMatching("IODisplayConnect"),
&it) != 0) &it) != 0)
{ {
@ -231,7 +231,7 @@ static double getFallbackRefreshRate(CGDirectDisplayID displayID)
io_iterator_t it; io_iterator_t it;
io_service_t service; io_service_t service;
if (IOServiceGetMatchingServices(kIOMainPortDefault, if (IOServiceGetMatchingServices(MACH_PORT_NULL,
IOServiceMatching("IOFramebuffer"), IOServiceMatching("IOFramebuffer"),
&it) != 0) &it) != 0)
{ {

View File

@ -41,13 +41,6 @@
typedef void* id; typedef void* id;
#endif #endif
// NOTE: Many Cocoa enum values have been renamed and we need to build across
// SDK versions where one is unavailable or the other deprecated
// We use the newer names in code and these macros to handle compatibility
#if MAC_OS_X_VERSION_MAX_ALLOWED < 120000
#define kIOMainPortDefault kIOMasterPortDefault
#endif
// NOTE: Many Cocoa enum values have been renamed and we need to build across // NOTE: Many Cocoa enum values have been renamed and we need to build across
// SDK versions where one is unavailable or the other deprecated // SDK versions where one is unavailable or the other deprecated
// We use the newer names in code and these macros to handle compatibility // We use the newer names in code and these macros to handle compatibility