diff options
Diffstat (limited to 'src/debug/ildbsymlib/umisc.h')
-rw-r--r-- | src/debug/ildbsymlib/umisc.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/debug/ildbsymlib/umisc.h b/src/debug/ildbsymlib/umisc.h new file mode 100644 index 0000000000..fda40474ff --- /dev/null +++ b/src/debug/ildbsymlib/umisc.h @@ -0,0 +1,69 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// =========================================================================== +// File: umisc.h +// + +// =========================================================================== + + +// Abstract: +// +// A collection of utility macros. +// + +#ifndef UMISC_H +#define UMISC_H + +#define COM_METHOD HRESULT STDMETHODCALLTYPE + +inline HRESULT HrFromWin32(DWORD dwWin32Error) +{ + return HRESULT_FROM_WIN32(dwWin32Error); +} + +// Some helper #def's to safely Release, close & delete Objects under +// failure conditions + +#define RELEASE(x) \ + do \ + { \ + if (x) \ + { \ + IUnknown *punk = x; \ + x = NULL; \ + punk->Release(); \ + } \ + } while (0) + + +#include "debugmacros.h" +// +// Good for verifying params withing range. +// +#define IfFalseGo(expr, HR) IfFailGo((expr) ? S_OK : (HR)) + +// ---------------------------------------------------------------------------- +// Validation macros +// Note that the Win32 APIs like IsBadReadPtr are banned +// +#define IsValidReadPtr(ptr, type) ((ptr)!=NULL) + +#define IsValidWritePtr(ptr, type) ((ptr)!=NULL) + +#define IsValidReadBufferPtr(ptr, type, len) ((ptr)!=NULL) + +#define IsValidWriteBufferPtr(ptr, type, len) ((ptr)!=NULL) + +#define IsValidInterfacePtr(ptr, type) ((ptr)!=NULL) + +#define IsValidCodePtr(ptr) ((ptr)!=NULL) + +#define IsValidStringPtr(ptr) ((ptr)!=NULL) + +#define IsValidIID(iid) TRUE + +#define IsValidCLSID(clsid) TRUE + +#endif |