2014-09-24 06:44:37 +02:00
|
|
|
//===- llvm/Support/Unix/Host.inc -------------------------------*- C++ -*-===//
|
2009-02-08 22:10:57 +01:00
|
|
|
//
|
2008-10-02 03:17:28 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2009-02-08 22:10:57 +01:00
|
|
|
//
|
2008-10-02 03:17:28 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// 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 "Unix.h"
|
2015-01-14 12:23:27 +01:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/Config/config.h"
|
2010-12-19 21:43:38 +01:00
|
|
|
#include <cctype>
|
2008-10-02 03:17:28 +02:00
|
|
|
#include <string>
|
2015-01-14 12:23:27 +01:00
|
|
|
#include <sys/utsname.h>
|
2008-10-02 03:17:28 +02:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2009-03-31 19:30:15 +02:00
|
|
|
static std::string getOSVersion() {
|
2008-10-02 03:17:28 +02:00
|
|
|
struct utsname info;
|
|
|
|
|
|
|
|
if (uname(&info))
|
|
|
|
return "";
|
|
|
|
|
2009-03-31 19:30:15 +02:00
|
|
|
return info.release;
|
2008-10-02 03:17:28 +02:00
|
|
|
}
|
|
|
|
|
2012-01-05 19:28:46 +01:00
|
|
|
std::string sys::getDefaultTargetTriple() {
|
2015-02-12 16:12:13 +01:00
|
|
|
std::string TargetTripleString(LLVM_DEFAULT_TARGET_TRIPLE);
|
2009-03-31 19:30:15 +02:00
|
|
|
|
|
|
|
// On darwin, we want to update the version to match that of the
|
2011-11-01 22:32:20 +01:00
|
|
|
// target.
|
2015-02-12 16:12:13 +01:00
|
|
|
std::string::size_type DarwinDashIdx = TargetTripleString.find("-darwin");
|
2009-03-31 19:30:15 +02:00
|
|
|
if (DarwinDashIdx != std::string::npos) {
|
2015-02-12 16:12:13 +01:00
|
|
|
TargetTripleString.resize(DarwinDashIdx + strlen("-darwin"));
|
|
|
|
TargetTripleString += getOSVersion();
|
2009-03-31 19:30:15 +02:00
|
|
|
}
|
|
|
|
|
2015-02-12 16:12:13 +01:00
|
|
|
return Triple::normalize(TargetTripleString);
|
2008-10-02 03:17:28 +02:00
|
|
|
}
|