NAKAMURA Takumi | 5a43055 | 2015-08-05 06:11:08 +0000 | [diff] [blame] | 1 | //==- llvm/Support/Windows/COM.inc - Windows COM Implementation -*- C++ -*-===// |
Zachary Turner | c205570 | 2015-04-27 17:19:26 +0000 | [diff] [blame] | 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Zachary Turner | c205570 | 2015-04-27 17:19:26 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file implements the Windows portion of COM support. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | //=== WARNING: Implementation here must contain only Windows code. |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | |
| 17 | #include <objbase.h> |
| 18 | |
| 19 | namespace llvm { |
| 20 | namespace sys { |
| 21 | |
| 22 | InitializeCOMRAII::InitializeCOMRAII(COMThreadingMode Threading, |
| 23 | bool SpeedOverMemory) { |
| 24 | DWORD Coinit = 0; |
| 25 | if (Threading == COMThreadingMode::SingleThreaded) |
| 26 | Coinit |= COINIT_APARTMENTTHREADED; |
| 27 | else |
| 28 | Coinit |= COINIT_MULTITHREADED; |
| 29 | if (SpeedOverMemory) |
| 30 | Coinit |= COINIT_SPEED_OVER_MEMORY; |
| 31 | ::CoInitializeEx(nullptr, Coinit); |
| 32 | } |
| 33 | |
| 34 | InitializeCOMRAII::~InitializeCOMRAII() { ::CoUninitialize(); } |
| 35 | } |
| 36 | } |