aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/System/Host.cpp24
-rw-r--r--lib/System/Unix/Host.inc42
-rw-r--r--lib/System/Win32/Host.inc35
3 files changed, 101 insertions, 0 deletions
diff --git a/lib/System/Host.cpp b/lib/System/Host.cpp
new file mode 100644
index 0000000..fd2d952
--- /dev/null
+++ b/lib/System/Host.cpp
@@ -0,0 +1,24 @@
+//===-- Host.cpp - Implement OS Host Concept --------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This header file implements the operating system Host concept.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/System/Host.h"
+#include "llvm/Config/config.h"
+
+// Include the platform-specific parts of this class.
+#ifdef LLVM_ON_UNIX
+#include "Unix/Host.inc"
+#endif
+#ifdef LLVM_ON_WIN32
+#include "Win32/Host.inc"
+#endif
+
diff --git a/lib/System/Unix/Host.inc b/lib/System/Unix/Host.inc
new file mode 100644
index 0000000..7bee66f
--- /dev/null
+++ b/lib/System/Unix/Host.inc
@@ -0,0 +1,42 @@
+ //===- llvm/System/Unix/Host.inc --------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the UNIX Host support.
+//
+//===----------------------------------------------------------------------===//
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only generic UNIX code that
+//=== is guaranteed to work on *all* UNIX variants.
+//===----------------------------------------------------------------------===//
+
+#include <llvm/Config/config.h>
+#include "Unix.h"
+#include <sys/utsname.h>
+#include <string>
+
+using namespace llvm;
+
+std::string llvm::sys::osName() {
+ struct utsname info;
+
+ if (uname(&info))
+ return "";
+
+ return info.sysname;
+}
+
+std::string llvm::sys::osVersion() {
+ struct utsname info;
+
+ if (uname(&info))
+ return "";
+
+ return info.release;
+}
diff --git a/lib/System/Win32/Host.inc b/lib/System/Win32/Host.inc
new file mode 100644
index 0000000..f105b38
--- /dev/null
+++ b/lib/System/Win32/Host.inc
@@ -0,0 +1,35 @@
+//===- llvm/System/Win32/Host.inc -------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the Win32 Host support.
+//
+//===----------------------------------------------------------------------===//
+
+#include "Win32.h"
+#include <cstdio>
+#include <string>
+
+using namespace llvm;
+
+std::string sys::osName() {
+ return "Windows";
+}
+
+std::string sys::osVersion() {
+ OSVERSIONINFO osvi = { 0 };
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+ if (!GetVersionEx(&osvi))
+ return "";
+
+ char buf[64];
+ sprintf(buf, "%d.%d", osvi.dwMajorVersion, osvi.dwMinorVersion);
+
+ return buf;
+}