Needed to build libc++.
-- v2: include: Add math.h _(l|f)dtest function declarations. include: Fix _strtod_l/strtold/_strtold_l declarations. include: Add some __sys_nerr declaration. include: Add some ___mb_cur_max_func declarations. include: Add some struct timespec definitions. include: Add some localized ctype.h function declarations. include: Add __pctype_func declaration.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/msvcp90/locale.c | 1 - include/msvcrt/corecrt_wctype.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/msvcp90/locale.c b/dlls/msvcp90/locale.c index 146dfb23005..6cbc91d5f5a 100644 --- a/dlls/msvcp90/locale.c +++ b/dlls/msvcp90/locale.c @@ -53,7 +53,6 @@ wchar_t* __cdecl _W_Getmonths(void); void* __cdecl _Gettnames(void); unsigned int __cdecl ___lc_codepage_func(void); int __cdecl ___lc_collate_cp_func(void); -const unsigned short* __cdecl __pctype_func(void); const locale_facet* __thiscall locale__Getfacet(const locale*, size_t); const locale* __cdecl locale_classic(void);
diff --git a/include/msvcrt/corecrt_wctype.h b/include/msvcrt/corecrt_wctype.h index 26130aa4839..e1dcaa8e38a 100644 --- a/include/msvcrt/corecrt_wctype.h +++ b/include/msvcrt/corecrt_wctype.h @@ -24,6 +24,7 @@ extern "C" { #define _LEADBYTE 0x8000 #define _ALPHA (0x0100|_UPPER|_LOWER) /* (C1_ALPHA|_UPPER|_LOWER) */
+_ACRTIMP const unsigned short* __cdecl __pctype_func(void); _ACRTIMP int __cdecl _isleadbyte_l(int,_locale_t); _ACRTIMP int __cdecl _iswalnum_l(wint_t,_locale_t); _ACRTIMP int __cdecl _iswalpha_l(wint_t,_locale_t);
From: Rémi Bernon rbernon@codeweavers.com
--- include/msvcrt/ctype.h | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/include/msvcrt/ctype.h b/include/msvcrt/ctype.h index 312888c3cfc..88e79411f64 100644 --- a/include/msvcrt/ctype.h +++ b/include/msvcrt/ctype.h @@ -25,6 +25,10 @@ _ACRTIMP int __cdecl __toascii(int); _ACRTIMP int __cdecl _isblank_l(int,_locale_t); _ACRTIMP int __cdecl _isctype(int,int); _ACRTIMP int __cdecl _isctype_l(int,int,_locale_t); +_ACRTIMP int __cdecl _islower_l(int,_locale_t); +_ACRTIMP int __cdecl _isupper_l(int,_locale_t); +_ACRTIMP int __cdecl _isdigit_l(int,_locale_t); +_ACRTIMP int __cdecl _isxdigit_l(int,_locale_t); _ACRTIMP int __cdecl _tolower(int); _ACRTIMP int __cdecl _tolower_l(int,_locale_t); _ACRTIMP int __cdecl _toupper(int);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/msvcrt/time.c | 12 ------------ include/msvcrt/time.h | 18 ++++++++++++++++++ libs/ldap/include/ac/time.h | 7 ------- 3 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c index 155454c5659..8199fe01649 100644 --- a/dlls/msvcrt/time.c +++ b/dlls/msvcrt/time.c @@ -1867,18 +1867,6 @@ int CDECL _get_daylight(int *hours)
#define TIME_UTC 1
-struct _timespec32 -{ - __time32_t tv_sec; - LONG tv_nsec; -}; - -struct _timespec64 -{ - __time64_t tv_sec; - LONG tv_nsec; -}; - /********************************************************************* * _timespec64_get (UCRTBASE.@) */ diff --git a/include/msvcrt/time.h b/include/msvcrt/time.h index 42e2fc4b1e2..c295b191bd5 100644 --- a/include/msvcrt/time.h +++ b/include/msvcrt/time.h @@ -37,6 +37,24 @@ typedef __msvcrt_long clock_t; extern "C" { #endif
+struct _timespec32 +{ + __time32_t tv_sec; + long tv_nsec; +}; + +struct _timespec64 +{ + __time64_t tv_sec; + long tv_nsec; +}; + +struct timespec +{ + time_t tv_sec; + long tv_nsec; +}; + #ifdef __i386__ #define _daylight (*__p__daylight()) #define _dstbias (*__p__dstbias()) diff --git a/libs/ldap/include/ac/time.h b/libs/ldap/include/ac/time.h index 4cc0f914f36..0b8372fb551 100644 --- a/libs/ldap/include/ac/time.h +++ b/libs/ldap/include/ac/time.h @@ -29,11 +29,4 @@ # include <time.h> #endif
-#if defined(_WIN32) && !defined(HAVE_CLOCK_GETTIME) - struct timespec { - time_t tv_sec; - int tv_nsec; - }; -#endif - #endif /* _AC_TIME_H */
From: Rémi Bernon rbernon@codeweavers.com
--- include/msvcrt/stdlib.h | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/include/msvcrt/stdlib.h b/include/msvcrt/stdlib.h index df307196a12..8f836a8fa7f 100644 --- a/include/msvcrt/stdlib.h +++ b/include/msvcrt/stdlib.h @@ -122,7 +122,9 @@ extern unsigned int _fmode; #endif /* __i386__ */
_ACRTIMP int __cdecl ___mb_cur_max_func(void); +_ACRTIMP int __cdecl ___mb_cur_max_l_func(_locale_t); #define __mb_cur_max ___mb_cur_max_func() +#define MB_CUR_MAX ___mb_cur_max_func() _ACRTIMP __msvcrt_ulong* __cdecl __doserrno(void); #define _doserrno (*__doserrno()) _ACRTIMP int* __cdecl _errno(void);
From: Rémi Bernon rbernon@codeweavers.com
--- include/msvcrt/stdlib.h | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/include/msvcrt/stdlib.h b/include/msvcrt/stdlib.h index 8f836a8fa7f..45ef5bfb1e7 100644 --- a/include/msvcrt/stdlib.h +++ b/include/msvcrt/stdlib.h @@ -129,6 +129,8 @@ _ACRTIMP __msvcrt_ulong* __cdecl __doserrno(void); #define _doserrno (*__doserrno()) _ACRTIMP int* __cdecl _errno(void); #define errno (*_errno()) +_ACRTIMP int* __cdecl __sys_nerr(void); +#define _sys_nerr (*__sys_nerr())
/* FIXME: We need functions to access these: * int _sys_nerr;
From: Rémi Bernon rbernon@codeweavers.com
--- include/msvcrt/stdlib.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/include/msvcrt/stdlib.h b/include/msvcrt/stdlib.h index 45ef5bfb1e7..ce03f15310b 100644 --- a/include/msvcrt/stdlib.h +++ b/include/msvcrt/stdlib.h @@ -231,6 +231,9 @@ _ACRTIMP void __cdecl srand(unsigned int); _ACRTIMP float __cdecl strtof(const char*,char**); _ACRTIMP float __cdecl _strtof_l(const char*,char**,_locale_t); _ACRTIMP double __cdecl strtod(const char*,char**); +_ACRTIMP double __cdecl _strtod_l(const char*,char**,_locale_t); +_ACRTIMP long double __cdecl strtold(const char*,char**); +_ACRTIMP long double __cdecl _strtold_l(const char*,char**,_locale_t); _ACRTIMP __msvcrt_long __cdecl strtol(const char*,char**,int); _ACRTIMP __msvcrt_ulong __cdecl strtoul(const char*,char**,int); _ACRTIMP __int64 __cdecl _strtoll_l(const char*,char**,int,_locale_t); @@ -257,11 +260,6 @@ _ACRTIMP _invalid_parameter_handler __cdecl _set_thread_local_invalid_parameter_ void __cdecl _invalid_parameter(const wchar_t *expr, const wchar_t *func, const wchar_t *file, unsigned int line, uintptr_t arg);
-#ifdef _UCRT -_ACRTIMP double __cdecl _strtold_l(const char*,char**,_locale_t); -static inline long double strtold(const char *string, char **endptr) { return _strtold_l(string, endptr, NULL); } -#endif /* _UCRT */ - #ifdef __cplusplus extern "C++" {
From: Rémi Bernon rbernon@codeweavers.com
And some C++ related inline helpers. --- include/msvcrt/math.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/include/msvcrt/math.h b/include/msvcrt/math.h index 03c4bf57f59..5a41b061907 100644 --- a/include/msvcrt/math.h +++ b/include/msvcrt/math.h @@ -284,7 +284,22 @@ static const union { #define FP_ILOGB0 (-0x7fffffff - _C2) #define FP_ILOGBNAN 0x7fffffff
-#if _MSVCR_VER >= 120 +_ACRTIMP short __cdecl _dtest(double*); +_ACRTIMP short __cdecl _ldtest(long double*); +_ACRTIMP short __cdecl _fdtest(float*); + +#ifdef __cplusplus + +extern "C++" { +inline int fpclassify(float x) throw() { return _fdtest(&x); } +inline int fpclassify(double x) throw() { return _dtest(&x); } +inline int fpclassify(long double x) throw() { return _ldtest(&x); } +template <class T> inline bool isfinite(T x) throw() { return fpclassify(x) <= 0; } +template <class T> inline bool isinf(T x) throw() { return fpclassify(x) == FP_INFINITE; } +template <class T> inline bool isnan(T x) throw() { return fpclassify(x) == FP_NAN; } +} /* extern "C++" */ + +#elif _MSVCR_VER >= 120
_ACRTIMP short __cdecl _dclass(double); _ACRTIMP short __cdecl _fdclass(float);
Jacek Caban (@jacek) commented about include/msvcrt/stdlib.h:
_ACRTIMP float __cdecl strtof(const char*,char**); _ACRTIMP float __cdecl _strtof_l(const char*,char**,_locale_t); _ACRTIMP double __cdecl strtod(const char*,char**); +_ACRTIMP double __cdecl _strtod_l(const char*,char**,_locale_t); +_ACRTIMP long double __cdecl strtold(const char*,char**); +_ACRTIMP long double __cdecl _strtold_l(const char*,char**,_locale_t);
This is not right on mingw targets, where `long double` is 80 bit, while `ucrtbase.dll` treats it as 64 bit. We could skip that workaround in MSVC mode, if that helps.
On Fri Oct 25 08:48:16 2024 +0000, Jacek Caban wrote:
This is not right on mingw targets, where `long double` is 80 bit, while `ucrtbase.dll` treats it as 64 bit. We could skip that workaround in MSVC mode, if that helps.
Could we define something like `__msvcrt_long_double` instead?
On Fri Oct 25 08:50:30 2024 +0000, Rémi Bernon wrote:
Could we define something like `__msvcrt_long_double` instead?
It wouldn't be enough for `-Wincompatible-library-redeclaration`, see 4f40ffb9c5f1.
On Fri Oct 25 08:59:20 2024 +0000, Jacek Caban wrote:
It wouldn't be enough for `-Wincompatible-library-redeclaration`, see 4f40ffb9c5f1.
Hmm I see. Would this be right or should I keep the _UCRT guard (I'm not sure why it's there in the first place)?
```c #ifdef _MSC_VER _ACRTIMP long double __cdecl strtold(const char*,char**); _ACRTIMP long double __cdecl _strtold_l(const char*,char**,_locale_t); #else static inline long double strtold(const char *string, char **endptr) { return strtod(string, endptr); } static inline long double _strtold_l(const char *string, char **endptr, _locale_t locale) { return _strtod_l(string, endptr, locale); } #endif ```
Btw I see there's also _atold which returns a long double, but it doesn't seem to be exported or even defined anywhere... not sure where that came from, perhaps we should remove it?
On Fri Oct 25 09:11:13 2024 +0000, Rémi Bernon wrote:
Hmm I see. Would this be right or should I keep the _UCRT guard (I'm not sure why it's there in the first place)?
#ifdef _MSC_VER _ACRTIMP long double __cdecl strtold(const char*,char**); _ACRTIMP long double __cdecl _strtold_l(const char*,char**,_locale_t); #else static inline long double strtold(const char *string, char **endptr) { return strtod(string, endptr); } static inline long double _strtold_l(const char *string, char **endptr, _locale_t locale) { return _strtod_l(string, endptr, locale); } #endif
Btw I see there's also _atold which returns a long double, but it doesn't seem to be exported or even defined anywhere... not sure where that came from, perhaps we should remove it?
Those are exported since msvcr120, so to be precise, it would be something like: ``` #if defined(__GNUC__) || _MSVCR_VER < 120 // use inlines #else // use dllimport #endif ```
`_atold` seems to be a result of importing the header from some ancient mingw and never fixing it, we should probably remove it.