| | 2 | |
| | 3 | dnl @synopsis AC_C99_FUNC_LRINT |
| | 4 | dnl |
| | 5 | dnl Check whether C99's lrint function is available. |
| | 6 | dnl @version 1.3 Feb 12 2002 |
| | 7 | dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com> |
| | 8 | dnl |
| | 9 | dnl Permission to use, copy, modify, distribute, and sell this file for any |
| | 10 | dnl purpose is hereby granted without fee, provided that the above copyright |
| | 11 | dnl and this permission notice appear in all copies. No representations are |
| | 12 | dnl made about the suitability of this software for any purpose. It is |
| | 13 | dnl provided "as is" without express or implied warranty. |
| | 14 | dnl |
| | 15 | AC_DEFUN([AC_C99_FUNC_LRINT], |
| | 16 | [AC_CACHE_CHECK(for lrint, |
| | 17 | ac_cv_c99_lrint, |
| | 18 | [ |
| | 19 | lrint_save_CFLAGS=$CFLAGS |
| | 20 | CFLAGS="-O2 -lm" |
| | 21 | AC_TRY_LINK([ |
| | 22 | #define _ISOC9X_SOURCE 1 |
| | 23 | #define _ISOC99_SOURCE 1 |
| | 24 | #define __USE_ISOC99 1 |
| | 25 | #define __USE_ISOC9X 1 |
| | 26 | |
| | 27 | #include <math.h> |
| | 28 | ], if (!lrint(3.14159)) lrint(2.7183);, ac_cv_c99_lrint=yes, ac_cv_c99_lrint=no) |
| | 29 | |
| | 30 | CFLAGS=$lrint_save_CFLAGS |
| | 31 | |
| | 32 | ]) |
| | 33 | |
| | 34 | if test "$ac_cv_c99_lrint" = yes; then |
| | 35 | AC_DEFINE(HAVE_LRINT, 1, |
| | 36 | [Define if you have C99's lrint function.]) |
| | 37 | fi |
| | 38 | ])# AC_C99_FUNC_LRINT |
| | 39 | dnl @synopsis AC_C99_FUNC_LRINTF |
| | 40 | dnl |
| | 41 | dnl Check whether C99's lrintf function is available. |
| | 42 | dnl @version 1.3 Feb 12 2002 |
| | 43 | dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com> |
| | 44 | dnl |
| | 45 | dnl Permission to use, copy, modify, distribute, and sell this file for any |
| | 46 | dnl purpose is hereby granted without fee, provided that the above copyright |
| | 47 | dnl and this permission notice appear in all copies. No representations are |
| | 48 | dnl made about the suitability of this software for any purpose. It is |
| | 49 | dnl provided "as is" without express or implied warranty. |
| | 50 | dnl |
| | 51 | AC_DEFUN([AC_C99_FUNC_LRINTF], |
| | 52 | [AC_CACHE_CHECK(for lrintf, |
| | 53 | ac_cv_c99_lrintf, |
| | 54 | [ |
| | 55 | lrintf_save_CFLAGS=$CFLAGS |
| | 56 | CFLAGS="-O2 -lm" |
| | 57 | AC_TRY_LINK([ |
| | 58 | #define _ISOC9X_SOURCE 1 |
| | 59 | #define _ISOC99_SOURCE 1 |
| | 60 | #define __USE_ISOC99 1 |
| | 61 | #define __USE_ISOC9X 1 |
| | 62 | |
| | 63 | #include <math.h> |
| | 64 | ], if (!lrintf(3.14159)) lrintf(2.7183);, ac_cv_c99_lrintf=yes, ac_cv_c99_lrintf=no) |
| | 65 | |
| | 66 | CFLAGS=$lrintf_save_CFLAGS |
| | 67 | |
| | 68 | ]) |
| | 69 | |
| | 70 | if test "$ac_cv_c99_lrintf" = yes; then |
| | 71 | AC_DEFINE(HAVE_LRINTF, 1, |
| | 72 | [Define if you have C99's lrintf function.]) |
| | 73 | fi |
| | 74 | ])# AC_C99_FUNC_LRINTF |
| | 75 | dnl @synopsis AC_C99_FUNC_LLRINT |
| | 76 | dnl |
| | 77 | dnl Check whether C99's llrint function is available. |
| | 78 | dnl @version 1.1 Sep 30 2002 |
| | 79 | dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com> |
| | 80 | dnl |
| | 81 | dnl Permission to use, copy, modify, distribute, and sell this file for any |
| | 82 | dnl purpose is hereby granted without fee, provided that the above copyright |
| | 83 | dnl and this permission notice appear in all copies. No representations are |
| | 84 | dnl made about the suitability of this software for any purpose. It is |
| | 85 | dnl provided "as is" without express or implied warranty. |
| | 86 | dnl |
| | 87 | AC_DEFUN([AC_C99_FUNC_LLRINT], |
| | 88 | [AC_CACHE_CHECK(for llrint, |
| | 89 | ac_cv_c99_llrint, |
| | 90 | [ |
| | 91 | llrint_save_CFLAGS=$CFLAGS |
| | 92 | CFLAGS="-O2 -lm" |
| | 93 | AC_TRY_LINK([ |
| | 94 | #define _ISOC9X_SOURCE 1 |
| | 95 | #define _ISOC99_SOURCE 1 |
| | 96 | #define __USE_ISOC99 1 |
| | 97 | #define __USE_ISOC9X 1 |
| | 98 | |
| | 99 | #include <math.h> |
| | 100 | #include <stdint.h> |
| | 101 | ], int64_t x ; x = llrint(3.14159) ;, ac_cv_c99_llrint=yes, ac_cv_c99_llrint=no) |
| | 102 | |
| | 103 | CFLAGS=$llrint_save_CFLAGS |
| | 104 | |
| | 105 | ]) |
| | 106 | |
| | 107 | if test "$ac_cv_c99_llrint" = yes; then |
| | 108 | AC_DEFINE(HAVE_LLRINT, 1, |
| | 109 | [Define if you have C99's llrint function.]) |
| | 110 | fi |
| | 111 | ])# AC_C99_FUNC_LLRINT |
| | 112 | |
| | 113 | |
| | 114 | |
| | 115 | dnl @synopsis AC_C_CLIP_MODE |
| | 116 | dnl |
| | 117 | dnl Determine the clipping mode when converting float to int. |
| | 118 | dnl @version 1.0 May 17 2003 |
| | 119 | dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com> |
| | 120 | dnl |
| | 121 | dnl Permission to use, copy, modify, distribute, and sell this file for any |
| | 122 | dnl purpose is hereby granted without fee, provided that the above copyright |
| | 123 | dnl and this permission notice appear in all copies. No representations are |
| | 124 | dnl made about the suitability of this software for any purpose. It is |
| | 125 | dnl provided "as is" without express or implied warranty. |
| | 126 | |
| | 127 | |
| | 128 | |
| | 129 | dnl Find the clipping mode in the following way: |
| | 130 | dnl 1) If we are not cross compiling test it. |
| | 131 | dnl 2) IF we are cross compiling, assume that clipping isn't done correctly. |
| | 132 | |
| | 133 | AC_DEFUN([AC_C_CLIP_MODE], |
| | 134 | [AC_CACHE_CHECK(processor clipping capabilities, |
| | 135 | ac_cv_c_clip_type, |
| | 136 | |
| | 137 | # Initialize to unknown |
| | 138 | ac_cv_c_clip_positive=unknown |
| | 139 | ac_cv_c_clip_negative=unknown |
| | 140 | |
| | 141 | if test $ac_cv_c_clip_positive = unknown ; then |
| | 142 | AC_TRY_RUN( |
| | 143 | [[ |
| | 144 | #define _ISOC9X_SOURCE 1 |
| | 145 | #define _ISOC99_SOURCE 1 |
| | 146 | #define __USE_ISOC99 1 |
| | 147 | #define __USE_ISOC9X 1 |
| | 148 | #include <math.h> |
| | 149 | int main (void) |
| | 150 | { double fval ; |
| | 151 | int k, ival ; |
| | 152 | |
| | 153 | fval = 1.0 * 0x7FFFFFFF ; |
| | 154 | for (k = 0 ; k < 100 ; k++) |
| | 155 | { ival = (lrint (fval)) >> 24 ; |
| | 156 | if (ival != 127) |
| | 157 | return 1 ; |
| | 158 | |
| | 159 | fval *= 1.2499999 ; |
| | 160 | } ; |
| | 161 | |
| | 162 | return 0 ; |
| | 163 | } |
| | 164 | ]], |
| | 165 | ac_cv_c_clip_positive=yes, |
| | 166 | ac_cv_c_clip_positive=no, |
| | 167 | ac_cv_c_clip_positive=unknown |
| | 168 | ) |
| | 169 | |
| | 170 | AC_TRY_RUN( |
| | 171 | [[ |
| | 172 | #define _ISOC9X_SOURCE 1 |
| | 173 | #define _ISOC99_SOURCE 1 |
| | 174 | #define __USE_ISOC99 1 |
| | 175 | #define __USE_ISOC9X 1 |
| | 176 | #include <math.h> |
| | 177 | int main (void) |
| | 178 | { double fval ; |
| | 179 | int k, ival ; |
| | 180 | |
| | 181 | fval = -8.0 * 0x10000000 ; |
| | 182 | for (k = 0 ; k < 100 ; k++) |
| | 183 | { ival = (lrint (fval)) >> 24 ; |
| | 184 | if (ival != -128) |
| | 185 | return 1 ; |
| | 186 | |
| | 187 | fval *= 1.2499999 ; |
| | 188 | } ; |
| | 189 | |
| | 190 | return 0 ; |
| | 191 | } |
| | 192 | ]], |
| | 193 | ac_cv_c_clip_negative=yes, |
| | 194 | ac_cv_c_clip_negative=no, |
| | 195 | ac_cv_c_clip_negative=unknown |
| | 196 | ) |
| | 197 | |
| | 198 | fi |
| | 199 | |
| | 200 | if test $ac_cv_c_clip_positive = yes ; then |
| | 201 | ac_cv_c_clip_positive=1 |
| | 202 | else |
| | 203 | ac_cv_c_clip_positive=0 |
| | 204 | fi |
| | 205 | |
| | 206 | if test $ac_cv_c_clip_negative = yes ; then |
| | 207 | ac_cv_c_clip_negative=1 |
| | 208 | else |
| | 209 | ac_cv_c_clip_negative=0 |
| | 210 | fi |
| | 211 | |
| | 212 | [[ |
| | 213 | case "$ac_cv_c_clip_positive$ac_cv_c_clip_negative" in |
| | 214 | "00") |
| | 215 | ac_cv_c_clip_type="none" |
| | 216 | ;; |
| | 217 | "10") |
| | 218 | ac_cv_c_clip_type="positive" |
| | 219 | ;; |
| | 220 | "01") |
| | 221 | ac_cv_c_clip_type="negative" |
| | 222 | ;; |
| | 223 | "11") |
| | 224 | ac_cv_c_clip_type="both" |
| | 225 | ;; |
| | 226 | esac |
| | 227 | ]] |
| | 228 | |
| | 229 | ) |
| | 230 | ] |
| | 231 | |
| | 232 | )# AC_C_CLIP_MODE |