Skip to content

Commit

Permalink
Remove some #ifdef _CRTBLD blocks (#3964)
Browse files Browse the repository at this point in the history
  • Loading branch information
achabense authored Sep 7, 2023
1 parent 6c69a73 commit 9b468b3
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 44 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
21 changes: 0 additions & 21 deletions stl/inc/yvals.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,6 @@ _EMIT_STL_WARNING(STL4001, "/clr:pure is deprecated and will be REMOVED.");
#endif
#endif // _CRTIMP2_PURE

#ifdef _CRTBLD
// These functions are for enabling STATIC_CPPLIB functionality
#define _cpp_stdin (__acrt_iob_func(0))
#define _cpp_stdout (__acrt_iob_func(1))
#define _cpp_stderr (__acrt_iob_func(2))
#define _cpp_isleadbyte(c) (__pctype_func()[static_cast<unsigned char>(c)] & _LEADBYTE)
#endif // defined(_CRTBLD)

#ifndef _CRTIMP2_IMPORT
#if defined(CRTDLL2) && defined(_CRTBLD)
#define _CRTIMP2_IMPORT __declspec(dllexport)
Expand Down Expand Up @@ -449,19 +441,6 @@ class _CRTIMP2_PURE_IMPORT _EmptyLockit { // empty lock class used for bin compa
#define _END_LOCINFO() }
#endif // ^^^ !defined(_M_CEE) ^^^

#ifdef _CRTBLD

#ifdef _M_CEE
#define _RELIABILITY_CONTRACT \
[System::Runtime::ConstrainedExecution::ReliabilityContract( \
System::Runtime::ConstrainedExecution::Consistency::WillNotCorruptState, \
System::Runtime::ConstrainedExecution::Cer::Success)]
#else // ^^^ defined(_M_CEE) / !defined(_M_CEE) vvv
#define _RELIABILITY_CONTRACT
#endif // ^^^ !defined(_M_CEE) ^^^

#endif // defined(_CRTBLD)

#if _HAS_EXCEPTIONS
#define _TRY_BEGIN try {
#define _CATCH(x) \
Expand Down
2 changes: 2 additions & 0 deletions stl/src/awint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include <Windows.h>

#define _cpp_isleadbyte(c) (__pctype_func()[static_cast<unsigned char>(c)] & _LEADBYTE)

_CRT_BEGIN_C_HEADER

#if _STL_WIN32_WINNT >= _WIN32_WINNT_WIN8
Expand Down
2 changes: 1 addition & 1 deletion stl/src/cerr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static std::_Init_locks initlocks;

_STD_BEGIN

__PURE_APPDOMAIN_GLOBAL static filebuf ferr(_cpp_stderr);
__PURE_APPDOMAIN_GLOBAL static filebuf ferr(stderr);

#if defined(_M_CEE_PURE)
__PURE_APPDOMAIN_GLOBAL extern ostream cerr(&ferr);
Expand Down
2 changes: 1 addition & 1 deletion stl/src/cin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static std::_Init_locks initlocks;

_STD_BEGIN

__PURE_APPDOMAIN_GLOBAL static filebuf fin(_cpp_stdin);
__PURE_APPDOMAIN_GLOBAL static filebuf fin(stdin);

#if defined(_M_CEE_PURE)
__PURE_APPDOMAIN_GLOBAL extern istream cin(&fin);
Expand Down
2 changes: 1 addition & 1 deletion stl/src/clog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static std::_Init_locks initlocks;

_STD_BEGIN

__PURE_APPDOMAIN_GLOBAL static filebuf flog(_cpp_stderr);
__PURE_APPDOMAIN_GLOBAL static filebuf flog(stderr);

#if defined(_M_CEE_PURE)
__PURE_APPDOMAIN_GLOBAL extern ostream clog(&flog);
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
2 changes: 1 addition & 1 deletion stl/src/cout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static std::_Init_locks initlocks;

_STD_BEGIN

__PURE_APPDOMAIN_GLOBAL static filebuf fout(_cpp_stdout);
__PURE_APPDOMAIN_GLOBAL static filebuf fout(stdout);

#if defined(_M_CEE_PURE)
__PURE_APPDOMAIN_GLOBAL extern ostream cout(&fout);
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
2 changes: 1 addition & 1 deletion stl/src/wcerr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static std::_Init_locks initlocks;

_STD_BEGIN

__PURE_APPDOMAIN_GLOBAL static wfilebuf wferr(_cpp_stderr);
__PURE_APPDOMAIN_GLOBAL static wfilebuf wferr(stderr);
#if defined(_M_CEE_PURE)
__PURE_APPDOMAIN_GLOBAL extern wostream wcerr(&wferr);
#else
Expand Down
2 changes: 1 addition & 1 deletion stl/src/wcin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static std::_Init_locks initlocks;

_STD_BEGIN

__PURE_APPDOMAIN_GLOBAL static wfilebuf wfin(_cpp_stdin);
__PURE_APPDOMAIN_GLOBAL static wfilebuf wfin(stdin);
#if defined(_M_CEE_PURE)
__PURE_APPDOMAIN_GLOBAL extern wistream wcin(&wfin);
#else
Expand Down
2 changes: 1 addition & 1 deletion stl/src/wclog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static std::_Init_locks initlocks;

_STD_BEGIN

__PURE_APPDOMAIN_GLOBAL static wfilebuf wflog(_cpp_stderr);
__PURE_APPDOMAIN_GLOBAL static wfilebuf wflog(stderr);
#if defined(_M_CEE_PURE)
__PURE_APPDOMAIN_GLOBAL extern wostream wclog(&wflog);
#else
Expand Down
2 changes: 1 addition & 1 deletion stl/src/wcout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static std::_Init_locks initlocks;

_STD_BEGIN

__PURE_APPDOMAIN_GLOBAL static wfilebuf wfout(_cpp_stdout);
__PURE_APPDOMAIN_GLOBAL static wfilebuf wfout(stdout);
#if defined(_M_CEE_PURE)
__PURE_APPDOMAIN_GLOBAL extern wostream wcout(&wfout);
#else
Expand Down
9 changes: 9 additions & 0 deletions stl/src/xmtx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@

#include <Windows.h>

#ifdef _M_CEE
#define _RELIABILITY_CONTRACT \
[System::Runtime::ConstrainedExecution::ReliabilityContract( \
System::Runtime::ConstrainedExecution::Consistency::WillNotCorruptState, \
System::Runtime::ConstrainedExecution::Cer::Success)]
#else // ^^^ defined(_M_CEE) / !defined(_M_CEE) vvv
#define _RELIABILITY_CONTRACT
#endif // ^^^ !defined(_M_CEE) ^^^

_EXTERN_C_UNLESS_PURE

using _Rmtx = CRITICAL_SECTION;
Expand Down

0 comments on commit 9b468b3

Please sign in to comment.