Rename Windows.h to WindowsSupport.h to avoid ambiguity
authorReid Kleckner <reid@kleckner.net>
Wed, 12 Feb 2014 21:26:20 +0000 (21:26 +0000)
committerReid Kleckner <reid@kleckner.net>
Wed, 12 Feb 2014 21:26:20 +0000 (21:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201258 91177308-0d34-0410-b5e6-96231b3b80d8

15 files changed:
lib/Support/CrashRecoveryContext.cpp
lib/Support/Threading.cpp
lib/Support/Windows/DynamicLibrary.inc
lib/Support/Windows/Host.inc
lib/Support/Windows/Memory.inc
lib/Support/Windows/Mutex.inc
lib/Support/Windows/Path.inc
lib/Support/Windows/Process.inc
lib/Support/Windows/Program.inc
lib/Support/Windows/RWMutex.inc
lib/Support/Windows/Signals.inc
lib/Support/Windows/ThreadLocal.inc
lib/Support/Windows/TimeValue.inc
lib/Support/Windows/Windows.h [deleted file]
lib/Support/Windows/WindowsSupport.h [new file with mode: 0644]

index 92c370dda44be0e9c0a01059f60d8209bbf20fea..29f73fc539cd93e3a9bc249ae9848c089a6a6fc3 100644 (file)
@@ -132,7 +132,7 @@ CrashRecoveryContext::unregisterCleanup(CrashRecoveryContextCleanup *cleanup) {
 
 #ifdef LLVM_ON_WIN32
 
 
 #ifdef LLVM_ON_WIN32
 
-#include "Windows/Windows.h"
+#include "Windows/WindowsSupport.h"
 
 // On Windows, we can make use of vectored exception handling to
 // catch most crashing situations.  Note that this does mean
 
 // On Windows, we can make use of vectored exception handling to
 // catch most crashing situations.  Note that this does mean
index 13fba2ea25848169b8068e3a1dda229fc64a8877..9d7ac6c18deb7db208265a7e116a0f0131486578 100644 (file)
@@ -103,7 +103,7 @@ void llvm::llvm_execute_on_thread(void (*Fn)(void*), void *UserData,
   ::pthread_attr_destroy(&Attr);
 }
 #elif LLVM_ENABLE_THREADS!=0 && defined(LLVM_ON_WIN32)
   ::pthread_attr_destroy(&Attr);
 }
 #elif LLVM_ENABLE_THREADS!=0 && defined(LLVM_ON_WIN32)
-#include "Windows/Windows.h"
+#include "Windows/WindowsSupport.h"
 #include <process.h>
 
 struct ThreadInfo {
 #include <process.h>
 
 struct ThreadInfo {
index 5a7b21920a9e2bf73815ba939f2b732e66f72dd9..504471eaff35bd095f9f59e46f8a00ccc2ea8827 100644 (file)
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
 //
 //===----------------------------------------------------------------------===//
 
-#include "Windows.h"
+#include "WindowsSupport.h"
 
 #ifdef __MINGW32__
  #include <imagehlp.h>
 
 #ifdef __MINGW32__
  #include <imagehlp.h>
index 2e6d6f190370b9143a9417b89a37e14b96c7df59..7bda89dc49c7fa2b0d521c0a5139475f4664a120 100644 (file)
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
 //
 //===----------------------------------------------------------------------===//
 
-#include "Windows.h"
+#include "WindowsSupport.h"
 #include <cstdio>
 #include <string>
 
 #include <cstdio>
 #include <string>
 
index 12604524d406f8db17b93fad0969b1f032184963..ebe78782b9043b2ecede515d0a5bf62fb70081d0 100644 (file)
@@ -17,7 +17,7 @@
 #include "llvm/Support/Process.h"
 
 // The Windows.h header must be the last one included.
 #include "llvm/Support/Process.h"
 
 // The Windows.h header must be the last one included.
-#include "Windows.h"
+#include "WindowsSupport.h"
 
 namespace {
 
 
 namespace {
 
index 583dc6359a161350b41b272ec80f812bb87f0b45..ab79d079122f1f1202099260305a7f11b0012bf8 100644 (file)
@@ -16,7 +16,7 @@
 //===          is guaranteed to work on *all* Win32 variants.
 //===----------------------------------------------------------------------===//
 
 //===          is guaranteed to work on *all* Win32 variants.
 //===----------------------------------------------------------------------===//
 
-#include "Windows.h"
+#include "WindowsSupport.h"
 #include "llvm/Support/Mutex.h"
 
 namespace llvm {
 #include "llvm/Support/Mutex.h"
 
 namespace llvm {
index 8329d271b39ff1d149fe33bd1585f98566028462..46e9ce7acb2c84bd3eb40aedddb7e6b527084b58 100644 (file)
@@ -24,7 +24,7 @@
 
 // These two headers must be included last, and make sure shlobj is required
 // after Windows.h to make sure it picks up our definition of _WIN32_WINNT
 
 // These two headers must be included last, and make sure shlobj is required
 // after Windows.h to make sure it picks up our definition of _WIN32_WINNT
-#include "Windows.h"
+#include "WindowsSupport.h"
 #include <shlobj.h>
 
 #undef max
 #include <shlobj.h>
 
 #undef max
index a0e3bc413a3f2c32d9de0fc28fafeefc5b1337c7..a794ca08f670d4a9dfe8577dd0af8b6986afdd27 100644 (file)
@@ -15,7 +15,7 @@
 #include <malloc.h>
 
 // The Windows.h header must be after LLVM and standard headers.
 #include <malloc.h>
 
 // The Windows.h header must be after LLVM and standard headers.
-#include "Windows.h"
+#include "WindowsSupport.h"
 
 #include <direct.h>
 #include <io.h>
 
 #include <direct.h>
 #include <io.h>
index dc09738e2e71dc204199b3ec314e0a16e839b814..365e87eea592d01c56a2d11ac737059ae3ccfa8a 100644 (file)
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
 //
 //===----------------------------------------------------------------------===//
 
-#include "Windows.h"
+#include "WindowsSupport.h"
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/Support/FileSystem.h"
 #include <cstdio>
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/Support/FileSystem.h"
 #include <cstdio>
index c4318448e7ce99bda0e6d8e7fd023d28a7645814..00d0e93d8d58647d0b0952e862f15e6d3899b869 100644 (file)
@@ -16,7 +16,7 @@
 //===          is guaranteed to work on *all* Win32 variants.
 //===----------------------------------------------------------------------===//
 
 //===          is guaranteed to work on *all* Win32 variants.
 //===----------------------------------------------------------------------===//
 
-#include "Windows.h"
+#include "WindowsSupport.h"
 
 namespace llvm {
 using namespace sys;
 
 namespace llvm {
 using namespace sys;
index 5add76a0c03b5967ba34bfa07a795aef5774b6a5..a28b0b8003d34c4310a0f6bd4ac4ff11c142935f 100644 (file)
@@ -17,7 +17,7 @@
 #include <vector>
 
 // The Windows.h header must be after LLVM and standard headers.
 #include <vector>
 
 // The Windows.h header must be after LLVM and standard headers.
-#include "Windows.h"
+#include "WindowsSupport.h"
 
 #ifdef __MINGW32__
  #include <imagehlp.h>
 
 #ifdef __MINGW32__
  #include <imagehlp.h>
index 057deb325d6e8dcfbe75febcdabe531852c43ff5..3914cf72fa95d143eb3cb91c7711ec24c748948b 100644 (file)
@@ -16,7 +16,7 @@
 //===          is guaranteed to work on *all* Win32 variants.
 //===----------------------------------------------------------------------===//
 
 //===          is guaranteed to work on *all* Win32 variants.
 //===----------------------------------------------------------------------===//
 
-#include "Windows.h"
+#include "WindowsSupport.h"
 #include "llvm/Support/ThreadLocal.h"
 
 namespace llvm {
 #include "llvm/Support/ThreadLocal.h"
 
 namespace llvm {
index 98b07d6e4479f0c15d28db13a5a9108c3c5d5498..6c59024d9c6a8c88f944a48d97b039c86a75756c 100644 (file)
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
 //
 //===----------------------------------------------------------------------===//
 
-#include "Windows.h"
+#include "WindowsSupport.h"
 #include <cctype>
 #include <time.h>
 
 #include <cctype>
 #include <time.h>
 
diff --git a/lib/Support/Windows/Windows.h b/lib/Support/Windows/Windows.h
deleted file mode 100644 (file)
index 5666de2..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-//===- Win32/Win32.h - Common Win32 Include File ----------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines things specific to Win32 implementations.
-//
-//===----------------------------------------------------------------------===//
-
-//===----------------------------------------------------------------------===//
-//=== WARNING: Implementation here must contain only generic Win32 code that
-//===          is guaranteed to work on *all* Win32 variants.
-//===----------------------------------------------------------------------===//
-
-// mingw-w64 tends to define it as 0x0502 in its headers.
-#undef _WIN32_WINNT
-#undef _WIN32_IE
-
-// Require at least Windows XP(5.1) API.
-#define _WIN32_WINNT 0x0501
-#define _WIN32_IE    0x0600 // MinGW at it again.
-#define WIN32_LEAN_AND_MEAN
-
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Config/config.h" // Get build system configuration settings
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/system_error.h"
-#include <windows.h>
-#include <wincrypt.h>
-#include <cassert>
-#include <string>
-#include <vector>
-
-inline bool MakeErrMsg(std::string* ErrMsg, const std::string& prefix) {
-  if (!ErrMsg)
-    return true;
-  char *buffer = NULL;
-  DWORD R = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
-                          FORMAT_MESSAGE_FROM_SYSTEM,
-                          NULL, GetLastError(), 0, (LPSTR)&buffer, 1, NULL);
-  if (R)
-    *ErrMsg = prefix + buffer;
-  else
-    *ErrMsg = prefix + "Unknown error";
-
-  LocalFree(buffer);
-  return R != 0;
-}
-
-template <typename HandleTraits>
-class ScopedHandle {
-  typedef typename HandleTraits::handle_type handle_type;
-  handle_type Handle;
-
-  ScopedHandle(const ScopedHandle &other); // = delete;
-  void operator=(const ScopedHandle &other); // = delete;
-public:
-  ScopedHandle()
-    : Handle(HandleTraits::GetInvalid()) {}
-
-  explicit ScopedHandle(handle_type h)
-    : Handle(h) {}
-
-  ~ScopedHandle() {
-    if (HandleTraits::IsValid(Handle))
-      HandleTraits::Close(Handle);
-  }
-
-  handle_type take() {
-    handle_type t = Handle;
-    Handle = HandleTraits::GetInvalid();
-    return t;
-  }
-
-  ScopedHandle &operator=(handle_type h) {
-    if (HandleTraits::IsValid(Handle))
-      HandleTraits::Close(Handle);
-    Handle = h;
-    return *this;
-  }
-
-  // True if Handle is valid.
-  LLVM_EXPLICIT operator bool() const {
-    return HandleTraits::IsValid(Handle) ? true : false;
-  }
-
-  operator handle_type() const {
-    return Handle;
-  }
-};
-
-struct CommonHandleTraits {
-  typedef HANDLE handle_type;
-
-  static handle_type GetInvalid() {
-    return INVALID_HANDLE_VALUE;
-  }
-
-  static void Close(handle_type h) {
-    ::CloseHandle(h);
-  }
-
-  static bool IsValid(handle_type h) {
-    return h != GetInvalid();
-  }
-};
-
-struct JobHandleTraits : CommonHandleTraits {
-  static handle_type GetInvalid() {
-    return NULL;
-  }
-};
-
-struct CryptContextTraits : CommonHandleTraits {
-  typedef HCRYPTPROV handle_type;
-
-  static handle_type GetInvalid() {
-    return 0;
-  }
-
-  static void Close(handle_type h) {
-    ::CryptReleaseContext(h, 0);
-  }
-
-  static bool IsValid(handle_type h) {
-    return h != GetInvalid();
-  }
-};
-
-struct FindHandleTraits : CommonHandleTraits {
-  static void Close(handle_type h) {
-    ::FindClose(h);
-  }
-};
-
-struct FileHandleTraits : CommonHandleTraits {};
-
-typedef ScopedHandle<CommonHandleTraits> ScopedCommonHandle;
-typedef ScopedHandle<FileHandleTraits>   ScopedFileHandle;
-typedef ScopedHandle<CryptContextTraits> ScopedCryptContext;
-typedef ScopedHandle<FindHandleTraits>   ScopedFindHandle;
-typedef ScopedHandle<JobHandleTraits>    ScopedJobHandle;
-
-namespace llvm {
-template <class T>
-class SmallVectorImpl;
-
-template <class T>
-typename SmallVectorImpl<T>::const_pointer
-c_str(SmallVectorImpl<T> &str) {
-  str.push_back(0);
-  str.pop_back();
-  return str.data();
-}
-
-namespace sys {
-namespace windows {
-error_code UTF8ToUTF16(StringRef utf8,
-                       SmallVectorImpl<wchar_t> &utf16);
-error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len,
-                       SmallVectorImpl<char> &utf8);
-} // end namespace windows
-} // end namespace sys
-} // end namespace llvm.
diff --git a/lib/Support/Windows/WindowsSupport.h b/lib/Support/Windows/WindowsSupport.h
new file mode 100644 (file)
index 0000000..6bef444
--- /dev/null
@@ -0,0 +1,172 @@
+//===- WindowsSupport.h - Common Windows Include File -----------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines things specific to Windows implementations.  In addition to
+// providing some helpers for working with win32 APIs, this header wraps
+// <windows.h> with some portability macros.  Always include WindowsSupport.h
+// instead of including <windows.h> directly.
+//
+//===----------------------------------------------------------------------===//
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only generic Win32 code that
+//===          is guaranteed to work on *all* Win32 variants.
+//===----------------------------------------------------------------------===//
+
+// mingw-w64 tends to define it as 0x0502 in its headers.
+#undef _WIN32_WINNT
+#undef _WIN32_IE
+
+// Require at least Windows XP(5.1) API.
+#define _WIN32_WINNT 0x0501
+#define _WIN32_IE    0x0600 // MinGW at it again.
+#define WIN32_LEAN_AND_MEAN
+
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Config/config.h" // Get build system configuration settings
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/system_error.h"
+#include <windows.h>
+#include <wincrypt.h>
+#include <cassert>
+#include <string>
+#include <vector>
+
+inline bool MakeErrMsg(std::string* ErrMsg, const std::string& prefix) {
+  if (!ErrMsg)
+    return true;
+  char *buffer = NULL;
+  DWORD R = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+                          FORMAT_MESSAGE_FROM_SYSTEM,
+                          NULL, GetLastError(), 0, (LPSTR)&buffer, 1, NULL);
+  if (R)
+    *ErrMsg = prefix + buffer;
+  else
+    *ErrMsg = prefix + "Unknown error";
+
+  LocalFree(buffer);
+  return R != 0;
+}
+
+template <typename HandleTraits>
+class ScopedHandle {
+  typedef typename HandleTraits::handle_type handle_type;
+  handle_type Handle;
+
+  ScopedHandle(const ScopedHandle &other); // = delete;
+  void operator=(const ScopedHandle &other); // = delete;
+public:
+  ScopedHandle()
+    : Handle(HandleTraits::GetInvalid()) {}
+
+  explicit ScopedHandle(handle_type h)
+    : Handle(h) {}
+
+  ~ScopedHandle() {
+    if (HandleTraits::IsValid(Handle))
+      HandleTraits::Close(Handle);
+  }
+
+  handle_type take() {
+    handle_type t = Handle;
+    Handle = HandleTraits::GetInvalid();
+    return t;
+  }
+
+  ScopedHandle &operator=(handle_type h) {
+    if (HandleTraits::IsValid(Handle))
+      HandleTraits::Close(Handle);
+    Handle = h;
+    return *this;
+  }
+
+  // True if Handle is valid.
+  LLVM_EXPLICIT operator bool() const {
+    return HandleTraits::IsValid(Handle) ? true : false;
+  }
+
+  operator handle_type() const {
+    return Handle;
+  }
+};
+
+struct CommonHandleTraits {
+  typedef HANDLE handle_type;
+
+  static handle_type GetInvalid() {
+    return INVALID_HANDLE_VALUE;
+  }
+
+  static void Close(handle_type h) {
+    ::CloseHandle(h);
+  }
+
+  static bool IsValid(handle_type h) {
+    return h != GetInvalid();
+  }
+};
+
+struct JobHandleTraits : CommonHandleTraits {
+  static handle_type GetInvalid() {
+    return NULL;
+  }
+};
+
+struct CryptContextTraits : CommonHandleTraits {
+  typedef HCRYPTPROV handle_type;
+
+  static handle_type GetInvalid() {
+    return 0;
+  }
+
+  static void Close(handle_type h) {
+    ::CryptReleaseContext(h, 0);
+  }
+
+  static bool IsValid(handle_type h) {
+    return h != GetInvalid();
+  }
+};
+
+struct FindHandleTraits : CommonHandleTraits {
+  static void Close(handle_type h) {
+    ::FindClose(h);
+  }
+};
+
+struct FileHandleTraits : CommonHandleTraits {};
+
+typedef ScopedHandle<CommonHandleTraits> ScopedCommonHandle;
+typedef ScopedHandle<FileHandleTraits>   ScopedFileHandle;
+typedef ScopedHandle<CryptContextTraits> ScopedCryptContext;
+typedef ScopedHandle<FindHandleTraits>   ScopedFindHandle;
+typedef ScopedHandle<JobHandleTraits>    ScopedJobHandle;
+
+namespace llvm {
+template <class T>
+class SmallVectorImpl;
+
+template <class T>
+typename SmallVectorImpl<T>::const_pointer
+c_str(SmallVectorImpl<T> &str) {
+  str.push_back(0);
+  str.pop_back();
+  return str.data();
+}
+
+namespace sys {
+namespace windows {
+error_code UTF8ToUTF16(StringRef utf8,
+                       SmallVectorImpl<wchar_t> &utf16);
+error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len,
+                       SmallVectorImpl<char> &utf8);
+} // end namespace windows
+} // end namespace sys
+} // end namespace llvm.