Add llvm::sys::{osName,osVersion} for retrieving operating system name
[oota-llvm.git] / lib / System / Win32 / Host.inc
1 //===- llvm/System/Win32/Host.inc -------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the Win32 Host support.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "Win32.h"
15 #include <cstdio>
16 #include <string>
17
18 using namespace llvm;
19
20 std::string sys::osName() {
21   return "Windows";
22 }
23
24 std::string sys::osVersion() {
25   OSVERSIONINFO osvi = { 0 };
26   osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
27
28   if (!GetVersionEx(&osvi))
29     return "";
30   
31   char buf[64];
32   sprintf(buf, "%d.%d", osvi.dwMajorVersion, osvi.dwMinorVersion);
33
34   return buf;  
35 }