diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-08-15 01:00:30 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-08-15 01:00:30 +0200 |
commit | c5c938055524b8b7e41ad361b0063f9ed1762044 (patch) | |
tree | 6f2961ef872e33679e02c0d0ef82334381db93f3 /src/corelib/global/qglobal.cpp | |
parent | 8bd48a1c335b404ebbeb7c09c859e0715e6b5cd4 (diff) | |
parent | 0d024bd0a63fa7a741f4f118a3b48806b695594f (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: Id7954ada1f8658d3b1da5e8241a09f2d201a7c56
Diffstat (limited to 'src/corelib/global/qglobal.cpp')
-rw-r--r-- | src/corelib/global/qglobal.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index c0db2c3db6..30a44aeef8 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -88,6 +88,11 @@ # include <sys/systeminfo.h> #endif +#if defined(Q_OS_DARWIN) && QT_HAS_INCLUDE(<IOKit/IOKitLib.h>) +# include <IOKit/IOKitLib.h> +# include <private/qcore_mac_p.h> +#endif + #ifdef Q_OS_UNIX #include <sys/utsname.h> #include <private/qcore_unix_p.h> @@ -2960,20 +2965,19 @@ enum { */ QByteArray QSysInfo::machineUniqueId() { -#ifdef Q_OS_BSD4 +#if defined(Q_OS_DARWIN) && QT_HAS_INCLUDE(<IOKit/IOKitLib.h>) + char uuid[UuidStringLen + 1]; + io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); + QCFString stringRef = (CFStringRef)IORegistryEntryCreateCFProperty(service, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0); + CFStringGetCString(stringRef, uuid, sizeof(uuid), kCFStringEncodingMacRoman); + return QByteArray(uuid); +#elif defined(Q_OS_BSD4) && defined(KERN_HOSTUUID) char uuid[UuidStringLen + 1]; size_t uuidlen = sizeof(uuid); -# ifdef KERN_HOSTUUID int name[] = { CTL_KERN, KERN_HOSTUUID }; if (sysctl(name, sizeof name / sizeof name[0], &uuid, &uuidlen, nullptr, 0) == 0 && uuidlen == sizeof(uuid)) return QByteArray(uuid, uuidlen - 1); - -# else - // Darwin: no fixed value, we need to search by name - if (sysctlbyname("kern.uuid", uuid, &uuidlen, nullptr, 0) == 0 && uuidlen == sizeof(uuid)) - return QByteArray(uuid, uuidlen - 1); -# endif #elif defined(Q_OS_UNIX) // The modern name on Linux is /etc/machine-id, but that path is // unlikely to exist on non-Linux (non-systemd) systems. The old |