From: Nathan Binkert Date: Mon, 15 Dec 2003 23:24:02 +0000 (-0500) Subject: Add support for getting the hostname X-Git-Tag: m5_1.0_beta2~232 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ce4aba3e54eb69b0902c75de2db1810ed7dcfe6b;p=gem5.git Add support for getting the hostname --HG-- extra : convert_revision : 498a950e574059eac2e3b1969880ecc04cf53f31 --- 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 -#include -#include -#include #include #include #include +#include +#include +#include +#include +#include + +#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) { diff --git a/base/hostinfo.hh b/base/hostinfo.hh index 2293d2b6a..453a1e69a 100644 --- a/base/hostinfo.hh +++ b/base/hostinfo.hh @@ -29,8 +29,12 @@ #ifndef __HOSTINFO_HH__ #define __HOSTINFO_HH__ +#include + #include "sim/host.hh" +std::string &hostname(); + uint64_t procInfo(char *filename, char *target); inline uint64_t memUsage()