Skip to content

Commit

Permalink
10.0.22621.0
Browse files Browse the repository at this point in the history
  • Loading branch information
huangqinjin committed Sep 9, 2022
1 parent fe28bbb commit f941b37
Show file tree
Hide file tree
Showing 11 changed files with 343 additions and 28 deletions.
4 changes: 2 additions & 2 deletions convert/_fptostr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ static bool should_round_up(

if (round_mode == FE_UPWARD)
{
return *mantissa_it != '0' && sign != '-';
return check_trailing(mantissa_it, trailing_digits) && sign != '-';
}

if (round_mode == FE_DOWNWARD)
{
return *mantissa_it != '0' && sign == '-';
return check_trailing(mantissa_it, trailing_digits) && sign == '-';
}

return false;
Expand Down
28 changes: 28 additions & 0 deletions convert/cfout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,33 @@ using namespace __crt_strtox;

namespace
{
// Guard class for floating point control word modifications in the interrupt exception mask.
class fp_control_word_guard
{
public:
explicit fp_control_word_guard(unsigned int const mask = ~0u) : _mask(mask)
{
_controlfp_s(&_original_control_word, 0, 0);
}

fp_control_word_guard(unsigned int const new_control, unsigned int const mask) : _mask(mask)
{
unsigned int float_control;
_controlfp_s(&_original_control_word, 0, 0);
_controlfp_s(&float_control, new_control, _mask);
}

~fp_control_word_guard()
{
unsigned int reset_cw;
_controlfp_s(&reset_cw, _original_control_word, _mask);
}

private:
unsigned int _original_control_word;
unsigned int _mask;
};

class scoped_fp_state_reset
{
public:
Expand Down Expand Up @@ -335,5 +362,6 @@ extern "C" __acrt_has_trailing_digits __cdecl __acrt_fltout(
// The digit generator produces a truncated sequence of digits. To allow
// our caller to correctly round the mantissa, we need to generate an extra
// digit.
fp_control_word_guard const fpc(_MCW_EM, _MCW_EM);
return convert_to_fos_high_precision(value.x, precision + 1, precision_style, &flt->decpt, result, result_count);
}
10 changes: 8 additions & 2 deletions inc/corecrt_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ BOOL __cdecl __acrt_CreateProcessA(
);

_Success_(return > 0)
DWORD __cdecl __acrt_GetTempPathA(
DWORD __cdecl __acrt_GetTempPath2A(
DWORD nBufferLength,
_Out_writes_to_(nBufferLength, return + 1) PSTR lpBuffer
);
Expand Down Expand Up @@ -1241,6 +1241,11 @@ int WINAPI __acrt_GetDateFormatEx(
_In_opt_ LPCWSTR calendar
);

int WINAPI __acrt_GetTempPath2W(
_In_ DWORD nBufferLength,
_Out_writes_to_opt_(BufferLength, return +1) LPWSTR lpBuffer
);

DWORD64 WINAPI __acrt_GetEnabledXStateFeatures(void);

int WINAPI __acrt_GetLocaleInfoEx(
Expand Down Expand Up @@ -1364,7 +1369,8 @@ bool __cdecl __acrt_can_use_xstate_apis(void);
HWND __cdecl __acrt_get_parent_window(void);
bool __cdecl __acrt_is_interactive(void);


bool __cdecl __acrt_app_verifier_enabled(void);
bool __cdecl __acrt_is_secure_process(void);

LCID __cdecl __acrt_DownlevelLocaleNameToLCID(
_In_opt_ LPCWSTR localeName
Expand Down
4 changes: 2 additions & 2 deletions inc/corecrt_internal_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct __crt_char_traits;
_APPLY(get_full_path_name, __acrt_get_full_path_name_narrow_acp_or_utf8, __acrt_get_full_path_name_wide ) \
_APPLY(get_module_file_name, __acrt_GetModuleFileNameA, GetModuleFileNameW ) \
_APPLY(get_or_create_environment_nolock, __dcrt_get_or_create_narrow_environment_nolock, __dcrt_get_or_create_wide_environment_nolock ) \
_APPLY(get_temp_path, __acrt_GetTempPathA, GetTempPathW ) \
_APPLY(get_temp_path, __acrt_GetTempPath2A, __acrt_GetTempPath2W ) \
_APPLY(getc_nolock, _getc_nolock, _getwc_nolock ) \
_APPLY(gettche_nolock, _getche_nolock, _getwche_nolock ) \
_APPLY(initialize_environment_nolock, _initialize_narrow_environment, _initialize_wide_environment ) \
Expand Down Expand Up @@ -199,7 +199,7 @@ struct __crt_integer_traits<long long>
// the other needs to be cloned into the other.
//
// Places where we don't use current global locale, user-supplied locale, or ACP/UTF-8 adapter:
// CP_ACP - __acrt_GetTempPathA (via tmpnam)
// CP_ACP - __acrt_GetTempPath2A (via tmpnam)
// * Documented to do so on MSDN.
// * Required by API design - static buffer returned to user
// * Therefore, characters cannot be modified according to locale.
Expand Down
1 change: 1 addition & 0 deletions include/fenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ _ACRTIMP int __cdecl fesetround(_In_ int _Round);
};

double _Ans = 0.0;
(void) _Ans; // Suppress set-but-not-used warnings. _Ans is not "used" in the traditional static-analysis sense, but it is needed to trigger a floating point exception below.
size_t _Index;

if ((_Except &= FE_ALL_EXCEPT) == 0)
Expand Down
80 changes: 69 additions & 11 deletions include/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ _UCRT_DISABLE_CLANG_WARNINGS

_CRT_BEGIN_C_HEADER


#ifndef _CRT_USE_CONFORMING_ANNEX_K_TIME
#define _CRT_USE_CONFORMING_ANNEX_K_TIME 0
#endif

//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
Expand Down Expand Up @@ -446,23 +448,51 @@ _ACRTIMP int __cdecl _timespec64_get(
return _ctime32_s(_Buffer, _SizeInBytes, _Time);
}

#if _CRT_USE_CONFORMING_ANNEX_K_TIME
_Check_return_wat_
static __inline struct tm* __CRTDECL gmtime_s(
_In_ time_t const* const _Time,
_Out_ struct tm* const _Tm
)
{
if (_gmtime32_s(_Tm, _Time) == 0)
{
return _Tm;
}
return NULL;
}

_Check_return_wat_
static __inline struct tm* __CRTDECL localtime_s(
_In_ time_t const* const _Time,
_Out_ struct tm* const _Tm
)
{
if (_localtime32_s(_Tm, _Time) == 0)
{
return _Tm;
}
return NULL;
}
#else // _CRT_USE_CONFORMING_ANNEX_K_TIME
_Check_return_wat_
static __inline errno_t __CRTDECL gmtime_s(
_Out_ struct tm* const _Tm,
_In_ time_t const* const _Time
_Out_ struct tm* const _Tm,
_In_ time_t const* const _Time
)
{
return _gmtime32_s(_Tm, _Time);
}

_Check_return_wat_
static __inline errno_t __CRTDECL localtime_s(
_Out_ struct tm* const _Tm,
_In_ time_t const* const _Time
static __inline errno_t __CRTDECL localtime_s(
_Out_ struct tm* const _Tm,
_In_ time_t const* const _Time
)
{
return _localtime32_s(_Tm, _Time);
}
#endif // _CRT_USE_CONFORMING_ANNEX_K_TIME
#endif

#else // ^^^ _USE_32BIT_TIME_T ^^^ // vvv !_USE_32BIT_TIME_T vvv
Expand Down Expand Up @@ -542,23 +572,51 @@ _ACRTIMP int __cdecl _timespec64_get(
return _ctime64_s(_Buffer, _SizeInBytes, _Time);
}

#if _CRT_USE_CONFORMING_ANNEX_K_TIME
_Check_return_wat_
static __inline struct tm* __CRTDECL gmtime_s(
_In_ time_t const* const _Time,
_Out_ struct tm* const _Tm
)
{
if (_gmtime64_s(_Tm, _Time) == 0)
{
return _Tm;
}
return NULL;
}

_Check_return_wat_
static __inline struct tm* __CRTDECL localtime_s(
_In_ time_t const* const _Time,
_Out_ struct tm* const _Tm
)
{
if (_localtime64_s(_Tm, _Time) == 0)
{
return _Tm;
}
return NULL;
}
#else // _CRT_USE_CONFORMING_ANNEX_K_TIME
_Check_return_wat_
static __inline errno_t __CRTDECL gmtime_s(
_Out_ struct tm* const _Tm,
_In_ time_t const* const _Time
_Out_ struct tm* const _Tm,
_In_ time_t const* const _Time
)
{
return _gmtime64_s(_Tm, _Time);
}

_Check_return_wat_
static __inline errno_t __CRTDECL localtime_s(
_Out_ struct tm* const _Tm,
_In_ time_t const* const _Time
static __inline errno_t __CRTDECL localtime_s(
_Out_ struct tm* const _Tm,
_In_ time_t const* const _Time
)
{
return _localtime64_s(_Tm, _Time);
}
#endif // _CRT_USE_CONFORMING_ANNEX_K_TIME
#endif

#endif // !_USE_32BIT_TIME_T
Expand Down
22 changes: 22 additions & 0 deletions internal/peb_access.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// peb_access.cpp
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Wrapper functions to access fields in the PEB.
//

// Using internal headers for definitions. Only call publicly available functions.
#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>

extern "C" bool __cdecl __acrt_app_verifier_enabled()
{
return (NtCurrentTeb()->ProcessEnvironmentBlock->NtGlobalFlag & FLG_APPLICATION_VERIFIER) != 0;
}

extern "C" bool __cdecl __acrt_is_secure_process()
{
return (NtCurrentTeb()->ProcessEnvironmentBlock->ProcessParameters->Flags & RTL_USER_PROC_SECURE_PROCESS) != 0;
}
Loading

0 comments on commit f941b37

Please sign in to comment.