Skip to content

Commit

Permalink
Windows: Switch supported MinGW CRT to UCRT
Browse files Browse the repository at this point in the history
MSVCRT is deprecated and the reasons FEX used it no longer apply, so
support UCRT and UCRT only.
  • Loading branch information
bylaws committed Sep 27, 2024
1 parent b6d3df0 commit f9df7b0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
26 changes: 13 additions & 13 deletions Source/Windows/Common/CRT/IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,31 +278,23 @@ int fclose(FILE* File) {
return 0;
}

int fseeko64(FILE* File, _off64_t Offset, int Origin) {
DLLEXPORT_FUNC(int, _fseeki64, (FILE* File, _off64_t Offset, int Origin)) {
SetFilePointerEx(File->Handle, LARGE_INTEGER {.QuadPart = Offset}, nullptr, OriginToMoveMethod(Origin));
return 0;
}

int fseeko(FILE* File, _off_t Offset, int Origin) {
return fseeko64(File, Offset, Origin);
}

int fseek(FILE* File, long Offset, int Origin) {
return fseeko64(File, Offset, Origin);
return _fseeki64(File, Offset, Origin);
}

_off64_t ftello64(FILE* File) {
DLLEXPORT_FUNC(_off64_t, _ftelli64, (FILE* File)) {
LARGE_INTEGER Res;
SetFilePointerEx(File->Handle, LARGE_INTEGER {}, &Res, FILE_CURRENT);
return Res.QuadPart;
}

_off_t ftello(FILE* File) {
return static_cast<_off_t>(ftello64(File));
}

long ftell(FILE* File) {
return static_cast<long>(ftello64(File));
return static_cast<long>(_ftelli64(File));
}

size_t fread(void* __restrict__ DstBuf, size_t ElementSize, size_t Count, FILE* __restrict__ File) {
Expand All @@ -328,7 +320,11 @@ int fflush(FILE* _File) {
UNIMPLEMENTED();
}

int __mingw_vfprintf(FILE* __restrict__, const char* __restrict__, va_list) {
int fprintf(FILE* __restrict__, const char* __restrict__, ...) {
UNIMPLEMENTED();
}

int vfprintf(FILE* __restrict__, const char* __restrict__, va_list) {
UNIMPLEMENTED();
}

Expand All @@ -348,6 +344,10 @@ int fputc(int _Ch, FILE* _File) {
UNIMPLEMENTED();
}

int fputs(const char * __restrict__ _Str,FILE * __restrict__ _File) {
UNIMPLEMENTED();
}

int getc(FILE* _File) {
UNIMPLEMENTED();
}
Expand Down
31 changes: 20 additions & 11 deletions Source/Windows/Common/CRT/String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ char* strdup(const char* Src) {
return _strdup(Src);
}

float __mingw_strtof(const char* __restrict__, char** __restrict__) {
float strtof(const char* __restrict__, char** __restrict__) {
UNIMPLEMENTED();
}

double __mingw_strtod(const char* __restrict__, char** __restrict__) {
double strtod(const char* __restrict__, char** __restrict__) {
UNIMPLEMENTED();
}

Expand All @@ -60,15 +60,15 @@ long double strtold(const char* __restrict__, char** __restrict__) {
UNIMPLEMENTED();
}

double __mingw_wcstod(const wchar_t* __restrict__ _Str, wchar_t** __restrict__ _EndPtr) {
double wcstod(const wchar_t* __restrict__ _Str, wchar_t** __restrict__ _EndPtr) {
UNIMPLEMENTED();
}

long double wcstold(const wchar_t* __restrict__, wchar_t** __restrict__) {
UNIMPLEMENTED();
}

float __mingw_wcstof(const wchar_t* __restrict__ nptr, wchar_t** __restrict__ endptr) {
float wcstof(const wchar_t* __restrict__ nptr, wchar_t** __restrict__ endptr) {
UNIMPLEMENTED();
}

Expand All @@ -80,10 +80,14 @@ DLLEXPORT_FUNC(unsigned __int64, _strtoui64_l, (const char* _String, char** _End
UNIMPLEMENTED();
}

int __mingw_vsscanf(const char* __restrict__ _Str, const char* __restrict__ Format, va_list argp) {
int __stdio_common_vsscanf(unsigned __int64 options, const char *input, size_t length, const char *format, _locale_t locale, va_list valist) {
UNIMPLEMENTED();
}

int __stdio_common_vswprintf(unsigned __int64 options, wchar_t *str, size_t len, const wchar_t *format, _locale_t locale, va_list valist) {
return _vsnwprintf(str, len, format, valist);
}

int __mingw_vsnwprintf(wchar_t* __restrict__ Dest, size_t Count, const wchar_t* __restrict__ Format, va_list Args) {
int ret = _vsnwprintf(Dest, Count, Format, Args);
return ret;
Expand All @@ -94,11 +98,11 @@ int __mingw_vsprintf(char* __restrict__ Dest, const char* __restrict__ Format, v
return ret;
}

size_t strftime(char* __restrict__ _Buf, size_t _SizeInBytes, const char* __restrict__ _Format, const struct tm* __restrict__ _Tm) {
DLLEXPORT_FUNC(size_t, _strftime_l, (char * __restrict__ Buf,size_t Max_size,const char * __restrict__ Format,const struct tm * __restrict__ Tm,_locale_t Locale)) {
UNIMPLEMENTED();
}

int __mingw_vsnprintf(char* __restrict__ Dest, size_t Count, const char* __restrict__ Format, va_list Args) {
int vsnprintf(char* __restrict__ Dest, size_t Count, const char* __restrict__ Format, va_list Args) {
int ret = _vsnprintf(Dest, Count, Format, Args);
if (ret == -1) {
Dest[Count - 1] = '\0';
Expand All @@ -107,6 +111,15 @@ int __mingw_vsnprintf(char* __restrict__ Dest, size_t Count, const char* __restr
return ret;
}

int snprintf(char *stream, size_t n, const char *format, ...)
{
__builtin_va_list args;
__builtin_va_start(args, format);
int ret = vsnprintf(stream, n, format, args);
__builtin_va_end(args);
return ret;
}

char* setlocale(int _Category, const char* _Locale) {
return Locale;
}
Expand Down Expand Up @@ -166,10 +179,6 @@ DLLEXPORT_FUNC(errno_t, strerror_s, (char* _Buf, size_t _SizeInBytes, int _ErrNu
UNIMPLEMENTED();
}

DLLEXPORT_FUNC(int, _sscanf_l, (const char* buffer, const char* format, _locale_t locale, ...)) {
UNIMPLEMENTED();
}

DLLEXPORT_FUNC(int, _isctype, (int _C, int _Type)) {
UNIMPLEMENTED();
}
Expand Down

0 comments on commit f9df7b0

Please sign in to comment.