lgamma-compat.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* ABI compatibility for lgamma functions.
  2. Copyright (C) 2015-2019 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. <http://www.gnu.org/licenses/>. */
  15. #ifndef LGAMMA_COMPAT_H
  16. #define LGAMMA_COMPAT_H 1
  17. #include <math-svid-compat.h>
  18. #include <shlib-compat.h>
  19. /* XSI POSIX requires lgamma to set signgam, but ISO C does not permit
  20. this. Namespace issues can be avoided if the functions set
  21. __signgam and signgam is a weak alias, but this only works if both
  22. signgam and __signgam were exported from the glibc version the
  23. program was linked against. Before glibc 2.23, lgamma functions
  24. set signgam which was not a weak alias for __signgam, so old
  25. binaries have dynamic symbols for signgam only and the versions of
  26. lgamma used for old binaries must set both signgam and __signgam.
  27. Those versions also do a check of _LIB_VERSION != _ISOC_ to match
  28. old glibc.
  29. Users of this file define USE_AS_COMPAT to 0 when building the main
  30. version of lgamma, 1 when building the compatibility version. */
  31. #define LGAMMA_OLD_VER GLIBC_2_0
  32. #define LGAMMA_NEW_VER GLIBC_2_23
  33. #define HAVE_LGAMMA_COMPAT SHLIB_COMPAT (libm, LGAMMA_OLD_VER, LGAMMA_NEW_VER)
  34. /* Whether to build this version at all. */
  35. #define BUILD_LGAMMA \
  36. (LIBM_SVID_COMPAT && (HAVE_LGAMMA_COMPAT || !USE_AS_COMPAT))
  37. /* The name to use for this version. */
  38. #if USE_AS_COMPAT
  39. # define LGFUNC(FUNC) FUNC ## _compat
  40. #else
  41. # define LGFUNC(FUNC) FUNC
  42. #endif
  43. /* If there is a compatibility version, gamma (not an ISO C function,
  44. so never a problem for it to set signgam) points directly to it
  45. rather than having separate versions. */
  46. #define GAMMA_ALIAS (USE_AS_COMPAT ? HAVE_LGAMMA_COMPAT : !HAVE_LGAMMA_COMPAT)
  47. /* How to call the underlying lgamma_r function. */
  48. #define CALL_LGAMMA(TYPE, FUNC, ARG) \
  49. ({ \
  50. TYPE lgamma_tmp; \
  51. int local_signgam; \
  52. if (USE_AS_COMPAT) \
  53. { \
  54. lgamma_tmp = FUNC ((ARG), &local_signgam); \
  55. if (_LIB_VERSION != _ISOC_) \
  56. signgam = __signgam = local_signgam; \
  57. } \
  58. else \
  59. lgamma_tmp = FUNC ((ARG), &__signgam); \
  60. lgamma_tmp; \
  61. })
  62. #endif /* lgamma-compat.h. */