base: Clean up base/hostinfo

General fixes to the style of base/hostinfo.(cc|hh).

Remove unnecessary includes.

Remove signature of private functions from header.

Add documentation.

Remove unnecessary include in sim_events.cc.

Change-Id: I54e1f13231e512d26cf0127cc80256fb5e91bf91
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/41393
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Daniel R. Carvalho
2021-02-13 10:44:01 -03:00
committed by Daniel Carvalho
parent 7ca5ed70e6
commit eb76992dad
3 changed files with 15 additions and 22 deletions

View File

@@ -26,28 +26,20 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "base/hostinfo.hh"
#include <unistd.h>
#ifdef __APPLE__
#include <mach/mach_init.h>
#include <mach/shared_region.h>
#include <mach/task.h>
#endif
#include "base/hostinfo.hh"
#include <cctype>
#include <cerrno>
#include <cmath>
#else
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#endif
#include "base/logging.hh"
#include "base/str.hh"
#include "base/types.hh"
std::string
__get_hostname()
@@ -65,10 +57,11 @@ hostname()
return hostname;
}
#ifndef __APPLE__
uint64_t
procInfo(const char *filename, const char *target)
{
int done = 0;
int done = 0;
char line[80];
char format[80];
long usage;
@@ -82,7 +75,7 @@ procInfo(const char *filename, const char *target)
sscanf(line, format, &usage);
fclose(fp);
return usage ;
return usage;
}
}
}
@@ -92,6 +85,7 @@ procInfo(const char *filename, const char *target)
return 0;
}
#endif
uint64_t
memUsage()

View File

@@ -29,20 +29,20 @@
#ifndef __HOSTINFO_HH__
#define __HOSTINFO_HH__
#include <cstdint>
#include <string>
#include "base/types.hh"
std::string __get_hostname();
/**
* Get the host name for the current machine.
*
* @return The machine's host name.
*/
std::string &hostname();
uint64_t procInfo(const char *filename, const char *target);
/**
* Determine the simulator process' total virtual memory usage.
*
* @return virtual memory usage in kilobytes
* @return Virtual memory usage in kilobytes
*/
uint64_t memUsage();

View File

@@ -45,7 +45,6 @@
#include <string>
#include "base/callback.hh"
#include "base/hostinfo.hh"
#include "sim/eventq.hh"
#include "sim/sim_exit.hh"
#include "sim/stats.hh"