Add support for getting the hostname

--HG--
extra : convert_revision : 498a950e574059eac2e3b1969880ecc04cf53f31
This commit is contained in:
Nathan Binkert 2003-12-15 18:24:02 -05:00
parent ef659565ff
commit ce4aba3e54
2 changed files with 29 additions and 4 deletions

View file

@ -26,16 +26,37 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <math.h>
#include <unistd.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include "base/misc.hh"
#include "sim/host.hh"
using namespace std;
string
__get_hostname()
{
char host[256];
if (gethostname(host, sizeof host) == -1)
warn("could not get host name!");
return host;
}
string &
hostname()
{
static string hostname = __get_hostname();
return hostname;
}
uint64_t
procInfo(char *filename, char *target)
{

View file

@ -29,8 +29,12 @@
#ifndef __HOSTINFO_HH__
#define __HOSTINFO_HH__
#include <string>
#include "sim/host.hh"
std::string &hostname();
uint64_t procInfo(char *filename, char *target);
inline uint64_t memUsage()