Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CMake
CMake
Commits
e2c756fc
Commit
e2c756fc
authored
Jan 14, 2013
by
Brad King
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'upstream-kwsys' into update-kwsys
parents
6f57a904
4ba0ac7b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
129 additions
and
37 deletions
+129
-37
Source/kwsys/CMakeLists.txt
Source/kwsys/CMakeLists.txt
+16
-0
Source/kwsys/ProcessUNIX.c
Source/kwsys/ProcessUNIX.c
+3
-2
Source/kwsys/SystemInformation.cxx
Source/kwsys/SystemInformation.cxx
+83
-35
Source/kwsys/kwsysPlatformTestsCXX.cxx
Source/kwsys/kwsysPlatformTestsCXX.cxx
+27
-0
No files found.
Source/kwsys/CMakeLists.txt
View file @
e2c756fc
...
...
@@ -574,6 +574,8 @@ IF(KWSYS_USE_SystemTools)
ENDIF
()
IF
(
KWSYS_USE_SystemInformation
)
SET_PROPERTY
(
SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS SIZEOF_VOID_P=
${
CMAKE_SIZEOF_VOID_P
}
)
IF
(
NOT CYGWIN
)
INCLUDE
(
CheckIncludeFiles
)
CHECK_INCLUDE_FILES
(
"sys/types.h;ifaddrs.h"
KWSYS_SYS_HAS_IFADDRS_H
)
...
...
@@ -638,6 +640,20 @@ IF(KWSYS_USE_SystemInformation)
SET_PROPERTY
(
SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS KWSYS_CXX_HAS__ATOI64=1
)
ENDIF
()
IF
(
BORLAND
)
KWSYS_PLATFORM_CXX_TEST
(
KWSYS_CXX_HAS_BORLAND_ASM
"Checking whether Borland CXX compiler supports assembler instructions"
DIRECT
)
IF
(
KWSYS_CXX_HAS_BORLAND_ASM
)
SET_PROPERTY
(
SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS KWSYS_CXX_HAS_BORLAND_ASM=1
)
KWSYS_PLATFORM_CXX_TEST
(
KWSYS_CXX_HAS_BORLAND_ASM_CPUID
"Checking whether Borland CXX compiler supports CPUID assembler instruction"
DIRECT
)
IF
(
KWSYS_CXX_HAS_BORLAND_ASM_CPUID
)
SET_PROPERTY
(
SOURCE SystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS KWSYS_CXX_HAS_BORLAND_ASM_CPUID=1
)
ENDIF
()
ENDIF
()
ENDIF
()
IF
(
KWSYS_USE___INT64
)
SET_PROPERTY
(
SOURCE SystemInformation.cxx testSystemInformation.cxx APPEND PROPERTY
COMPILE_DEFINITIONS KWSYS_USE___INT64=1
)
...
...
Source/kwsys/ProcessUNIX.c
View file @
e2c756fc
...
...
@@ -418,9 +418,10 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command)
parse it. */
newCommands
[
cp
->
NumberOfCommands
]
=
kwsysSystem_Parse_CommandForUnix
(
*
command
,
0
);
if
(
!
newCommands
[
cp
->
NumberOfCommands
])
if
(
!
newCommands
[
cp
->
NumberOfCommands
]
||
!
newCommands
[
cp
->
NumberOfCommands
][
0
])
{
/* Out of memory. */
/* Out of memory
or no command parsed
. */
free
(
newCommands
);
return
0
;
}
...
...
Source/kwsys/SystemInformation.cxx
View file @
e2c756fc
...
...
@@ -202,7 +202,7 @@ typedef struct rlimit ResourceLimitType;
#define USE_CPUID_INTRINSICS 0
#endif
#if USE_ASM_INSTRUCTIONS || USE_CPUID_INTRINSICS
#if USE_ASM_INSTRUCTIONS || USE_CPUID_INTRINSICS
|| defined(KWSYS_CXX_HAS_BORLAND_ASM_CPUID)
# define USE_CPUID 1
#else
# define USE_CPUID 0
...
...
@@ -224,6 +224,7 @@ static bool call_cpuid(int select, int result[4])
return
true
;
#else
int
tmp
[
4
];
#if defined(_MSC_VER)
// Use SEH to determine CPUID presence
__try
{
_asm
{
...
...
@@ -262,7 +263,24 @@ static bool call_cpuid(int select, int result[4])
return
false
;
}
memcpy
(
result
,
tmp
,
sizeof
(
tmp
));
memcpy
(
result
,
tmp
,
sizeof
(
tmp
));
#elif defined(KWSYS_CXX_HAS_BORLAND_ASM_CPUID)
unsigned
int
a
,
b
,
c
,
d
;
__asm
{
mov
EAX
,
select
;
cpuid
mov
a
,
EAX
;
mov
b
,
EBX
;
mov
c
,
ECX
;
mov
d
,
EDX
;
}
result
[
0
]
=
a
;
result
[
1
]
=
b
;
result
[
2
]
=
c
;
result
[
3
]
=
d
;
#endif
// The cpuid instruction succeeded.
return
true
;
#endif
...
...
@@ -432,7 +450,7 @@ protected:
int
CPUCount
();
unsigned
char
LogicalCPUPerPhysicalCPU
();
unsigned
char
GetAPICId
();
unsigned
int
IsHyperThreadingSupported
();
bool
IsHyperThreadingSupported
();
static
LongLong
GetCyclesDifference
(
DELAY_FUNC
,
unsigned
int
);
// For Linux and Cygwin, /proc/cpuinfo formats are slightly different
...
...
@@ -456,7 +474,8 @@ protected:
kwsys_stl
::
string
SysCtlBuffer
;
// For Solaris
bool
QuerySolarisInfo
();
bool
QuerySolarisMemory
();
bool
QuerySolarisProcessor
();
kwsys_stl
::
string
ParseValueFromKStat
(
const
char
*
arguments
);
kwsys_stl
::
string
RunProcess
(
kwsys_stl
::
vector
<
const
char
*>
args
);
...
...
@@ -481,9 +500,11 @@ protected:
//For AIX
bool
QueryAIXMemory
();
bool
QueryProcessorBySysconf
();
bool
QueryProcessor
();
// Evaluate the memory information.
bool
QueryMemoryBySysconf
();
bool
QueryMemory
();
size_t
TotalVirtualMemory
;
size_t
AvailableVirtualMemory
;
...
...
@@ -1287,7 +1308,7 @@ void SystemInformationImplementation::RunCPUCheck()
#elif defined(__APPLE__)
this
->
ParseSysCtl
();
#elif defined (__SVR4) && defined (__sun)
this
->
QuerySolaris
Info
();
this
->
QuerySolaris
Processor
();
#elif defined(__HAIKU__)
this
->
QueryHaikuInfo
();
#elif defined(__QNX__)
...
...
@@ -1313,7 +1334,7 @@ void SystemInformationImplementation::RunMemoryCheck()
#if defined(__APPLE__)
this
->
ParseSysCtl
();
#elif defined (__SVR4) && defined (__sun)
this
->
QuerySolaris
Info
();
this
->
QuerySolaris
Memory
();
#elif defined(__HAIKU__)
this
->
QueryHaikuInfo
();
#elif defined(__QNX__)
...
...
@@ -3016,7 +3037,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
return
true
;
}
bool
SystemInformationImplementation
::
QueryProcessor
()
bool
SystemInformationImplementation
::
QueryProcessor
BySysconf
()
{
#if defined(_SC_NPROC_ONLN) && !defined(_SC_NPROCESSORS_ONLN)
// IRIX names this slightly different
...
...
@@ -3039,6 +3060,11 @@ bool SystemInformationImplementation::QueryProcessor()
#endif
}
bool
SystemInformationImplementation
::
QueryProcessor
()
{
return
this
->
QueryProcessorBySysconf
();
}
/**
Get total system RAM in units of KiB.
*/
...
...
@@ -3559,8 +3585,7 @@ bool SystemInformationImplementation::QueryAIXMemory()
#endif
}
/** Query for the memory status */
bool
SystemInformationImplementation
::
QueryMemory
()
bool
SystemInformationImplementation
::
QueryMemoryBySysconf
()
{
#if defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)
// Assume the mmap() granularity as returned by _SC_PAGESIZE is also
...
...
@@ -3597,6 +3622,12 @@ bool SystemInformationImplementation::QueryMemory()
#endif
}
/** Query for the memory status */
bool
SystemInformationImplementation
::
QueryMemory
()
{
return
this
->
QueryMemoryBySysconf
();
}
/** */
size_t
SystemInformationImplementation
::
GetTotalVirtualMemory
()
{
...
...
@@ -3729,8 +3760,13 @@ unsigned char SystemInformationImplementation::LogicalCPUPerPhysicalCPU(void)
/** Works only for windows */
unsigned
int
SystemInformationImplementation
::
IsHyperThreadingSupported
()
bool
SystemInformationImplementation
::
IsHyperThreadingSupported
()
{
if
(
this
->
Features
.
ExtendedFeatures
.
SupportsHyperthreading
)
{
return
true
;
}
#if USE_CPUID
int
Regs
[
4
]
=
{
0
,
0
,
0
,
0
},
VendorId
[
4
]
=
{
0
,
0
,
0
,
0
};
...
...
@@ -3748,13 +3784,15 @@ unsigned int SystemInformationImplementation::IsHyperThreadingSupported()
if
(((
Regs
[
0
]
&
FAMILY_ID
)
==
PENTIUM4_ID
)
||
(
Regs
[
0
]
&
EXT_FAMILY_ID
))
{
if
(
VendorId
[
1
]
==
'
uneG
'
)
if
(
VendorId
[
1
]
==
0x756e6547
)
//
'uneG'
{
if
(
VendorId
[
3
]
==
'
Ieni
'
)
if
(
VendorId
[
3
]
==
0x49656e69
)
//
'Ieni'
{
if
(
VendorId
[
2
]
==
'
letn
'
)
if
(
VendorId
[
2
]
==
0x6c65746e
)
//
'letn'
{
return
(
Regs
[
3
]
&
HT_BIT
);
// Genuine Intel with hyper-Threading technology
// Genuine Intel with hyper-Threading technology
this
->
Features
.
ExtendedFeatures
.
SupportsHyperthreading
=
((
Regs
[
3
]
&
HT_BIT
)
!=
0
);
return
this
->
Features
.
ExtendedFeatures
.
SupportsHyperthreading
;
}
}
}
...
...
@@ -4251,16 +4289,40 @@ kwsys_stl::string SystemInformationImplementation::ParseValueFromKStat(const cha
return
value
;
}
/** Querying for system information from Solaris */
bool
SystemInformationImplementation
::
QuerySolaris
Info
()
bool
SystemInformationImplementation
::
QuerySolaris
Memory
()
{
// Parse values
this
->
NumberOfPhysicalCPU
=
static_cast
<
unsigned
int
>
(
atoi
(
this
->
ParseValueFromKStat
(
"-n syste_misc -s ncpus"
).
c_str
()));
this
->
NumberOfLogicalCPU
=
this
->
NumberOfPhysicalCPU
;
this
->
Features
.
ExtendedFeatures
.
LogicalProcessorsPerPhysical
=
1
;
#if defined (__SVR4) && defined (__sun)
// Solaris allows querying this value by sysconf, but if this is
// a 32 bit process on a 64 bit host the returned memory will be
// limited to 4GiB. So if this is a 32 bit process or if the sysconf
// method fails use the kstat interface.
#if SIZEOF_VOID_P == 8
if
(
this
->
QueryMemoryBySysconf
())
{
return
true
;
}
#endif
char
*
tail
;
unsigned
long
totalMemory
=
strtoul
(
this
->
ParseValueFromKStat
(
"-s physmem"
).
c_str
(),
&
tail
,
0
);
this
->
TotalPhysicalMemory
=
totalMemory
/
128
;
return
true
;
#else
return
false
;
#endif
}
bool
SystemInformationImplementation
::
QuerySolarisProcessor
()
{
if
(
!
this
->
QueryProcessorBySysconf
())
{
return
false
;
}
// Parse values
this
->
CPUSpeedInMHz
=
static_cast
<
float
>
(
atoi
(
this
->
ParseValueFromKStat
(
"-s clock_MHz"
).
c_str
()));
// Chip family
...
...
@@ -4277,20 +4339,6 @@ bool SystemInformationImplementation::QuerySolarisInfo()
this
->
FindManufacturer
();
}
// Cache size
this
->
Features
.
L1CacheSize
=
0
;
this
->
Features
.
L2CacheSize
=
0
;
char
*
tail
;
unsigned
long
totalMemory
=
strtoul
(
this
->
ParseValueFromKStat
(
"-s physmem"
).
c_str
(),
&
tail
,
0
);
this
->
TotalPhysicalMemory
=
totalMemory
/
128
;
// Undefined values (for now at least)
this
->
TotalVirtualMemory
=
0
;
this
->
AvailablePhysicalMemory
=
0
;
this
->
AvailableVirtualMemory
=
0
;
return
true
;
}
...
...
Source/kwsys/kwsysPlatformTestsCXX.cxx
View file @
e2c756fc
...
...
@@ -580,3 +580,30 @@ int main()
}
}
#endif
#ifdef TEST_KWSYS_CXX_HAS_BORLAND_ASM
int
main
()
{
int
a
=
1
;
__asm
{
xor
EBX
,
EBX
;
mov
a
,
EBX
;
}
return
a
;
}
#endif
#ifdef TEST_KWSYS_CXX_HAS_BORLAND_ASM_CPUID
int
main
()
{
int
a
=
0
;
__asm
{
xor
EAX
,
EAX
;
cpuid
;
mov
a
,
EAX
;
}
return
a
;
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment