--- mingw-w64-crt/misc/_create_locale.c | 25 ++----- mingw-w64-crt/misc/_free_locale.c | 25 ++----- mingw-w64-crt/misc/_get_current_locale.c | 32 ++++----- mingw-w64-crt/misc/output_format.c | 85 ++++++------------------ mingw-w64-crt/misc/wassert.c | 37 ++--------- mingw-w64-crt/stdio/_vscprintf.c | 40 ++--------- mingw-w64-crt/stdio/_vscwprintf.c | 40 ++--------- 7 files changed, 63 insertions(+), 221 deletions(-)
diff --git a/mingw-w64-crt/misc/_create_locale.c b/mingw-w64-crt/misc/_create_locale.c index 00947b3ac196..3cdeb1ae8045 100644 --- a/mingw-w64-crt/misc/_create_locale.c +++ b/mingw-w64-crt/misc/_create_locale.c @@ -4,30 +4,17 @@ * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ -#include <windows.h> #include <locale.h> -#include <msvcrt.h> -static _locale_t __cdecl init_func(int category, const char *locale); -_locale_t (__cdecl *__MINGW_IMP_SYMBOL(_create_locale))(int, const char *) = init_func; - -static _locale_t __cdecl null_func(int category, const char *locale) +static _locale_t __cdecl emu__create_locale(int category, const char *locale) { (void)category; (void)locale; return NULL; } -static _locale_t __cdecl init_func(int category, const char *locale) -{ - HMODULE msvcrt = __mingw_get_msvcrt_handle(); - _locale_t (__cdecl *func)(int, const char *) = NULL; - - if (msvcrt) - func = (void*)GetProcAddress(msvcrt, "_create_locale"); - - if (!func) - func = null_func; - - return (__MINGW_IMP_SYMBOL(_create_locale) = func)(category, locale); -} +#define RETT _locale_t +#define FUNC _create_locale +#define ARGS int category, const char * locale +#define CALL category, locale +#include "msvcrt_or_emu_glue.h" diff --git a/mingw-w64-crt/misc/_free_locale.c b/mingw-w64-crt/misc/_free_locale.c index d94e2274fafb..cd7c36317bcc 100644 --- a/mingw-w64-crt/misc/_free_locale.c +++ b/mingw-w64-crt/misc/_free_locale.c @@ -4,28 +4,15 @@ * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ -#include <windows.h> #include <locale.h> -#include <msvcrt.h> -static void __cdecl init_func(_locale_t locale); -void (__cdecl *__MINGW_IMP_SYMBOL(_free_locale))(_locale_t) = init_func; - -static void __cdecl stub_func(_locale_t locale) +static void __cdecl emu__free_locale(_locale_t locale) { (void)locale; } -static void __cdecl init_func(_locale_t locale) -{ - HMODULE msvcrt = __mingw_get_msvcrt_handle(); - void (__cdecl *func)(_locale_t) = NULL; - - if (msvcrt) - func = (void*)GetProcAddress(msvcrt, "_free_locale"); - - if (!func) - func = stub_func; - - (__MINGW_IMP_SYMBOL(_free_locale) = func)(locale); -} +#define RETT void +#define FUNC _free_locale +#define ARGS _locale_t locale +#define CALL locale +#include "msvcrt_or_emu_glue.h" diff --git a/mingw-w64-crt/misc/_get_current_locale.c b/mingw-w64-crt/misc/_get_current_locale.c index f5ccc4afc192..97dfba684919 100644 --- a/mingw-w64-crt/misc/_get_current_locale.c +++ b/mingw-w64-crt/misc/_get_current_locale.c @@ -1,26 +1,18 @@ -#include <windows.h> -#include <locale.h> -#include <msvcrt.h> +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ -static _locale_t __cdecl init_func(void); -_locale_t (__cdecl *__MINGW_IMP_SYMBOL(_get_current_locale))(void) = init_func; +#include <locale.h> -static _locale_t __cdecl null_func(void) +static _locale_t __cdecl emu__get_current_locale(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)(); -} +#define RETT _locale_t +#define FUNC _get_current_locale +#define ARGS void +#define CALL +#include "msvcrt_or_emu_glue.h" diff --git a/mingw-w64-crt/misc/output_format.c b/mingw-w64-crt/misc/output_format.c index d55da8bdcdf0..cad3b3a4225b 100644 --- a/mingw-w64-crt/misc/output_format.c +++ b/mingw-w64-crt/misc/output_format.c @@ -1,77 +1,32 @@ -#define _get_output_format __dummy__get_output_format -#define _set_output_format __dummy__set_output_format -#include <windows.h> +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ -#undef _get_output_format -#undef _set_output_format +#include <stdio.h> +#include <windows.h> static unsigned int last_value = 0; -typedef unsigned int (*f_get_output_format)(void); -typedef unsigned int (*f_set_output_format)(unsigned int); -static unsigned int fake_get_output_format(void) +static unsigned int emu__get_output_format(void) { return last_value; } -static unsigned int fake_set_output_format(unsigned int value) +static unsigned int emu__set_output_format(unsigned int value) { return InterlockedExchange((LONG*)&last_value, value); } - -#ifndef __LIBMSVCRT_OS__ - -unsigned int __attribute__ ((alias ("fake_set_output_format"))) _set_output_format(unsigned int); -f_set_output_format __MINGW_IMP_SYMBOL(_set_output_format) = _set_output_format; - - -unsigned int __attribute__ ((alias ("fake_get_output_format"))) _get_output_format(void); -f_get_output_format __MINGW_IMP_SYMBOL(_get_output_format) = _get_output_format; - -#else - -#include <msvcrt.h> - -static unsigned int init_set_output_format(unsigned int); -f_set_output_format __MINGW_IMP_SYMBOL(_set_output_format) = init_set_output_format; - -unsigned int _set_output_format(unsigned int format); -unsigned int _set_output_format(unsigned int format) -{ - return __MINGW_IMP_SYMBOL(_set_output_format)(format); -} - -static unsigned int init_set_output_format(unsigned int format) -{ - f_set_output_format sof; - - sof = (void*) GetProcAddress (__mingw_get_msvcrt_handle(), "_set_output_format"); - if(!sof) - sof = fake_set_output_format; - - return (__MINGW_IMP_SYMBOL(_set_output_format) = sof)(format); -} - - -static unsigned int init_get_output_format(void); -f_get_output_format __MINGW_IMP_SYMBOL(_get_output_format) = init_get_output_format; - -unsigned int _get_output_format(void); -unsigned int _get_output_format(void) -{ - return __MINGW_IMP_SYMBOL(_get_output_format)(); -} - -static unsigned int init_get_output_format(void) -{ - f_get_output_format gof; - - gof = (void*) GetProcAddress (__mingw_get_msvcrt_handle(), "_get_output_format"); - if(!gof) - gof = fake_get_output_format; - - return (__MINGW_IMP_SYMBOL(_get_output_format) = gof)(); -} - -#endif +#define RETT unsigned int +#define FUNC _get_output_format +#define ARGS void +#define CALL +#include "msvcrt_or_emu_glue.h" + +#define RETT unsigned int +#define FUNC _set_output_format +#define ARGS unsigned int format +#define CALL format +#include "msvcrt_or_emu_glue.h" diff --git a/mingw-w64-crt/misc/wassert.c b/mingw-w64-crt/misc/wassert.c index b43ddaf20ba8..690239423b75 100644 --- a/mingw-w64-crt/misc/wassert.c +++ b/mingw-w64-crt/misc/wassert.c @@ -9,7 +9,7 @@ /* _wassert is not available on XP, so forward it to _assert if needed */ __MINGW_ATTRIB_NORETURN -static void __cdecl mingw_wassert(const wchar_t *_Message, const wchar_t *_File, unsigned _Line) +static void __cdecl emu__wassert(const wchar_t *_Message, const wchar_t *_File, unsigned _Line) { char *message = NULL, *file = NULL; size_t len; @@ -27,34 +27,11 @@ static void __cdecl mingw_wassert(const wchar_t *_Message, const wchar_t *_File, } _assert(message, file, _Line); - - free(message); - free(file); -} - -#ifndef __LIBMSVCRT_OS__ - -void __cdecl __attribute__ ((alias ("mingw_wassert"))) _wassert(const wchar_t *, const wchar_t *, unsigned); -void (__cdecl *__MINGW_IMP_SYMBOL(_wassert))(const wchar_t*, const wchar_t*, unsigned) = _wassert; - -#else - -#include <windows.h> -#include "msvcrt.h" - -static void __cdecl init_wassert(const wchar_t *message, const wchar_t *file, unsigned line); - -void (__cdecl *__MINGW_IMP_SYMBOL(_wassert))(const wchar_t*, const wchar_t*,unsigned) = init_wassert; - -static void __cdecl init_wassert(const wchar_t *message, const wchar_t *file, unsigned line) -{ - void *func; - - func = (void*)GetProcAddress(__mingw_get_msvcrt_handle(), "_wassert"); - if(!func) - func = mingw_wassert; - - return (__MINGW_IMP_SYMBOL(_wassert) = func)(message, file, line); } -#endif +#define NORETURN +#define RETT void +#define FUNC _wassert +#define ARGS const wchar_t * message, const wchar_t * file, unsigned line +#define CALL message, file, line +#include "msvcrt_or_emu_glue.h" diff --git a/mingw-w64-crt/stdio/_vscprintf.c b/mingw-w64-crt/stdio/_vscprintf.c index 557b517eead9..1926ad42a813 100644 --- a/mingw-w64-crt/stdio/_vscprintf.c +++ b/mingw-w64-crt/stdio/_vscprintf.c @@ -11,7 +11,7 @@ #include <errno.h> /* emulation of _vscprintf() via _vsnprintf() */ -static int __cdecl emu_vscprintf(const char * __restrict__ format, va_list arglist) +static int __cdecl emu__vscprintf(const char * __restrict__ format, va_list arglist) { char *buffer, *new_buffer; size_t size; @@ -52,36 +52,8 @@ static int __cdecl emu_vscprintf(const char * __restrict__ format, va_list argli return ret; } -#ifndef __LIBMSVCRT_OS__ - -int __attribute__ ((alias ("emu_vscprintf"))) __cdecl _vscprintf (const char * __restrict__, va_list); -int (__cdecl *__MINGW_IMP_SYMBOL(_vscprintf))(const char * __restrict__, va_list) = _vscprintf; - -#else - -#include <msvcrt.h> - -static int __cdecl init_vscprintf(const char * __restrict__ format, va_list arglist); - -int (__cdecl *__MINGW_IMP_SYMBOL(_vscprintf))(const char * __restrict__, va_list) = init_vscprintf; - -static int __cdecl init_vscprintf(const char * __restrict__ format, va_list arglist) -{ - HMODULE msvcrt = __mingw_get_msvcrt_handle(); - int (__cdecl *func)(const char * __restrict__, va_list) = NULL; - - if (msvcrt) - func = (int (__cdecl *)(const char * __restrict__, va_list))GetProcAddress(msvcrt, "_vscprintf"); - - if (!func) - func = emu_vscprintf; - - return (__MINGW_IMP_SYMBOL(_vscprintf) = func)(format, arglist); -} - -int __cdecl _vscprintf(const char * __restrict__ format, va_list arglist) -{ - return __MINGW_IMP_SYMBOL(_vscprintf)(format, arglist); -} - -#endif +#define RETT int +#define FUNC _vscprintf +#define ARGS const char * restrict format, va_list arglist +#define CALL format, arglist +#include "msvcrt_or_emu_glue.h" diff --git a/mingw-w64-crt/stdio/_vscwprintf.c b/mingw-w64-crt/stdio/_vscwprintf.c index 192a4602123e..635074b4e7c3 100644 --- a/mingw-w64-crt/stdio/_vscwprintf.c +++ b/mingw-w64-crt/stdio/_vscwprintf.c @@ -11,7 +11,7 @@ #include <errno.h> /* emulation of _vscwprintf() via _vsnwprintf() */ -static int __cdecl emu_vscwprintf(const wchar_t * __restrict__ format, va_list arglist) +static int __cdecl emu__vscwprintf(const wchar_t * __restrict__ format, va_list arglist) { wchar_t *buffer, *new_buffer; size_t size; @@ -52,36 +52,8 @@ static int __cdecl emu_vscwprintf(const wchar_t * __restrict__ format, va_list a return ret; } -#ifndef __LIBMSVCRT_OS__ - -int __attribute__ ((alias ("emu_vscwprintf"))) __cdecl _vscwprintf(const wchar_t * __restrict__, va_list); -int (__cdecl *__MINGW_IMP_SYMBOL(_vscwprintf))(const wchar_t * __restrict__, va_list) = _vscwprintf; - -#else - -#include <msvcrt.h> - -static int __cdecl init_vscwprintf(const wchar_t * __restrict__ format, va_list arglist); - -int (__cdecl *__MINGW_IMP_SYMBOL(_vscwprintf))(const wchar_t * __restrict__, va_list) = init_vscwprintf; - -static int __cdecl init_vscwprintf(const wchar_t * __restrict__ format, va_list arglist) -{ - HMODULE msvcrt = __mingw_get_msvcrt_handle(); - int (__cdecl *func)(const wchar_t * __restrict__, va_list) = NULL; - - if (msvcrt) - func = (int (__cdecl *)(const wchar_t * __restrict__, va_list))GetProcAddress(msvcrt, "_vscwprintf"); - - if (!func) - func = emu_vscwprintf; - - return (__MINGW_IMP_SYMBOL(_vscwprintf) = func)(format, arglist); -} - -int __cdecl _vscwprintf(const wchar_t * __restrict__ format, va_list arglist) -{ - return __MINGW_IMP_SYMBOL(_vscwprintf)(format, arglist); -} - -#endif +#define RETT int +#define FUNC _vscwprintf +#define ARGS const wchar_t * restrict format, va_list arglist +#define CALL format, arglist +#include "msvcrt_or_emu_glue.h" -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public