huge_val.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* `HUGE_VAL' constants for m68k (where it is infinity).
  2. Used by <stdlib.h> and <math.h> functions for overflow.
  3. Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. #ifndef _MATH_H
  18. # error "Never use <bits/huge_val.h> directly; include <math.h> instead."
  19. #endif
  20. #include <features.h>
  21. #include <sys/cdefs.h>
  22. /* IEEE positive infinity (-HUGE_VAL is negative infinity). */
  23. #ifdef __GNUC__
  24. # if __GNUC_PREREQ(2,96)
  25. # define HUGE_VAL (__extension__ 0x1.0p2047)
  26. # else
  27. # define HUGE_VAL \
  28. (__extension__ \
  29. ((union { unsigned long long __l; double __d; }) \
  30. { __l: 0x7ff0000000000000ULL }).__d)
  31. # endif
  32. #else /* not GCC */
  33. static union { unsigned char __c[8]; double __d; } __huge_val =
  34. { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } };
  35. # define HUGE_VAL (__huge_val.__d)
  36. #endif /* GCC. */
  37. /* ISO C 99 extensions: (float) HUGE_VALF and (long double) HUGE_VALL. */
  38. #ifdef __USE_ISOC99
  39. # if __GNUC_PREREQ(2,96)
  40. # define HUGE_VALF (__extension__ 0x1.0p255f)
  41. # define HUGE_VALL (__extension__ 0x1.0p32767L)
  42. # else
  43. # ifdef __GNUC__
  44. # define HUGE_VALF \
  45. (__extension__ \
  46. ((union { unsigned long __l; float __f; }) \
  47. { __l: 0x7f800000UL }).__f)
  48. # define HUGE_VALL \
  49. (__extension__ \
  50. ((union { unsigned long __l[3]; long double __ld; }) \
  51. { __l: { 0x7fff0000UL, 0x80000000UL, 0UL } }).__ld)
  52. # else /* not GCC */
  53. static union { unsigned char __c[4]; float __f; } __huge_valf =
  54. { { 0x7f, 0x80, 0, 0 } };
  55. # define HUGE_VALF (__huge_valf.__f)
  56. static union { unsigned char __c[12]; long double __ld; } __huge_vall =
  57. { { 0x7f, 0xff, 0, 0, 0x80, 0, 0, 0, 0, 0, 0, 0 } };
  58. # define HUGE_VALL (__huge_vall.__ld)
  59. # endif /* GCC. */
  60. # endif /* GCC 2.95. */
  61. #endif /* __USE_ISOC99. */