Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
KWSys
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sylvain Joubert
KWSys
Commits
3aca6642
Commit
3aca6642
authored
12 years ago
by
Rolf Eike Beer
Browse files
Options
Downloads
Patches
Plain Diff
SystemInformation: query memory size, CPU count, and CPU speed on BSD
Change-Id: I9d9ed23708dbc1388a04f17cbb9bb88ee6feae30
parent
61bd9b42
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SystemInformation.cxx
+74
-0
74 additions, 0 deletions
SystemInformation.cxx
with
74 additions
and
0 deletions
SystemInformation.cxx
+
74
−
0
View file @
3aca6642
...
@@ -86,6 +86,15 @@ typedef int siginfo_t;
...
@@ -86,6 +86,15 @@ typedef int siginfo_t;
# endif
# endif
#endif
#endif
#if defined(__OpenBSD__) || defined(__NetBSD__)
# include <sys/param.h>
# include <sys/sysctl.h>
#endif
#if defined(__DragonFly__)
# include <sys/sysctl.h>
#endif
#ifdef __APPLE__
#ifdef __APPLE__
# include <sys/sysctl.h>
# include <sys/sysctl.h>
# include <mach/vm_statistics.h>
# include <mach/vm_statistics.h>
...
@@ -448,6 +457,10 @@ protected:
...
@@ -448,6 +457,10 @@ protected:
bool
QueryQNXMemory
();
bool
QueryQNXMemory
();
bool
QueryQNXProcessor
();
bool
QueryQNXProcessor
();
//For OpenBSD, FreeBSD, NetBSD, DragonFly
bool
QueryBSDMemory
();
bool
QueryBSDProcessor
();
// Evaluate the memory information.
// Evaluate the memory information.
int
QueryMemory
();
int
QueryMemory
();
size_t
TotalVirtualMemory
;
size_t
TotalVirtualMemory
;
...
@@ -1257,6 +1270,8 @@ void SystemInformationImplementation::RunCPUCheck()
...
@@ -1257,6 +1270,8 @@ void SystemInformationImplementation::RunCPUCheck()
this
->
QueryHaikuInfo
();
this
->
QueryHaikuInfo
();
#elif defined(__QNX__)
#elif defined(__QNX__)
this
->
QueryQNXProcessor
();
this
->
QueryQNXProcessor
();
#elif defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
this
->
QueryBSDProcessor
();
#else
#else
this
->
RetreiveInformationFromCpuInfoFile
();
this
->
RetreiveInformationFromCpuInfoFile
();
#endif
#endif
...
@@ -1277,6 +1292,8 @@ void SystemInformationImplementation::RunMemoryCheck()
...
@@ -1277,6 +1292,8 @@ void SystemInformationImplementation::RunMemoryCheck()
this
->
QueryHaikuInfo
();
this
->
QueryHaikuInfo
();
#elif defined(__QNX__)
#elif defined(__QNX__)
this
->
QueryQNXMemory
();
this
->
QueryQNXMemory
();
#elif defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
this
->
QueryBSDMemory
();
#else
#else
this
->
QueryMemory
();
this
->
QueryMemory
();
#endif
#endif
...
@@ -4140,6 +4157,31 @@ bool SystemInformationImplementation::QueryQNXMemory()
...
@@ -4140,6 +4157,31 @@ bool SystemInformationImplementation::QueryQNXMemory()
return
false
;
return
false
;
}
}
bool
SystemInformationImplementation
::
QueryBSDMemory
()
{
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
int
ctrl
[
2
]
=
{
CTL_HW
,
HW_PHYSMEM
};
#if defined(HW_PHYSMEM64)
int64_t
k
;
ctrl
[
1
]
=
HW_PHYSMEM64
;
#else
int
k
;
#endif
size_t
sz
=
sizeof
(
k
);
if
(
sysctl
(
ctrl
,
2
,
&
k
,
&
sz
,
NULL
,
0
)
!=
0
)
{
return
false
;
}
this
->
TotalPhysicalMemory
=
k
>>
10
>>
10
;
return
true
;
#else
return
false
;
#endif
}
bool
SystemInformationImplementation
::
QueryQNXProcessor
()
bool
SystemInformationImplementation
::
QueryQNXProcessor
()
{
{
#if defined(__QNX__)
#if defined(__QNX__)
...
@@ -4193,6 +4235,38 @@ bool SystemInformationImplementation::QueryQNXProcessor()
...
@@ -4193,6 +4235,38 @@ bool SystemInformationImplementation::QueryQNXProcessor()
#endif
#endif
}
}
bool
SystemInformationImplementation
::
QueryBSDProcessor
()
{
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
int
k
;
size_t
sz
=
sizeof
(
k
);
int
ctrl
[
2
]
=
{
CTL_HW
,
HW_NCPU
};
if
(
sysctl
(
ctrl
,
2
,
&
k
,
&
sz
,
NULL
,
0
)
!=
0
)
{
return
false
;
}
this
->
NumberOfPhysicalCPU
=
k
;
this
->
NumberOfLogicalCPU
=
this
->
NumberOfPhysicalCPU
;
#if defined(HW_CPUSPEED)
ctrl
[
1
]
=
HW_CPUSPEED
;
if
(
sysctl
(
ctrl
,
2
,
&
k
,
&
sz
,
NULL
,
0
)
!=
0
)
{
return
false
;
}
this
->
CPUSpeedInMHz
=
(
float
)
k
;
#endif
return
true
;
#else
return
false
;
#endif
}
/** Query the operating system information */
/** Query the operating system information */
bool
SystemInformationImplementation
::
QueryOSInformation
()
bool
SystemInformationImplementation
::
QueryOSInformation
()
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment