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

Namespaces

 detail
 
 fs
 
 locale
 
 path
 
 unicode
 
 windows
 

Classes

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  InitializeCOMRAII
 
class  Memory
 This class provides various memory handling functions that manipulate MemoryBlock instances. More...
 
class  MemoryBlock
 This class encapsulates the notion of a memory block which has an address and a size. More...
 
class  MutexImpl
 Platform agnostic Mutex class. More...
 
class  OwningMemoryBlock
 Owning version of MemoryBlock. More...
 
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  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  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...
 
class  SmartScopedLock
 
struct  SmartScopedReader
 ScopedReader - RAII acquisition of a reader lock. More...
 
struct  SmartScopedWriter
 ScopedWriter - RAII acquisition of a writer lock. More...
 
class  ThreadLocal
 ThreadLocal - A class used to abstract thread-local storage. More...
 
class  ThreadLocalImpl
 
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
 
template<typename D = std::chrono::nanoseconds>
using TimePoint = std::chrono::time_point< std::chrono::system_clock, D >
 A time point on the system clock. More...
 
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)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE std::time_t toTimeT (TimePoint<> TP)
 Convert a TimePoint to std::time_t. More...
 
LLVM_ATTRIBUTE_ALWAYS_INLINE TimePoint< std::chrono::seconds > toTimePoint (std::time_t T)
 Convert a std::time_t to a TimePoint. More...
 
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...
 
template<typename FailT , typename Fun , typename... Args>
auto RetryAfterSignal (const FailT &Fail, const Fun &F, const Args &... As) -> decltype(F(As...))
 
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...
 
int getHostNumPhysicalCores ()
 Get the number of physical cores (as opposed to logical cores returned from thread::hardware_concurrency(), which includes hyperthreads). More...
 
ErrorOr< std::string > findProgramByName (StringRef Name, ArrayRef< StringRef > Paths={})
 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, ArrayRef< Optional< StringRef >> Redirects={}, 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, ArrayRef< Optional< StringRef >> Redirects={}, unsigned MemoryLimit=0, std::string *ErrMsg=nullptr, bool *ExecutionFailed=nullptr)
 Similar to ExecuteAndWait, but returns immediately. More...
 
bool commandLineFitsWithinSystemLimits (StringRef Program, 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 (StringRef Argv0, 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 RunSignalHandlers ()
 
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)
 
bool operator< (uint32_t Value, UnicodeCharRange Range)
 
bool operator< (UnicodeCharRange Range, uint32_t Value)
 
bool RunningOnValgrind ()
 
void ValgrindDiscardTranslations (const void *Addr, size_t Len)
 
std::chrono::microseconds toDuration (const struct timeval &TV)
 Convert a struct timeval to a duration. More...
 
struct timespec toTimeSpec (TimePoint<> TP)
 Convert a time point to struct timespec. More...
 
struct timeval toTimeVal (TimePoint< std::chrono::microseconds > TP)
 Convert a time point to struct timeval. More...
 
std::chrono::nanoseconds toDuration (FILETIME Time)
 
TimePoint toTimePoint (FILETIME Time)
 
FILETIME toFILETIME (TimePoint<> TP)
 

Variables

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

Typedef Documentation

◆ cas_flag

Definition at line 35 of file Atomic.h.

◆ Mutex

Mutex - A standard, always enforced mutex.

Definition at line 138 of file Mutex.h.

◆ RWMutex

Definition at line 142 of file RWMutex.h.

◆ ScopedLock

Definition at line 154 of file Mutex.h.

◆ ScopedReader

Definition at line 158 of file RWMutex.h.

◆ ScopedWriter

Definition at line 174 of file RWMutex.h.

◆ TimePoint

template<typename D = std::chrono::nanoseconds>
using llvm::sys::TimePoint = typedef std::chrono::time_point<std::chrono::system_clock, D>

A time point on the system clock.

This is provided for two reasons:

  • to insulate us agains subtle differences in behavoir to differences in system clock precision (which is implementation-defined and differs between platforms).
  • to shorten the type name The default precision is nanoseconds. If need a specific precision specify it explicitly. If unsure, use the default. If you need a time point on a clock other than the system_clock, use std::chrono directly.

Definition at line 34 of file Chrono.h.

Enumeration Type Documentation

◆ COMThreadingMode

Enumerator
SingleThreaded 
MultiThreaded 

Definition at line 21 of file COM.h.

◆ WindowsEncodingMethod

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 142 of file Program.h.

Function Documentation

◆ AddSignalHandler()

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().

◆ ChangeStdinToBinary()

std::error_code llvm::sys::ChangeStdinToBinary ( )

◆ ChangeStdoutToBinary()

std::error_code llvm::sys::ChangeStdoutToBinary ( )

Referenced by getFD().

◆ commandLineFitsWithinSystemLimits()

bool llvm::sys::commandLineFitsWithinSystemLimits ( StringRef  Program,
ArrayRef< const char *>  Args 
)

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

◆ CompareAndSwap()

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

Definition at line 45 of file Atomic.cpp.

Referenced by llvm::call_once().

◆ DisableSystemDialogsOnCrash()

void llvm::sys::DisableSystemDialogsOnCrash ( )

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

◆ DontRemoveFileOnSignal()

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::sys::fs::TempFile::discard(), and llvm::sys::fs::TempFile::keep().

◆ ExecuteAndWait()

int llvm::sys::ExecuteAndWait ( StringRef  Program,
const char **  Args,
const char **  Env = nullptr,
ArrayRef< Optional< StringRef >>  Redirects = {},
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 presumed this is the result of the findProgramByName method.
ArgsA 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 array of optional paths. Should have a size of zero or three. If the array is empty, no redirections are performed. Otherwise, the inferior process's stdin(0), stdout(1), and stderr(2) will be redirected to the corresponding paths, if the optional path is present (not llvm::None). 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 assert(), Execute(), llvm::sys::ProcessInfo::ReturnCode, and Wait().

Referenced by ExecGraphViewer(), and printSymbolizedStackTrace().

◆ ExecuteNoWait()

ProcessInfo llvm::sys::ExecuteNoWait ( StringRef  Program,
const char **  Args,
const char **  Env = nullptr,
ArrayRef< Optional< StringRef >>  Redirects = {},
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 50 of file Program.cpp.

References assert(), and Execute().

Referenced by ExecGraphViewer().

◆ findProgramByName()

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

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.

Referenced by ExecGraphViewer(), and printSymbolizedStackTrace().

◆ getDefaultTargetTriple()

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::LTOCodeGenerator::compile(), llvm::object::MachOObjectFile::getHostArch(), LLVMGetDefaultTargetTriple(), and parseBitcodeFileImpl().

◆ getHostCPUFeatures()

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 1345 of file Host.cpp.

Referenced by getFeaturesStr(), and getHostNumPhysicalCores().

◆ getHostCPUName()

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 1093 of file Host.cpp.

References assert(), computeHostNumPhysicalCores(), llvm::count(), llvm::Data, llvm::errs(), llvm::ErrorOr< T >::getError(), llvm::MemoryBuffer::getFileAsStream(), llvm::SmallSet< T, N, C >::insert(), and llvm::SmallSet< T, N, C >::size().

Referenced by getCPUStr(), and llvm::sys::detail::getHostCPUNameForBPF().

◆ getHostNumPhysicalCores()

int llvm::sys::getHostNumPhysicalCores ( )

Get the number of physical cores (as opposed to logical cores returned from thread::hardware_concurrency(), which includes hyperthreads).

Returns -1 if unknown for the current host system.

Definition at line 1165 of file Host.cpp.

References llvm::StringSwitch< T, R >::Case(), computeHostNumPhysicalCores(), llvm::StringSwitch< T, R >::Default(), E, llvm::N86::EBX, getHostCPUFeatures(), getProcCpuinfoContent(), I, P, llvm::SmallVectorTemplateCommon< T >::size(), and startswith().

Referenced by llvm::heavyweight_hardware_concurrency().

◆ getProcessTriple()

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 1348 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().

◆ getSwappedBytes() [1/13]

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

◆ getSwappedBytes() [2/13]

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

Definition at line 73 of file SwapByteOrder.h.

References C.

◆ getSwappedBytes() [3/13]

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

Definition at line 74 of file SwapByteOrder.h.

References C.

◆ getSwappedBytes() [4/13]

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

Definition at line 76 of file SwapByteOrder.h.

References SwapByteOrder_16().

◆ getSwappedBytes() [5/13]

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

Definition at line 77 of file SwapByteOrder.h.

References SwapByteOrder_16().

◆ getSwappedBytes() [6/13]

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

Definition at line 79 of file SwapByteOrder.h.

References SwapByteOrder_32().

◆ getSwappedBytes() [7/13]

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

Definition at line 80 of file SwapByteOrder.h.

References SwapByteOrder_32().

◆ getSwappedBytes() [8/13]

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

Definition at line 83 of file SwapByteOrder.h.

References SwapByteOrder_32().

◆ getSwappedBytes() [9/13]

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

Definition at line 84 of file SwapByteOrder.h.

References C, getSwappedBytes(), SwapByteOrder_32(), and SwapByteOrder_64().

◆ getSwappedBytes() [10/13]

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

Definition at line 92 of file SwapByteOrder.h.

References SwapByteOrder_64().

◆ getSwappedBytes() [11/13]

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

Definition at line 95 of file SwapByteOrder.h.

References SwapByteOrder_64().

◆ getSwappedBytes() [12/13]

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

Definition at line 99 of file SwapByteOrder.h.

References C, and SwapByteOrder_32().

◆ getSwappedBytes() [13/13]

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

Definition at line 109 of file SwapByteOrder.h.

References C, and SwapByteOrder_64().

◆ MemoryFence()

void llvm::sys::MemoryFence ( )

◆ operator<() [1/2]

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

◆ operator<() [2/2]

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

Definition at line 35 of file UnicodeCharRanges.h.

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

◆ PrintStackTrace()

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

Print the stack trace using the given raw_ostream object.

◆ PrintStackTraceOnErrorSignal()

void llvm::sys::PrintStackTraceOnErrorSignal ( StringRef  Argv0,
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.

Parameters
Argv0the current binary name, used to find the symbolizer relative to the current binary before searching $PATH; can be StringRef(), in which case we will only search $PATH.
DisableCrashReportingif true, disable the normal crash reporting mechanisms on the underlying operating system.

◆ RemoveFileOnSignal()

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.

Referenced by llvm::sys::fs::TempFile::create().

◆ RetryAfterSignal()

template<typename FailT , typename Fun , typename... Args>
auto llvm::sys::RetryAfterSignal ( const FailT &  Fail,
const Fun &  F,
const Args &...  As 
) -> decltype(F(As...))
inline

Definition at line 34 of file Errno.h.

References F(), and Fail.

Referenced by getMemoryBufferForStream(), and getOpenFileImpl().

◆ RunInterruptHandlers()

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().

◆ RunningOnValgrind()

bool llvm::sys::RunningOnValgrind ( )

Definition at line 48 of file Valgrind.cpp.

◆ RunSignalHandlers()

void llvm::sys::RunSignalHandlers ( )

Definition at line 46 of file Signals.cpp.

References CallBacksToRun, llvm::Depth, findModulesAndOffsets(), and I.

◆ SetInterruptFunction()

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.

◆ StrError() [1/2]

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().

◆ StrError() [2/2]

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().

◆ swapByteOrder()

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

◆ SwapByteOrder_16()

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 30 of file SwapByteOrder.h.

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

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

◆ SwapByteOrder_32()

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 44 of file SwapByteOrder.h.

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

◆ 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 60 of file SwapByteOrder.h.

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

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

◆ toDuration() [1/2]

std::chrono::microseconds llvm::sys::toDuration ( const struct timeval &  TV)
inline

Convert a struct timeval to a duration.

Note that timeval can be used both as a time point and a duration. Be sure to check what the input represents.

Definition at line 78 of file Unix.h.

◆ toDuration() [2/2]

std::chrono::nanoseconds llvm::sys::toDuration ( FILETIME  Time)
inline

Definition at line 218 of file WindowsSupport.h.

◆ toFILETIME()

FILETIME llvm::sys::toFILETIME ( TimePoint<>  TP)
inline

Definition at line 239 of file WindowsSupport.h.

References llvm::sys::path::widenPath().

◆ toTimePoint() [1/2]

LLVM_ATTRIBUTE_ALWAYS_INLINE TimePoint<std::chrono::seconds> llvm::sys::toTimePoint ( std::time_t  T)
inline

Convert a std::time_t to a TimePoint.

Definition at line 45 of file Chrono.h.

Referenced by llvm::object::ArchiveMemberHeader::getLastModified().

◆ toTimePoint() [2/2]

TimePoint llvm::sys::toTimePoint ( FILETIME  Time)
inline

Definition at line 227 of file WindowsSupport.h.

◆ toTimeSpec()

struct timespec llvm::sys::toTimeSpec ( TimePoint<>  TP)

Convert a time point to struct timespec.

Definition at line 84 of file Unix.h.

References llvm::count(), and toTimeT().

◆ toTimeT()

LLVM_ATTRIBUTE_ALWAYS_INLINE std::time_t llvm::sys::toTimeT ( TimePoint<>  TP)
inline

Convert a TimePoint to std::time_t.

Definition at line 37 of file Chrono.h.

References LLVM_ATTRIBUTE_ALWAYS_INLINE.

Referenced by llvm::getStructTM(), printRestOfMemberHeader(), toTimeSpec(), and toTimeVal().

◆ toTimeVal()

struct timeval llvm::sys::toTimeVal ( TimePoint< std::chrono::microseconds >  TP)

Convert a time point to struct timeval.

Definition at line 94 of file Unix.h.

References llvm::count(), and toTimeT().

◆ ValgrindDiscardTranslations()

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

Definition at line 52 of file Valgrind.cpp.

◆ Wait()

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 llvm::call_once(), and ExecuteAndWait().

◆ writeFileWithEncoding()

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

◆ IsBigEndianHost

constexpr bool llvm::sys::IsBigEndianHost = false

◆ IsLittleEndianHost

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