cfloat-compat.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Compatibility macros for old and new Alpha complex float ABI.
  2. Copyright (C) 2004-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library. If not, see
  14. <https://www.gnu.org/licenses/>. */
  15. /* The behaviour of complex float changed between GCC 3.3 and 3.4.
  16. In 3.3 and before (below, complex version 1, or "c1"), complex float
  17. values were packed into one floating point register.
  18. In 3.4 and later (below, complex version 2, or "c2"), GCC changed to
  19. follow the official Tru64 ABI, which passes the components of a complex
  20. as separate parameters. */
  21. typedef union { double d; _Complex float cf; } c1_compat;
  22. # define c1_cfloat_decl(x) double x
  23. # define c1_cfloat_real(x) __real__ c1_cfloat_value (x)
  24. # define c1_cfloat_imag(x) __imag__ c1_cfloat_value (x)
  25. # define c1_cfloat_value(x) (((c1_compat *)(void *)&x)->cf)
  26. # define c1_cfloat_rettype double
  27. # define c1_cfloat_return(x) ({ c1_compat _; _.cf = (x); _.d; })
  28. # define c2_cfloat_decl(x) _Complex float x
  29. # define c2_cfloat_real(x) __real__ x
  30. # define c2_cfloat_imag(x) __imag__ x
  31. # define c2_cfloat_value(x) x
  32. # define c2_cfloat_rettype _Complex float
  33. # define c2_cfloat_return(x) x
  34. /* Get the proper symbol versions defined for each function. */
  35. #include <shlib-compat.h>
  36. #include <libm-alias-float.h>
  37. #if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_3_4)
  38. #define cfloat_versions_compat(func) \
  39. compat_symbol (libm, __c1_##func, func, GLIBC_2_1)
  40. #else
  41. #define cfloat_versions_compat(func)
  42. #endif
  43. #define cfloat_versions(func) \
  44. cfloat_versions_compat(func##f); \
  45. versioned_symbol (libm, __c2_##func##f, func##f, GLIBC_2_3_4); \
  46. extern typeof(__c2_##func##f) __##func##f attribute_hidden; \
  47. strong_alias (__c2_##func##f, __##func##f); \
  48. libm_alias_float_other (__##func, func)