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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_FABSF 38float 39fabsf(float x) 40{ 41 return (float) fabs(x); 42} 43#endif 44 45#ifndef HAVE_FABSL 46long double 47fabsl(long double x) 48{ 49 return fabs((double) x); 50} 51#endif 52 53 54#ifndef HAVE_ACOSF 55float 56acosf(float x) 57{ 58 return (float) acos(x); 59} 60#endif 61 62#ifndef HAVE_ACOSL 63long double 64acosl(long double x) 65{ 66 return acos((double) x); 67} 68#endif 69 70 71#ifndef HAVE_ASINF 72float 73asinf(float x) 74{ 75 return (float) asin(x); 76} 77#endif 78 79#ifndef HAVE_ASINL 80long double 81asinl(long double x) 82{ 83 return asin((double) x); 84} 85#endif 86 87 88#ifndef HAVE_ATANF 89float 90atanf(float x) 91{ 92 return (float) atan(x); 93} 94#endif 95 96#ifndef HAVE_ATANL 97long double 98atanl(long double x) 99{ 100 return atan ((double) x); 101} 102#endif 103 104 105#ifndef HAVE_ATAN2F 106float 107atan2f(float x, float y) 108{ 109 return (float) atan2(x, y); 110} 111#endif 112 113#ifndef HAVE_ATAN2L 114long double 115atan2l(long double x, long double y) 116{ 117 return atan2((double) x, (double) y); 118} 119#endif 120 121 122#ifndef HAVE_CEILF 123float 124ceilf(float x) 125{ 126 return (float) ceil(x); 127} 128#endif 129 130#ifndef HAVE_CEILL 131long double 132ceill(long double x) 133{ 134 return ceil((double) x); 135} 136#endif 137 138 139#ifndef HAVE_COSF 140float 141cosf(float x) 142{ 143 return (float) cos(x); 144} 145#endif 146 147#ifndef HAVE_COSL 148long double 149cosl(long double x) 150{ 151 return cos((double) x); 152} 153#endif 154 155 156#ifndef HAVE_COSHF 157float 158coshf(float x) 159{ 160 return (float) cosh(x); 161} 162#endif 163 164#ifndef HAVE_COSHL 165long double 166coshl(long double x) 167{ 168 return cosh((double) x); 169} 170#endif 171 172 173#ifndef HAVE_EXPF 174float 175expf(float x) 176{ 177 return (float) exp(x); 178} 179#endif 180 181#ifndef HAVE_EXPL 182long double 183expl(long double x) 184{ 185 return exp((double) x); 186} 187#endif 188 189 190#ifndef HAVE_FLOORF 191float 192floorf(float x) 193{ 194 return (float) floor(x); 195} 196#endif 197 198#ifndef HAVE_FLOORL 199long double 200floorl(long double x) 201{ 202 return floor((double) x); 203} 204#endif 205 206 207#ifndef HAVE_FMODF 208float 209fmodf(float x, float y) 210{ 211 return (float) fmod(x, y); 212} 213#endif 214 215#ifndef HAVE_FMODL 216long double 217fmodl(long double x, long double y) 218{ 219 return fmod((double) x, (double) y); 220} 221#endif 222 223 224#ifndef HAVE_FREXPF 225float 226frexpf(float x, int *exp) 227{ 228 return (float) frexp(x, exp); 229} 230#endif 231 232#ifndef HAVE_FREXPL 233long double 234frexpl(long double x, int *exp) 235{ 236 return frexp((double) x, exp); 237} 238#endif 239 240 241#ifndef HAVE_SQRTF 242float 243sqrtf(float x) 244{ 245 return (float) sqrt(x); 246} 247#endif 248 249#ifndef HAVE_SQRTL 250long double 251sqrtl(long double x) 252{ 253 return sqrt((double) x); 254} 255#endif 256 257 258/* Compute the hypothenuse of a right triangle with side x and y. */ 259#ifndef HAVE_HYPOTF 260float 261hypotf(float x, float y) 262{ 263 float s = fabsf(x) + fabsf(y); 264 if (s == 0.0F) 265 return s; 266 x /= s; y /= s; 267 return s * sqrtf(x * x + y * y); 268} 269#endif 270 271#ifndef HAVE_HYPOT 272double 273hypot(double x, double y) 274{ 275 double s = fabs(x) + fabs(y); 276 if (s == 0.0) 277 return s; 278 x /= s; y /= s; 279 return s * sqrt(x * x + y * y); 280} 281#endif 282 283#ifndef HAVE_HYPOTL 284long double 285hypotl(long double x, long double y) 286{ 287 long double s = fabsl(x) + fabsl(y); 288 if (s == 0.0L) 289 return s; 290 x /= s; y /= s; 291 return s * sqrtl(x * x + y * y); 292} 293#endif 294 295 296 297#ifndef HAVE_LDEXPF 298float 299ldexpf(float x, int exp) 300{ 301 return (float) ldexp(x, exp); 302} 303#endif 304 305#ifndef HAVE_LDEXPL 306long double 307ldexpl(long double x, int exp) 308{ 309 return ldexp((double) x, exp); 310} 311#endif 312 313 314#ifndef HAVE_LOGF 315float 316logf(float x) 317{ 318 return (float) log(x); 319} 320#endif 321 322#ifndef HAVE_LOGL 323long double 324logl(long double x) 325{ 326 return log((double) x); 327} 328#endif 329 330 331#ifndef HAVE_LOG10F 332float 333log10f(float x) 334{ 335 return (float) log10(x); 336} 337#endif 338 339#ifndef HAVE_LOG10L 340long double 341log10l(long double x) 342{ 343 return log10((double) x); 344} 345#endif 346 347 348#ifndef HAVE_MODFF 349float 350modff(float x, float *iptr) 351{ 352 double result, temp; 353 354 result = modf(x, &temp); 355 *iptr = (float) temp; 356 return (float) result; 357} 358#endif 359 360#ifndef HAVE_MODFL 361long double 362modfl(long double x, long double *iptr) 363{ 364 double result, temp; 365 366 result = modf((double) x, &temp); 367 *iptr = temp; 368 return result; 369} 370#endif 371 372 373#ifndef HAVE_POWF 374float 375powf(float x, float y) 376{ 377 return (float) pow(x, y); 378} 379#endif 380 381#ifndef HAVE_POWL 382long double 383powl(long double x, long double y) 384{ 385 return pow((double) x, (double) y); 386} 387#endif 388 389 390#ifndef HAVE_SINF 391float 392sinf(float x) 393{ 394 return (float) sin(x); 395} 396#endif 397 398#ifndef HAVE_SINL 399long double 400sinl(long double x) 401{ 402 return sin((double) x); 403} 404#endif 405 406 407#ifndef HAVE_SINHF 408float 409sinhf(float x) 410{ 411 return (float) sinh(x); 412} 413#endif 414 415#ifndef HAVE_SINHL 416long double 417sinhl(long double x) 418{ 419 return sinh((double) x); 420} 421#endif 422 423 424#ifndef HAVE_TANF 425float 426tanf(float x) 427{ 428 return (float) tan(x); 429} 430#endif 431 432#ifndef HAVE_TANL 433long double 434tanl(long double x) 435{ 436 return tan((double) x); 437} 438#endif 439 440 441#ifndef HAVE_TANHF 442float 443tanhf(float x) 444{ 445 return (float) tanh(x); 446} 447#endif 448 449#ifndef HAVE_TANHL 450long double 451tanhl(long double x) 452{ 453 return tanh((double) x); 454} 455#endif 456