1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
8 #ifndef _HANDLETABLE_INL
9 #define _HANDLETABLE_INL
11 inline void HndAssignHandle(OBJECTHANDLE handle, OBJECTREF objref)
25 // unwrap the objectref we were given
26 _UNCHECKED_OBJECTREF value = OBJECTREF_TO_UNCHECKED_OBJECTREF(objref);
28 HndLogSetEvent(handle, value);
30 // if we are doing a non-NULL pointer store then invoke the write-barrier
32 HndWriteBarrier(handle, objref);
35 *(_UNCHECKED_OBJECTREF *)handle = value;
38 inline void* HndInterlockedCompareExchangeHandle(OBJECTHANDLE handle, OBJECTREF objref, OBJECTREF oldObjref)
45 // unwrap the objectref we were given
46 _UNCHECKED_OBJECTREF value = OBJECTREF_TO_UNCHECKED_OBJECTREF(objref);
47 _UNCHECKED_OBJECTREF oldValue = OBJECTREF_TO_UNCHECKED_OBJECTREF(oldObjref);
49 // if we are doing a non-NULL pointer store then invoke the write-barrier
51 HndWriteBarrier(handle, objref);
55 void* ret = Interlocked::CompareExchangePointer(reinterpret_cast<_UNCHECKED_OBJECTREF volatile*>(handle), value, oldValue);
58 HndLogSetEvent(handle, value);
63 inline BOOL HndFirstAssignHandle(OBJECTHANDLE handle, OBJECTREF objref)
77 // unwrap the objectref we were given
78 _UNCHECKED_OBJECTREF value = OBJECTREF_TO_UNCHECKED_OBJECTREF(objref);
79 _UNCHECKED_OBJECTREF null = NULL;
81 // store the pointer if we are the first ones here
82 BOOL success = (NULL == Interlocked::CompareExchangePointer(reinterpret_cast<_UNCHECKED_OBJECTREF volatile*>(handle),
86 // if we successfully did a non-NULL pointer store then invoke the write-barrier
90 HndWriteBarrier(handle, objref);
92 HndLogSetEvent(handle, value);
99 #endif // _HANDLETABLE_INL