1 //===- Win32/Win32.h - Common Win32 Include File ----------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines things specific to Win32 implementations.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 //=== WARNING: Implementation here must contain only generic Win32 code that
16 //=== is guaranteed to work on *all* Win32 variants.
17 //===----------------------------------------------------------------------===//
19 // mingw-w64 tends to define it as 0x0502 in its headers.
22 // Require at least Windows XP(5.1) API.
23 #define _WIN32_WINNT 0x0501
24 #define _WIN32_IE 0x0600 // MinGW at it again.
25 #define WIN32_LEAN_AND_MEAN
27 #include "llvm/Config/config.h" // Get build system configuration settings
33 inline bool MakeErrMsg(std::string* ErrMsg, const std::string& prefix) {
37 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
38 NULL, GetLastError(), 0, (LPSTR)&buffer, 1, NULL);
39 *ErrMsg = prefix + buffer;
48 AutoHandle(HANDLE h) : handle(h) {}
59 AutoHandle &operator=(HANDLE h) {
65 template <class HandleType, uintptr_t InvalidHandle,
66 class DeleterType, DeleterType D>
71 ScopedHandle() : Handle(InvalidHandle) {}
72 ScopedHandle(HandleType handle) : Handle(handle) {}
75 if (Handle != HandleType(InvalidHandle))
80 HandleType temp = Handle;
81 Handle = HandleType(InvalidHandle);
85 operator HandleType() const { return Handle; }
87 ScopedHandle &operator=(HandleType handle) {
92 typedef void (*unspecified_bool_type)();
93 static void unspecified_bool_true() {}
95 // True if Handle is valid.
96 operator unspecified_bool_type() const {
97 return Handle == HandleType(InvalidHandle) ? 0 : unspecified_bool_true;
100 bool operator!() const {
101 return Handle == HandleType(InvalidHandle);
105 typedef ScopedHandle<HANDLE, uintptr_t(-1),
106 BOOL (WINAPI*)(HANDLE), ::FindClose>
111 class SmallVectorImpl;
114 typename SmallVectorImpl<T>::const_pointer
115 c_str(SmallVectorImpl<T> &str) {
120 } // end namespace llvm.