1*9880d681SAndroid Build Coastguard Worker//==- llvm/Support/Windows/COM.inc - Windows COM Implementation -*- C++ -*-===// 2*9880d681SAndroid Build Coastguard Worker// 3*9880d681SAndroid Build Coastguard Worker// The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker// 5*9880d681SAndroid Build Coastguard Worker// This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker// License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker// 8*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker// 10*9880d681SAndroid Build Coastguard Worker// This file implements the Windows portion of COM support. 11*9880d681SAndroid Build Coastguard Worker// 12*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 15*9880d681SAndroid Build Coastguard Worker//=== WARNING: Implementation here must contain only Windows code. 16*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker#include <objbase.h> 19*9880d681SAndroid Build Coastguard Worker 20*9880d681SAndroid Build Coastguard Workernamespace llvm { 21*9880d681SAndroid Build Coastguard Workernamespace sys { 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard WorkerInitializeCOMRAII::InitializeCOMRAII(COMThreadingMode Threading, 24*9880d681SAndroid Build Coastguard Worker bool SpeedOverMemory) { 25*9880d681SAndroid Build Coastguard Worker DWORD Coinit = 0; 26*9880d681SAndroid Build Coastguard Worker if (Threading == COMThreadingMode::SingleThreaded) 27*9880d681SAndroid Build Coastguard Worker Coinit |= COINIT_APARTMENTTHREADED; 28*9880d681SAndroid Build Coastguard Worker else 29*9880d681SAndroid Build Coastguard Worker Coinit |= COINIT_MULTITHREADED; 30*9880d681SAndroid Build Coastguard Worker if (SpeedOverMemory) 31*9880d681SAndroid Build Coastguard Worker Coinit |= COINIT_SPEED_OVER_MEMORY; 32*9880d681SAndroid Build Coastguard Worker ::CoInitializeEx(nullptr, Coinit); 33*9880d681SAndroid Build Coastguard Worker} 34*9880d681SAndroid Build Coastguard Worker 35*9880d681SAndroid Build Coastguard WorkerInitializeCOMRAII::~InitializeCOMRAII() { ::CoUninitialize(); } 36*9880d681SAndroid Build Coastguard Worker} 37*9880d681SAndroid Build Coastguard Worker} 38