shithub: libsamplerate

Download patch

ref: 47fa1bf8fc8b46c21db21233b43a6cde186773a8
parent: 61dee13337cd11360081205d9ea8ed84afec5854
author: Erik de Castro Lopo <erikd@mega-nerd.com>
date: Mon Sep 27 07:47:58 EDT 2010

src/float_cast.h : Add lrint/lrintf version for Win64. Thanks to Dmitry Baikov.

--- a/src/float_cast.h
+++ b/src/float_cast.h
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 2001-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
+** Copyright (C) 2001-2010 Erik de Castro Lopo <erikd@mega-nerd.com>
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -16,7 +16,7 @@
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
-/* Version 1.4 */
+/* Version 1.5 */
 
 #ifndef FLOAT_CAST_HEADER
 #define FLOAT_CAST_HEADER
@@ -120,6 +120,32 @@
 
 		return retval ;
 	} /* float2int */
+
+#elif (defined (WIN64) || defined(_WIN64))
+
+	/*	Win64 section should be places before Win32 one, because
+	**	most likely both WIN32 and WIN64 will be defined in 64-bit case.
+	*/
+
+	#include	<math.h>
+
+	/*	Win64 doesn't seem to have these functions, nor inline assembly.
+	**	Therefore implement inline versions of these functions here.
+	*/
+	#include    <emmintrin.h>
+	#include    <mmintrin.h>
+
+	__inline long int
+	lrint(double flt)
+	{
+		return _mm_cvtsd_si32(_mm_load_sd(&flt));
+	}
+
+	__inline long int
+	lrintf(float flt)
+	{
+		return _mm_cvtss_si32(_mm_load_ss(&flt));
+	}
 
 #elif (defined (WIN32) || defined (_WIN32))