summaryrefslogtreecommitdiff
path: root/base/hostinfo.cc
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2003-12-15 18:24:02 -0500
committerNathan Binkert <binkertn@umich.edu>2003-12-15 18:24:02 -0500
commitce4aba3e54eb69b0902c75de2db1810ed7dcfe6b (patch)
treeb0e747e920051d0a8600a883266cb4332ab30e0e /base/hostinfo.cc
parentef659565ffcd8927323d068c29f03a4d628c010e (diff)
downloadgem5-ce4aba3e54eb69b0902c75de2db1810ed7dcfe6b.tar.xz
Add support for getting the hostname
--HG-- extra : convert_revision : 498a950e574059eac2e3b1969880ecc04cf53f31
Diffstat (limited to 'base/hostinfo.cc')
-rw-r--r--base/hostinfo.cc29
1 files changed, 25 insertions, 4 deletions
diff --git a/base/hostinfo.cc b/base/hostinfo.cc
index 5efb77356..cb5c04efc 100644
--- a/base/hostinfo.cc
+++ b/base/hostinfo.cc
@@ -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)
{