Use size_t instead of long to represent memory usage. long is 32 bits
[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 /// Determine if the ostream provided is connected to the std::cout and 
23 /// displayed or not (to a console window). If so, generate a warning message 
24 /// advising against display of bytecode and return true. Otherwise just return
25 /// false
26 /// @brief Check for output written to a console
27 bool CheckBytecodeOutputToConsole(
28   std::ostream* stream_to_check, ///< The stream to be checked
29   bool print_warning = true ///< Control whether warnings are printed
30 );
31
32 /// FindExecutable - Find a named executable, giving the argv[0] of program
33 /// being executed. This allows us to find another LLVM tool if it is built into
34 /// the same directory, but that directory is neither the current directory, nor
35 /// in the PATH.  If the executable cannot be found, return an empty string.
36 /// @brief Find a named executable.
37 sys::Path FindExecutable(const std::string &ExeName,
38                          const std::string &ProgramPath);
39
40 /// RunProgramWithTimeout - This function provides an alternate interface to the
41 /// sys::Program::ExecuteAndWait interface.
42 /// @see sys:Program::ExecuteAndWait
43 inline int RunProgramWithTimeout(const sys::Path &ProgramPath,
44                                 const char **Args,
45                                 const sys::Path &StdInFile,
46                                 const sys::Path &StdOutFile,
47                                 const sys::Path &StdErrFile,
48                                 unsigned NumSeconds = 0) {
49   const sys::Path* redirects[3];
50   redirects[0] = &StdInFile;
51   redirects[1] = &StdOutFile;
52   redirects[2] = &StdErrFile;
53   
54   return 
55     sys::Program::ExecuteAndWait(ProgramPath, Args, 0, redirects, NumSeconds);
56 }
57
58 } // End llvm namespace
59
60 #endif