zig/lib/libc/mingw/misc/_get_current_locale.c
Andrew Kelley 49d1a4c562 move lib dirs to lib subdir
also start prefering NtDll API. so far:
 * NtQueryInformationFile
 * NtClose

adds a performance workaround for windows unicode conversion. but that
should probably be removed before merging
2019-07-15 17:54:50 -04:00

27 lines
585 B
C

#include <windows.h>
#include <locale.h>
#include <msvcrt.h>
static _locale_t __cdecl init_func(void);
_locale_t (__cdecl *__MINGW_IMP_SYMBOL(_get_current_locale))(void) = init_func;
static _locale_t __cdecl null_func(void)
{
return NULL;
}
static _locale_t __cdecl init_func(void)
{
HMODULE msvcrt = __mingw_get_msvcrt_handle();
_locale_t (__cdecl *func)(void) = NULL;
if (msvcrt) {
func = (void*)GetProcAddress(msvcrt, "_get_current_locale");
}
if (!func)
func = null_func;
return (__MINGW_IMP_SYMBOL(_get_current_locale) = func)();
}