WinAdapter.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //===-- WinAdapter.cpp - Windows Adapter for other platforms ----*- 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. #ifndef _WIN32
  10. #include "dxc/Support/WinAdapter.h"
  11. #include "dxc/Support/WinFunctions.h"
  12. DEFINE_CROSS_PLATFORM_UUIDOF(IUnknown)
  13. DEFINE_CROSS_PLATFORM_UUIDOF(INoMarshal)
  14. DEFINE_CROSS_PLATFORM_UUIDOF(IStream)
  15. DEFINE_CROSS_PLATFORM_UUIDOF(ISequentialStream)
  16. //===--------------------------- IUnknown ---------------------------------===//
  17. ULONG IUnknown::AddRef() {
  18. ++m_count;
  19. return m_count;
  20. }
  21. ULONG IUnknown::Release() {
  22. ULONG result = --m_count;
  23. if (m_count == 0) {
  24. delete this;
  25. }
  26. return result;
  27. }
  28. IUnknown::~IUnknown() {}
  29. //===--------------------------- IMalloc ----------------------------------===//
  30. void *IMalloc::Alloc(size_t size) { return malloc(size); }
  31. void *IMalloc::Realloc(void *ptr, size_t size) { return realloc(ptr, size); }
  32. void IMalloc::Free(void *ptr) { free(ptr); }
  33. HRESULT IMalloc::QueryInterface(REFIID riid, void **ppvObject) {
  34. assert(false && "QueryInterface not implemented for IMalloc.");
  35. return E_NOINTERFACE;
  36. }
  37. //===--------------------------- CAllocator -------------------------------===//
  38. void *CAllocator::Reallocate(void *p, size_t nBytes) throw() {
  39. return realloc(p, nBytes);
  40. }
  41. void *CAllocator::Allocate(size_t nBytes) throw() { return malloc(nBytes); }
  42. void CAllocator::Free(void *p) throw() { free(p); }
  43. //===--------------------------- CHandle -------------------------------===//
  44. CHandle::CHandle(HANDLE h) { m_h = h; }
  45. CHandle::~CHandle() { CloseHandle(m_h); }
  46. CHandle::operator HANDLE() const throw() { return m_h; }
  47. #endif