Skip to content

Commit a409dbb

Browse files
mvpsonatique
authored andcommitted
macOS: Fix for libusb_get_port_numbers on macOS 26+
macOS 26 has changed port number property name: ``` % diff -u /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/ Frameworks/IOKit.framework/Headers/usb/IOUSBHostFamilyDefinitions.h /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/System/Library/ Frameworks/IOKit.framework/Headers/usb/IOUSBHostFamilyDefinitions.h ... -#define kUSBHostPortPropertyPortNumber "port" +#define kUSBHostPortPropertyPortNumber "usb-port-number" ... ``` Unfortunately, we cannot just use constant `kUSBHostPortPropertyPortNumber` in libusb code because it would mean that the same binary that works on macOS 15 will not work on macOS 26. Solution is to use appropriate string for port number property depending on running OS version. Closes libusb#1700 References libusb#1661
1 parent c9f02b2 commit a409dbb

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

libusb/os/darwin_usb.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,15 @@ static bool get_device_port (io_service_t service, UInt8 *port) {
13091309

13101310
kresult = IORegistryEntryGetParentEntry (service, kIOServicePlane, &parent);
13111311
if (kIOReturnSuccess == kresult) {
1312-
ret = get_ioregistry_value_data (parent, CFSTR("port"), 1, port);
1312+
/*
1313+
macOS 10 to 15 always had port number property as "port".
1314+
macOS 26 has changed it to "usb-port-number".
1315+
For the same binaries to run correctly on both macOS 15 and macOS 26+,
1316+
we have to detect os version at runtime and use correct port name property.
1317+
*/
1318+
uint32_t os_version = get_running_version();
1319+
CFStringRef cfstrPort = os_version < 260000 ? CFSTR("port") : CFSTR("usb-port-number");
1320+
ret = get_ioregistry_value_data (parent, cfstrPort, 1, port);
13131321
IOObjectRelease (parent);
13141322
}
13151323

libusb/version_nano.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define LIBUSB_NANO 11984
1+
#define LIBUSB_NANO 11986

0 commit comments

Comments
 (0)