LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

SystemUtils.h

Go to the documentation of this file.
00001 //===- SystemUtils.h - Utilities to do low-level system stuff ---*- C++ -*-===//
00002 // 
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by the LLVM research group and is distributed under
00006 // the University of Illinois Open Source License. See LICENSE.TXT for details.
00007 // 
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains functions used to do a variety of low-level, often
00011 // system-specific, tasks.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_SUPPORT_SYSTEMUTILS_H
00016 #define LLVM_SUPPORT_SYSTEMUTILS_H
00017 
00018 #include <string>
00019 
00020 namespace llvm {
00021 
00022 /// isExecutableFile - This function returns true if the filename specified
00023 /// exists and is executable.
00024 ///
00025 bool isExecutableFile(const std::string &ExeFileName);
00026 
00027 /// isStandardOutAConsole - Return true if we can tell that the standard output
00028 /// stream goes to a terminal window or console.
00029 bool isStandardOutAConsole();
00030 
00031 /// FindExecutable - Find a named executable, giving the argv[0] of program
00032 /// being executed. This allows us to find another LLVM tool if it is built into
00033 /// the same directory, but that directory is neither the current directory, nor
00034 /// in the PATH.  If the executable cannot be found, return an empty string.
00035 /// 
00036 std::string FindExecutable(const std::string &ExeName,
00037                            const std::string &ProgramPath);
00038 
00039 /// RunProgramWithTimeout - This function executes the specified program, with
00040 /// the specified null-terminated argument array, with the stdin/out/err fd's
00041 /// redirected, with a timeout specified by the last argument.  This terminates
00042 /// the calling program if there is an error executing the specified program.
00043 /// It returns the return value of the program, or -1 if a timeout is detected.
00044 ///
00045 int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args,
00046                           const std::string &StdInFile = "",
00047                           const std::string &StdOutFile = "",
00048                           const std::string &StdErrFile = "",
00049                           unsigned NumSeconds = 0);
00050 
00051 /// ExecWait - Execute a program with the given arguments and environment and 
00052 /// wait for it to terminate.
00053 ///
00054 int ExecWait (const char * const argv[], const char * const envp[]);
00055 
00056 /// AllocateRWXMemory - Allocate a slab of memory with read/write/execute
00057 /// permissions.  This is typically used for JIT applications where we want
00058 /// to emit code to the memory then jump to it.  Getting this type of memory
00059 /// is very OS specific.
00060 ///
00061 void *AllocateRWXMemory(unsigned NumBytes);
00062 
00063 } // End llvm namespace
00064 
00065 #endif