Host.inc (276479) | Host.inc (280031) |
---|---|
1 //===- llvm/Support/Unix/Host.inc -------------------------------*- C++ -*-===// | 1//===- llvm/Support/Unix/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 UNIX Host support. 11// 12//===----------------------------------------------------------------------===// 13 14//===----------------------------------------------------------------------===// 15//=== WARNING: Implementation here must contain only generic UNIX code that 16//=== is guaranteed to work on *all* UNIX variants. 17//===----------------------------------------------------------------------===// 18 | 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 UNIX Host support. 11// 12//===----------------------------------------------------------------------===// 13 14//===----------------------------------------------------------------------===// 15//=== WARNING: Implementation here must contain only generic UNIX code that 16//=== is guaranteed to work on *all* UNIX variants. 17//===----------------------------------------------------------------------===// 18 |
19#include "llvm/Config/config.h" 20#include "llvm/ADT/StringRef.h" | |
21#include "Unix.h" | 19#include "Unix.h" |
22#include <sys/utsname.h> | 20#include "llvm/ADT/StringRef.h" 21#include "llvm/Config/config.h" |
23#include <cctype> 24#include <string> | 22#include <cctype> 23#include <string> |
25#include <cstdlib> // ::getenv | 24#include <sys/utsname.h> |
26 27using namespace llvm; 28 | 25 26using namespace llvm; 27 |
29#ifdef __FreeBSD__ 30std::string sys::getDefaultTargetTriple() { 31 return LLVM_DEFAULT_TARGET_TRIPLE; 32} 33#else // __FreeBSD__ | |
34static std::string getOSVersion() { 35 struct utsname info; 36 37 if (uname(&info)) 38 return ""; 39 40 return info.release; 41} 42 43std::string sys::getDefaultTargetTriple() { 44 StringRef TargetTripleString(LLVM_DEFAULT_TARGET_TRIPLE); 45 std::pair<StringRef, StringRef> ArchSplit = TargetTripleString.split('-'); 46 | 28static std::string getOSVersion() { 29 struct utsname info; 30 31 if (uname(&info)) 32 return ""; 33 34 return info.release; 35} 36 37std::string sys::getDefaultTargetTriple() { 38 StringRef TargetTripleString(LLVM_DEFAULT_TARGET_TRIPLE); 39 std::pair<StringRef, StringRef> ArchSplit = TargetTripleString.split('-'); 40 |
47 // Normalize the arch, since the target triple may not actually match the target. | 41 // Normalize the arch, since the target triple may not actually match the 42 // target. |
48 std::string Arch = ArchSplit.first; 49 50 std::string Triple(Arch); 51 Triple += '-'; 52 Triple += ArchSplit.second; 53 54 // Force i<N>86 to i386. 55 if (Triple[0] == 'i' && isdigit(Triple[1]) && --- 5 unchanged lines hidden (view full) --- 61 std::string::size_type DarwinDashIdx = Triple.find("-darwin"); 62 if (DarwinDashIdx != std::string::npos) { 63 Triple.resize(DarwinDashIdx + strlen("-darwin")); 64 Triple += getOSVersion(); 65 } 66 67 return Triple::normalize(Triple); 68} | 43 std::string Arch = ArchSplit.first; 44 45 std::string Triple(Arch); 46 Triple += '-'; 47 Triple += ArchSplit.second; 48 49 // Force i<N>86 to i386. 50 if (Triple[0] == 'i' && isdigit(Triple[1]) && --- 5 unchanged lines hidden (view full) --- 56 std::string::size_type DarwinDashIdx = Triple.find("-darwin"); 57 if (DarwinDashIdx != std::string::npos) { 58 Triple.resize(DarwinDashIdx + strlen("-darwin")); 59 Triple += getOSVersion(); 60 } 61 62 return Triple::normalize(Triple); 63} |
69#endif // __FreeBSD__ | |