summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/posix/HostInfoPosix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Host/posix/HostInfoPosix.cpp')
-rw-r--r--lldb/source/Host/posix/HostInfoPosix.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/lldb/source/Host/posix/HostInfoPosix.cpp b/lldb/source/Host/posix/HostInfoPosix.cpp
new file mode 100644
index 00000000000..ae65e0ef019
--- /dev/null
+++ b/lldb/source/Host/posix/HostInfoPosix.cpp
@@ -0,0 +1,39 @@
+//===-- HostInfoPosix.cpp ---------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/posix/HostInfoPosix.h"
+
+#include <netdb.h>
+#include <limits.h>
+#include <unistd.h>
+
+using namespace lldb_private;
+
+size_t
+HostInfoPosix::GetPageSize()
+{
+ return ::getpagesize();
+}
+
+bool
+HostInfoPosix::GetHostname(std::string &s)
+{
+ char hostname[PATH_MAX];
+ hostname[sizeof(hostname) - 1] = '\0';
+ if (::gethostname(hostname, sizeof(hostname) - 1) == 0)
+ {
+ struct hostent *h = ::gethostbyname(hostname);
+ if (h)
+ s.assign(h->h_name);
+ else
+ s.assign(hostname);
+ return true;
+ }
+ return false;
+}
OpenPOWER on IntegriCloud