For PR351:
[oota-llvm.git] / include / llvm / Support / SystemUtils.h
1 //===- SystemUtils.h - Utilities to do low-level system stuff ---*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains functions used to do a variety of low-level, often
11 // system-specific, tasks.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_SUPPORT_SYSTEMUTILS_H
16 #define LLVM_SUPPORT_SYSTEMUTILS_H
17
18 #include "llvm/System/Program.h"
19
20 namespace llvm {
21
22 /// isStandardOutAConsole - Return true if we can tell that the standard output
23 /// stream goes to a terminal window or console.
24 bool isStandardOutAConsole();
25
26 /// FindExecutable - Find a named executable, giving the argv[0] of program
27 /// being executed. This allows us to find another LLVM tool if it is built into
28 /// the same directory, but that directory is neither the current directory, nor
29 /// in the PATH.  If the executable cannot be found, return an empty string.
30 /// @brief Find a named executable.
31 sys::Path FindExecutable(const std::string &ExeName,
32                          const std::string &ProgramPath);
33
34 /// RunProgramWithTimeout - This function provides an alternate interface to the
35 /// sys::Program::ExecuteAndWait interface.
36 /// @see sys:Program::ExecuteAndWait
37 inline int llvm::RunProgramWithTimeout(const sys::Path &ProgramPath,
38                                 const char **Args,
39                                 const sys::Path &StdInFile,
40                                 const sys::Path &StdOutFile,
41                                 const sys::Path &StdErrFile,
42                                 unsigned NumSeconds = 0) {
43   const sys::Path* redirects[3];
44   redirects[0] = &StdInFile;
45   redirects[1] = &StdOutFile;
46   redirects[2] = &StdErrFile;
47   
48   return 
49     sys::Program::ExecuteAndWait(ProgramPath, Args, 0, redirects, NumSeconds);
50 }
51
52 } // End llvm namespace
53
54 #endif