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 "typedefs.h"
17 
18 // TODO(turaj): switch to WEBRTC_POSIX when available
19 #if defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
20 #define WebRtcIsac_lrint lrint
21 #elif (defined(WEBRTC_ARCH_X86) && defined(WIN32))
WebRtcIsac_lrint(double x_dbl)22 static __inline long int WebRtcIsac_lrint(double x_dbl) {
23   long int x_int;
24 
25   __asm {
26     fld x_dbl
27     fistp x_int
28   };
29 
30   return x_int;
31 }
32 #else // Do a slow but correct implementation of lrint
33 
WebRtcIsac_lrint(double x_dbl)34 static __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  // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_
43