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 
12 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_
13 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_
14 
15 #include <math.h>
16 #include "webrtc/typedefs.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)21 static __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   return x_int;
30 }
31 #else // Do a slow but correct implementation of lrint
32 
WebRtcIsac_lrint(double x_dbl)33 static __inline long int WebRtcIsac_lrint(double x_dbl) {
34   long int x_int;
35   x_int = (long int)floor(x_dbl + 0.499999999999);
36   return x_int;
37 }
38 
39 #endif
40 
41 #endif  // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_
42