blob: 54f3ecf28ec259da649bd8cdfc2da0e61e104b59 [file] [log] [blame]
NAKAMURA Takumi5a430552015-08-05 06:11:08 +00001//==- llvm/Support/Windows/COM.inc - Windows COM Implementation -*- C++ -*-===//
Zachary Turnerc2055702015-04-27 17:19:26 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the Windows portion of COM support.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15//=== WARNING: Implementation here must contain only Windows code.
16//===----------------------------------------------------------------------===//
17
18#include <objbase.h>
19
20namespace llvm {
21namespace sys {
22
23InitializeCOMRAII::InitializeCOMRAII(COMThreadingMode Threading,
24 bool SpeedOverMemory) {
25 DWORD Coinit = 0;
26 if (Threading == COMThreadingMode::SingleThreaded)
27 Coinit |= COINIT_APARTMENTTHREADED;
28 else
29 Coinit |= COINIT_MULTITHREADED;
30 if (SpeedOverMemory)
31 Coinit |= COINIT_SPEED_OVER_MEMORY;
32 ::CoInitializeEx(nullptr, Coinit);
33}
34
35InitializeCOMRAII::~InitializeCOMRAII() { ::CoUninitialize(); }
36}
37}