LLVM API Documentation

Host.h

Go to the documentation of this file.
00001 //===- llvm/System/Host.h - Host machine characteristics --------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // Methods for querying the nature of the host machine.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_SYSTEM_HOST_H
00015 #define LLVM_SYSTEM_HOST_H
00016 
00017 #include <string>
00018 
00019 namespace llvm {
00020 namespace sys {
00021 
00022   inline bool isLittleEndianHost() {
00023     union {
00024       int i;
00025       char c;
00026     };
00027     i = 1;
00028     return c;
00029   }
00030 
00031   inline bool isBigEndianHost() {
00032     return !isLittleEndianHost();
00033   }
00034 
00035   /// getHostTriple() - Return the target triple of the running
00036   /// system.
00037   ///
00038   /// The target triple is a string in the format of:
00039   ///   CPU_TYPE-VENDOR-OPERATING_SYSTEM
00040   /// or
00041   ///   CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM
00042   std::string getHostTriple();
00043 
00044 }
00045 }
00046 
00047 #endif