diff options
author | Zachary Turner <zturner@google.com> | 2015-04-27 17:19:26 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2015-04-27 17:19:26 +0000 |
commit | c205570127c9f35607e55e96c4a2fac4c2553e99 (patch) | |
tree | 3915f9f2683dffdcca3549d6f94c04bbe5c82b1f /llvm/lib/Support/Windows | |
parent | 035025c0da0bbcd987093187b23ccd284d0942d9 (diff) | |
download | bcm5719-llvm-c205570127c9f35607e55e96c4a2fac4c2553e99.tar.gz bcm5719-llvm-c205570127c9f35607e55e96c4a2fac4c2553e99.zip |
Make an RAII com initializer.
Differential Revision: http://reviews.llvm.org/D9267
Reviewed By: Aaron Ballman, David Majnemer
llvm-svn: 235898
Diffstat (limited to 'llvm/lib/Support/Windows')
-rw-r--r-- | llvm/lib/Support/Windows/COM.inc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/llvm/lib/Support/Windows/COM.inc b/llvm/lib/Support/Windows/COM.inc new file mode 100644 index 00000000000..0c50d6f74ea --- /dev/null +++ b/llvm/lib/Support/Windows/COM.inc @@ -0,0 +1,37 @@ +//===- llvm/Support/Windows/COM.inc - Windows COM Implementation *- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the Windows portion of COM support. +// +//===----------------------------------------------------------------------===// + +//===----------------------------------------------------------------------===// +//=== WARNING: Implementation here must contain only Windows code. +//===----------------------------------------------------------------------===// + +#include <objbase.h> + +namespace llvm { +namespace sys { + +InitializeCOMRAII::InitializeCOMRAII(COMThreadingMode Threading, + bool SpeedOverMemory) { + DWORD Coinit = 0; + if (Threading == COMThreadingMode::SingleThreaded) + Coinit |= COINIT_APARTMENTTHREADED; + else + Coinit |= COINIT_MULTITHREADED; + if (SpeedOverMemory) + Coinit |= COINIT_SPEED_OVER_MEMORY; + ::CoInitializeEx(nullptr, Coinit); +} + +InitializeCOMRAII::~InitializeCOMRAII() { ::CoUninitialize(); } +} +} |