mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-04 21:31:03 +00:00
Make an RAII com initializer.
Differential Revision: http://reviews.llvm.org/D9267 Reviewed By: Aaron Ballman, David Majnemer git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235898 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4e9cdece79
commit
d8caa1c4ca
36
include/llvm/Support/COM.h
Normal file
36
include/llvm/Support/COM.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
//===- llvm/Support/COM.h ---------------------------------------*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
/// \file
|
||||||
|
///
|
||||||
|
/// Provides a library for accessing COM functionality of the Host OS.
|
||||||
|
///
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_SUPPORT_COM_H
|
||||||
|
#define LLVM_SUPPORT_COM_H
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
namespace sys {
|
||||||
|
|
||||||
|
enum class COMThreadingMode { SingleThreaded, MultiThreaded };
|
||||||
|
|
||||||
|
class InitializeCOMRAII {
|
||||||
|
public:
|
||||||
|
explicit InitializeCOMRAII(COMThreadingMode Threading,
|
||||||
|
bool SpeedOverMemory = false);
|
||||||
|
~InitializeCOMRAII();
|
||||||
|
|
||||||
|
private:
|
||||||
|
InitializeCOMRAII(const InitializeCOMRAII &) = delete;
|
||||||
|
void operator=(const InitializeCOMRAII &) = delete;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -37,6 +37,7 @@ add_llvm_library(LLVMSupport
|
|||||||
BlockFrequency.cpp
|
BlockFrequency.cpp
|
||||||
BranchProbability.cpp
|
BranchProbability.cpp
|
||||||
circular_raw_ostream.cpp
|
circular_raw_ostream.cpp
|
||||||
|
COM.cpp
|
||||||
CommandLine.cpp
|
CommandLine.cpp
|
||||||
Compression.cpp
|
Compression.cpp
|
||||||
ConvertUTF.c
|
ConvertUTF.c
|
||||||
|
23
lib/Support/COM.cpp
Normal file
23
lib/Support/COM.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
//===-- COM.cpp - Implement COM utility classes -----------------*- 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 utility classes related to COM.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/Support/COM.h"
|
||||||
|
|
||||||
|
#include "llvm/Config/config.h"
|
||||||
|
|
||||||
|
// Include the platform-specific parts of this class.
|
||||||
|
#ifdef LLVM_ON_UNIX
|
||||||
|
#include "Unix/COM.inc"
|
||||||
|
#elif LLVM_ON_WIN32
|
||||||
|
#include "Windows/COM.inc"
|
||||||
|
#endif
|
27
lib/Support/Unix/COM.inc
Normal file
27
lib/Support/Unix/COM.inc
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
//===- llvm/Support/Unix/COM.inc - Unix 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 Unix portion of COM support.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//=== WARNING: Implementation here must contain only generic UNIX code that
|
||||||
|
//=== is guaranteed to work on *all* UNIX variants.
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
namespace sys {
|
||||||
|
|
||||||
|
COMInitializer::COMInitializer(COMThreadingMode Threading,
|
||||||
|
bool SpeedOverMemory) {}
|
||||||
|
|
||||||
|
COMInitializer::~COMInitializer() {}
|
||||||
|
}
|
||||||
|
}
|
37
lib/Support/Windows/COM.inc
Normal file
37
lib/Support/Windows/COM.inc
Normal file
@ -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(); }
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user