1 /* 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_ 12 #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_ 13 14 #include <math.h> 15 16 #include "rtc_base/system/arch.h" 17 18 #if defined(WEBRTC_POSIX) 19 #define WebRtcIsac_lrint lrint 20 #elif (defined(WEBRTC_ARCH_X86) && defined(WIN32)) WebRtcIsac_lrint(double x_dbl)21static __inline long int WebRtcIsac_lrint(double x_dbl) { 22 long int x_int; 23 24 __asm { 25 fld x_dbl 26 fistp x_int 27 } 28 ; 29 30 return x_int; 31 } 32 #else // Do a slow but correct implementation of lrint 33 WebRtcIsac_lrint(double x_dbl)34static __inline long int WebRtcIsac_lrint(double x_dbl) { 35 long int x_int; 36 x_int = (long int)floor(x_dbl + 0.499999999999); 37 return x_int; 38 } 39 40 #endif 41 42 #endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_ 43