__pctype_func is available in msvcrt since VC70. __p__pctype is available in i386 msvcrt version since VC20. _pctype is available in all versions except in UCRT.
Define fallback __pctype_func() function implementation via __p__pctype() function. And define __p__pctype() via _pctype variable. With this change every CRT import library provides __pctype_func() function. So remove #ifdefs for _pctype declarations in header files and unifies _pctype definitions between different CRT libraries. --- mingw-w64-crt/Makefile.am | 7 +++++++ mingw-w64-crt/lib-common/msvcrt.def.in | 2 +- mingw-w64-crt/misc/__p__pctype.c | 16 ++++++++++++++++ mingw-w64-crt/misc/__pctype_func.c | 16 ++++++++++++++++ mingw-w64-headers/crt/ctype.h | 17 ----------------- mingw-w64-headers/crt/wchar.h | 17 ----------------- mingw-w64-headers/crt/wctype.h | 17 ----------------- 7 files changed, 40 insertions(+), 52 deletions(-) create mode 100644 mingw-w64-crt/misc/__p__pctype.c create mode 100644 mingw-w64-crt/misc/__pctype_func.c diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index 8442f8b94f7c..f56e57cb8fda 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -436,6 +436,7 @@ src_msvcrt32=\ $(src_msvcrt) \ math/x86/_copysignf.c \ misc/___mb_cur_max_func.c \ + misc/__pctype_func.c \ misc/_create_locale.c \ misc/_free_locale.c \ misc/_get_current_locale.c \ @@ -584,6 +585,8 @@ src_crtdll=\ misc/__p__acmdln.c \ misc/__p__commode.c \ misc/__p__fmode.c \ + misc/__p__pctype.c \ + misc/__pctype_func.c \ misc/__set_app_type.c \ misc/dummy__setusermatherr.c \ misc/imaxabs.c \ @@ -610,6 +613,8 @@ src_msvcrt10=\ misc/__p__acmdln.c \ misc/__p__commode.c \ misc/__p__fmode.c \ + misc/__p__pctype.c \ + misc/__pctype_func.c \ misc/__set_app_type.c \ misc/dummy__setusermatherr.c \ misc/imaxabs.c \ @@ -630,6 +635,7 @@ src_msvcrt20=\ crt/msvcrt20_getmainargs.c \ crt/msvcrt20_wgetmainargs.c \ misc/___mb_cur_max_func.c \ + misc/__pctype_func.c \ misc/__set_app_type.c \ misc/dummy__setusermatherr.c \ misc/imaxabs.c \ @@ -647,6 +653,7 @@ src_msvcrt20=\ src_msvcrt40=\ misc/___mb_cur_max_func.c \ + misc/__pctype_func.c \ misc/imaxabs.c \ misc/imaxdiv.c \ misc/invalid_parameter_handler.c \ diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in b/mingw-w64-crt/lib-common/msvcrt.def.in index b5e55deda2a3..6f4881906776 100644 --- a/mingw-w64-crt/lib-common/msvcrt.def.in +++ b/mingw-w64-crt/lib-common/msvcrt.def.in @@ -1110,7 +1110,7 @@ __crtCompareStringW __crtGetStringTypeW __crtLCMapStringW F_NON_I386(__iob_func) ; i386 __iob_func replaced by alias -__pctype_func +F_NON_I386(__pctype_func) ; i386 __pctype_func replaced by emu __wcserror _aligned_free _aligned_malloc diff --git a/mingw-w64-crt/misc/__p__pctype.c b/mingw-w64-crt/misc/__p__pctype.c new file mode 100644 index 000000000000..06d685501422 --- /dev/null +++ b/mingw-w64-crt/misc/__p__pctype.c @@ -0,0 +1,16 @@ +/** + * 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. + */ + +#include <_mingw.h> + +extern const unsigned short** __MINGW_IMP_SYMBOL(_pctype); + +const unsigned short** __cdecl __p__pctype(void); +const unsigned short** __cdecl __p__pctype(void) +{ + return __MINGW_IMP_SYMBOL(_pctype); +} +const unsigned short** (__cdecl *__MINGW_IMP_SYMBOL(__p__pctype))(void) = __p__pctype; diff --git a/mingw-w64-crt/misc/__pctype_func.c b/mingw-w64-crt/misc/__pctype_func.c new file mode 100644 index 000000000000..0e8579f3cef5 --- /dev/null +++ b/mingw-w64-crt/misc/__pctype_func.c @@ -0,0 +1,16 @@ +/** + * 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. + */ + +#include <_mingw.h> + +_CRTIMP const unsigned short** __cdecl __p__pctype(void); + +const unsigned short* __cdecl __pctype_func(void); +const unsigned short* __cdecl __pctype_func(void) +{ + return *__p__pctype(); +} +const unsigned short* (__cdecl *__MINGW_IMP_SYMBOL(__pctype_func))(void) = __pctype_func; diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h index f23bcdc2ee84..e0d23c06535e 100644 --- a/mingw-w64-headers/crt/ctype.h +++ b/mingw-w64-headers/crt/ctype.h @@ -22,28 +22,11 @@ extern "C" { #ifndef __PCTYPE_FUNC #define __PCTYPE_FUNC __pctype_func() -#ifdef _MSVCRT_ -#define __pctype_func() (_pctype) -#else -#ifdef _UCRT _CRTIMP const unsigned short* __pctype_func(void); -#else -#define __pctype_func() (* __MINGW_IMP_SYMBOL(_pctype)) -#endif -#endif #endif #ifndef _pctype -#ifdef _MSVCRT_ - extern const unsigned short *_pctype; -#else -#ifdef _UCRT #define _pctype (__pctype_func()) -#else - extern const unsigned short ** __MINGW_IMP_SYMBOL(_pctype); -#define _pctype (* __MINGW_IMP_SYMBOL(_pctype)) -#endif -#endif #endif #endif diff --git a/mingw-w64-headers/crt/wchar.h b/mingw-w64-headers/crt/wchar.h index 6af60ca1c6bf..9ac5f5a9cc77 100644 --- a/mingw-w64-headers/crt/wchar.h +++ b/mingw-w64-headers/crt/wchar.h @@ -154,28 +154,11 @@ _CRTIMP FILE *__cdecl __acrt_iob_func(unsigned index); #ifndef __PCTYPE_FUNC #define __PCTYPE_FUNC __pctype_func() -#ifdef _MSVCRT_ -#define __pctype_func() (_pctype) -#else -#ifdef _UCRT _CRTIMP const unsigned short* __pctype_func(void); -#else -#define __pctype_func() (* __MINGW_IMP_SYMBOL(_pctype)) -#endif -#endif #endif #ifndef _pctype -#ifdef _MSVCRT_ - extern const unsigned short *_pctype; -#else -#ifdef _UCRT #define _pctype (__pctype_func()) -#else - extern const unsigned short ** __MINGW_IMP_SYMBOL(_pctype); -#define _pctype (* __MINGW_IMP_SYMBOL(_pctype)) -#endif -#endif #endif #endif #endif diff --git a/mingw-w64-headers/crt/wctype.h b/mingw-w64-headers/crt/wctype.h index 7a05f9ed7aec..b04a6cadc908 100644 --- a/mingw-w64-headers/crt/wctype.h +++ b/mingw-w64-headers/crt/wctype.h @@ -45,28 +45,11 @@ extern "C" { #ifndef __PCTYPE_FUNC #define __PCTYPE_FUNC __pctype_func() -#ifdef _MSVCRT_ -#define __pctype_func() (_pctype) -#else -#ifdef _UCRT _CRTIMP const unsigned short* __pctype_func(void); -#else -#define __pctype_func() (* __MINGW_IMP_SYMBOL(_pctype)) -#endif -#endif #endif #ifndef _pctype -#ifdef _MSVCRT_ - extern const unsigned short *_pctype; -#else -#ifdef _UCRT #define _pctype (__pctype_func()) -#else - extern const unsigned short ** __MINGW_IMP_SYMBOL(_pctype); -#define _pctype (* __MINGW_IMP_SYMBOL(_pctype)) -#endif -#endif #endif #endif -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public