[UCRT] Import Microsoft.Windows.SDK.CRTSource version 10.0.22621.3

Imported from https://www.nuget.org/packages/Microsoft.Windows.SDK.CRTSource/10.0.22621.3
License: MIT
This commit is contained in:
Timo Kreuzer 2024-05-11 07:03:12 +02:00
parent f1b60c66f0
commit 04e0dc4a7a
568 changed files with 115483 additions and 0 deletions

View file

@ -0,0 +1,48 @@
//
// getw.cpp
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Defines _getw(), which reads a binary integer to a stream.
//
#include <corecrt_internal_stdio.h>
// Reads a binary int value from the stream, byte-by-byte. On success, returns
// the value written; on failure (error or eof), returns EOF. Note, however,
// that the value may be EOF--that is, after all, a valid integer--so be sure to
// test ferror() and feof() to check for error conditions.
extern "C" int __cdecl _getw(FILE* const stream)
{
_VALIDATE_RETURN(stream != nullptr, EINVAL, EOF);
int return_value = EOF;
_lock_file(stream);
__try
{
int value = 0;
char* const first = reinterpret_cast<char*>(&value);
char* const last = first + sizeof(value);
for (char* it = first; it != last; ++it)
{
*it = static_cast<char>(_getc_nolock(stream));
}
if (feof(stream))
__leave;
if (ferror(stream))
__leave;
return_value = value;
}
__finally
{
_unlock_file(stream);
}
return return_value;
}