summaryrefslogtreecommitdiff
path: root/src/debug/ildbsymlib/umisc.h
blob: fda40474ff3fd74bd80422243fc4deaacc9eab2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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