3c6aa9dd7155bc24b2539ab937b89fcba20a5c76
[oota-llvm.git] / include / llvm / System / Host.h
1 //===- llvm/System/Host.h - Host machine characteristics --------*- 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 // Methods for querying the nature of the host machine.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_SYSTEM_HOST_H
15 #define LLVM_SYSTEM_HOST_H
16
17 #include <string>
18
19 namespace llvm {
20 namespace sys {
21
22   inline bool isLittleEndianHost() {
23     union {
24       int i;
25       char c;
26     };
27     i = 1;
28     return c;
29   }
30
31   inline bool isBigEndianHost() {
32     return !isLittleEndianHost();
33   }
34
35   /// getHostTriple() - Return the target triple of the running
36   /// system.
37   ///
38   /// The target triple is a string in the format of:
39   ///   CPU_TYPE-VENDOR-OPERATING_SYSTEM
40   /// or
41   ///   CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM
42   std::string getHostTriple();
43
44 }
45 }
46
47 #endif