Blame math/lgamma-compat.h

Packit 6c4009
/* ABI compatibility for lgamma functions.
Packit 6c4009
   Copyright (C) 2015-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef LGAMMA_COMPAT_H
Packit 6c4009
#define LGAMMA_COMPAT_H 1
Packit 6c4009
Packit 6c4009
#include <math-svid-compat.h>
Packit 6c4009
#include <shlib-compat.h>
Packit 6c4009
Packit 6c4009
/* XSI POSIX requires lgamma to set signgam, but ISO C does not permit
Packit 6c4009
   this.  Namespace issues can be avoided if the functions set
Packit 6c4009
   __signgam and signgam is a weak alias, but this only works if both
Packit 6c4009
   signgam and __signgam were exported from the glibc version the
Packit 6c4009
   program was linked against.  Before glibc 2.23, lgamma functions
Packit 6c4009
   set signgam which was not a weak alias for __signgam, so old
Packit 6c4009
   binaries have dynamic symbols for signgam only and the versions of
Packit 6c4009
   lgamma used for old binaries must set both signgam and __signgam.
Packit 6c4009
   Those versions also do a check of _LIB_VERSION != _ISOC_ to match
Packit 6c4009
   old glibc.
Packit 6c4009
Packit 6c4009
   Users of this file define USE_AS_COMPAT to 0 when building the main
Packit 6c4009
   version of lgamma, 1 when building the compatibility version.  */
Packit 6c4009
Packit 6c4009
#define LGAMMA_OLD_VER GLIBC_2_0
Packit 6c4009
#define LGAMMA_NEW_VER GLIBC_2_23
Packit 6c4009
#define HAVE_LGAMMA_COMPAT SHLIB_COMPAT (libm, LGAMMA_OLD_VER, LGAMMA_NEW_VER)
Packit 6c4009
Packit 6c4009
/* Whether to build this version at all.  */
Packit 6c4009
#define BUILD_LGAMMA \
Packit 6c4009
  (LIBM_SVID_COMPAT && (HAVE_LGAMMA_COMPAT || !USE_AS_COMPAT))
Packit 6c4009
Packit 6c4009
/* The name to use for this version.  */
Packit 6c4009
#if USE_AS_COMPAT
Packit 6c4009
# define LGFUNC(FUNC) FUNC ## _compat
Packit 6c4009
#else
Packit 6c4009
# define LGFUNC(FUNC) FUNC
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* If there is a compatibility version, gamma (not an ISO C function,
Packit 6c4009
   so never a problem for it to set signgam) points directly to it
Packit 6c4009
   rather than having separate versions.  */
Packit 6c4009
#define GAMMA_ALIAS (USE_AS_COMPAT ? HAVE_LGAMMA_COMPAT : !HAVE_LGAMMA_COMPAT)
Packit 6c4009
Packit 6c4009
/* How to call the underlying lgamma_r function.  */
Packit 6c4009
#define CALL_LGAMMA(TYPE, FUNC, ARG)			\
Packit 6c4009
  ({							\
Packit 6c4009
    TYPE lgamma_tmp;					\
Packit 6c4009
    int local_signgam;					\
Packit 6c4009
    if (USE_AS_COMPAT)					\
Packit 6c4009
      {							\
Packit 6c4009
	lgamma_tmp = FUNC ((ARG), &local_signgam);	\
Packit 6c4009
	if (_LIB_VERSION != _ISOC_)			\
Packit 6c4009
	  signgam = __signgam = local_signgam;		\
Packit 6c4009
      }							\
Packit 6c4009
    else						\
Packit 6c4009
      lgamma_tmp = FUNC ((ARG), &__signgam);		\
Packit 6c4009
    lgamma_tmp;						\
Packit 6c4009
  })
Packit 6c4009
Packit 6c4009
#endif /* lgamma-compat.h.  */