Skip to content

Commit

Permalink
relocate _Mtx_clear_owner and _Mtx_reset_owner
Browse files Browse the repository at this point in the history
  • Loading branch information
achabense committed Aug 17, 2023
1 parent 8674b3d commit a5d7849
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
5 changes: 0 additions & 5 deletions stl/inc/xthreads.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ _CRTIMP2_PURE _Thrd_result __cdecl _Mtx_lock(_Mtx_t);
_CRTIMP2_PURE _Thrd_result __cdecl _Mtx_trylock(_Mtx_t);
_CRTIMP2_PURE _Thrd_result __cdecl _Mtx_unlock(_Mtx_t); // TRANSITION, ABI: Always succeeds

#ifdef _CRTBLD
_CRTIMP2_PURE void __cdecl _Mtx_clear_owner(_Mtx_t);
_CRTIMP2_PURE void __cdecl _Mtx_reset_owner(_Mtx_t);
#endif // _CRTBLD

// shared mutex
// these declarations must be in sync with those in sharedmutex.cpp
void __cdecl _Smtx_lock_exclusive(_Smtx_t*);
Expand Down
12 changes: 12 additions & 0 deletions stl/src/cond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ _CRTIMP2_PURE void __cdecl _Cnd_destroy(const _Cnd_t cond) { // clean up
}
}

// TRANSITION, ABI: should be static; dllexported for binary compatibility
_CRTIMP2_PURE void __cdecl _Mtx_clear_owner(_Mtx_t mtx) { // set owner to nobody
mtx->_Thread_id = -1;
--mtx->_Count;
}

// TRANSITION, ABI: should be static; dllexported for binary compatibility
_CRTIMP2_PURE void __cdecl _Mtx_reset_owner(_Mtx_t mtx) { // set owner to current thread
mtx->_Thread_id = static_cast<long>(GetCurrentThreadId());
++mtx->_Count;
}

_CRTIMP2_PURE _Thrd_result __cdecl _Cnd_wait(const _Cnd_t cond, const _Mtx_t mtx) { // wait until signaled
const auto cs = &mtx->_Critical_section;
_Mtx_clear_owner(mtx);
Expand Down
10 changes: 0 additions & 10 deletions stl/src/mutex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,6 @@ _CRTIMP2_PURE void* __cdecl _Mtx_getconcrtcs(_Mtx_t mtx) { // get internal cs im
return &mtx->_Critical_section;
}

_CRTIMP2_PURE void __cdecl _Mtx_clear_owner(_Mtx_t mtx) { // set owner to nobody
mtx->_Thread_id = -1;
--mtx->_Count;
}

_CRTIMP2_PURE void __cdecl _Mtx_reset_owner(_Mtx_t mtx) { // set owner to current thread
mtx->_Thread_id = static_cast<long>(GetCurrentThreadId());
++mtx->_Count;
}

_END_EXTERN_C

/*
Expand Down

0 comments on commit a5d7849

Please sign in to comment.