1 /* Stub definitions for libmath subpart of libstdc++. */ 2 3 /* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. 4 5 This file is part of the GNU ISO C++ Library. This library is free 6 software; you can redistribute it and/or modify it under the 7 terms of the GNU General Public License as published by the 8 Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 This library is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License along 17 with this library; see the file COPYING. If not, write to the Free 18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 19 USA. 20 21 As a special exception, you may use this file as part of a free software 22 library without restriction. Specifically, if other files instantiate 23 templates or use macros or inline functions from this file, or you compile 24 this file and link it with other files to produce an executable, this 25 file does not by itself cause the resulting executable to be covered by 26 the GNU General Public License. This exception does not however 27 invalidate any other reasons why the executable file might be covered by 28 the GNU General Public License. */ 29 30 #include <math.h> 31 #include "config.h" 32 33 /* For targets which do not have support for long double versions, 34 we use the crude approximation. We'll do better later. */ 35 36 37 #ifndef HAVE_ATAN2F 38 float 39 atan2f(float x, float y) 40 { 41 return (float) atan2(x, y); 42 } 43 #endif 44 45 #ifndef HAVE_ATAN2L 46 long double 47 atan2l(long double x, long double y) 48 { 49 return atan2((double) x, (double) y); 50 } 51 #endif 52 53 54 #ifndef HAVE_COSF 55 float 56 cosf(float x) 57 { 58 return (float) cos(x); 59 } 60 #endif 61 62 #ifndef HAVE_COSL 63 long double 64 cosl(long double x) 65 { 66 return cos((double) x); 67 } 68 #endif 69 70 71 #ifndef HAVE_COSHF 72 float 73 coshf(float x) 74 { 75 return (float) cosh(x); 76 } 77 #endif 78 79 #ifndef HAVE_COSHL 80 long double 81 coshl(long double x) 82 { 83 return cosh((double) x); 84 } 85 #endif 86 87 88 #ifndef HAVE_EXPF 89 float 90 expf(float x) 91 { 92 return (float) exp(x); 93 } 94 #endif 95 96 #ifndef HAVE_EXPL 97 long double 98 expl(long double x) 99 { 100 return exp((double) x); 101 } 102 #endif 103 104 105 /* Compute the hypothenuse of a right triangle with side x and y. */ 106 #ifndef HAVE_HYPOTF 107 float 108 hypotf(float x, float y) 109 { 110 float s = fabsf(x) + fabsf(y); 111 if (s == 0.0F) 112 return s; 113 x /= s; y /= s; 114 return s * sqrtf(x * x + y * y); 115 } 116 #endif 117 118 #ifndef HAVE_HYPOT 119 double 120 hypot(double x, double y) 121 { 122 double s = fabs(x) + fabs(y); 123 if (s == 0.0) 124 return s; 125 x /= s; y /= s; 126 return s * sqrt(x * x + y * y); 127 } 128 #endif 129 130 #ifndef HAVE_HYPOTL 131 long double 132 hypotl(long double x, long double y) 133 { 134 long double s = fabsl(x) + fabsl(y); 135 if (s == 0.0L) 136 return s; 137 x /= s; y /= s; 138 return s * sqrtl(x * x + y * y); 139 } 140 #endif 141 142 143 144 #ifndef HAVE_LOGF 145 float 146 logf(float x) 147 { 148 return (float) log(x); 149 } 150 #endif 151 152 #ifndef HAVE_LOGL 153 long double 154 logl(long double x) 155 { 156 return log((double) x); 157 } 158 #endif 159 160 161 #ifndef HAVE_LOG10F 162 float 163 log10f(float x) 164 { 165 return (float) log10(x); 166 } 167 #endif 168 169 #ifndef HAVE_LOG10L 170 long double 171 log10l(long double x) 172 { 173 return log10((double) x); 174 } 175 #endif 176 177 178 #ifndef HAVE_POWF 179 float 180 powf(float x, float y) 181 { 182 return (float) pow(x, y); 183 } 184 #endif 185 186 #ifndef HAVE_POWL 187 long double 188 powl(long double x, long double y) 189 { 190 return pow((double) x, (double) y); 191 } 192 #endif 193 194 195 #ifndef HAVE_SINF 196 float 197 sinf(float x) 198 { 199 return (float) sin(x); 200 } 201 #endif 202 203 #ifndef HAVE_SINL 204 long double 205 sinl(long double x) 206 { 207 return sin((double) x); 208 } 209 #endif 210 211 212 #ifndef HAVE_SINHF 213 float 214 sinhf(float x) 215 { 216 return (float) sinh(x); 217 } 218 #endif 219 220 #ifndef HAVE_SINHL 221 long double 222 sinhl(long double x) 223 { 224 return sinh((double) x); 225 } 226 #endif 227 228 229 #ifndef HAVE_SQRTF 230 float 231 sqrtf(float x) 232 { 233 return (float) sqrt(x); 234 } 235 #endif 236 237 #ifndef HAVE_SQRTL 238 long double 239 sqrtl(long double x) 240 { 241 return sqrt((double) x); 242 } 243 #endif 244 245 246 #ifndef HAVE_TANF 247 float 248 tanf(float x) 249 { 250 return (float) tan(x); 251 } 252 #endif 253 254 #ifndef HAVE_TANL 255 long double 256 tanl(long double x) 257 { 258 return tan((double) x); 259 } 260 #endif 261 262 263 #ifndef HAVE_TANHF 264 float 265 tanhf(float x) 266 { 267 return (float) tanh(x); 268 } 269 #endif 270 271 #ifndef HAVE_TANHL 272 long double 273 tanhl(long double x) 274 { 275 return tanh((double) x); 276 } 277 #endif 278