From 829511a337283e11af42264dac019d809c02f5ae Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 31 Dec 2024 16:24:00 +1100 Subject: [PATCH] macOS: Use custom declaration for master/main port default --- src/Platform_Posix.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Platform_Posix.c b/src/Platform_Posix.c index 177422fb7..3ee1f3b6e 100644 --- a/src/Platform_Posix.c +++ b/src/Platform_Posix.c @@ -1451,6 +1451,10 @@ static cc_result GetMachineID(cc_uint32* key) { return res; } #elif defined CC_BUILD_MACOS +/* kIOMasterPortDefault is deprecated since macOS 12.0 (replaced with kIOMainPortDefault) */ +/* And since kIOMasterPortDefault is just 0/NULL anyways, just manually declare it */ +static const mach_port_t masterPortDefault = 0; + /* Read kIOPlatformUUIDKey from I/O registry for the key */ static cc_result GetMachineID(cc_uint32* key) { io_registry_entry_t registry; @@ -1458,7 +1462,7 @@ static cc_result GetMachineID(cc_uint32* key) { char tmp[256] = { 0 }; #ifdef kIOPlatformUUIDKey - registry = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/"); + registry = IORegistryEntryFromPath(masterPortDefault, "IOService:/"); if (!registry) return ERR_NOT_SUPPORTED; devID = IORegistryEntryCreateCFProperty(registry, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0); @@ -1466,7 +1470,7 @@ static cc_result GetMachineID(cc_uint32* key) { DecodeMachineID(tmp, String_Length(tmp), key); } #else - registry = IOServiceGetMatchingService(kIOMasterPortDefault, + registry = IOServiceGetMatchingService(masterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); devID = IORegistryEntryCreateCFProperty(registry, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0);