https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b05cc3620875c3816e332d...
commit b05cc3620875c3816e332d065671ed1dac894fa1 Author: Timo Kreuzer timo.kreuzer@reactos.org AuthorDate: Wed Jul 28 10:25:22 2021 +0200 Commit: Timo Kreuzer timo.kreuzer@reactos.org CommitDate: Wed Aug 4 02:03:07 2021 +0200
[CRT] Fix CRT headers a bit
* Remove unused internal version of float.h * Define _STATIC_ASSERT in crtdefs.h * Add some missing declarations --- modules/rostests/apitests/crt/wctomb.c | 2 - sdk/include/crt/crtdbg.h | 5 - sdk/include/crt/crtdefs.h | 9 ++ sdk/include/crt/emmintrin.h | 2 +- sdk/include/crt/locale.h | 10 ++ sdk/include/crt/malloc.h | 4 - sdk/include/crt/stdio.h | 7 ++ sdk/lib/crt/include/float.h | 176 --------------------------------- sdk/lib/crt/locale/locale.c | 2 +- 9 files changed, 28 insertions(+), 189 deletions(-)
diff --git a/modules/rostests/apitests/crt/wctomb.c b/modules/rostests/apitests/crt/wctomb.c index 7ccb713d1b7..8048f56df13 100644 --- a/modules/rostests/apitests/crt/wctomb.c +++ b/modules/rostests/apitests/crt/wctomb.c @@ -14,8 +14,6 @@ #include <errno.h> #include <locale.h>
-unsigned int cdecl ___lc_codepage_func(void); - START_TEST(wctomb) { int Length; diff --git a/sdk/include/crt/crtdbg.h b/sdk/include/crt/crtdbg.h index 9b72b56a60c..3a20d5316fb 100644 --- a/sdk/include/crt/crtdbg.h +++ b/sdk/include/crt/crtdbg.h @@ -81,11 +81,6 @@ extern "C" { size_t lTotalCount; } _CrtMemState;
-#ifndef _STATIC_ASSERT -#define _STATIC_ASSERT(expr) extern char (*static_assert(void)) [(expr) ? 1 : -1] -#endif - - // Debug reporting functions
#ifdef _DEBUG diff --git a/sdk/include/crt/crtdefs.h b/sdk/include/crt/crtdefs.h index d4ad5fd2178..582ae24edb2 100644 --- a/sdk/include/crt/crtdefs.h +++ b/sdk/include/crt/crtdefs.h @@ -182,6 +182,15 @@
#define __crt_typefix(ctype)
+#ifndef _STATIC_ASSERT + #ifdef __cplusplus + #define _STATIC_ASSERT(expr) static_assert((expr), #expr) + #elif defined(__clang__) || defined(__GNUC__) + #define _STATIC_ASSERT(expr) _Static_assert((expr), #expr) + #else + #define _STATIC_ASSERT(expr) extern char (*__static_assert__(void)) [(expr) ? 1 : -1] + #endif +#endif /* _STATIC_ASSERT */
/** Deprecated ***************************************************************/
diff --git a/sdk/include/crt/emmintrin.h b/sdk/include/crt/emmintrin.h index 5f8ceb19338..87ae2058d86 100644 --- a/sdk/include/crt/emmintrin.h +++ b/sdk/include/crt/emmintrin.h @@ -22,7 +22,7 @@ typedef union _DECLSPEC_INTRIN_TYPE _CRT_ALIGN(16) __m128i unsigned __int32 m128i_u32[4]; unsigned __int64 m128i_u64[2]; } __m128i; -C_ASSERT(sizeof(__m128i) == 16); +_STATIC_ASSERT(sizeof(__m128i) == 16);
typedef struct _DECLSPEC_INTRIN_TYPE _CRT_ALIGN(16) __m128d { diff --git a/sdk/include/crt/locale.h b/sdk/include/crt/locale.h index fff1376ce01..d24699d0463 100644 --- a/sdk/include/crt/locale.h +++ b/sdk/include/crt/locale.h @@ -113,6 +113,16 @@ extern "C" { __free_locale( _In_opt_ _locale_t _Locale);
+_CRTIMP +unsigned int +__cdecl +___lc_collate_cp_func(void); + +_CRTIMP +unsigned int +__cdecl +___lc_codepage_func(void); + #ifndef _WLOCALE_DEFINED #define _WLOCALE_DEFINED _Check_return_opt_ diff --git a/sdk/include/crt/malloc.h b/sdk/include/crt/malloc.h index c0ebb2ec25b..553032edfb7 100644 --- a/sdk/include/crt/malloc.h +++ b/sdk/include/crt/malloc.h @@ -24,10 +24,6 @@ extern "C" { #define _HEAP_MAXREQ 0xFFFFFFE0 #endif
-#ifndef _STATIC_ASSERT -#define _STATIC_ASSERT(expr) extern char (*static_assert(void)) [(expr) ? 1 : -1] -#endif - /* Return codes for _heapwalk() */ #define _HEAPEMPTY (-1) #define _HEAPOK (-2) diff --git a/sdk/include/crt/stdio.h b/sdk/include/crt/stdio.h index 9ac92d50672..6d181a541b2 100644 --- a/sdk/include/crt/stdio.h +++ b/sdk/include/crt/stdio.h @@ -114,6 +114,13 @@ extern "C" {
#endif
+#if defined(_M_IX86) // newer Windows versions always have it +_CRTIMP int* __cdecl __p__commode(void); +#endif + +/* On newer Windows windows versions, (*__p__commode()) is used */ +extern _CRTIMP int _commode; + #define _IOREAD 0x0001 #define _IOWRT 0x0002
diff --git a/sdk/lib/crt/include/float.h b/sdk/lib/crt/include/float.h deleted file mode 100644 index 48281188df5..00000000000 --- a/sdk/lib/crt/include/float.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * float.h - * This file has no copyright assigned and is placed in the Public Domain. - * This file is a part of the mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER within the package. - * - * Constants related to floating point arithmetic. - * - * Also included here are some non-ANSI bits for accessing the floating - * point controller. - * - * NOTE: GCC provides float.h, but it doesn't include the non-standard - * stuff for accessing the fp controller. We include_next the - * GCC-supplied header and just define the MS-specific extensions - * here. - * - */ -#ifdef __GNUC__ - #include_next <float.h> -#endif -#ifndef _MINGW_FLOAT_H_ -#define _MINGW_FLOAT_H_ - -/* All the headers include this file. */ -#ifdef __GNUC__ - #include <_mingw.h> -#endif -/* - * Functions and definitions for controlling the FPU. - */ -#ifndef __STRICT_ANSI__ - -/* TODO: These constants are only valid for x86 machines */ - -/* Control word masks for unMask */ -#define _MCW_EM 0x0008001F /* Error masks */ -#define _MCW_IC 0x00040000 /* Infinity */ -#define _MCW_RC 0x00000300 /* Rounding */ -#define _MCW_PC 0x00030000 /* Precision */ - -/* Control word values for unNew (use with related unMask above) */ -#define _EM_INVALID 0x00000010 -#define _EM_DENORMAL 0x00080000 -#define _EM_ZERODIVIDE 0x00000008 -#define _EM_OVERFLOW 0x00000004 -#define _EM_UNDERFLOW 0x00000002 -#define _EM_INEXACT 0x00000001 -#define _IC_AFFINE 0x00040000 -#define _IC_PROJECTIVE 0x00000000 -#define _RC_CHOP 0x00000300 -#define _RC_UP 0x00000200 -#define _RC_DOWN 0x00000100 -#define _RC_NEAR 0x00000000 -#define _PC_24 0x00020000 -#define _PC_53 0x00010000 -#define _PC_64 0x00000000 - -/* These are also defined in Mingw math.h, needed to work around - GCC build issues. */ -/* Return values for fpclass. */ -#ifndef __MINGW_FPCLASS_DEFINED -#define __MINGW_FPCLASS_DEFINED 1 -#define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */ -#define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */ -#define _FPCLASS_NINF 0x0004 /* Negative Infinity */ -#define _FPCLASS_NN 0x0008 /* Negative Normal */ -#define _FPCLASS_ND 0x0010 /* Negative Denormal */ -#define _FPCLASS_NZ 0x0020 /* Negative Zero */ -#define _FPCLASS_PZ 0x0040 /* Positive Zero */ -#define _FPCLASS_PD 0x0080 /* Positive Denormal */ -#define _FPCLASS_PN 0x0100 /* Positive Normal */ -#define _FPCLASS_PINF 0x0200 /* Positive Infinity */ -#endif /* __MINGW_FPCLASS_DEFINED */ - -/* _statusfp bit flags */ -#define _SW_INEXACT 0x00000001 /* inexact (precision) */ -#define _SW_UNDERFLOW 0x00000002 /* underflow */ -#define _SW_OVERFLOW 0x00000004 /* overflow */ -#define _SW_ZERODIVIDE 0x00000008 /* zero divide */ -#define _SW_INVALID 0x00000010 /* invalid */ -#define _SW_DENORMAL 0x00080000 /* denormal status bit */ - -#define _SW_UNEMULATED 0x00000040 /* unemulated instruction */ -#define _SW_SQRTNEG 0x00000080 /* square root of a neg number */ -#define _SW_STACKOVERFLOW 0x00000200 /* FP stack overflow */ -#define _SW_STACKUNDERFLOW 0x00000400 /* FP stack underflow */ - -/* Floating point error signals and return codes */ -#define _FPE_INVALID 0x81 -#define _FPE_DENORMAL 0x82 -#define _FPE_ZERODIVIDE 0x83 -#define _FPE_OVERFLOW 0x84 -#define _FPE_UNDERFLOW 0x85 -#define _FPE_INEXACT 0x86 -#define _FPE_UNEMULATED 0x87 -#define _FPE_SQRTNEG 0x88 -#define _FPE_STACKOVERFLOW 0x8a -#define _FPE_STACKUNDERFLOW 0x8b -#define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */ - -#ifndef DBL_MAX_10_EXP -#define DBL_MAX_10_EXP 308 -#endif -#ifndef UINT64_MAX -#define UINT64_MAX 0xffffffffffffffff -#endif - -#ifndef RC_INVOKED - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _CRTIMP -#ifdef _DLL -#define _CRTIMP __declspec(dllimport) -#else -#define _CRTIMP -#endif /* _DLL */ -#endif - -/* Set the FPU control word as cw = (cw & ~unMask) | (unNew & unMask), - * i.e. change the bits in unMask to have the values they have in unNew, - * leaving other bits unchanged. */ -_CRTIMP unsigned int __cdecl _controlfp (unsigned int unNew, unsigned int unMask); -_CRTIMP unsigned int __cdecl _control87 (unsigned int unNew, unsigned int unMask); - - -_CRTIMP unsigned int __cdecl _clearfp (void); /* Clear the FPU status word */ -_CRTIMP unsigned int __cdecl _statusfp (void); /* Report the FPU status word */ -#define _clear87 _clearfp -#define _status87 _statusfp - - -/* - MSVCRT.dll _fpreset initializes the control register to 0x27f, - the status register to zero and the tag word to 0FFFFh. - This differs from asm instruction finit/fninit which set control - word to 0x37f (64 bit mantissa precison rather than 53 bit). - By default, the mingw version of _fpreset sets fp control as - per fninit. To use the MSVCRT.dll _fpreset, include CRT_fp8.o when - building your application. -*/ -void __cdecl _fpreset (void); -void __cdecl fpreset (void); - -/* Global 'variable' for the current floating point error code. */ -_CRTIMP int * __cdecl __fpecode(void); -#define _fpecode (*(__fpecode())) - -/* - * IEEE recommended functions. MS puts them in float.h - * but they really belong in math.h. - */ - -_CRTIMP double __cdecl _chgsign (double); -_CRTIMP double __cdecl _copysign (double, double); -_CRTIMP double __cdecl _logb (double); -_CRTIMP double __cdecl _nextafter (double, double); -_CRTIMP double __cdecl _scalb (double, long); - -_CRTIMP int __cdecl _finite (double); -_CRTIMP int __cdecl _fpclass (double); -_CRTIMP int __cdecl _isnan (double); - -#ifdef __cplusplus -} -#endif - -#endif /* Not RC_INVOKED */ - -#endif /* Not __STRICT_ANSI__ */ - -#endif /* _FLOAT_H_ */ - - diff --git a/sdk/lib/crt/locale/locale.c b/sdk/lib/crt/locale/locale.c index 0f599a4135f..897aa2ec38d 100644 --- a/sdk/lib/crt/locale/locale.c +++ b/sdk/lib/crt/locale/locale.c @@ -632,7 +632,7 @@ unsigned int CDECL ___lc_codepage_func(void) /********************************************************************* * ___lc_collate_cp_func (MSVCRT.@) */ -int CDECL ___lc_collate_cp_func(void) +unsigned int CDECL ___lc_collate_cp_func(void) { return get_locinfo()->lc_collate_cp; }