mirror of
https://github.com/reactos/reactos.git
synced 2024-09-30 06:27:38 +00:00
[INCLUDE]
- Add some more C99 math functions - Fix definition of __forceinline and FORCEINLINE for C99 - Fix and add definition of _aligned_malloc and _aligned_free - Fix definition of is(w)blank, as a C99 function, it is not in msvcrt.dll and has to be implemented in msvcrtex All of this taken from the mingw-w64 project svn path=/trunk/; revision=56995
This commit is contained in:
parent
a06b1e416e
commit
01197a3cc8
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,10 +259,98 @@ 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__
|
||||
|
||||
/* 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);
|
||||
|
@ -291,6 +377,12 @@ extern "C++" {
|
|||
extern float __cdecl log2f (float);
|
||||
extern long double __cdecl log2l (long double);
|
||||
|
||||
/* 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);
|
||||
|
@ -299,3 +391,9 @@ extern "C++" {
|
|||
|
||||
#endif /* __STDC_VERSION__ >= 199901L */
|
||||
#endif /* __NO_ISOCEXT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif /* !_INC_MATH */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -31,7 +31,11 @@
|
|||
#include <specstrings.h>
|
||||
|
||||
#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 */
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue