diff --git a/reactos/include/crt/_mingw.h b/reactos/include/crt/_mingw.h index 6bf5a7982de..f63e7dac32e 100644 --- a/reactos/include/crt/_mingw.h +++ b/reactos/include/crt/_mingw.h @@ -172,7 +172,11 @@ allow GCC to optimize away some EH unwind code, at least in DW2 case. */ # endif # define __ptr32 # define __ptr64 -# define __forceinline extern __inline __attribute((always_inline)) +# if ( __MINGW_GNUC_PREREQ(4, 3) && __STDC_VERSION__ >= 199901L) +# define __forceinline extern inline __attribute__((__always_inline__,__gnu_inline__)) +# else +# define __forceinline extern __inline__ __attribute__((__always_inline__)) +# endif #endif #ifdef __cplusplus diff --git a/reactos/include/crt/ctype.h b/reactos/include/crt/ctype.h index 294e0171111..8236b2c8261 100644 --- a/reactos/include/crt/ctype.h +++ b/reactos/include/crt/ctype.h @@ -112,7 +112,7 @@ extern "C" { _CRTIMP int __cdecl __iscsymf(int _C); _CRTIMP int __cdecl __iscsym(int _C); #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || !defined (NO_OLDNAMES) - _CRTIMP int __cdecl isblank(int _C); + int __cdecl isblank(int _C); #endif #endif /* !_CTYPE_DEFINED */ @@ -156,7 +156,7 @@ extern "C" { _CRTIMP int __cdecl is_wctype(wint_t _C,wctype_t _Type); #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || !defined (NO_OLDNAMES) - _CRTIMP int __cdecl iswblank(wint_t _C); + int __cdecl iswblank(wint_t _C); #endif #endif diff --git a/reactos/include/crt/malloc.h b/reactos/include/crt/malloc.h index b90bfc5e97c..51542e6cdee 100644 --- a/reactos/include/crt/malloc.h +++ b/reactos/include/crt/malloc.h @@ -52,6 +52,18 @@ extern "C" { extern unsigned int _amblksiz; +/* Make sure that X86intrin.h doesn't produce here collisions. */ +#if (!defined (_XMMINTRIN_H_INCLUDED) && !defined (_MM_MALLOC_H_INCLUDED)) || defined(_aligned_malloc) +#define __DO_ALIGN_DEFINES +#endif + +#ifdef __DO_ALIGN_DEFINES +#pragma push_macro("_aligned_free") +#pragma push_macro("_aligned_malloc") +#undef _aligned_free +#undef _aligned_malloc +#endif + #define _mm_free(a) _aligned_free(a) #define _mm_malloc(a,b) _aligned_malloc(a,b) @@ -62,8 +74,12 @@ extern "C" { void *__cdecl malloc(size_t _Size); void *__cdecl realloc(void *_Memory,size_t _NewSize); _CRTIMP void *__cdecl _recalloc(void *_Memory,size_t _Count,size_t _Size); - /* _CRTIMP void __cdecl _aligned_free(void *_Memory); - _CRTIMP void *__cdecl _aligned_malloc(size_t _Size,size_t _Alignment); */ + +#ifdef __DO_ALIGN_DEFINES + _CRTIMP void __cdecl _aligned_free(void *_Memory); + _CRTIMP void *__cdecl _aligned_malloc(size_t _Size,size_t _Alignment); +#endif + _CRTIMP void *__cdecl _aligned_offset_malloc(size_t _Size,size_t _Alignment,size_t _Offset); _CRTIMP void *__cdecl _aligned_realloc(void *_Memory,size_t _Size,size_t _Alignment); _CRTIMP void *__cdecl _aligned_recalloc(void *_Memory,size_t _Count,size_t _Size,size_t _Alignment); @@ -71,6 +87,14 @@ extern "C" { _CRTIMP void *__cdecl _aligned_offset_recalloc(void *_Memory,size_t _Count,size_t _Size,size_t _Alignment,size_t _Offset); #endif +#ifdef __DO_ALIGN_DEFINES +#undef __DO_ALIGN_DEFINES + +#pragma pop_macro("_aligned_malloc") +#pragma pop_macro("_aligned_free") + +#endif + #define _MAX_WAIT_MALLOC_CRT 60000 _CRTIMP int __cdecl _resetstkoflw (void); diff --git a/reactos/include/crt/math.h b/reactos/include/crt/math.h index 6b0443b076a..563941bd2e9 100644 --- a/reactos/include/crt/math.h +++ b/reactos/include/crt/math.h @@ -240,8 +240,6 @@ extern "C++" { #pragma pack(pop) -#endif /* !_INC_MATH */ - #if defined(_USE_MATH_DEFINES) && !defined(_MATH_DEFINES_DEFINED) #define _MATH_DEFINES_DEFINED @@ -261,41 +259,141 @@ extern "C++" { #endif /* _USE_MATH_DEFINES */ +#ifdef __cplusplus +extern "C" { +#endif + #ifndef __NO_ISOCEXT #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \ || !defined __STRICT_ANSI__ || defined __GLIBCPP__ - /* Inverse hyperbolic trig functions */ - /* 7.12.5.1 */ +/* 7.12.3.1 */ +/* + Return values for fpclassify. + These are based on Intel x87 fpu condition codes + in the high byte of status word and differ from + the return values for MS IEEE 754 extension _fpclass() +*/ +#define FP_NAN 0x0100 +#define FP_NORMAL 0x0400 +#define FP_INFINITE (FP_NAN | FP_NORMAL) +#define FP_ZERO 0x4000 +#define FP_SUBNORMAL (FP_NORMAL | FP_ZERO) +/* 0x0200 is signbit mask */ + +/* + We can't inline float or double, because we want to ensure truncation + to semantic type before classification. + (A normal long double value might become subnormal when + converted to double, and zero when converted to float.) +*/ + + extern int __cdecl __fpclassifyl (long double); + extern int __cdecl __fpclassifyf (float); + extern int __cdecl __fpclassify (double); + +#ifndef __CRT__NO_INLINE + __CRT_INLINE int __cdecl __fpclassifyl (long double x) { + unsigned short sw; + __asm__ __volatile__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x)); + return sw & (FP_NAN | FP_NORMAL | FP_ZERO ); + } + __CRT_INLINE int __cdecl __fpclassify (double x) { +#ifdef __x86_64__ + __mingw_dbl_type_t hlp; + unsigned int l, h; + + hlp.x = x; + h = hlp.lh.high; + l = hlp.lh.low | (h & 0xfffff); + h &= 0x7ff00000; + if ((h | l) == 0) + return FP_ZERO; + if (!h) + return FP_SUBNORMAL; + if (h == 0x7ff00000) + return (l ? FP_NAN : FP_INFINITE); + return FP_NORMAL; +#else + unsigned short sw; + __asm__ __volatile__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x)); + return sw & (FP_NAN | FP_NORMAL | FP_ZERO ); +#endif + } + __CRT_INLINE int __cdecl __fpclassifyf (float x) { +#ifdef __x86_64__ + __mingw_flt_type_t hlp; + + hlp.x = x; + hlp.val &= 0x7fffffff; + if (hlp.val == 0) + return FP_ZERO; + if (hlp.val < 0x800000) + return FP_SUBNORMAL; + if (hlp.val >= 0x7f800000) + return (hlp.val > 0x7f800000 ? FP_NAN : FP_INFINITE); + return FP_NORMAL; +#else + unsigned short sw; + __asm__ __volatile__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x)); + return sw & (FP_NAN | FP_NORMAL | FP_ZERO ); +#endif + } +#endif + +#define fpclassify(x) (sizeof (x) == sizeof (float) ? __fpclassifyf (x) \ + : sizeof (x) == sizeof (double) ? __fpclassify (x) \ + : __fpclassifyl (x)) + +/* 7.12.3.2 */ +#define isfinite(x) ((fpclassify(x) & FP_NAN) == 0) + +/* 7.12.3.3 */ +#define isinf(x) (fpclassify(x) == FP_INFINITE) + +/* Inverse hyperbolic trig functions */ +/* 7.12.5.1 */ extern double __cdecl acosh (double); extern float __cdecl acoshf (float); extern long double __cdecl acoshl (long double); - /* 7.12.5.2 */ +/* 7.12.5.2 */ extern double __cdecl asinh (double); extern float __cdecl asinhf (float); extern long double __cdecl asinhl (long double); - /* 7.12.5.3 */ +/* 7.12.5.3 */ extern double __cdecl atanh (double); extern float __cdecl atanhf (float); extern long double __cdecl atanhl (long double); - /* 7.12.6.2 */ +/* 7.12.6.2 */ extern double __cdecl exp2(double); extern float __cdecl exp2f(float); extern long double __cdecl exp2l(long double); - /* 7.12.6.10 */ +/* 7.12.6.10 */ extern double __cdecl log2 (double); extern float __cdecl log2f (float); extern long double __cdecl log2l (long double); - /* 7.12.9.8 */ - /* round towards zero, regardless of fpu control word settings */ +/* 7.12.9.6 */ +/* round away from zero, regardless of fpu control word settings */ + extern double __cdecl round (double); + extern float __cdecl roundf (float); + extern long double __cdecl roundl (long double); + +/* 7.12.9.8 */ +/* round towards zero, regardless of fpu control word settings */ extern double __cdecl trunc (double); extern float __cdecl truncf (float); extern long double __cdecl truncl (long double); #endif /* __STDC_VERSION__ >= 199901L */ #endif /* __NO_ISOCEXT */ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif /* !_INC_MATH */ diff --git a/reactos/include/crt/stdlib.h b/reactos/include/crt/stdlib.h index 8fdd8084e2a..f8693d651b7 100644 --- a/reactos/include/crt/stdlib.h +++ b/reactos/include/crt/stdlib.h @@ -342,8 +342,17 @@ extern "C" { void *__cdecl malloc(size_t _Size); void *__cdecl realloc(void *_Memory,size_t _NewSize); _CRTIMP void *__cdecl _recalloc(void *_Memory,size_t _Count,size_t _Size); - //_CRTIMP void __cdecl _aligned_free(void *_Memory); - //_CRTIMP void *__cdecl _aligned_malloc(size_t _Size,size_t _Alignment); +/* Make sure that X86intrin.h doesn't produce here collisions. */ +#if (!defined (_XMMINTRIN_H_INCLUDED) && !defined (_MM_MALLOC_H_INCLUDED)) || defined(_aligned_malloc) +#pragma push_macro("_aligned_free") +#pragma push_macro("_aligned_malloc") +#undef _aligned_free +#undef _aligned_malloc + _CRTIMP void __cdecl _aligned_free(void *_Memory); + _CRTIMP void *__cdecl _aligned_malloc(size_t _Size,size_t _Alignment); +#pragma pop_macro("_aligned_free") +#pragma pop_macro("_aligned_malloc") +#endif _CRTIMP void *__cdecl _aligned_offset_malloc(size_t _Size,size_t _Alignment,size_t _Offset); _CRTIMP void *__cdecl _aligned_realloc(void *_Memory,size_t _Size,size_t _Alignment); _CRTIMP void *__cdecl _aligned_recalloc(void *_Memory,size_t _Count,size_t _Size,size_t _Alignment); diff --git a/reactos/include/psdk/intsafe.h b/reactos/include/psdk/intsafe.h index dec439f3b10..62b4dccb5df 100644 --- a/reactos/include/psdk/intsafe.h +++ b/reactos/include/psdk/intsafe.h @@ -31,7 +31,11 @@ #include #if defined(__GNUC__) && !defined(__forceinline) -#define __forceinline extern __inline __attribute((always_inline)) +# if ( __MINGW_GNUC_PREREQ(4, 3) && __STDC_VERSION__ >= 199901L) +# define __forceinline extern inline __attribute__((__always_inline__,__gnu_inline__)) +# else +# define __forceinline extern __inline__ __attribute__((__always_inline__)) +# endif #endif /* Handle ntintsafe here too */ diff --git a/reactos/include/psdk/ntdef.h b/reactos/include/psdk/ntdef.h index 081c1c06f56..a0aaf31d546 100644 --- a/reactos/include/psdk/ntdef.h +++ b/reactos/include/psdk/ntdef.h @@ -264,7 +264,11 @@ #elif defined(_MSC_VER) #define FORCEINLINE __inline #else /* __GNUC__ */ -#define FORCEINLINE extern __inline__ __attribute__((always_inline)) +# if ( __MINGW_GNUC_PREREQ(4, 3) && __STDC_VERSION__ >= 199901L) +# define FORCEINLINE extern inline __attribute__((__always_inline__,__gnu_inline__)) +# else +# define FORCEINLINE extern __inline__ __attribute__((__always_inline__)) +# endif #endif #endif /* FORCEINLINE */ diff --git a/reactos/include/psdk/winnt.h b/reactos/include/psdk/winnt.h index fa8f1850ec4..205d68d66ce 100644 --- a/reactos/include/psdk/winnt.h +++ b/reactos/include/psdk/winnt.h @@ -176,7 +176,11 @@ extern "C" { #elif (_MSC_VER) #define FORCEINLINE __inline #else -#define FORCEINLINE extern __inline__ __attribute__((always_inline)) +# if ( __MINGW_GNUC_PREREQ(4, 3) && __STDC_VERSION__ >= 199901L) +# define FORCEINLINE extern inline __attribute__((__always_inline__,__gnu_inline__)) +# else +# define FORCEINLINE extern __inline__ __attribute__((__always_inline__)) +# endif #endif #endif