From b0573efc9c0ce20229d3f03e1a6868f2a24070ad Mon Sep 17 00:00:00 2001 From: Jean Philippe Date: Thu, 6 Feb 2020 17:45:34 +0000 Subject: [PATCH 01/14] Update _MSVC_STL_UPDATE value to February 2020 --- stl/inc/yvals_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 30bfce0f010..5724cb98480 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -441,7 +441,7 @@ #define _CPPLIB_VER 650 #define _MSVC_STL_VERSION 142 -#define _MSVC_STL_UPDATE 202001L +#define _MSVC_STL_UPDATE 202002L #ifndef _ALLOW_COMPILER_AND_STL_VERSION_MISMATCH #ifdef __EDG__ From 7e5b7b3a87ded697b2abf48535de1f7330f7110d Mon Sep 17 00:00:00 2001 From: Jean Philippe Date: Thu, 6 Feb 2020 18:41:12 +0000 Subject: [PATCH 02/14] Updated macro constants to constexpr variables #270 --- stl/src/xtime.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/src/xtime.cpp b/stl/src/xtime.cpp index ecc3ffd9569..dc065dbfb2f 100644 --- a/stl/src/xtime.cpp +++ b/stl/src/xtime.cpp @@ -8,10 +8,10 @@ #include #include -#define NSEC_PER_SEC 1000000000L -#define NSEC_PER_MSEC 1000000L -#define NSEC_PER_USEC 1000L -#define MSEC_PER_SEC 1000 +constexpr long NSEC_PER_SEC = 1000000000L; +constexpr long NSEC_PER_MSEC = 1000000L; +constexpr long NSEC_PER_USEC = 1000L; +constexpr int MSEC_PER_SEC = 1000; static void xtime_normalize(xtime* xt) { // adjust so that 0 <= nsec < 1 000 000 000 while (xt->nsec < 0) { // normalize target time From 59b9474af343c987e5e6883341de134c6185af51 Mon Sep 17 00:00:00 2001 From: Jean Philippe Date: Thu, 6 Feb 2020 19:05:05 +0000 Subject: [PATCH 03/14] Revert "Updated macro constants to constexpr variables #270" This reverts commit 7e5b7b3a87ded697b2abf48535de1f7330f7110d. --- stl/src/xtime.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/src/xtime.cpp b/stl/src/xtime.cpp index dc065dbfb2f..ecc3ffd9569 100644 --- a/stl/src/xtime.cpp +++ b/stl/src/xtime.cpp @@ -8,10 +8,10 @@ #include #include -constexpr long NSEC_PER_SEC = 1000000000L; -constexpr long NSEC_PER_MSEC = 1000000L; -constexpr long NSEC_PER_USEC = 1000L; -constexpr int MSEC_PER_SEC = 1000; +#define NSEC_PER_SEC 1000000000L +#define NSEC_PER_MSEC 1000000L +#define NSEC_PER_USEC 1000L +#define MSEC_PER_SEC 1000 static void xtime_normalize(xtime* xt) { // adjust so that 0 <= nsec < 1 000 000 000 while (xt->nsec < 0) { // normalize target time From 91167a0102342b6d5c28a0e9c42461ab9ad07a69 Mon Sep 17 00:00:00 2001 From: Jean Philippe Date: Thu, 6 Feb 2020 23:21:02 +0000 Subject: [PATCH 04/14] Changed macro constants to constexpr variables #270 --- stl/src/xtime.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stl/src/xtime.cpp b/stl/src/xtime.cpp index ecc3ffd9569..c2e75ee3de7 100644 --- a/stl/src/xtime.cpp +++ b/stl/src/xtime.cpp @@ -8,10 +8,10 @@ #include #include -#define NSEC_PER_SEC 1000000000L -#define NSEC_PER_MSEC 1000000L -#define NSEC_PER_USEC 1000L -#define MSEC_PER_SEC 1000 +constexpr long NSEC_PER_SEC = 1000000000L; +constexpr long NSEC_PER_MSEC = 1000000L; +constexpr long NSEC_PER_USEC = 1000L; +constexpr int MSEC_PER_SEC = 1000; static void xtime_normalize(xtime* xt) { // adjust so that 0 <= nsec < 1 000 000 000 while (xt->nsec < 0) { // normalize target time @@ -43,10 +43,10 @@ static xtime xtime_diff(const xtime* xt, } -#define EPOCH 0x19DB1DED53E8000i64 -#define NSEC100_PER_SEC (NSEC_PER_SEC / 100) -#define NSEC100_PER_MSEC (NSEC_PER_MSEC / 100) +constexpr long long EPOCH = 0x19DB1DED53E8000i64; +constexpr long NSEC100_PER_SEC = NSEC_PER_SEC / 100; +constexpr long NSEC100_PER_MSEC = NSEC_PER_MSEC / 100; _EXTERN_C From eecf8283a20c9af20d61d1c916f3927dedb7de4b Mon Sep 17 00:00:00 2001 From: Jean Philippe Date: Fri, 7 Feb 2020 00:41:35 +0000 Subject: [PATCH 05/14] updated variables to _Ugly naming convention --- stl/src/xtime.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/stl/src/xtime.cpp b/stl/src/xtime.cpp index c2e75ee3de7..744735f0ba2 100644 --- a/stl/src/xtime.cpp +++ b/stl/src/xtime.cpp @@ -8,19 +8,19 @@ #include #include -constexpr long NSEC_PER_SEC = 1000000000L; -constexpr long NSEC_PER_MSEC = 1000000L; -constexpr long NSEC_PER_USEC = 1000L; -constexpr int MSEC_PER_SEC = 1000; +constexpr long _Nsec_per_sec = 1000000000L; +constexpr long _Nsec_per_msec = 1000000L; +constexpr long _Nsec_per_usec = 1000L; +constexpr int _Msec_per_sec = 1000; static void xtime_normalize(xtime* xt) { // adjust so that 0 <= nsec < 1 000 000 000 while (xt->nsec < 0) { // normalize target time xt->sec -= 1; - xt->nsec += NSEC_PER_SEC; + xt->nsec += _Nsec_per_sec; } - while (NSEC_PER_SEC <= xt->nsec) { // normalize target time + while (_Nsec_per_sec <= xt->nsec) { // normalize target time xt->sec += 1; - xt->nsec -= NSEC_PER_SEC; + xt->nsec -= _Nsec_per_sec; } } @@ -30,7 +30,7 @@ static xtime xtime_diff(const xtime* xt, xtime_normalize(&diff); if (diff.nsec < now->nsec) { // avoid underflow diff.sec -= now->sec + 1; - diff.nsec += NSEC_PER_SEC - now->nsec; + diff.nsec += _Nsec_per_sec - now->nsec; } else { // no underflow diff.sec -= now->sec; diff.nsec -= now->nsec; @@ -43,28 +43,27 @@ static xtime xtime_diff(const xtime* xt, } - -constexpr long long EPOCH = 0x19DB1DED53E8000i64; -constexpr long NSEC100_PER_SEC = NSEC_PER_SEC / 100; -constexpr long NSEC100_PER_MSEC = NSEC_PER_MSEC / 100; +constexpr long long _Epoch = 0x19DB1DED53E8000i64; +constexpr long _Nsec100_per_sec = _Nsec_per_sec / 100; +constexpr long _Nsec100_per_msec = _Nsec_per_msec / 100; _EXTERN_C long long _Xtime_get_ticks() { // get system time in 100-nanosecond intervals since the epoch FILETIME ft; __crtGetSystemTimePreciseAsFileTime(&ft); - return ((static_cast(ft.dwHighDateTime)) << 32) + static_cast(ft.dwLowDateTime) - EPOCH; + return ((static_cast(ft.dwHighDateTime)) << 32) + static_cast(ft.dwLowDateTime) - _Epoch; } static void sys_get_time(xtime* xt) { // get system time with nanosecond resolution unsigned long long now = _Xtime_get_ticks(); - xt->sec = static_cast<__time64_t>(now / NSEC100_PER_SEC); - xt->nsec = static_cast(now % NSEC100_PER_SEC) * 100; + xt->sec = static_cast<__time64_t>(now / _Nsec100_per_sec); + xt->nsec = static_cast(now % _Nsec100_per_sec) * 100; } long _Xtime_diff_to_millis2(const xtime* xt1, const xtime* xt2) { // convert time to milliseconds xtime diff = xtime_diff(xt1, xt2); - return static_cast(diff.sec * MSEC_PER_SEC + (diff.nsec + NSEC_PER_MSEC - 1) / NSEC_PER_MSEC); + return static_cast(diff.sec * _Msec_per_sec + (diff.nsec + _Nsec_per_msec - 1) / _Nsec_per_msec); } long _Xtime_diff_to_millis(const xtime* xt) { // convert time to milliseconds From c403c181acb5734220afdc00402ece3852cbc2f6 Mon Sep 17 00:00:00 2001 From: Jean Philippe Date: Fri, 7 Feb 2020 01:00:46 +0000 Subject: [PATCH 06/14] Update stl/src/xtime.cpp Co-Authored-By: Casey Carter --- stl/src/xtime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/src/xtime.cpp b/stl/src/xtime.cpp index 744735f0ba2..892ba4e8e6c 100644 --- a/stl/src/xtime.cpp +++ b/stl/src/xtime.cpp @@ -43,7 +43,7 @@ static xtime xtime_diff(const xtime* xt, } -constexpr long long _Epoch = 0x19DB1DED53E8000i64; +constexpr long long _Epoch = 0x19DB1DED53E8000LL; constexpr long _Nsec100_per_sec = _Nsec_per_sec / 100; constexpr long _Nsec100_per_msec = _Nsec_per_msec / 100; From 8551ae878af80735cd1ac60b4612c67b91ab76b4 Mon Sep 17 00:00:00 2001 From: Jean Philippe Date: Fri, 7 Feb 2020 18:03:03 +0000 Subject: [PATCH 07/14] updated macro change --- stl/src/filesys.cpp | 9 +++++---- stl/src/ios.cpp | 8 ++++---- stl/src/iosptrs.cpp | 8 ++++---- stl/src/xlock.cpp | 21 +++++++++++---------- stl/src/xnotify.cpp | 12 ++++++------ stl/src/xstoflt.cpp | 24 ++++++++++++------------ stl/src/xstoul.cpp | 8 ++++---- stl/src/xstoull.cpp | 7 +++---- stl/src/xstoxflt.cpp | 26 +++++++++++++------------- stl/src/xtime.cpp | 3 +-- stl/src/xwstoflt.cpp | 24 ++++++++++++------------ stl/src/xwstoxfl.cpp | 24 ++++++++++++------------ 12 files changed, 87 insertions(+), 87 deletions(-) diff --git a/stl/src/filesys.cpp b/stl/src/filesys.cpp index ac16cf6f794..6dcdc4bb353 100644 --- a/stl/src/filesys.cpp +++ b/stl/src/filesys.cpp @@ -267,9 +267,10 @@ _FS_DLL unsigned long long __CLRCALL_PURE_OR_CDECL _File_size(const wchar_t* _Fn // 1908 is leap year #2 // 1968 is leap year #17 -#define WIN_TICKS_PER_SECOND 10000000ULL -#define WIN_TICKS_FROM_EPOCH (((1970 - 1601) * 365 + 3 * 24 + 17) * 86400ULL * WIN_TICKS_PER_SECOND) +constexpr UINT64 _Win_ticks_per_second = 10000000ULL; +constexpr UINT64 _Win_ticks_from_epoch = (((1970 - 1601) * 365 + 3 * 24 + 17) * 86400ULL * _Win_ticks_per_second); + _FS_DLL int64_t __CLRCALL_PURE_OR_CDECL _Last_write_time(const wchar_t* _Fname) { // get last write time WIN32_FILE_ATTRIBUTE_DATA _Data; @@ -281,7 +282,7 @@ _FS_DLL int64_t __CLRCALL_PURE_OR_CDECL _Last_write_time(const wchar_t* _Fname) // success, convert time unsigned long long _Wtime = static_cast(_Data.ftLastWriteTime.dwHighDateTime) << 32 | _Data.ftLastWriteTime.dwLowDateTime; - return static_cast(_Wtime - WIN_TICKS_FROM_EPOCH); + return static_cast(_Wtime - _Win_ticks_from_epoch); } @@ -294,7 +295,7 @@ _FS_DLL int __CLRCALL_PURE_OR_CDECL _Set_last_write_time(const wchar_t* _Fname, } // convert to FILETIME and set - unsigned long long _Wtime = static_cast(_When) + WIN_TICKS_FROM_EPOCH; + unsigned long long _Wtime = static_cast(_When) + _Win_ticks_from_epoch; FILETIME _Ft; _Ft.dwLowDateTime = static_cast(_Wtime); // intentionally discard upper bits _Ft.dwHighDateTime = static_cast(_Wtime >> 32); diff --git a/stl/src/ios.cpp b/stl/src/ios.cpp index 4f0be30a97d..91ee2363d34 100644 --- a/stl/src/ios.cpp +++ b/stl/src/ios.cpp @@ -7,7 +7,7 @@ #include _STD_BEGIN -#define NSTDSTR 8 // cin, wcin, cout, wcout, cerr, wcerr, clog, wclog +constexpr int _Nstdstr = 8; // cin, wcin, cout, wcout, cerr, wcerr, clog, wclog // TRANSITION, ABI: _BADOFF is preserved for binary compatibility #if defined(_M_CEE_PURE) @@ -22,8 +22,8 @@ __PURE_APPDOMAIN_GLOBAL int ios_base::_Index = 0; // initialize source of unique __PURE_APPDOMAIN_GLOBAL bool ios_base::_Sync = true; // initialize synchronization flag -__PURE_APPDOMAIN_GLOBAL static ios_base* stdstr[NSTDSTR + 2] = {0}; // [1, NSTDSTR] hold pointers to standard streams -__PURE_APPDOMAIN_GLOBAL static char stdopens[NSTDSTR + 2] = {0}; // [1, NSTDSTR] hold open counts for standard streams +__PURE_APPDOMAIN_GLOBAL static ios_base* stdstr[_Nstdstr + 2] = {0}; // [1, _Nstdstr] hold pointers to standard streams +__PURE_APPDOMAIN_GLOBAL static char stdopens[_Nstdstr + 2] = {0}; // [1, _Nstdstr] hold open counts for standard streams // void __CLR_OR_THIS_CALL ios_base::clear(iostate state, bool reraise) { // set state, possibly reraise exception // _Mystate = (iostate)(state & _Statmask); @@ -74,7 +74,7 @@ void __CLRCALL_PURE_OR_CDECL ios_base::_Ios_base_dtor(ios_base* _This) { // dest void __CLRCALL_PURE_OR_CDECL ios_base::_Addstd(ios_base* _This) { // add standard stream to destructor list _BEGIN_LOCK(_LOCK_STREAM) - for (_This->_Stdstr = 0; ++_This->_Stdstr < NSTDSTR;) { + for (_This->_Stdstr = 0; ++_This->_Stdstr < _Nstdstr;) { if (stdstr[_This->_Stdstr] == 0 || stdstr[_This->_Stdstr] == _This) { break; // found a candidate } diff --git a/stl/src/iosptrs.cpp b/stl/src/iosptrs.cpp index 4f7626d8f68..1390583e078 100644 --- a/stl/src/iosptrs.cpp +++ b/stl/src/iosptrs.cpp @@ -30,11 +30,11 @@ __PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wostream* _Ptr_wclog = 0; _STD_END // FINALIZATION CODE -#define NATS 10 // fclose, xgetloc, locks, facet free, etc. +constexpr int _Nats = 10; // fclose, xgetloc, locks, facet free, etc. // static data -__PURE_APPDOMAIN_GLOBAL static void(__cdecl* atfuns_cdecl[NATS])() = {0}; -__PURE_APPDOMAIN_GLOBAL static size_t atcount_cdecl = {NATS}; +__PURE_APPDOMAIN_GLOBAL static void(__cdecl* atfuns_cdecl[_Nats])() = {0}; +__PURE_APPDOMAIN_GLOBAL static size_t atcount_cdecl = {_Nats}; _MRTIMP2 void __cdecl _Atexit(void(__cdecl* pf)()) { // add to wrapup list if (atcount_cdecl == 0) { abort(); // stack full, give up @@ -45,7 +45,7 @@ _MRTIMP2 void __cdecl _Atexit(void(__cdecl* pf)()) { // add to wrapup list struct _Init_atexit { // controller for atexit processing __CLR_OR_THIS_CALL ~_Init_atexit() noexcept { // process wrapup functions - while (atcount_cdecl < NATS) { + while (atcount_cdecl < _Nats) { void(__cdecl * pf)() = (void(__cdecl*)()) DecodePointer(atfuns_cdecl[atcount_cdecl++]); if (pf) { (*pf)(); diff --git a/stl/src/xlock.cpp b/stl/src/xlock.cpp index 80eafb295b1..bbd37779368 100644 --- a/stl/src/xlock.cpp +++ b/stl/src/xlock.cpp @@ -11,12 +11,12 @@ _STD_BEGIN -#define MAX_LOCK 8 // must be power of two +constexpr int _Max_lock = 8; // must be power of two #pragma warning(disable : 4074) #pragma init_seg(compiler) -static _Rmtx mtx[MAX_LOCK]; +static _Rmtx mtx[_Max_lock]; static long init = -1; #if !defined(MRTDLL) @@ -70,7 +70,7 @@ __thiscall _Lockit::_Lockit() noexcept : _Locktype(0) { // lock default mutex __thiscall _Lockit::_Lockit(int kind) noexcept : _Locktype(kind) { // lock the mutex if (_Locktype == _LOCK_LOCALE) { _lock_locales(); - } else if (_Locktype < MAX_LOCK) { + } else if (_Locktype < _Max_lock) { _Mtxlock(&mtx[_Locktype]); } } @@ -78,7 +78,7 @@ __thiscall _Lockit::_Lockit(int kind) noexcept : _Locktype(kind) { // lock the m __thiscall _Lockit::~_Lockit() noexcept { // unlock the mutex if (_Locktype == _LOCK_LOCALE) { _unlock_locales(); - } else if (_Locktype < MAX_LOCK) { + } else if (_Locktype < _Max_lock) { _Mtxunlock(&mtx[_Locktype]); } } @@ -93,7 +93,7 @@ void __cdecl _Lockit::_Lockit_ctor(_Lockit* _This, int kind) noexcept { // lock if (kind == _LOCK_LOCALE) { _lock_locales(); } else { - _This->_Locktype = kind & (MAX_LOCK - 1); + _This->_Locktype = kind & (_Max_lock - 1); _Mtxlock(&mtx[_This->_Locktype]); } } @@ -107,7 +107,7 @@ void __cdecl _Lockit::_Lockit_ctor(int kind) noexcept { // lock the mutex if (kind == _LOCK_LOCALE) { _lock_locales(); } else { - _Mtxlock(&mtx[kind & (MAX_LOCK - 1)]); + _Mtxlock(&mtx[kind & (_Max_lock - 1)]); } } @@ -116,16 +116,17 @@ void __cdecl _Lockit::_Lockit_dtor(int kind) noexcept { // unlock the mutex if (kind == _LOCK_LOCALE) { _unlock_locales(); } else { - _Mtxunlock(&mtx[kind & (MAX_LOCK - 1)]); + _Mtxunlock(&mtx[kind & (_Max_lock - 1)]); } } -extern "C" void _Lock_at_thread_exit_mutex() { // lock the at-thread-exit mutex +_EXTERN_C +void _Lock_at_thread_exit_mutex() { // lock the at-thread-exit mutex _Mtxlock(&mtx[_LOCK_AT_THREAD_EXIT]); } - -extern "C" void _Unlock_at_thread_exit_mutex() { // unlock the at-thread-exit mutex +void _Unlock_at_thread_exit_mutex() { // unlock the at-thread-exit mutex _Mtxunlock(&mtx[_LOCK_AT_THREAD_EXIT]); } +_END_EXTERN_C _STD_END diff --git a/stl/src/xnotify.cpp b/stl/src/xnotify.cpp index 1a4b0fb9e9e..c3e87255399 100644 --- a/stl/src/xnotify.cpp +++ b/stl/src/xnotify.cpp @@ -9,7 +9,7 @@ #include -#define NITEMS 20 +constexpr int _Nitems = 20; namespace { struct _At_thread_exit_data { // data for condition-variable slot @@ -20,7 +20,7 @@ namespace { }; struct _At_thread_exit_block { // block of condition-variable slots - _At_thread_exit_data data[NITEMS]; + _At_thread_exit_data data[_Nitems]; int num_used; _At_thread_exit_block* next; }; @@ -40,14 +40,14 @@ void _Cnd_register_at_thread_exit( _Lock_at_thread_exit_mutex(); while (block != 0) { // loop through list of blocks - if (block->num_used == NITEMS) { // block is full; move to next block and allocate + if (block->num_used == _Nitems) { // block is full; move to next block and allocate if (block->next == 0) { block->next = (_At_thread_exit_block*) calloc(1, sizeof(_At_thread_exit_block)); } block = block->next; } else { // found block with available space - for (int i = 0; i < NITEMS; ++i) { // find empty slot + for (int i = 0; i < _Nitems; ++i) { // find empty slot if (block->data[i].mtx == 0) { // store into empty slot block->data[i].id._Id = GetCurrentThreadId(); block->data[i].mtx = mtx; @@ -69,7 +69,7 @@ void _Cnd_unregister_at_thread_exit(_Mtx_t mtx) { // unregister condition variab _Lock_at_thread_exit_mutex(); while (block != 0) { // loop through list of blocks - for (int i = 0; block->num_used != 0 && i < NITEMS; ++i) { + for (int i = 0; block->num_used != 0 && i < _Nitems; ++i) { if (block->data[i].mtx == mtx) { // release slot block->data[i].mtx = 0; --block->num_used; @@ -88,7 +88,7 @@ void _Cnd_do_broadcast_at_thread_exit() { // notify condition variables waiting _Lock_at_thread_exit_mutex(); while (block != 0) { // loop through list of blocks - for (int i = 0; block->num_used != 0 && i < NITEMS; ++i) { + for (int i = 0; block->num_used != 0 && i < _Nitems; ++i) { if (block->data[i].mtx != 0 && block->data[i].id._Id == currentThreadId) { // notify and release slot if (block->data[i].res) { *block->data[i].res = 1; diff --git a/stl/src/xstoflt.cpp b/stl/src/xstoflt.cpp index 16199533a2f..1abff128492 100644 --- a/stl/src/xstoflt.cpp +++ b/stl/src/xstoflt.cpp @@ -10,25 +10,25 @@ _EXTERN_C_UNLESS_PURE -#define BASE 10 // decimal -#define NDIG 9 // decimal digits per long word -#define MAXSIG (5 * NDIG) // maximum significant digits to keep +constexpr int _Base = 10; // decimal +constexpr int _Ndig = 9; // decimal digits per long word +constexpr int _Maxsig = (5 * _Ndig); // maximum significant digits to keep int _Stoflt(const char* s0, const char* s, char** endptr, long lo[], int maxsig) { // convert string to array of long plus exponent - char buf[MAXSIG + 1]; // worst case, with room for rounding digit + char buf[_Maxsig + 1]; // worst case, with room for rounding digit int nsig = 0; // number of significant digits seen int seen = 0; // any valid field characters seen int sticky = 0; // note any nonzero digits discarded int word = 0; // just before current long word to fill - maxsig *= NDIG; // convert word count to digit count - if (MAXSIG < maxsig) { - maxsig = MAXSIG; // protect against bad call + maxsig *= _Ndig; // convert word count to digit count + if (_Maxsig < maxsig) { + maxsig = _Maxsig; // protect against bad call } lo[0] = 0; // power of ten exponent - lo[1] = 0; // first NDIG-digit word of fraction + lo[1] = 0; // first _Ndig-digit word of fraction while (*s == '0') { // strip leading zeros seen = 1; @@ -82,14 +82,14 @@ int _Stoflt(const char* s0, const char* s, char** endptr, long lo[], if (seen) { // convert digit sequence to words int bufidx = 0; // next digit in buffer - int wordidx = NDIG - nsig % NDIG; // next digit in word (% NDIG) + int wordidx = _Ndig - nsig % _Ndig; // next digit in word (% _Ndig) - word = wordidx % NDIG == 0 ? 0 : 1; + word = wordidx % _Ndig == 0 ? 0 : 1; for (; bufidx < nsig; ++wordidx, ++bufidx) { - if (wordidx % NDIG == 0) { + if (wordidx % _Ndig == 0) { lo[++word] = buf[bufidx]; } else { - lo[word] = lo[word] * BASE + buf[bufidx]; + lo[word] = lo[word] * _Base + buf[bufidx]; } } diff --git a/stl/src/xstoul.cpp b/stl/src/xstoul.cpp index df57338efb7..d43dbc91dbe 100644 --- a/stl/src/xstoul.cpp +++ b/stl/src/xstoul.cpp @@ -14,7 +14,7 @@ _EXTERN_C_UNLESS_PURE // macros -#define BASE_MAX 36 // largest valid base +constexpr int _Base_max = 36; // largest valid base // static data static const char digits[] = // valid digits @@ -22,11 +22,11 @@ static const char digits[] = // valid digits #if (ULONG_MAX >> 16) >> 16 == 0xffffffff // 64-bits! -static const char ndigs[BASE_MAX + 1] = {0, 0, 65, 41, 33, 28, 25, 23, 22, 21, 20, 19, 18, 18, 17, 17, 17, 16, 16, 16, +static const char ndigs[_Base_max + 1] = {0, 0, 65, 41, 33, 28, 25, 23, 22, 21, 20, 19, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13}; #else // (ULONG_MAX >> 16) >> 16 == 0xffffffff // 32-bits! -static const char ndigs[BASE_MAX + 1] = {0, 0, 33, 21, 17, 14, 13, 12, 11, 11, 10, 10, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, +static const char ndigs[_Base_max + 1] = {0, 0, 33, 21, 17, 14, 13, 12, 11, 11, 10, 10, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}; #endif // (ULONG_MAX >> 16) >> 16 == 0xffffffff @@ -49,7 +49,7 @@ _CRTIMP2_PURE unsigned long __CLRCALL_PURE_OR_CDECL _Stoulx( } sign = *sc == '-' || *sc == '+' ? *sc++ : '+'; - if (base < 0 || base == 1 || BASE_MAX < base) { // silly base + if (base < 0 || base == 1 || _Base_max < base) { // silly base if (endptr != 0) { *endptr = (char*) s; } diff --git a/stl/src/xstoull.cpp b/stl/src/xstoull.cpp index d236cc8c030..1c5ceb13fb7 100644 --- a/stl/src/xstoull.cpp +++ b/stl/src/xstoull.cpp @@ -13,14 +13,13 @@ _EXTERN_C_UNLESS_PURE -// macros -#define BASE_MAX 36 // largest valid base +constexpr int _Base_max = 36; // largest valid base // static data static const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; // valid digits // 64-bits! -static const char ndigs[BASE_MAX + 1] = {0, 0, 65, 41, 33, 28, 25, 23, 22, 21, 20, 19, 18, 18, 17, 17, 17, 16, 16, 16, +static const char ndigs[_Base_max + 1] = {0, 0, 65, 41, 33, 28, 25, 23, 22, 21, 20, 19, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13}; _CRTIMP2_PURE unsigned long long __CLRCALL_PURE_OR_CDECL _Stoullx( @@ -41,7 +40,7 @@ _CRTIMP2_PURE unsigned long long __CLRCALL_PURE_OR_CDECL _Stoullx( } sign = (char) (*sc == '-' || *sc == '+' ? *sc++ : '+'); - if (base < 0 || base == 1 || BASE_MAX < base) { // silly base + if (base < 0 || base == 1 || _Base_max < base) { // silly base if (endptr != 0) { *endptr = (char*) s; } diff --git a/stl/src/xstoxflt.cpp b/stl/src/xstoxflt.cpp index db63479d596..48a1e3f2d1c 100644 --- a/stl/src/xstoxflt.cpp +++ b/stl/src/xstoxflt.cpp @@ -11,13 +11,13 @@ _EXTERN_C_UNLESS_PURE -#define BASE 16 // hexadecimal -#define NDIG 7 // hexadecimal digits per long element -#define MAXSIG (5 * NDIG) // maximum significant digits to keep +constexpr int _Base = 16; // hexadecimal +constexpr int _Ndig = 7; // hexadecimal digits per long element +constexpr int _Maxsig = (5 * _Ndig); // maximum significant digits to keep int _Stoxflt(const char* s0, const char* s, char** endptr, long lo[], int maxsig) { // convert string to array of long plus exponent - char buf[MAXSIG + 1]; // worst case, with room for rounding digit + char buf[_Maxsig + 1]; // worst case, with room for rounding digit int nsig = 0; // number of significant digits seen int seen = 0; // any valid field characters seen int word = 0; // current long word to fill @@ -27,13 +27,13 @@ int _Stoxflt(const char* s0, const char* s, char** endptr, long lo[], static const char vals[] = {// values of hex digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 10, 11, 12, 13, 14, 15}; - maxsig *= NDIG; // convert word count to digit count - if (MAXSIG < maxsig) { - maxsig = MAXSIG; // protect against bad call + maxsig *= _Ndig; // convert word count to digit count + if (_Maxsig < maxsig) { + maxsig = _Maxsig; // protect against bad call } lo[0] = 0; // power of ten exponent - lo[1] = 0; // first NDIG-digit word of fraction + lo[1] = 0; // first _Ndig-digit word of fraction while (*s == '0') { // strip leading zeros ++s; @@ -69,7 +69,7 @@ int _Stoxflt(const char* s0, const char* s, char** endptr, long lo[], } if (maxsig < nsig) { // discard excess digit after rounding up - if (BASE / 2 <= buf[maxsig]) { + if (_Base / 2 <= buf[maxsig]) { ++buf[maxsig - 1]; // okay if digit becomes BASE } @@ -88,14 +88,14 @@ int _Stoxflt(const char* s0, const char* s, char** endptr, long lo[], lo[0] <<= 2; // change hex exponent to binary exponent if (seen) { // convert digit sequence to words int bufidx = 0; // next digit in buffer - int wordidx = NDIG - nsig % NDIG; // next digit in word (% NDIG) + int wordidx = _Ndig - nsig % _Ndig; // next digit in word (% _Ndig) - word = wordidx % NDIG == 0 ? 0 : 1; + word = wordidx % _Ndig == 0 ? 0 : 1; for (; bufidx < nsig; ++wordidx, ++bufidx) { - if (wordidx % NDIG == 0) { + if (wordidx % _Ndig == 0) { lo[++word] = buf[bufidx]; } else { - lo[word] = lo[word] * BASE + buf[bufidx]; + lo[word] = lo[word] * _Base + buf[bufidx]; } } diff --git a/stl/src/xtime.cpp b/stl/src/xtime.cpp index 892ba4e8e6c..12286f52e59 100644 --- a/stl/src/xtime.cpp +++ b/stl/src/xtime.cpp @@ -10,7 +10,6 @@ constexpr long _Nsec_per_sec = 1000000000L; constexpr long _Nsec_per_msec = 1000000L; -constexpr long _Nsec_per_usec = 1000L; constexpr int _Msec_per_sec = 1000; static void xtime_normalize(xtime* xt) { // adjust so that 0 <= nsec < 1 000 000 000 @@ -45,7 +44,7 @@ static xtime xtime_diff(const xtime* xt, constexpr long long _Epoch = 0x19DB1DED53E8000LL; constexpr long _Nsec100_per_sec = _Nsec_per_sec / 100; -constexpr long _Nsec100_per_msec = _Nsec_per_msec / 100; +//constexpr long _Nsec100_per_msec = _Nsec_per_msec / 100; _EXTERN_C diff --git a/stl/src/xwstoflt.cpp b/stl/src/xwstoflt.cpp index 3cbfce6c705..6c7f4caf9e1 100644 --- a/stl/src/xwstoflt.cpp +++ b/stl/src/xwstoflt.cpp @@ -10,20 +10,20 @@ _EXTERN_C_UNLESS_PURE -#define BASE 10 // decimal -#define NDIG 9 // decimal digits per long element -#define MAXSIG (5 * NDIG) // maximum significant digits to keep +constexpr int _Base = 10; // decimal +constexpr int _Ndig = 9; // decimal digits per long element +constexpr int _Maxsig = (5 * _Ndig); // maximum significant digits to keep int _WStoflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], int maxsig) { // convert wide string to array of long plus exponent - char buf[MAXSIG + 1]; // worst case, with room for rounding digit + char buf[_Maxsig + 1]; // worst case, with room for rounding digit int nsig = 0; // number of significant digits seen int seen = 0; // any valid field characters seen int word = 0; // current long word to fill - maxsig *= NDIG; // convert word count to digit count - if (MAXSIG < maxsig) { - maxsig = MAXSIG; // protect against bad call + maxsig *= _Ndig; // convert word count to digit count + if (_Maxsig < maxsig) { + maxsig = _Maxsig; // protect against bad call } lo[0] = 0; // power of ten exponent @@ -68,7 +68,7 @@ int _WStoflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], } if (maxsig < nsig) { // discard excess digit after rounding up - if (BASE / 2 <= buf[maxsig]) { + if (_Base / 2 <= buf[maxsig]) { ++buf[maxsig - 1]; // okay if digit becomes BASE } @@ -86,14 +86,14 @@ int _WStoflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], if (seen) { // convert digit sequence to words int bufidx = 0; // next digit in buffer - int wordidx = NDIG - nsig % NDIG; // next digit in word (% NDIG) + int wordidx = _Ndig - nsig % _Ndig; // next digit in word (% NDIG) - word = wordidx % NDIG == 0 ? 0 : 1; + word = wordidx % _Ndig == 0 ? 0 : 1; for (; bufidx < nsig; ++wordidx, ++bufidx) { - if (wordidx % NDIG == 0) { + if (wordidx % _Ndig == 0) { lo[++word] = buf[bufidx]; } else { - lo[word] = lo[word] * BASE + buf[bufidx]; + lo[word] = lo[word] * _Base + buf[bufidx]; } } diff --git a/stl/src/xwstoxfl.cpp b/stl/src/xwstoxfl.cpp index ab17bfab5b1..bfe683f1ab8 100644 --- a/stl/src/xwstoxfl.cpp +++ b/stl/src/xwstoxfl.cpp @@ -11,13 +11,13 @@ _EXTERN_C_UNLESS_PURE -#define BASE 16 // hexadecimal -#define NDIG 7 // hexadecimal digits per long element -#define MAXSIG (5 * NDIG) // maximum significant digits to keep +constexpr int _Base = 16; // hexadecimal +constexpr int _Ndig = 7; // hexadecimal digits per long element +constexpr int _Maxsig = (5 * _Ndig); // maximum significant digits to keep int _WStoxflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], int maxsig) { // convert wide string to array of long plus exponent - char buf[MAXSIG + 1]; // worst case, with room for rounding digit + char buf[_Maxsig + 1]; // worst case, with room for rounding digit int nsig = 0; // number of significant digits seen int seen = 0; // any valid field characters seen int word = 0; // current long word to fill @@ -29,9 +29,9 @@ int _WStoxflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], static const char vals[] = {// values of hex digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 10, 11, 12, 13, 14, 15}; - maxsig *= NDIG; // convert word count to digit count - if (MAXSIG < maxsig) { - maxsig = MAXSIG; // protect against bad call + maxsig *= _Ndig; // convert word count to digit count + if (_Maxsig < maxsig) { + maxsig = _Maxsig; // protect against bad call } lo[0] = 0; // power of ten exponent @@ -74,7 +74,7 @@ int _WStoxflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], } if (maxsig < nsig) { // discard excess digit after rounding up - if (BASE / 2 <= buf[maxsig]) { + if (_Base / 2 <= buf[maxsig]) { ++buf[maxsig - 1]; // okay if digit becomes BASE } @@ -93,14 +93,14 @@ int _WStoxflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], lo[0] <<= 2; // change hex exponent to binary exponent if (seen) { // convert digit sequence to words int bufidx = 0; // next digit in buffer - int wordidx = NDIG - nsig % NDIG; // next digit in word (% NDIG) + int wordidx = _Ndig - nsig % _Ndig; // next digit in word (% NDIG) - word = wordidx % NDIG == 0 ? 0 : 1; + word = wordidx % _Ndig == 0 ? 0 : 1; for (; bufidx < nsig; ++wordidx, ++bufidx) { - if (wordidx % NDIG == 0) { + if (wordidx % _Ndig == 0) { lo[++word] = buf[bufidx]; } else { - lo[word] = lo[word] * BASE + buf[bufidx]; + lo[word] = lo[word] * _Base + buf[bufidx]; } } From fd3f8e8d754c32286b0e8f1016442fc5368b5d19 Mon Sep 17 00:00:00 2001 From: Jean Philippe Date: Fri, 7 Feb 2020 18:07:11 +0000 Subject: [PATCH 08/14] removed unecesarry comment --- stl/src/xtime.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/stl/src/xtime.cpp b/stl/src/xtime.cpp index 12286f52e59..348be79082c 100644 --- a/stl/src/xtime.cpp +++ b/stl/src/xtime.cpp @@ -44,7 +44,6 @@ static xtime xtime_diff(const xtime* xt, constexpr long long _Epoch = 0x19DB1DED53E8000LL; constexpr long _Nsec100_per_sec = _Nsec_per_sec / 100; -//constexpr long _Nsec100_per_msec = _Nsec_per_msec / 100; _EXTERN_C From bde3b367ca1d5d4067d8f47955dd3070597fa07c Mon Sep 17 00:00:00 2001 From: Jean Philippe Date: Fri, 7 Feb 2020 18:22:19 +0000 Subject: [PATCH 09/14] clang-format updated --- stl/src/xtime.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/src/xtime.cpp b/stl/src/xtime.cpp index 348be79082c..f39d35031e0 100644 --- a/stl/src/xtime.cpp +++ b/stl/src/xtime.cpp @@ -42,8 +42,8 @@ static xtime xtime_diff(const xtime* xt, } -constexpr long long _Epoch = 0x19DB1DED53E8000LL; -constexpr long _Nsec100_per_sec = _Nsec_per_sec / 100; +constexpr long long _Epoch = 0x19DB1DED53E8000LL; +constexpr long _Nsec100_per_sec = _Nsec_per_sec / 100; _EXTERN_C From e483f6a49354b01abf57c63b4f3afe90ebee3973 Mon Sep 17 00:00:00 2001 From: Jean Philippe Date: Fri, 7 Feb 2020 20:50:21 +0000 Subject: [PATCH 10/14] removed unnecessary parentheses --- stl/src/filesys.cpp | 4 ++-- stl/src/xstoflt.cpp | 2 +- stl/src/xstoxflt.cpp | 2 +- stl/src/xwstoflt.cpp | 2 +- stl/src/xwstoxfl.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/stl/src/filesys.cpp b/stl/src/filesys.cpp index 6dcdc4bb353..1e74200637d 100644 --- a/stl/src/filesys.cpp +++ b/stl/src/filesys.cpp @@ -268,8 +268,8 @@ _FS_DLL unsigned long long __CLRCALL_PURE_OR_CDECL _File_size(const wchar_t* _Fn // 1968 is leap year #17 -constexpr UINT64 _Win_ticks_per_second = 10000000ULL; -constexpr UINT64 _Win_ticks_from_epoch = (((1970 - 1601) * 365 + 3 * 24 + 17) * 86400ULL * _Win_ticks_per_second); +constexpr uint64_t _Win_ticks_per_second = 10000000ULL; +constexpr uint64_t _Win_ticks_from_epoch = ((1970 - 1601) * 365 + 3 * 24 + 17) * 86400ULL * _Win_ticks_per_second; _FS_DLL int64_t __CLRCALL_PURE_OR_CDECL _Last_write_time(const wchar_t* _Fname) { // get last write time diff --git a/stl/src/xstoflt.cpp b/stl/src/xstoflt.cpp index 1abff128492..ccec14ff6e9 100644 --- a/stl/src/xstoflt.cpp +++ b/stl/src/xstoflt.cpp @@ -12,7 +12,7 @@ _EXTERN_C_UNLESS_PURE constexpr int _Base = 10; // decimal constexpr int _Ndig = 9; // decimal digits per long word -constexpr int _Maxsig = (5 * _Ndig); // maximum significant digits to keep +constexpr int _Maxsig = 5 * _Ndig; // maximum significant digits to keep int _Stoflt(const char* s0, const char* s, char** endptr, long lo[], int maxsig) { // convert string to array of long plus exponent diff --git a/stl/src/xstoxflt.cpp b/stl/src/xstoxflt.cpp index 48a1e3f2d1c..08fa2ee4963 100644 --- a/stl/src/xstoxflt.cpp +++ b/stl/src/xstoxflt.cpp @@ -13,7 +13,7 @@ _EXTERN_C_UNLESS_PURE constexpr int _Base = 16; // hexadecimal constexpr int _Ndig = 7; // hexadecimal digits per long element -constexpr int _Maxsig = (5 * _Ndig); // maximum significant digits to keep +constexpr int _Maxsig = 5 * _Ndig; // maximum significant digits to keep int _Stoxflt(const char* s0, const char* s, char** endptr, long lo[], int maxsig) { // convert string to array of long plus exponent diff --git a/stl/src/xwstoflt.cpp b/stl/src/xwstoflt.cpp index 6c7f4caf9e1..5890bbd3335 100644 --- a/stl/src/xwstoflt.cpp +++ b/stl/src/xwstoflt.cpp @@ -12,7 +12,7 @@ _EXTERN_C_UNLESS_PURE constexpr int _Base = 10; // decimal constexpr int _Ndig = 9; // decimal digits per long element -constexpr int _Maxsig = (5 * _Ndig); // maximum significant digits to keep +constexpr int _Maxsig = 5 * _Ndig; // maximum significant digits to keep int _WStoflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], int maxsig) { // convert wide string to array of long plus exponent diff --git a/stl/src/xwstoxfl.cpp b/stl/src/xwstoxfl.cpp index bfe683f1ab8..8f99dda8098 100644 --- a/stl/src/xwstoxfl.cpp +++ b/stl/src/xwstoxfl.cpp @@ -13,7 +13,7 @@ _EXTERN_C_UNLESS_PURE constexpr int _Base = 16; // hexadecimal constexpr int _Ndig = 7; // hexadecimal digits per long element -constexpr int _Maxsig = (5 * _Ndig); // maximum significant digits to keep +constexpr int _Maxsig = 5 * _Ndig; // maximum significant digits to keep int _WStoxflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], int maxsig) { // convert wide string to array of long plus exponent From 1eee3367b0f3a0550851d7f9c48a0ba6d723a54d Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 7 Feb 2020 14:32:27 -0800 Subject: [PATCH 11/14] Update comments. --- stl/src/xstoflt.cpp | 2 +- stl/src/xstoxflt.cpp | 2 +- stl/src/xwstoflt.cpp | 6 +++--- stl/src/xwstoxfl.cpp | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stl/src/xstoflt.cpp b/stl/src/xstoflt.cpp index ccec14ff6e9..9ef65dfe932 100644 --- a/stl/src/xstoflt.cpp +++ b/stl/src/xstoflt.cpp @@ -69,7 +69,7 @@ int _Stoflt(const char* s0, const char* s, char** endptr, long lo[], } if (sticky) { - buf[maxsig - 1] += 1; // okay if digit becomes BASE + buf[maxsig - 1] += 1; // okay if digit becomes _Base } for (; 0 < nsig && buf[nsig - 1] == '\0'; --nsig) { diff --git a/stl/src/xstoxflt.cpp b/stl/src/xstoxflt.cpp index 08fa2ee4963..f679521d601 100644 --- a/stl/src/xstoxflt.cpp +++ b/stl/src/xstoxflt.cpp @@ -70,7 +70,7 @@ int _Stoxflt(const char* s0, const char* s, char** endptr, long lo[], if (maxsig < nsig) { // discard excess digit after rounding up if (_Base / 2 <= buf[maxsig]) { - ++buf[maxsig - 1]; // okay if digit becomes BASE + ++buf[maxsig - 1]; // okay if digit becomes _Base } nsig = maxsig; diff --git a/stl/src/xwstoflt.cpp b/stl/src/xwstoflt.cpp index 5890bbd3335..983723c4c4a 100644 --- a/stl/src/xwstoflt.cpp +++ b/stl/src/xwstoflt.cpp @@ -27,7 +27,7 @@ int _WStoflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], } lo[0] = 0; // power of ten exponent - lo[1] = 0; // first NDIG-digit word of fraction + lo[1] = 0; // first _Ndig-digit word of fraction while (*s == L'0') { // strip leading zeros ++s; @@ -69,7 +69,7 @@ int _WStoflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], if (maxsig < nsig) { // discard excess digit after rounding up if (_Base / 2 <= buf[maxsig]) { - ++buf[maxsig - 1]; // okay if digit becomes BASE + ++buf[maxsig - 1]; // okay if digit becomes _Base } nsig = maxsig; @@ -86,7 +86,7 @@ int _WStoflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], if (seen) { // convert digit sequence to words int bufidx = 0; // next digit in buffer - int wordidx = _Ndig - nsig % _Ndig; // next digit in word (% NDIG) + int wordidx = _Ndig - nsig % _Ndig; // next digit in word (% _Ndig) word = wordidx % _Ndig == 0 ? 0 : 1; for (; bufidx < nsig; ++wordidx, ++bufidx) { diff --git a/stl/src/xwstoxfl.cpp b/stl/src/xwstoxfl.cpp index 8f99dda8098..4b5aceb4480 100644 --- a/stl/src/xwstoxfl.cpp +++ b/stl/src/xwstoxfl.cpp @@ -35,7 +35,7 @@ int _WStoxflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], } lo[0] = 0; // power of ten exponent - lo[1] = 0; // first NDIG-digit word of fraction + lo[1] = 0; // first _Ndig-digit word of fraction while (*s == L'0') { // strip leading zeros ++s; @@ -75,7 +75,7 @@ int _WStoxflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], if (maxsig < nsig) { // discard excess digit after rounding up if (_Base / 2 <= buf[maxsig]) { - ++buf[maxsig - 1]; // okay if digit becomes BASE + ++buf[maxsig - 1]; // okay if digit becomes _Base } nsig = maxsig; @@ -93,7 +93,7 @@ int _WStoxflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], lo[0] <<= 2; // change hex exponent to binary exponent if (seen) { // convert digit sequence to words int bufidx = 0; // next digit in buffer - int wordidx = _Ndig - nsig % _Ndig; // next digit in word (% NDIG) + int wordidx = _Ndig - nsig % _Ndig; // next digit in word (% _Ndig) word = wordidx % _Ndig == 0 ? 0 : 1; for (; bufidx < nsig; ++wordidx, ++bufidx) { From f4dbc825a507b3f01a6fbe4795ca531f17a4a30a Mon Sep 17 00:00:00 2001 From: Jean Philippe Date: Wed, 26 Feb 2020 12:40:17 +0000 Subject: [PATCH 12/14] added llvm-project --- llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm-project b/llvm-project index 47282b1b4bf..5b14abf0c1d 160000 --- a/llvm-project +++ b/llvm-project @@ -1 +1 @@ -Subproject commit 47282b1b4bf3e18d2e2166b87159115ed520a2aa +Subproject commit 5b14abf0c1d0b64cbdba0c42957d55956374e5b8 From 08b889597e571c688add6a6abeef8f1e4bb02f0b Mon Sep 17 00:00:00 2001 From: Jean Philippe Date: Wed, 26 Feb 2020 18:55:38 +0000 Subject: [PATCH 13/14] Refactored declaring multiple variables on a single line (#522) --- stl/inc/cvt/wbuffer | 3 ++- stl/inc/iostream | 52 ++++++++++++++++++++++++++++++--------------- stl/inc/random | 4 +++- stl/inc/xiosbase | 9 +++++--- stl/inc/ymath.h | 16 +++++++++++--- stl/src/filesys.cpp | 4 +++- stl/src/xstol.cpp | 3 ++- stl/src/xstoll.cpp | 3 ++- stl/src/xstoul.cpp | 9 +++++--- stl/src/xstoull.cpp | 12 +++++++---- stl/src/xxxprec.h | 9 +++++--- 11 files changed, 86 insertions(+), 38 deletions(-) diff --git a/stl/inc/cvt/wbuffer b/stl/inc/cvt/wbuffer index d1b5977db0a..dbec71ab687 100644 --- a/stl/inc/cvt/wbuffer +++ b/stl/inc/cvt/wbuffer @@ -261,7 +261,8 @@ namespace stdext { while (_Status != _Eof) { // get using codecvt facet char* _Buf = &_Str[0]; - _Elem _Ch, *_Dest; + _Elem _Ch; + _Elem* _Dest; const char* _Src; int _Meta; diff --git a/stl/inc/iostream b/stl/inc/iostream index f356ac22443..ea6a3a93516 100644 --- a/stl/inc/iostream +++ b/stl/inc/iostream @@ -18,27 +18,45 @@ _STL_DISABLE_CLANG_WARNINGS #undef new _STD_BEGIN #ifdef _M_CEE_PURE -__PURE_APPDOMAIN_GLOBAL extern istream cin, *_Ptr_cin; -__PURE_APPDOMAIN_GLOBAL extern ostream cout, *_Ptr_cout; -__PURE_APPDOMAIN_GLOBAL extern ostream cerr, *_Ptr_cerr; -__PURE_APPDOMAIN_GLOBAL extern ostream clog, *_Ptr_clog; +__PURE_APPDOMAIN_GLOBAL extern istream cin; +__PURE_APPDOMAIN_GLOBAL extern ostream cout; +__PURE_APPDOMAIN_GLOBAL extern ostream cerr; +__PURE_APPDOMAIN_GLOBAL extern ostream clog; +__PURE_APPDOMAIN_GLOBAL extern istream* _Ptr_cin; +__PURE_APPDOMAIN_GLOBAL extern ostream* _Ptr_cout; +__PURE_APPDOMAIN_GLOBAL extern ostream* _Ptr_cerr; +__PURE_APPDOMAIN_GLOBAL extern ostream* _Ptr_clog; + +__PURE_APPDOMAIN_GLOBAL extern wistream wcin; +__PURE_APPDOMAIN_GLOBAL extern wostream wcout; +__PURE_APPDOMAIN_GLOBAL extern wostream wcerr; +__PURE_APPDOMAIN_GLOBAL extern wostream wclog; +__PURE_APPDOMAIN_GLOBAL extern wistream* _Ptr_wcin; +__PURE_APPDOMAIN_GLOBAL extern wostream* _Ptr_wcout; +__PURE_APPDOMAIN_GLOBAL extern wostream* _Ptr_wcerr; +__PURE_APPDOMAIN_GLOBAL extern wostream* _Ptr_wclog; -__PURE_APPDOMAIN_GLOBAL extern wistream wcin, *_Ptr_wcin; -__PURE_APPDOMAIN_GLOBAL extern wostream wcout, *_Ptr_wcout; -__PURE_APPDOMAIN_GLOBAL extern wostream wcerr, *_Ptr_wcerr; -__PURE_APPDOMAIN_GLOBAL extern wostream wclog, *_Ptr_wclog; #else // _M_CEE_PURE // OBJECTS -__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT istream cin, *_Ptr_cin; -__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT ostream cout, *_Ptr_cout; -__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT ostream cerr, *_Ptr_cerr; -__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT ostream clog, *_Ptr_clog; - -__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wistream wcin, *_Ptr_wcin; -__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wostream wcout, *_Ptr_wcout; -__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wostream wcerr, *_Ptr_wcerr; -__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wostream wclog, *_Ptr_wclog; +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT istream cin; +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT ostream cout; +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT ostream cerr; +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT ostream clog; +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT istream* _Ptr_cin; +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT ostream* _Ptr_cout; +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT ostream* _Ptr_cerr; +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT ostream* _Ptr_clog; + +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wistream wcin; +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wostream wcout; +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wostream wcerr; +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wostream wclog; +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wistream* _Ptr_wcin; +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wostream* _Ptr_wcout; +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wostream* _Ptr_wcerr; +__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wostream* _Ptr_wclog; + // CLASS _Winit class _CRTIMP2_PURE_IMPORT _Winit { diff --git a/stl/inc/random b/stl/inc/random index 2a0988f8c66..9f4004ea3ac 100644 --- a/stl/inc/random +++ b/stl/inc/random @@ -619,7 +619,9 @@ struct _Circ_buf { // holds historical values for generators bool _Equals(const _Circ_buf& _Right) const { const _Ty* _Last1 = _Ax + _Idx; const _Ty* _Last2 = _Right._Ax + _Right._Idx; - const _Ty *_First, *_Last, *_Other; + const _Ty* _First; + const _Ty* _Last; + const _Ty* _Other; bool _Use2 = _Base() < _Right._Base(); if (_Use2) { // _Right's range is higher up in the array diff --git a/stl/inc/xiosbase b/stl/inc/xiosbase index 8a564342410..19f3a15bd0f 100644 --- a/stl/inc/xiosbase +++ b/stl/inc/xiosbase @@ -508,7 +508,8 @@ private: } _Iosarray& __CLR_OR_THIS_CALL _Findarr(int _Idx) { // locate or make a variable array element - _Iosarray *_Ptr1, *_Ptr2; + _Iosarray* _Ptr1; + _Iosarray* _Ptr2; for (_Ptr1 = _Arr, _Ptr2 = nullptr; _Ptr1; _Ptr1 = _Ptr1->_Next) { if (_Ptr1->_Index == _Idx) { @@ -529,7 +530,8 @@ private: void __CLR_OR_THIS_CALL _Tidy() noexcept { // discard storage for an ios_base _Callfns(erase_event); - _Iosarray *_Ptr1, *_Ptr2; + _Iosarray* _Ptr1; + _Iosarray* _Ptr2; for (_Ptr1 = _Arr; _Ptr1; _Ptr1 = _Ptr2) { // delete array element _Ptr2 = _Ptr1->_Next; @@ -537,7 +539,8 @@ private: } _Arr = nullptr; - _Fnarray *_Pfa1, *_Pfa2; + _Fnarray* _Pfa1; + _Fnarray* _Pfa2; for (_Pfa1 = _Calls; _Pfa1; _Pfa1 = _Pfa2) { // delete callback element _Pfa2 = _Pfa1->_Next; delete _Pfa1; diff --git a/stl/inc/ymath.h b/stl/inc/ymath.h index 60c3274ff99..850ccd6e173 100644 --- a/stl/inc/ymath.h +++ b/stl/inc/ymath.h @@ -45,7 +45,11 @@ _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Dtest(double*); _CRTIMP2_PURE double __CLRCALL_PURE_OR_CDECL _Sinh(double, double); _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Exp(double*, double, short); -extern _CRTIMP2_PURE_IMPORT /* const */ _Dconst _Denorm, _Hugeval, _Inf, _Nan, _Snan; +extern _CRTIMP2_PURE_IMPORT _Dconst _Denorm; +extern _CRTIMP2_PURE_IMPORT _Dconst _Hugeval; +extern _CRTIMP2_PURE_IMPORT _Dconst _Inf; +extern _CRTIMP2_PURE_IMPORT _Dconst _Nan; +extern _CRTIMP2_PURE_IMPORT _Dconst _Snan; // float DECLARATIONS _CRTIMP2_PURE float __CLRCALL_PURE_OR_CDECL _FCosh(float, float); @@ -53,7 +57,10 @@ _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _FDtest(float*); _CRTIMP2_PURE float __CLRCALL_PURE_OR_CDECL _FSinh(float, float); _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _FExp(float*, float, short); -extern _CRTIMP2_PURE_IMPORT /* const */ _Dconst _FDenorm, _FInf, _FNan, _FSnan; +extern _CRTIMP2_PURE_IMPORT _Dconst _FDenorm; +extern _CRTIMP2_PURE_IMPORT _Dconst _FInf; +extern _CRTIMP2_PURE_IMPORT _Dconst _FNan; +extern _CRTIMP2_PURE_IMPORT _Dconst _FSnan; // long double DECLARATIONS _CRTIMP2_PURE long double __CLRCALL_PURE_OR_CDECL _LCosh(long double, long double); @@ -61,7 +68,10 @@ _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LDtest(long double*); _CRTIMP2_PURE long double __CLRCALL_PURE_OR_CDECL _LSinh(long double, long double); _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LExp(long double*, long double, short); -extern _CRTIMP2_PURE_IMPORT /* const */ _Dconst _LDenorm, _LInf, _LNan, _LSnan; +extern _CRTIMP2_PURE_IMPORT _Dconst _LDenorm; +extern _CRTIMP2_PURE_IMPORT _Dconst _LInf; +extern _CRTIMP2_PURE_IMPORT _Dconst _LNan; +extern _CRTIMP2_PURE_IMPORT _Dconst _LSnan; _END_EXTERN_C_UNLESS_PURE diff --git a/stl/src/filesys.cpp b/stl/src/filesys.cpp index 1e74200637d..120c5e5e618 100644 --- a/stl/src/filesys.cpp +++ b/stl/src/filesys.cpp @@ -314,7 +314,9 @@ _FS_DLL space_info __CLRCALL_PURE_OR_CDECL _Statvfs(const wchar_t* _Fname) { _Devname.push_back(L'/'); } - _ULARGE_INTEGER _Available, _Capacity, _Free; + _ULARGE_INTEGER _Available; + _ULARGE_INTEGER _Capacity; + _ULARGE_INTEGER _Free; if (GetDiskFreeSpaceExW(_Devname.c_str(), &_Available, &_Capacity, &_Free)) { // convert values _Ans.capacity = _Capacity.QuadPart; diff --git a/stl/src/xstol.cpp b/stl/src/xstol.cpp index 4c11609563d..f1c5f244795 100644 --- a/stl/src/xstol.cpp +++ b/stl/src/xstol.cpp @@ -18,7 +18,8 @@ _CRTIMP2_PURE unsigned long __CLRCALL_PURE_OR_CDECL _Stoulx(const char*, char**, _CRTIMP2_PURE long __CLRCALL_PURE_OR_CDECL _Stolx( const char* s, char** endptr, int base, int* perr) { // convert string to long, with checking const char* sc; - char *se, sign; + char* se; + char sign; unsigned long x; if (endptr == 0) { diff --git a/stl/src/xstoll.cpp b/stl/src/xstoll.cpp index 1de3109101a..df446e5adc0 100644 --- a/stl/src/xstoll.cpp +++ b/stl/src/xstoll.cpp @@ -16,7 +16,8 @@ _CRTIMP2_PURE unsigned long long __CLRCALL_PURE_OR_CDECL _Stoullx(const char*, c _CRTIMP2_PURE long long __CLRCALL_PURE_OR_CDECL _Stollx( const char* s, char** endptr, int base, int* perr) { // convert string to long long, with checking const char* sc; - char *se, sign; + char* se; + char sign; unsigned long long x; if (endptr == 0) { diff --git a/stl/src/xstoul.cpp b/stl/src/xstoul.cpp index d43dbc91dbe..1824ef9a2b2 100644 --- a/stl/src/xstoul.cpp +++ b/stl/src/xstoul.cpp @@ -32,12 +32,15 @@ static const char ndigs[_Base_max + 1] = {0, 0, 33, 21, 17, 14, 13, 12, 11, 11, _CRTIMP2_PURE unsigned long __CLRCALL_PURE_OR_CDECL _Stoulx( const char* s, char** endptr, int base, int* perr) { // convert string to unsigned long, with checking - const char *sc, *sd; - const char *s1, *s2; + const char* sc; + const char* sd; + const char* s1; + const char* s2; char dig = 0; char sign; ptrdiff_t n; - unsigned long x, y; + unsigned long x; + unsigned long y; if (perr != 0) { *perr = 0; diff --git a/stl/src/xstoull.cpp b/stl/src/xstoull.cpp index 1c5ceb13fb7..103cf8afe46 100644 --- a/stl/src/xstoull.cpp +++ b/stl/src/xstoull.cpp @@ -24,11 +24,15 @@ static const char ndigs[_Base_max + 1] = {0, 0, 65, 41, 33, 28, 25, 23, 22, 21, _CRTIMP2_PURE unsigned long long __CLRCALL_PURE_OR_CDECL _Stoullx( const char* s, char** endptr, int base, int* perr) { // convert string to unsigned long long, with checking - const char *sc, *sd; - const char *s1, *s2; - char dig, sign; + const char* sc; + const char* sd; + const char* s1; + const char* s2; + char dig; + char sign; ptrdiff_t n; - unsigned long long x, y; + unsigned long long x; + unsigned long long y; if (perr != 0) { *perr = 0; diff --git a/stl/src/xxxprec.h b/stl/src/xxxprec.h index d1b25d54f04..72c7041e4f3 100644 --- a/stl/src/xxxprec.h +++ b/stl/src/xxxprec.h @@ -67,7 +67,8 @@ FTYPE FNAME(Xp_getw)(const FTYPE* p, int n) { // get total value FTYPE* FNAME(Xp_setw)(FTYPE* p, int n, FTYPE x) { // load a full-precision value FTYPE x0 = x; - short errx, xexp; + short errx; + short xexp; if (n > 0) { if (n == 1 || (errx = FNAME(Dunscale)(&xexp, &x0)) == 0) { @@ -102,7 +103,8 @@ FTYPE* FNAME(Xp_setw)(FTYPE* p, int n, FTYPE x) { // load a full-precision value FTYPE* FNAME(Xp_addh)(FTYPE* p, int n, FTYPE x0) { // add a half-precision value FTYPE xscaled = x0; - short errx, xexp; + short errx; + short xexp; if (n != 0) { if (0 < (errx = FNAME(Dunscale)(&xexp, &xscaled))) { @@ -209,7 +211,8 @@ FTYPE* FNAME(Xp_addh)(FTYPE* p, int n, FTYPE x0) { // add a half-precision value FTYPE* FNAME(Xp_mulh)(FTYPE* p, int n, FTYPE x0) { // multiply by a half-precision value short errx; - int j, k; + int j; + int k; FTYPE buf[NBUF]; if (0 < n) { // check for special values From 23d8354c87c5eeec93be07223a94a12c74313146 Mon Sep 17 00:00:00 2001 From: Jean Philippe Date: Wed, 26 Feb 2020 21:09:30 +0000 Subject: [PATCH 14/14] revert llvm-project bits changes --- llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm-project b/llvm-project index 5b14abf0c1d..47282b1b4bf 160000 --- a/llvm-project +++ b/llvm-project @@ -1 +1 @@ -Subproject commit 5b14abf0c1d0b64cbdba0c42957d55956374e5b8 +Subproject commit 47282b1b4bf3e18d2e2166b87159115ed520a2aa