Unified · Split
| @@ -1,23 +1,25 @@ | ||
| 1 | 1 | /* |
| 2 | −** Copyright (C) 2001-2003 Erik de Castro Lopo <erikd@mega-nerd.com> | |
| 2 | +** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd@mega-nerd.com> | |
| 3 | 3 | ** |
| 4 | 4 | ** This program is free software; you can redistribute it and/or modify |
| 5 | −** it under the terms of the GNU General Public License as published by | |
| 6 | −** the Free Software Foundation; either version 2 of the License, or | |
| 5 | +** it under the terms of the GNU Lesser General Public License as published by | |
| 6 | +** the Free Software Foundation; either version 2.1 of the License, or | |
| 7 | 7 | ** (at your option) any later version. |
| 8 | 8 | ** |
| 9 | 9 | ** This program is distributed in the hope that it will be useful, |
| 10 | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | −** GNU General Public License for more details. | |
| 12 | +** GNU Lesser General Public License for more details. | |
| 13 | 13 | ** |
| 14 | −** You should have received a copy of the GNU General Public License | |
| 14 | +** You should have received a copy of the GNU Lesser General Public License | |
| 15 | 15 | ** along with this program; if not, write to the Free Software |
| 16 | −** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. | |
| 16 | +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | −/* Version 1.3 */ | |
| 19 | +/* Version 1.4 */ | |
| 20 | 20 | |
| 21 | +#ifndef FLOAT_CAST_HEADER | |
| 22 | +#define FLOAT_CAST_HEADER | |
| 21 | 23 | |
| 22 | 24 | /*============================================================================ |
| 23 | 25 | ** On Intel Pentium processors (especially PIII and probably P4), converting |
| @@ -71,10 +73,59 @@ · 47 unmodified lines | ||
| 71 | 73 | |
| 72 | 74 | #include <math.h> |
| 73 | 75 | |
| 76 | +#elif (defined (__CYGWIN__)) | |
| 77 | + | |
| 78 | + #include <math.h> | |
| 79 | + | |
| 80 | + #undef HAVE_LRINT_REPLACEMENT | |
| 81 | + #define HAVE_LRINT_REPLACEMENT 1 | |
| 82 | + | |
| 83 | + #undef lrint | |
| 84 | + #undef lrintf | |
| 85 | + | |
| 86 | + #define lrint double2int | |
| 87 | + #define lrintf float2int | |
| 88 | + | |
| 89 | + /* | |
| 90 | + ** The native CYGWIN lrint and lrintf functions are buggy: | |
| 91 | + ** http://sourceware.org/ml/cygwin/2005-06/msg00153.html | |
| 92 | + ** http://sourceware.org/ml/cygwin/2005-09/msg00047.html | |
| 93 | + ** and slow. | |
| 94 | + ** These functions (pulled from the Public Domain MinGW math.h header) | |
| 95 | + ** replace the native versions. | |
| 96 | + */ | |
| 97 | + | |
| 98 | + static inline long double2int (double in) | |
| 99 | + { long retval ; | |
| 100 | + | |
| 101 | + __asm__ __volatile__ | |
| 102 | + ( "fistpl %0" | |
| 103 | + : "=m" (retval) | |
| 104 | + : "t" (in) | |
| 105 | + : "st" | |
| 106 | + ) ; | |
| 107 | + | |
| 108 | + return retval ; | |
| 109 | + } /* double2int */ | |
| 110 | + | |
| 111 | + static inline long float2int (float in) | |
| 112 | + { long retval ; | |
| 113 | + | |
| 114 | + __asm__ __volatile__ | |
| 115 | + ( "fistpl %0" | |
| 116 | + : "=m" (retval) | |
| 117 | + : "t" (in) | |
| 118 | + : "st" | |
| 119 | + ) ; | |
| 120 | + | |
| 121 | + return retval ; | |
| 122 | + } /* float2int */ | |
| 123 | + | |
| 74 | 124 | #elif (defined (WIN32) || defined (_WIN32)) |
| 75 | 125 | |
| 76 | 126 | #undef HAVE_LRINT_REPLACEMENT |
| 77 | 127 | #define HAVE_LRINT_REPLACEMENT 1 |
| 128 | + | |
| 78 | 129 | #include <math.h> |
| 79 | 130 | |
| 80 | 131 | /* |
| @@ -156,7 +207,7 @@ · 75 unmodified lines | ||
| 156 | 207 | #define lrint double2int |
| 157 | 208 | #define lrintf float2int |
| 158 | 209 | |
| 159 | − inline static long int | |
| 210 | + inline static long | |
| 160 | 211 | float2int (register float in) |
| 161 | 212 | { int res [2] ; |
| 162 | 213 | |
| @@ -171,7 +222,7 @@ · 8 unmodified lines | ||
| 171 | 222 | return res [1] ; |
| 172 | 223 | } /* lrintf */ |
| 173 | 224 | |
| 174 | − inline static long int | |
| 225 | + inline static long | |
| 175 | 226 | double2int (register double in) |
| 176 | 227 | { int res [2] ; |
| 177 | 228 | |
| @@ -200,6 +251,7 @@ · 22 unmodified lines | ||
| 200 | 251 | #endif |
| 201 | 252 | |
| 202 | 253 | |
| 254 | +#endif /* FLOAT_CAST_HEADER */ | |
| 203 | 255 | |
| 204 | 256 | /* |
| 205 | 257 | ** Do not edit or modify anything in this comment block. |