huge_val.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* `HUGE_VAL' constants for ix86 (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. /* IEEE positive infinity (-HUGE_VAL is negative infinity). */
  22. #if __GNUC_PREREQ(2,96)
  23. # define HUGE_VAL (__extension__ 0x1.0p2047)
  24. #else
  25. # define __HUGE_VAL_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }
  26. # define __huge_val_t union { unsigned char __c[8]; double __d; }
  27. # ifdef __GNUC__
  28. # define HUGE_VAL (__extension__ \
  29. ((__huge_val_t) { __c: __HUGE_VAL_bytes }).__d)
  30. # else /* Not GCC. */
  31. static __huge_val_t __huge_val = { __HUGE_VAL_bytes };
  32. # define HUGE_VAL (__huge_val.__d)
  33. # endif /* GCC. */
  34. #endif /* GCC 2.95 */
  35. /* ISO C99 extensions: (float) HUGE_VALF and (long double) HUGE_VALL. */
  36. #ifdef __USE_ISOC99
  37. # if __GNUC_PREREQ(2,96)
  38. # define HUGE_VALF (__extension__ 0x1.0p255f)
  39. # define HUGE_VALL (__extension__ 0x1.0p32767L)
  40. # else
  41. # define __HUGE_VALF_bytes { 0, 0, 0x80, 0x7f }
  42. # define __huge_valf_t union { unsigned char __c[4]; float __f; }
  43. # ifdef __GNUC__
  44. # define HUGE_VALF (__extension__ \
  45. ((__huge_valf_t) { __c: __HUGE_VALF_bytes }).__f)
  46. # else /* Not GCC. */
  47. static __huge_valf_t __huge_valf = { __HUGE_VALF_bytes };
  48. # define HUGE_VALF (__huge_valf.__f)
  49. # endif /* GCC. */
  50. # define __HUGE_VALL_bytes { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0x7f, 0, 0 }
  51. # define __huge_vall_t union { unsigned char __c[12]; long double __ld; }
  52. # ifdef __GNUC__
  53. # define HUGE_VALL (__extension__ \
  54. ((__huge_vall_t) { __c: __HUGE_VALL_bytes }).__ld)
  55. # else /* Not GCC. */
  56. static __huge_vall_t __huge_vall = { __HUGE_VALL_bytes };
  57. # define HUGE_VALL (__huge_vall.__ld)
  58. # endif /* GCC. */
  59. # endif /* GCC 2.95 */
  60. #endif /* __USE_ISOC99. */