]> iEval git - audio-libsamplerate.git/blame_incremental - libsamplerate/M4/clip_mode.m4
Bump version and update Changes
[audio-libsamplerate.git] / libsamplerate / M4 / clip_mode.m4
... / ...
CommitLineData
1dnl @synopsis AC_C_CLIP_MODE
2dnl
3dnl Determine the clipping mode when converting float to int.
4dnl @version 1.0 May 17 2003
5dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
6dnl
7dnl Permission to use, copy, modify, distribute, and sell this file for any
8dnl purpose is hereby granted without fee, provided that the above copyright
9dnl and this permission notice appear in all copies. No representations are
10dnl made about the suitability of this software for any purpose. It is
11dnl provided "as is" without express or implied warranty.
12
13
14
15
16
17
18
19dnl Find the clipping mode in the following way:
20dnl 1) If we are not cross compiling test it.
21dnl 2) IF we are cross compiling, assume that clipping isn't done correctly.
22
23AC_DEFUN([AC_C_CLIP_MODE],
24[AC_CACHE_CHECK(processor clipping capabilities,
25 ac_cv_c_clip_type,
26
27# Initialize to unknown
28ac_cv_c_clip_positive=unknown
29ac_cv_c_clip_negative=unknown
30
31
32if test $ac_cv_c_clip_positive = unknown ; then
33 AC_TRY_RUN(
34 [[
35 #define _ISOC9X_SOURCE 1
36 #define _ISOC99_SOURCE 1
37 #define __USE_ISOC99 1
38 #define __USE_ISOC9X 1
39 #include <math.h>
40 int main (void)
41 { double fval ;
42 int k, ival ;
43
44 fval = 1.0 * 0x7FFFFFFF ;
45 for (k = 0 ; k < 100 ; k++)
46 { ival = (lrint (fval)) >> 24 ;
47 if (ival != 127)
48 return 1 ;
49
50 fval *= 1.2499999 ;
51 } ;
52
53 return 0 ;
54 }
55 ]],
56 ac_cv_c_clip_positive=yes,
57 ac_cv_c_clip_positive=no,
58 ac_cv_c_clip_positive=unknown
59 )
60
61 AC_TRY_RUN(
62 [[
63 #define _ISOC9X_SOURCE 1
64 #define _ISOC99_SOURCE 1
65 #define __USE_ISOC99 1
66 #define __USE_ISOC9X 1
67 #include <math.h>
68 int main (void)
69 { double fval ;
70 int k, ival ;
71
72 fval = -8.0 * 0x10000000 ;
73 for (k = 0 ; k < 100 ; k++)
74 { ival = (lrint (fval)) >> 24 ;
75 if (ival != -128)
76 return 1 ;
77
78 fval *= 1.2499999 ;
79 } ;
80
81 return 0 ;
82 }
83 ]],
84 ac_cv_c_clip_negative=yes,
85 ac_cv_c_clip_negative=no,
86 ac_cv_c_clip_negative=unknown
87 )
88 fi
89
90if test $ac_cv_c_clip_positive = yes ; then
91 ac_cv_c_clip_positive=1
92else
93 ac_cv_c_clip_positive=0
94 fi
95
96if test $ac_cv_c_clip_negative = yes ; then
97 ac_cv_c_clip_negative=1
98else
99 ac_cv_c_clip_negative=0
100 fi
101
102[[
103case "$ac_cv_c_clip_positive$ac_cv_c_clip_negative" in
104 "00")
105 ac_cv_c_clip_type="none"
106 ;;
107 "10")
108 ac_cv_c_clip_type="positive"
109 ;;
110 "01")
111 ac_cv_c_clip_type="negative"
112 ;;
113 "11")
114 ac_cv_c_clip_type="both"
115 ;;
116 esac
117 ]]
118
119)
120]
121
122)# AC_C_CLIP_MODE
123
124
This page took 0.016044 seconds and 4 git commands to generate.