From b5d5d063532934cc018930211ded64313e72d39a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 7 Jul 2014 14:33:56 -0700 Subject: Attempt to add support for Solaris sysinfo call Totally untested. Change-Id: I2c2347a66cb3fcb71d97782090ac628bef0b247f Reviewed-by: Oswald Buddenhagen Reviewed-by: Richard J. Moore Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index fb7bd9fa01..572ee51448 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -85,6 +85,10 @@ # include #endif +#if defined(Q_OS_SOLARIS) +# include +#endif + #ifdef Q_OS_UNIX #include #include @@ -2211,9 +2215,24 @@ QString QSysInfo::currentCpuArchitecture() return QStringLiteral("ia64"); } #elif defined(Q_OS_UNIX) - // we could use detectUnixVersion() above, but we only need a field no other function does + long ret = -1; struct utsname u; - if (uname(&u) != -1) { + +# if defined(Q_OS_SOLARIS) + // We need a special call for Solaris because uname(2) on x86 returns "i86pc" for + // both 32- and 64-bit CPUs. Reference: + // http://docs.oracle.com/cd/E18752_01/html/816-5167/sysinfo-2.html#REFMAN2sysinfo-2 + // http://fxr.watson.org/fxr/source/common/syscall/systeminfo.c?v=OPENSOLARIS + // http://fxr.watson.org/fxr/source/common/conf/param.c?v=OPENSOLARIS;im=10#L530 + if (ret == -1) + ret = sysinfo(SI_ARCHITECTURE_64, u.machine, sizeof u.machine); +# endif + + if (ret == -1) + ret = uname(&u); + + // we could use detectUnixVersion() above, but we only need a field no other function does + if (ret != -1) { // the use of QT_BUILD_INTERNAL here is simply to ensure all branches build // as we don't often build on some of the less common platforms # if defined(Q_PROCESSOR_ARM) || defined(QT_BUILD_INTERNAL) @@ -2232,7 +2251,7 @@ QString QSysInfo::currentCpuArchitecture() return QLatin1String("power"); # endif # if defined(Q_PROCESSOR_SPARC) || defined(QT_BUILD_INTERNAL) - // Solaris psrinfo -v says "sparcv9", but uname -m says "sun4u" + // Solaris sysinfo(2) (above) uses "sparcv9", but uname -m says "sun4u"; // Linux says "sparc64" if (strcmp(u.machine, "sun4u") == 0 || strcmp(u.machine, "sparc64") == 0) return QStringLiteral("sparcv9"); @@ -2244,6 +2263,8 @@ QString QSysInfo::currentCpuArchitecture() if (strlen(u.machine) == 4 && u.machine[0] == 'i' && u.machine[2] == '8' && u.machine[3] == '6') return QStringLiteral("i386"); + if (strcmp(u.machine, "amd64") == 0) // Solaris + return QStringLiteral("x86_64"); # endif return QString::fromLatin1(u.machine); } -- cgit v1.2.3