posix: Remove internal_function attribute
[glibc.git] / math / lgamma-compat.h
blob189d12688271eefd9ff56456e6c823dd2fcdb895
1 /* ABI compatibility for lgamma functions.
2 Copyright (C) 2015-2017 Free Software Foundation, Inc.
3 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.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef LGAMMA_COMPAT_H
20 #define LGAMMA_COMPAT_H 1
22 #include <math-svid-compat.h>
23 #include <shlib-compat.h>
25 /* XSI POSIX requires lgamma to set signgam, but ISO C does not permit
26 this. Namespace issues can be avoided if the functions set
27 __signgam and signgam is a weak alias, but this only works if both
28 signgam and __signgam were exported from the glibc version the
29 program was linked against. Before glibc 2.23, lgamma functions
30 set signgam which was not a weak alias for __signgam, so old
31 binaries have dynamic symbols for signgam only and the versions of
32 lgamma used for old binaries must set both signgam and __signgam.
33 Those versions also do a check of _LIB_VERSION != _ISOC_ to match
34 old glibc.
36 Users of this file define USE_AS_COMPAT to 0 when building the main
37 version of lgamma, 1 when building the compatibility version. */
39 #define LGAMMA_OLD_VER GLIBC_2_0
40 #define LGAMMA_NEW_VER GLIBC_2_23
41 #define HAVE_LGAMMA_COMPAT SHLIB_COMPAT (libm, LGAMMA_OLD_VER, LGAMMA_NEW_VER)
43 /* Whether to build this version at all. */
44 #define BUILD_LGAMMA (HAVE_LGAMMA_COMPAT || !USE_AS_COMPAT)
46 /* The name to use for this version. */
47 #if USE_AS_COMPAT
48 # define LGFUNC(FUNC) FUNC ## _compat
49 #else
50 # define LGFUNC(FUNC) FUNC
51 #endif
53 /* If there is a compatibility version, gamma (not an ISO C function,
54 so never a problem for it to set signgam) points directly to it
55 rather than having separate versions. */
56 #define GAMMA_ALIAS (USE_AS_COMPAT ? HAVE_LGAMMA_COMPAT : !HAVE_LGAMMA_COMPAT)
58 /* How to call the underlying lgamma_r function. */
59 #define CALL_LGAMMA(TYPE, FUNC, ARG) \
60 ({ \
61 TYPE lgamma_tmp; \
62 int local_signgam; \
63 if (USE_AS_COMPAT) \
64 { \
65 lgamma_tmp = FUNC ((ARG), &local_signgam); \
66 if (_LIB_VERSION != _ISOC_) \
67 signgam = __signgam = local_signgam; \
68 } \
69 else \
70 lgamma_tmp = FUNC ((ARG), &__signgam); \
71 lgamma_tmp; \
74 #endif /* lgamma-compat.h. */