Added LLVM notice.
[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 SYSTEMUTILS_H
16 #define SYSTEMUTILS_H
17
18 #include <string>
19
20 /// isExecutableFile - This function returns true if the filename specified
21 /// exists and is executable.
22 ///
23 bool isExecutableFile(const std::string &ExeFileName);
24
25 /// FindExecutable - Find a named executable, giving the argv[0] of program
26 /// being executed. This allows us to find another LLVM tool if it is built into
27 /// the same directory, but that directory is neither the current directory, nor
28 /// in the PATH.  If the executable cannot be found, return an empty string.
29 /// 
30 std::string FindExecutable(const std::string &ExeName,
31                            const std::string &ProgramPath);
32
33 /// RunProgramWithTimeout - This function executes the specified program, with
34 /// the specified null-terminated argument array, with the stdin/out/err fd's
35 /// redirected, with a timeout specified on the commandline.  This terminates
36 /// the calling program if there is an error executing the specified program.
37 /// It returns the return value of the program, or -1 if a timeout is detected.
38 ///
39 int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args,
40                           const std::string &StdInFile = "",
41                           const std::string &StdOutFile = "",
42                           const std::string &StdErrFile = "");
43
44 /// ExecWait - Execute a program with the given arguments and environment and 
45 /// wait for it to terminate.
46 ///
47 int ExecWait (const char * const argv[], const char * const envp[]);
48 #endif