mirror of git://git.musl-libc.org/musl
honor __WCHAR_TYPE__ on archs with legacy long definition of wchar_t
historically, a number of 32-bit archs used long rather than int for wchar_t, for no good reason. GCC still uses the historical types, but clang replaced them all with int, and it seems PCC uses int too. mismatching the compiler's type for wchar_t is not an option due to wide string literals. note that the mismatch does not affect C++ ABI since wchar_t is its own builtin type/keyword in C++, distinct from both int and long, not a typedef. i386 already worked around this by honoring __WCHAR_TYPE__ if defined by the compiler, and only using the official legacy ABI type if not. add the same to the other affected archs. it might make sense at some point to switch to using int as the default if __WCHAR_TYPE__ is not defined, if the expectations is that new compilers will treat int as the correct choice, but it's unlikely that the case where __WCHAR_TYPE__ is undefined will ever be used anyway. I actually wanted to move the definition of wchar_t to the top-level shared alltypes.h.in, using __WCHAR_TYPE__ and falling back to int if not defined, but that can't be done without assuming all compilers define __WCHAR_TYPE__ thanks to some pathological archs where the ABI has wchar_t as an unsigned type.
This commit is contained in:
parent
8a544ee3a2
commit
1f0e9f9cc2
|
@ -6,8 +6,12 @@ TYPEDEF __builtin_va_list va_list;
|
|||
TYPEDEF __builtin_va_list __isoc_va_list;
|
||||
|
||||
#ifndef __cplusplus
|
||||
#ifdef __WCHAR_TYPE__
|
||||
TYPEDEF __WCHAR_TYPE__ wchar_t;
|
||||
#else
|
||||
TYPEDEF long wchar_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if __mcffpu__
|
||||
TYPEDEF float float_t;
|
||||
|
|
|
@ -6,8 +6,12 @@ TYPEDEF __builtin_va_list va_list;
|
|||
TYPEDEF __builtin_va_list __isoc_va_list;
|
||||
|
||||
#ifndef __cplusplus
|
||||
#ifdef __WCHAR_TYPE__
|
||||
TYPEDEF __WCHAR_TYPE__ wchar_t;
|
||||
#else
|
||||
TYPEDEF long wchar_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TYPEDEF float float_t;
|
||||
TYPEDEF double double_t;
|
||||
|
|
|
@ -6,8 +6,12 @@ TYPEDEF __builtin_va_list va_list;
|
|||
TYPEDEF __builtin_va_list __isoc_va_list;
|
||||
|
||||
#ifndef __cplusplus
|
||||
#ifdef __WCHAR_TYPE__
|
||||
TYPEDEF __WCHAR_TYPE__ wchar_t;
|
||||
#else
|
||||
TYPEDEF long wchar_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TYPEDEF float float_t;
|
||||
TYPEDEF double double_t;
|
||||
|
|
|
@ -6,8 +6,12 @@ TYPEDEF __builtin_va_list va_list;
|
|||
TYPEDEF __builtin_va_list __isoc_va_list;
|
||||
|
||||
#ifndef __cplusplus
|
||||
#ifdef __WCHAR_TYPE__
|
||||
TYPEDEF __WCHAR_TYPE__ wchar_t;
|
||||
#else
|
||||
TYPEDEF long wchar_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__FLT_EVAL_METHOD__) && __FLT_EVAL_METHOD__ == 2
|
||||
TYPEDEF long double float_t;
|
||||
|
|
Loading…
Reference in New Issue