blob: 0c50d6f74ea38d335ebe7f96ec228549e2deae28 [file] [log] [blame]
Zachary Turnerc2055702015-04-27 17:19:26 +00001//===- llvm/Support/Windows/COM.inc - Windows COM Implementation *- C++ -*-===//
2//
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}