LLVM  3.7.0
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
llvm::sys Namespace Reference

Namespaces

 fs
 
 locale
 
 path
 
 unicode
 
 windows
 

Classes

class  InitializeCOMRAII
 
class  DynamicLibrary
 This class provides a portable interface to dynamic libraries which also might be known as shared libraries, shared objects, dynamic shared objects, or dynamic link libraries. More...
 
class  MemoryBlock
 This class encapsulates the notion of a memory block which has an address and a size. More...
 
class  Memory
 This class provides various memory handling functions that manipulate MemoryBlock instances. More...
 
class  MutexImpl
 Platform agnostic Mutex class. More...
 
class  SmartMutex
 SmartMutex - A mutex with a compile time constant parameter that indicates whether this mutex should become a no-op when we're not running in multithreaded mode. More...
 
class  SmartScopedLock
 
class  Process
 A collection of legacy interfaces for querying information about the current executing process. More...
 
struct  ProcessInfo
 This is the OS-specific separator for PATH like environment variables: More...
 
class  RWMutexImpl
 Platform agnostic RWMutex class. More...
 
class  SmartRWMutex
 SmartMutex - An R/W mutex with a compile time constant parameter that indicates whether this mutex should become a no-op when we're not running in multithreaded mode. More...
 
struct  SmartScopedReader
 ScopedReader - RAII acquisition of a reader lock. More...
 
struct  SmartScopedWriter
 ScopedWriter - RAII acquisition of a writer lock. More...
 
class  ThreadLocalImpl
 
class  ThreadLocal
 ThreadLocal - A class used to abstract thread-local storage. More...
 
class  TimeValue
 This class is used where a precise fixed point in time is required. More...
 
struct  UnicodeCharRange
 Represents a closed range of Unicode code points [Lower, Upper]. More...
 
class  UnicodeCharSet
 Holds a reference to an ordered array of UnicodeCharRange and allows to quickly check if a code point is contained in the set represented by this array. More...
 
class  Watchdog
 This class provides an abstraction for a timeout around an operation that must complete in a given amount of time. More...
 

Typedefs

typedef uint32_t cas_flag
 
typedef SmartMutex< falseMutex
 Mutex - A standard, always enforced mutex. More...
 
typedef SmartScopedLock< falseScopedLock
 
typedef SmartRWMutex< falseRWMutex
 
typedef SmartScopedReader< falseScopedReader
 
typedef SmartScopedWriter< falseScopedWriter
 

Enumerations

enum  COMThreadingMode { COMThreadingMode::SingleThreaded, COMThreadingMode::MultiThreaded }
 
enum  WindowsEncodingMethod { WEM_UTF8, WEM_CurrentCodePage, WEM_UTF16 }
 File encoding options when writing contents that a non-UTF8 tool will read (on Windows systems). More...
 

Functions

void MemoryFence ()
 
cas_flag CompareAndSwap (volatile cas_flag *ptr, cas_flag new_value, cas_flag old_value)
 
cas_flag AtomicIncrement (volatile cas_flag *ptr)
 
cas_flag AtomicDecrement (volatile cas_flag *ptr)
 
cas_flag AtomicAdd (volatile cas_flag *ptr, cas_flag val)
 
cas_flag AtomicMul (volatile cas_flag *ptr, cas_flag val)
 
cas_flag AtomicDiv (volatile cas_flag *ptr, cas_flag val)
 
std::string StrError ()
 Returns a string representation of the errno value, using whatever thread-safe variant of strerror() is available. More...
 
std::string StrError (int errnum)
 Like the no-argument version above, but uses errnum instead of errno. More...
 
std::string getDefaultTargetTriple ()
 getDefaultTargetTriple() - Return the default target triple the compiler has been configured to produce code for. More...
 
std::string getProcessTriple ()
 getProcessTriple() - Return an appropriate target triple for generating code to be loaded into the current process, e.g. More...
 
StringRef getHostCPUName ()
 getHostCPUName - Get the LLVM name for the host CPU. More...
 
bool getHostCPUFeatures (StringMap< bool > &Features)
 getHostCPUFeatures - Get the LLVM names for the host CPU features. More...
 
ErrorOr< std::string > findProgramByName (StringRef Name, ArrayRef< StringRef > Paths=ArrayRef< StringRef >())
 Find the first executable file Name in Paths. More...
 
std::error_code ChangeStdinToBinary ()
 
std::error_code ChangeStdoutToBinary ()
 
int ExecuteAndWait (StringRef Program, const char **args, const char **env=nullptr, const StringRef **redirects=nullptr, unsigned secondsToWait=0, unsigned memoryLimit=0, std::string *ErrMsg=nullptr, bool *ExecutionFailed=nullptr)
 This function executes the program using the arguments provided. More...
 
ProcessInfo ExecuteNoWait (StringRef Program, const char **args, const char **env=nullptr, const StringRef **redirects=nullptr, unsigned memoryLimit=0, std::string *ErrMsg=nullptr, bool *ExecutionFailed=nullptr)
 Similar to ExecuteAndWait, but returns immediately. More...
 
bool argumentsFitWithinSystemLimits (ArrayRef< const char * > Args)
 Return true if the given arguments fit within system-specific argument length limits. More...
 
std::error_code writeFileWithEncoding (StringRef FileName, StringRef Contents, WindowsEncodingMethod Encoding=WEM_UTF8)
 Saves the UTF8-encoded contents string into the file FileName using a specific encoding. More...
 
ProcessInfo Wait (const ProcessInfo &PI, unsigned SecondsToWait, bool WaitUntilTerminates, std::string *ErrMsg=nullptr)
 This function waits for the process specified by PI to finish. More...
 
void RunInterruptHandlers ()
 This function runs all the registered interrupt handlers, including the removal of files registered by RemoveFileOnSignal. More...
 
bool RemoveFileOnSignal (StringRef Filename, std::string *ErrMsg=nullptr)
 This function registers signal handlers to ensure that if a signal gets delivered that the named file is removed. More...
 
void DontRemoveFileOnSignal (StringRef Filename)
 This function removes a file from the list of files to be removed on signal delivery. More...
 
void PrintStackTraceOnErrorSignal (bool DisableCrashReporting=false)
 When an error signal (such as SIBABRT or SIGSEGV) is delivered to the process, print a stack trace and then exit. More...
 
void DisableSystemDialogsOnCrash ()
 Disable all system dialog boxes that appear when the process crashes. More...
 
void PrintStackTrace (raw_ostream &OS)
 Print the stack trace using the given raw_ostream object. More...
 
void AddSignalHandler (void(*FnPtr)(void *), void *Cookie)
 AddSignalHandler - Add a function to be called when an abort/kill signal is delivered to the process. More...
 
void SetInterruptFunction (void(*IF)())
 This function registers a function to be called when the user "interrupts" the program (typically by pressing ctrl-c). More...
 
uint16_t SwapByteOrder_16 (uint16_t value)
 SwapByteOrder_16 - This function returns a byte-swapped representation of the 16-bit argument. More...
 
uint32_t SwapByteOrder_32 (uint32_t value)
 SwapByteOrder_32 - This function returns a byte-swapped representation of the 32-bit argument. More...
 
uint64_t SwapByteOrder_64 (uint64_t value)
 SwapByteOrder_64 - This function returns a byte-swapped representation of the 64-bit argument. More...
 
unsigned char getSwappedBytes (unsigned char C)
 
signed char getSwappedBytes (signed char C)
 
char getSwappedBytes (char C)
 
unsigned short getSwappedBytes (unsigned short C)
 
signed short getSwappedBytes (signed short C)
 
unsigned int getSwappedBytes (unsigned int C)
 
signed int getSwappedBytes (signed int C)
 
unsigned long getSwappedBytes (unsigned long C)
 
signed long getSwappedBytes (signed long C)
 
unsigned long long getSwappedBytes (unsigned long long C)
 
signed long long getSwappedBytes (signed long long C)
 
float getSwappedBytes (float C)
 
double getSwappedBytes (double C)
 
template<typename T >
void swapByteOrder (T &Value)
 
TimeValue operator+ (const TimeValue &tv1, const TimeValue &tv2)
 
TimeValue operator- (const TimeValue &tv1, const TimeValue &tv2)
 
bool operator< (uint32_t Value, UnicodeCharRange Range)
 
bool operator< (UnicodeCharRange Range, uint32_t Value)
 
bool RunningOnValgrind ()
 
void ValgrindDiscardTranslations (const void *Addr, size_t Len)
 

Variables

static const bool IsBigEndianHost = false
 
static const bool IsLittleEndianHost = !IsBigEndianHost
 

Typedef Documentation

typedef uint32_t llvm::sys::cas_flag

Definition at line 26 of file Atomic.h.

Mutex - A standard, always enforced mutex.

Definition at line 138 of file Mutex.h.

Definition at line 143 of file RWMutex.h.

Definition at line 154 of file Mutex.h.

Definition at line 158 of file RWMutex.h.

Definition at line 173 of file RWMutex.h.

Enumeration Type Documentation

Enumerator
SingleThreaded 
MultiThreaded 

Definition at line 21 of file COM.h.

File encoding options when writing contents that a non-UTF8 tool will read (on Windows systems).

For UNIX, we always use UTF-8.

Enumerator
WEM_UTF8 

UTF-8 is the LLVM native encoding, being the same as "do not perform encoding conversion".

WEM_CurrentCodePage 
WEM_UTF16 

Definition at line 138 of file Program.h.

Function Documentation

void llvm::sys::AddSignalHandler ( void(*)(void *)  FnPtr,
void *  Cookie 
)

AddSignalHandler - Add a function to be called when an abort/kill signal is delivered to the process.

The handler can have a cookie passed to it to identify what instance of the handler it is.

Referenced by llvm::dbgs(), and RegisterCrashPrinter().

bool llvm::sys::argumentsFitWithinSystemLimits ( ArrayRef< const char * >  Args)

Return true if the given arguments fit within system-specific argument length limits.

cas_flag llvm::sys::AtomicAdd ( volatile cas_flag *  ptr,
cas_flag  val 
)
cas_flag llvm::sys::AtomicDecrement ( volatile cas_flag *  ptr)
cas_flag llvm::sys::AtomicDiv ( volatile cas_flag *  ptr,
cas_flag  val 
)
cas_flag llvm::sys::AtomicIncrement ( volatile cas_flag *  ptr)
cas_flag llvm::sys::AtomicMul ( volatile cas_flag *  ptr,
cas_flag  val 
)
std::error_code llvm::sys::ChangeStdinToBinary ( )
std::error_code llvm::sys::ChangeStdoutToBinary ( )

Referenced by getFD().

cas_flag llvm::sys::CompareAndSwap ( volatile cas_flag *  ptr,
cas_flag  new_value,
cas_flag  old_value 
)
void llvm::sys::DisableSystemDialogsOnCrash ( )

Disable all system dialog boxes that appear when the process crashes.

void llvm::sys::DontRemoveFileOnSignal ( StringRef  Filename)

This function removes a file from the list of files to be removed on signal delivery.

Referenced by llvm::LockFileManager::~LockFileManager().

int llvm::sys::ExecuteAndWait ( StringRef  Program,
const char **  args,
const char **  env = nullptr,
const StringRef **  redirects = nullptr,
unsigned  secondsToWait = 0,
unsigned  memoryLimit = 0,
std::string *  ErrMsg = nullptr,
bool ExecutionFailed = nullptr 
)

This function executes the program using the arguments provided.

The invoked program will inherit the stdin, stdout, and stderr file descriptors, the environment and other configuration settings of the invoking program. This function waits for the program to finish, so should be avoided in library functions that aren't expected to block. Consider using ExecuteNoWait() instead.

Returns
an integer result code indicating the status of the program. A zero or positive value indicates the result code of the program. -1 indicates failure to execute -2 indicates a crash during execution or timeout
Parameters
ProgramPath of the program to be executed. It is
argspresumed this is the result of the findProgramByName method. A vector of strings that are passed to the program. The first element should be the name of the program. The list must be terminated by a null char* entry.
envAn optional vector of strings to use for the program's environment. If not provided, the current program's environment will be used.
redirectsAn optional array of pointers to paths. If the array is null, no redirection is done. The array should have a size of at least three. The inferior process's stdin(0), stdout(1), and stderr(2) will be redirected to the corresponding paths. When an empty path is passed in, the corresponding file descriptor will be disconnected (ie, /dev/null'd) in a portable way.
secondsToWaitIf non-zero, this specifies the amount of time to wait for the child process to exit. If the time expires, the child is killed and this call returns. If zero, this function will wait until the child finishes or forever if it doesn't.
memoryLimitIf non-zero, this specifies max. amount of memory can be allocated by process. If memory usage will be higher limit, the child is killed and this call returns. If zero
  • no memory limit.
ErrMsgIf non-zero, provides a pointer to a string instance in which error messages will be returned. If the string is non-empty upon return an error occurred while invoking the program.

Definition at line 30 of file Program.cpp.

References Execute(), llvm::sys::ProcessInfo::ReturnCode, and Wait().

Referenced by ExecGraphViewer().

ProcessInfo llvm::sys::ExecuteNoWait ( StringRef  Program,
const char **  args,
const char **  env = nullptr,
const StringRef **  redirects = nullptr,
unsigned  memoryLimit = 0,
std::string *  ErrMsg = nullptr,
bool ExecutionFailed = nullptr 
)

Similar to ExecuteAndWait, but returns immediately.

Returns
The
See Also
ProcessInfo of the newly launced process.
Note
On Microsoft Windows systems, users will need to either call
See Also
Wait until the process finished execution or win32 CloseHandle() API on ProcessInfo.ProcessHandle to avoid memory leaks.

Definition at line 49 of file Program.cpp.

References Execute().

Referenced by ExecGraphViewer().

ErrorOr<std::string> llvm::sys::findProgramByName ( StringRef  Name,
ArrayRef< StringRef >  Paths = ArrayRef< StringRef >() 
)

Find the first executable file Name in Paths.

This does not perform hashing as a shell would but instead stats each PATH entry individually so should generally be avoided. Core LLVM library functions and options should instead require fully specified paths.

Parameters
Namename of the executable to find. If it contains any system slashes, it will be returned as is.
Pathsoptional list of paths to search for Name. If empty it will use the system PATH environment instead.
Returns
The fully qualified path to the first Name in Paths if it exists. Name if Name has slashes in it. Otherwise an error.
std::string llvm::sys::getDefaultTargetTriple ( )

getDefaultTargetTriple() - Return the default target triple the compiler has been configured to produce code for.

The target triple is a string in the format of: CPU_TYPE-VENDOR-OPERATING_SYSTEM or CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM

Referenced by llvm::object::MachOObjectFile::getHostArch(), and LLVMGetDefaultTargetTriple().

bool llvm::sys::getHostCPUFeatures ( StringMap< bool > &  Features)

getHostCPUFeatures - Get the LLVM names for the host CPU features.

The particular format of the names are target dependent, and suitable for passing as -mattr to the target which matches the host.

Parameters
Features- A string mapping feature names to either true (if enabled) or false (if disabled). This routine makes no guarantees about exactly which features may appear in this map, except that they are all valid LLVM feature names.
Returns
- True on success.

Definition at line 893 of file Host.cpp.

Referenced by getFeaturesStr().

StringRef llvm::sys::getHostCPUName ( )

getHostCPUName - Get the LLVM name for the host CPU.

The particular format of the name is target dependent, and suitable for passing as -mcpu to the target which matches the host.

Returns
- The host CPU name, or empty if the CPU could not be determined.

Definition at line 729 of file Host.cpp.

Referenced by getCPUStr().

std::string llvm::sys::getProcessTriple ( )

getProcessTriple() - Return an appropriate target triple for generating code to be loaded into the current process, e.g.

when using the JIT.

Definition at line 898 of file Host.cpp.

References llvm::Triple::get32BitArchVariant(), llvm::Triple::get64BitArchVariant(), llvm::Triple::isArch32Bit(), llvm::Triple::isArch64Bit(), llvm::Triple::normalize(), and llvm::Triple::str().

Referenced by llvm::EngineBuilder::selectTarget().

unsigned char llvm::sys::getSwappedBytes ( unsigned char  C)
inline
signed char llvm::sys::getSwappedBytes ( signed char  C)
inline

Definition at line 71 of file SwapByteOrder.h.

char llvm::sys::getSwappedBytes ( char  C)
inline

Definition at line 72 of file SwapByteOrder.h.

unsigned short llvm::sys::getSwappedBytes ( unsigned short  C)
inline

Definition at line 74 of file SwapByteOrder.h.

References SwapByteOrder_16().

signed short llvm::sys::getSwappedBytes ( signed short  C)
inline

Definition at line 75 of file SwapByteOrder.h.

References SwapByteOrder_16().

unsigned int llvm::sys::getSwappedBytes ( unsigned int  C)
inline

Definition at line 77 of file SwapByteOrder.h.

References SwapByteOrder_32().

signed int llvm::sys::getSwappedBytes ( signed int  C)
inline

Definition at line 78 of file SwapByteOrder.h.

References SwapByteOrder_32().

unsigned long llvm::sys::getSwappedBytes ( unsigned long  C)
inline

Definition at line 81 of file SwapByteOrder.h.

References SwapByteOrder_32().

signed long llvm::sys::getSwappedBytes ( signed long  C)
inline

Definition at line 82 of file SwapByteOrder.h.

References SwapByteOrder_32().

unsigned long long llvm::sys::getSwappedBytes ( unsigned long long  C)
inline

Definition at line 90 of file SwapByteOrder.h.

References SwapByteOrder_64().

signed long long llvm::sys::getSwappedBytes ( signed long long  C)
inline

Definition at line 93 of file SwapByteOrder.h.

References SwapByteOrder_64().

float llvm::sys::getSwappedBytes ( float  C)
inline

Definition at line 97 of file SwapByteOrder.h.

References SwapByteOrder_32().

double llvm::sys::getSwappedBytes ( double  C)
inline

Definition at line 107 of file SwapByteOrder.h.

References SwapByteOrder_64().

void llvm::sys::MemoryFence ( )
TimeValue llvm::sys::operator+ ( const TimeValue &  tv1,
const TimeValue &  tv2 
)
inline
Returns
The sum of the two operands as a new TimeValue Addition operator.

Definition at line 371 of file TimeValue.h.

TimeValue llvm::sys::operator- ( const TimeValue &  tv1,
const TimeValue &  tv2 
)
inline
Returns
The difference of the two operands as a new TimeValue Subtraction operator.

Definition at line 377 of file TimeValue.h.

bool llvm::sys::operator< ( uint32_t  Value,
UnicodeCharRange  Range 
)
inline

Definition at line 32 of file UnicodeCharRanges.h.

References llvm::sys::UnicodeCharRange::Lower.

bool llvm::sys::operator< ( UnicodeCharRange  Range,
uint32_t  Value 
)
inline

Definition at line 35 of file UnicodeCharRanges.h.

References llvm::sys::UnicodeCharRange::Upper.

void llvm::sys::PrintStackTrace ( raw_ostream &  OS)

Print the stack trace using the given raw_ostream object.

void llvm::sys::PrintStackTraceOnErrorSignal ( bool  DisableCrashReporting = false)

When an error signal (such as SIBABRT or SIGSEGV) is delivered to the process, print a stack trace and then exit.

Print a stack trace if a fatal signal occurs.

bool llvm::sys::RemoveFileOnSignal ( StringRef  Filename,
std::string *  ErrMsg = nullptr 
)

This function registers signal handlers to ensure that if a signal gets delivered that the named file is removed.

Remove a file if a fatal signal occurs.

void llvm::sys::RunInterruptHandlers ( )

This function runs all the registered interrupt handlers, including the removal of files registered by RemoveFileOnSignal.

Referenced by llvm::PrintFatalError(), llvm::report_fatal_error(), and llvm::MCContext::reportFatalError().

bool llvm::sys::RunningOnValgrind ( )

Definition at line 32 of file Valgrind.cpp.

void llvm::sys::SetInterruptFunction ( void(*)()  IF)

This function registers a function to be called when the user "interrupts" the program (typically by pressing ctrl-c).

When the user interrupts the program, the specified interrupt function is called instead of the program being killed, and the interrupt function automatically disabled. Note that interrupt functions are not allowed to call any non-reentrant functions. An null interrupt function pointer disables the current installed function. Note also that the handler may be executed on a different thread on some platforms. Register a function to be called when ctrl-c is pressed.

std::string llvm::sys::StrError ( )

Returns a string representation of the errno value, using whatever thread-safe variant of strerror() is available.

Be sure to call this immediately after the function that set errno, or errno may have been overwritten by an intervening call.

Definition at line 32 of file Errno.cpp.

Referenced by MakeErrMsg().

std::string llvm::sys::StrError ( int  errnum)

Like the no-argument version above, but uses errnum instead of errno.

Definition at line 37 of file Errno.cpp.

References llvm::raw_ostream::flush().

template<typename T >
void llvm::sys::swapByteOrder ( T Value)
inline
uint16_t llvm::sys::SwapByteOrder_16 ( uint16_t  value)
inline

SwapByteOrder_16 - This function returns a byte-swapped representation of the 16-bit argument.

Definition at line 28 of file SwapByteOrder.h.

References llvm::MipsISD::Hi, and llvm::MipsISD::Lo.

Referenced by llvm::ByteSwap_16(), llvm::convertUTF16ToUTF8String(), and getSwappedBytes().

uint32_t llvm::sys::SwapByteOrder_32 ( uint32_t  value)
inline

SwapByteOrder_32 - This function returns a byte-swapped representation of the 32-bit argument.

Definition at line 42 of file SwapByteOrder.h.

Referenced by llvm::ByteSwap_32(), getSwappedBytes(), and SwapByteOrder_64().

uint64_t llvm::sys::SwapByteOrder_64 ( uint64_t  value)
inline

SwapByteOrder_64 - This function returns a byte-swapped representation of the 64-bit argument.

Definition at line 58 of file SwapByteOrder.h.

References llvm::MipsISD::Hi, llvm::MipsISD::Lo, and SwapByteOrder_32().

Referenced by llvm::ByteSwap_64(), and getSwappedBytes().

void llvm::sys::ValgrindDiscardTranslations ( const void *  Addr,
size_t  Len 
)

Definition at line 38 of file Valgrind.cpp.

ProcessInfo llvm::sys::Wait ( const ProcessInfo &  PI,
unsigned  SecondsToWait,
bool  WaitUntilTerminates,
std::string *  ErrMsg = nullptr 
)

This function waits for the process specified by PI to finish.

Returns
A
See Also
ProcessInfo struct with Pid set to:
  • The process id of the child process if the child process has changed state.
  • 0 if the child process has not changed state.
Note
Users of this function should always check the ReturnCode member of the
See Also
ProcessInfo returned from this function.
Parameters
PIThe child process that should be waited on.
SecondsToWaitIf non-zero, this specifies the amount of time to wait for the child process to exit. If the time expires, the child is killed and this function returns. If zero, this function will perform a non-blocking wait on the child process.
WaitUntilTerminatesIf true, ignores SecondsToWait and waits until child has terminated.
ErrMsgIf non-zero, provides a pointer to a string instance in which error messages will be returned. If the string is non-empty upon return an error occurred while invoking the program.

Referenced by ExecuteAndWait().

std::error_code llvm::sys::writeFileWithEncoding ( StringRef  FileName,
StringRef  Contents,
WindowsEncodingMethod  Encoding = WEM_UTF8 
)

Saves the UTF8-encoded contents string into the file FileName using a specific encoding.

This write file function adds the possibility to choose which encoding to use when writing a text file. On Windows, this is important when writing files with internationalization support with an encoding that is different from the one used in LLVM (UTF-8). We use this when writing response files, since GCC tools on MinGW only understand legacy code pages, and VisualStudio tools only understand UTF-16. For UNIX, using different encodings is silently ignored, since all tools work well with UTF-8. This function assumes that you only use UTF-8 text data and will convert it to your desired encoding before writing to the file.

FIXME: We use EM_CurrentCodePage to write response files for GNU tools in a MinGW/MinGW-w64 environment, which has serious flaws but currently is our best shot to make gcc/ld understand international characters. This should be changed as soon as binutils fix this to support UTF16 on mingw.

Returns
non-zero error_code if failed

Variable Documentation

const bool llvm::sys::IsBigEndianHost = false
static
const bool llvm::sys::IsLittleEndianHost = !IsBigEndianHost
static