22 #ifndef LLVM_SUPPORT_WINDOWSSUPPORT_H 23 #define LLVM_SUPPORT_WINDOWSSUPPORT_H 30 #define _WIN32_WINNT 0x0601 31 #define _WIN32_IE 0x0800 // MinGW at it again. FIXME: verify if still needed. 32 #define WIN32_LEAN_AND_MEAN 41 #include "llvm/Config/config.h" 46 #include <system_error> 58 OSVERSIONINFOEXW osvi = {};
59 osvi.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
60 osvi.dwMajorVersion = 6;
61 osvi.dwMinorVersion = 2;
62 osvi.wServicePackMajor = 0;
65 Mask = VerSetConditionMask(Mask, VER_MAJORVERSION, VER_GREATER_EQUAL);
66 Mask = VerSetConditionMask(Mask, VER_MINORVERSION, VER_GREATER_EQUAL);
67 Mask = VerSetConditionMask(Mask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
69 return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION |
74 inline bool MakeErrMsg(std::string *ErrMsg,
const std::string &prefix) {
78 DWORD LastError = GetLastError();
79 DWORD R = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
80 FORMAT_MESSAGE_FROM_SYSTEM |
81 FORMAT_MESSAGE_MAX_WIDTH_MASK,
82 NULL, LastError, 0, (LPSTR)&buffer, 1, NULL);
84 *ErrMsg = prefix +
": " + buffer;
86 *ErrMsg = prefix +
": Unknown error";
93 template <
typename HandleTraits>
95 typedef typename HandleTraits::handle_type handle_type;
102 : Handle(HandleTraits::GetInvalid()) {}
108 if (HandleTraits::IsValid(Handle))
109 HandleTraits::Close(Handle);
113 handle_type t = Handle;
114 Handle = HandleTraits::GetInvalid();
119 if (HandleTraits::IsValid(Handle))
120 HandleTraits::Close(Handle);
126 explicit operator bool()
const {
127 return HandleTraits::IsValid(Handle) ?
true :
false;
130 operator handle_type()
const {
139 return INVALID_HANDLE_VALUE;
147 return h != GetInvalid();
165 ::CryptReleaseContext(h, 0);
169 return h != GetInvalid();
185 return h != GetInvalid();
206 class SmallVectorImpl;
209 typename SmallVectorImpl<T>::const_pointer
219 ULARGE_INTEGER TimeInteger;
220 TimeInteger.LowPart = Time.dwLowDateTime;
221 TimeInteger.HighPart = Time.dwHighDateTime;
224 return std::chrono::nanoseconds(100 * TimeInteger.QuadPart);
228 ULARGE_INTEGER TimeInteger;
229 TimeInteger.LowPart = Time.dwLowDateTime;
230 TimeInteger.HighPart = Time.dwHighDateTime;
233 TimeInteger.QuadPart -= 11644473600ll * 10000000;
236 return TimePoint<>(std::chrono::nanoseconds(100 * TimeInteger.QuadPart));
240 ULARGE_INTEGER TimeInteger;
241 TimeInteger.QuadPart = TP.time_since_epoch().count() / 100;
242 TimeInteger.QuadPart += 11644473600ll * 10000000;
245 Time.dwLowDateTime = TimeInteger.LowPart;
246 Time.dwHighDateTime = TimeInteger.HighPart;
void push_back(const T &Elt)
std::error_code GetCommandLineArguments(SmallVectorImpl< const char *> &Args, BumpPtrAllocator &Alloc)
Compute iterated dominance frontiers using a linear time algorithm.
FILETIME toFILETIME(TimePoint<> TP)
static handle_type GetInvalid()
static void Close(handle_type h)
static void Close(handle_type h)
block Block Frequency true
static bool IsValid(handle_type h)
static bool IsValid(handle_type h)
ScopedHandle< JobHandleTraits > ScopedJobHandle
ScopedHandle< CommonHandleTraits > ScopedCommonHandle
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Allocate memory in an ever growing pool, as if by bump-pointer.
TimePoint toTimePoint(FILETIME Time)
static void Close(handle_type h)
static handle_type GetInvalid()
ScopedHandle(handle_type h)
static handle_type GetInvalid()
ScopedHandle< FindHandleTraits > ScopedFindHandle
bool RunningWindows8OrGreater()
Determines if the program is running on Windows 8 or newer.
SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)
bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix)
pointer data()
Return a pointer to the vector's buffer, even if empty().
ScopedHandle & operator=(handle_type h)
ScopedHandle< FileHandleTraits > ScopedFileHandle
static handle_type GetInvalid()
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
static void Close(handle_type h)
ScopedHandle< RegTraits > ScopedRegHandle
ScopedHandle< CryptContextTraits > ScopedCryptContext
static bool IsValid(handle_type h)
std::chrono::nanoseconds toDuration(FILETIME Time)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
std::string utohexstr(uint64_t X, bool LowerCase=false)
std::chrono::time_point< std::chrono::system_clock, D > TimePoint
A time point on the system clock.