KWSys 2013-01-10 (608d6b47)

Extract upstream KWSys using the following shell commands.

$ git archive --prefix=upstream-kwsys/ 608d6b47 | tar x
$ git shortlog --no-merges --abbrev=8 --format='%h %s' fc60c8b8..608d6b47
Rolf Eike Beer (6):
      297758a5 SystemInformation: fix conversion warning
      79ef34ef SystemInformation: fix calling kwsysProcess_WaitForData()
      f1068caf SystemInformation: speed up copying process data
      7dfc27d5 SystemInformation: check CPU vendor and SSE support on OpenBSD
      494d9d7a SystemInformation: get stepping code on Intel Macs
      608d6b47 SystemInformation: determine processor features on Intel Macs

Change-Id: I7f5bc5b7af2bf7d4e5c1ee291c286add0f17a7d5
This commit is contained in:
KWSys Robot 2013-01-10 18:34:34 +01:00 committed by Brad King
parent 495fa24d70
commit 6318834b95
2 changed files with 130 additions and 6 deletions

View File

@ -603,6 +603,13 @@ IF(KWSYS_USE_SystemInformation)
COMPILE_DEFINITIONS KWSYS_SYS_HAS_MPCTL_H=1)
ENDIF()
ENDIF()
IF(CMAKE_SYSTEM MATCHES "BSD")
CHECK_INCLUDE_FILES("machine/cpu.h" KWSYS_SYS_HAS_MACHINE_CPU_H)
IF(KWSYS_SYS_HAS_MACHINE_CPU_H)
SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS KWSYS_SYS_HAS_MACHINE_CPU_H=1)
ENDIF()
ENDIF()
IF(KWSYS_LFS_AVAILABLE AND NOT KWSYS_LFS_DISABLE)
SET(KWSYS_PLATFORM_CXX_TEST_DEFINES -DKWSYS_HAS_LFS=1)
ENDIF()

View File

@ -91,6 +91,10 @@ typedef int siginfo_t;
# include <sys/sysctl.h>
#endif
#if defined(KWSYS_SYS_HAS_MACHINE_CPU_H)
# include <machine/cpu.h>
#endif
#if defined(__DragonFly__)
# include <sys/sysctl.h>
#endif
@ -3026,7 +3030,7 @@ bool SystemInformationImplementation::QueryProcessor()
return false;
}
this->NumberOfPhysicalCPU = c;
this->NumberOfPhysicalCPU = static_cast<unsigned int>(c);
this->NumberOfLogicalCPU = this->NumberOfPhysicalCPU;
return true;
@ -4000,6 +4004,81 @@ bool SystemInformationImplementation::ParseSysCtl()
len = sizeof(value);
err = sysctlbyname("machdep.cpu.model", &value, &len, NULL, 0);
this->ChipID.Model = static_cast< int >( value );
// Chip Stepping
len = sizeof(value);
value = 0;
err = sysctlbyname("machdep.cpu.stepping", &value, &len, NULL, 0);
if (!err)
{
this->ChipID.Revision = static_cast< int >( value );
}
// feature string
char *buf = 0;
size_t allocSize = 128;
err = 0;
len = 0;
// sysctlbyname() will return with err==0 && len==0 if the buffer is too small
while (err == 0 && len == 0)
{
delete[] buf;
allocSize *= 2;
buf = new char[allocSize];
if (!buf)
{
break;
}
buf[0] = ' ';
len = allocSize - 2; // keep space for leading and trailing space
err = sysctlbyname("machdep.cpu.features", buf + 1, &len, NULL, 0);
}
if (!err && buf && len)
{
// now we can match every flags as space + flag + space
buf[len + 1] = ' ';
kwsys_stl::string cpuflags(buf, len + 2);
if ((cpuflags.find(" FPU ")!=kwsys_stl::string::npos))
{
this->Features.HasFPU = true;
}
if ((cpuflags.find(" TSC ")!=kwsys_stl::string::npos))
{
this->Features.HasTSC = true;
}
if ((cpuflags.find(" MMX ")!=kwsys_stl::string::npos))
{
this->Features.HasMMX = true;
}
if ((cpuflags.find(" SSE ")!=kwsys_stl::string::npos))
{
this->Features.HasSSE = true;
}
if ((cpuflags.find(" SSE2 ")!=kwsys_stl::string::npos))
{
this->Features.HasSSE2 = true;
}
if ((cpuflags.find(" APIC ")!=kwsys_stl::string::npos))
{
this->Features.HasAPIC = true;
}
if ((cpuflags.find(" CMOV ")!=kwsys_stl::string::npos))
{
this->Features.HasCMOV = true;
}
if ((cpuflags.find(" MTRR ")!=kwsys_stl::string::npos))
{
this->Features.HasMTRR = true;
}
if ((cpuflags.find(" ACPI ")!=kwsys_stl::string::npos))
{
this->Features.HasACPI = true;
}
}
delete[] buf;
}
// brand string
@ -4059,13 +4138,12 @@ kwsys_stl::string SystemInformationImplementation::RunProcess(kwsys_stl::vector<
char* data = NULL;
int length;
double timeout = 255;
int pipe; // pipe id as returned by kwsysProcess_WaitForData()
while(kwsysProcess_WaitForData(gp,&data,&length,&timeout)) // wait for 1s
while( ( pipe = kwsysProcess_WaitForData(gp,&data,&length,&timeout),
(pipe == kwsysProcess_Pipe_STDOUT || pipe == kwsysProcess_Pipe_STDERR) ) ) // wait for 1s
{
for(int i=0;i<length;i++)
{
buffer += data[i];
}
buffer.append(data, length);
}
kwsysProcess_WaitForExit(gp, 0);
@ -4424,6 +4502,45 @@ bool SystemInformationImplementation::QueryBSDProcessor()
this->CPUSpeedInMHz = (float) k;
#endif
#if defined(CPU_SSE)
ctrl[0] = CTL_MACHDEP;
ctrl[1] = CPU_SSE;
if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0)
{
return false;
}
this->Features.HasSSE = (k > 0);
#endif
#if defined(CPU_SSE2)
ctrl[0] = CTL_MACHDEP;
ctrl[1] = CPU_SSE2;
if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0)
{
return false;
}
this->Features.HasSSE2 = (k > 0);
#endif
#if defined(CPU_CPUVENDOR)
ctrl[0] = CTL_MACHDEP;
ctrl[1] = CPU_CPUVENDOR;
char vbuf[25];
::memset(vbuf, 0, sizeof(vbuf));
sz = sizeof(vbuf) - 1;
if (sysctl(ctrl, 2, vbuf, &sz, NULL, 0) != 0)
{
return false;
}
this->ChipID.Vendor = vbuf;
this->FindManufacturer();
#endif
return true;
#else
return false;