From c6f12ff6bafaf39a3eb9d9765cbfad1c9b5b07b5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 25 Nov 2014 09:08:34 +0000 Subject: [PATCH] [PSDK] When I wrote "the compiler can optimize this better" I was obviously referring to a sane compiler like MSVC. Optimize (U)Int32x32To64 on x86 GCC builds by using __emul(u), since the native math results in horribly inefficient code doing 3 multiplications and some shifts. svn path=/trunk/; revision=65480 --- reactos/include/psdk/ntdef.h | 13 +++++++++---- reactos/include/psdk/winnt.h | 17 +++++++++-------- reactos/include/xdk/ntbasedef.h | 13 +++++++++---- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/reactos/include/psdk/ntdef.h b/reactos/include/psdk/ntdef.h index 444bb8a1a84..fe01526c8fb 100644 --- a/reactos/include/psdk/ntdef.h +++ b/reactos/include/psdk/ntdef.h @@ -828,10 +828,15 @@ extern "C++" { \ #define MAXULONG 0xffffffff #define MAXLONGLONG (0x7fffffffffffffffLL) -/* Multiplication and Shift Operations. Note: we don't use inline - asm functions, the compiler can optimize this better. */ -#define Int32x32To64(a,b) (((__int64)(long)(a))*((__int64)(long)(b))) -#define UInt32x32To64(a,b) ((unsigned __int64)(unsigned int)(a)*(unsigned __int64)(unsigned int)(b)) +/* 32 to 64 bit multiplication. GCC is really bad at optimizing the native math */ +#if defined(_M_IX86) && defined(__GNUC__) && \ + !defined(MIDL_PASS)&& !defined(RC_INVOKED) && !defined(_M_CEE_PURE) + #define Int32x32To64(a,b) __emul(a,b) + #define UInt32x32To64(a,b) __emulu(a,b) +#else + #define Int32x32To64(a,b) (((__int64)(long)(a))*((__int64)(long)(b))) + #define UInt32x32To64(a,b) ((unsigned __int64)(unsigned int)(a)*(unsigned __int64)(unsigned int)(b)) +#endif #if defined(MIDL_PASS)|| defined(RC_INVOKED) || defined(_M_CEE_PURE) /* Use native math */ diff --git a/reactos/include/psdk/winnt.h b/reactos/include/psdk/winnt.h index 55be73a43c4..b9201aebfb2 100644 --- a/reactos/include/psdk/winnt.h +++ b/reactos/include/psdk/winnt.h @@ -761,10 +761,15 @@ extern "C++" { \ #define MAXDWORD 0xffffffff #define MAXLONGLONG (0x7fffffffffffffffLL) -/* Multiplication and Shift Operations. Note: we don't use inline - asm functions, the compiler can optimize this better. */ -#define Int32x32To64(a,b) (((__int64)(long)(a))*((__int64)(long)(b))) -#define UInt32x32To64(a,b) ((unsigned __int64)(unsigned int)(a)*(unsigned __int64)(unsigned int)(b)) +/* 32 to 64 bit multiplication. GCC is really bad at optimizing the native math */ +#if defined(_M_IX86) && defined(__GNUC__) && \ + !defined(MIDL_PASS)&& !defined(RC_INVOKED) && !defined(_M_CEE_PURE) + #define Int32x32To64(a,b) __emul(a,b) + #define UInt32x32To64(a,b) __emulu(a,b) +#else + #define Int32x32To64(a,b) (((__int64)(long)(a))*((__int64)(long)(b))) + #define UInt32x32To64(a,b) ((unsigned __int64)(unsigned int)(a)*(unsigned __int64)(unsigned int)(b)) +#endif #if defined(MIDL_PASS)|| defined(RC_INVOKED) || defined(_M_CEE_PURE) /* Use native math */ @@ -1709,10 +1714,6 @@ extern "C++" { \ #define THREAD_BASE_PRIORITY_MAX 2 #define THREAD_BASE_PRIORITY_MIN (-2) #define THREAD_BASE_PRIORITY_IDLE (-15) - -#define PROCESS_SET_LIMITED_INFORMATION 0x2000 -#define THREAD_RESUME 0x1000 - /* * To prevent gcc compiler warnings, bracket these defines when initialising * a SID_IDENTIFIER_AUTHORITY, eg. diff --git a/reactos/include/xdk/ntbasedef.h b/reactos/include/xdk/ntbasedef.h index 30b2c1e2f6d..3555b1e2c63 100644 --- a/reactos/include/xdk/ntbasedef.h +++ b/reactos/include/xdk/ntbasedef.h @@ -747,10 +747,15 @@ $if(_WINNT_) $endif(_WINNT_) #define MAXLONGLONG (0x7fffffffffffffffLL) -/* Multiplication and Shift Operations. Note: we don't use inline - asm functions, the compiler can optimize this better. */ -#define Int32x32To64(a,b) (((__int64)(long)(a))*((__int64)(long)(b))) -#define UInt32x32To64(a,b) ((unsigned __int64)(unsigned int)(a)*(unsigned __int64)(unsigned int)(b)) +/* 32 to 64 bit multiplication. GCC is really bad at optimizing the native math */ +#if defined(_M_IX86) && defined(__GNUC__) && \ + !defined(MIDL_PASS)&& !defined(RC_INVOKED) && !defined(_M_CEE_PURE) + #define Int32x32To64(a,b) __emul(a,b) + #define UInt32x32To64(a,b) __emulu(a,b) +#else + #define Int32x32To64(a,b) (((__int64)(long)(a))*((__int64)(long)(b))) + #define UInt32x32To64(a,b) ((unsigned __int64)(unsigned int)(a)*(unsigned __int64)(unsigned int)(b)) +#endif #if defined(MIDL_PASS)|| defined(RC_INVOKED) || defined(_M_CEE_PURE) /* Use native math */