huge_val.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 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 Library General Public License as
  7. published by the Free Software Foundation; either version 2 of the
  8. 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. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public
  14. License along with the GNU C Library; see the file COPYING.LIB. If not,
  15. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  16. Boston, MA 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. # define HUGE_VAL \
  25. (__extension__ \
  26. ((union { unsigned long long __l; double __d; }) \
  27. { __l: 0x7ff0000000000000ULL }).__d)
  28. #else /* not GCC */
  29. static union { unsigned char __c[8]; double __d; } __huge_val =
  30. { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } };
  31. # define HUGE_VAL (__huge_val.__d)
  32. #endif /* GCC. */
  33. /* ISO C 9X extensions: (float) HUGE_VALF and (long double) HUGE_VALL. */
  34. #ifdef __USE_ISOC9X
  35. # ifdef __GNUC__
  36. # define HUGE_VALF \
  37. (__extension__ \
  38. ((union { unsigned long __l; float __f; }) \
  39. { __l: 0x7f800000UL }).__f)
  40. # define HUGE_VALL \
  41. (__extension__ \
  42. ((union { unsigned long __l[3]; long double __ld; }) \
  43. { __l: { 0x7fff0000UL, 0x80000000UL, 0UL } }).__ld)
  44. # else /* not GCC */
  45. static union { unsigned char __c[4]; float __f; } __huge_valf =
  46. { { 0x7f, 0x80, 0, 0 } };
  47. # define HUGE_VALF (__huge_valf.__f)
  48. static union { unsigned char __c[12]; long double __ld; } __huge_vall =
  49. { { 0x7f, 0xff, 0, 0, 0x80, 0, 0, 0, 0, 0, 0, 0 } };
  50. # define HUGE_VALL (__huge_vall.__ld)
  51. # endif /* GCC. */
  52. #endif /* __USE_ISOC9X. */