]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
use compiler intrinsics for windows x64 build (FSBUILD-131)
authorMichael Jerris <mike@jerris.com>
Mon, 23 Feb 2009 17:56:59 +0000 (17:56 +0000)
committerMichael Jerris <mike@jerris.com>
Mon, 23 Feb 2009 17:56:59 +0000 (17:56 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12246 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/ilbc/src/iLBC_decode.c
libs/spandsp/src/spandsp/fast_convert.h
libs/voipcodecs/src/voipcodecs/dc_restore.h

index 55d080e07117253905afb25c62e25f24e61d807b..fc46fe408c52a9378190d3c19e93fc4c092924d6 100644 (file)
@@ -41,7 +41,7 @@
 #include "syntFilter.h"
 
 #if (defined(WIN32)  ||  defined(_WIN32)) && !defined(_WIN64)
-    __inline double rint(double dbl)
+    __inline long int rint(double dbl)
     {
         _asm 
        {
         }
     }
 #elif defined (_WIN64)
+#include <intrin.h>
     __inline__ long int rint(double x)
     {
-        return (long int) (x);
+#ifdef _M_X64
+               return (long int)_mm_cvtsd_si64x( _mm_loadu_pd ((const double*)&x) );
+#else
+#warning "Not Supported: Replacing with a simple C cast."
+       return (long int) (x);
+#endif
     }
 #endif
 
index a09882edfb0bf6171107c1eed7d4099ce89b2b36..2e794a2701f2b6c835b92da52526868230782a82 100644 (file)
@@ -303,29 +303,26 @@ extern "C"
     }
 #elif defined(WIN64)  ||  defined(_WIN64)
     /* x86_64 machines will do best with a simple assignment. */
+#include <intrin.h>
 
     __inline long int lrint(double x)
     {
-        long int i;
-
-        _asm
-        {
-            fld x
-            fistp i
-        };
-        return i;
+#ifdef _M_X64
+               return (long int)_mm_cvtsd_si64x( _mm_loadu_pd ((const double*)&x) );
+#else
+#warning "Not Supported: Replacing with a simple C cast."
+       return (long int) (x);
+#endif
     }
 
     __inline long int lrintf(float x)
     {
-        long int i;
-
-        _asm
-        {
-            fld x
-            fistp i
-        };
-        return i;
+#ifdef _M_X64
+               return _mm_cvt_ss2si( _mm_load_ss((const float*)&x) );
+#else
+#warning "Not Supported: Replacing with a simple C cast."
+       return (long int) (x);
+#endif
     }
 
     __inline long int lfastrint(double x)
index 6bd5cf7fba9b1a248ee6fd805c4008979ed0ed4c..89d98b1ea004cb3c3272a13a804662fc5498c626 100644 (file)
@@ -127,17 +127,34 @@ __inline long lrintf (float flt)
        return retval;\r
 }
 #elif defined(_WIN64)
+#include <intrin.h>
+
     __inline__ long int rint(double x)
     {
-        return (long int) (x);
+#ifdef _M_X64
+               return (long int)_mm_cvtsd_si64x( _mm_loadu_pd ((const double*)&x) );
+#else
+#warning "Not Supported: Replacing with a simple C cast."
+       return (long int) (x);
+#endif
     }
        __inline__ int rintf(float x)
        {
-               return (int) rint((double) x);
+#ifdef _M_X64
+               return _mm_cvt_ss2si( _mm_load_ss((const float*)&x) );
+#else
+#warning "Not Supported: Replacing with a simple C cast."
+       return (int) (x);
+#endif
        }
     __inline__ long int lrintf(float x)
     {
-        return (long int) (x);
+#ifdef _M_X64
+               return _mm_cvt_ss2si( _mm_load_ss((const float*)&x) );
+#else
+#warning "Not Supported: Replacing with a simple C cast."
+       return (long int) (x);
+#endif
     }
 #endif