]> git.ipfire.org Git - thirdparty/glibc.git/blame - include/shlib-compat.h
Fix last change
[thirdparty/glibc.git] / include / shlib-compat.h
CommitLineData
361742ed 1/* Macros for managing ABI-compatibility definitions using ELF symbol versions.
0269750c 2 Copyright (C) 2000, 2002, 2006, 2012 Free Software Foundation, Inc.
361742ed
RM
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
361742ed
RM
9
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
41bdb6e2 13 Lesser General Public License for more details.
361742ed 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
361742ed
RM
18
19#ifndef _SHLIB_COMPAT_H
20#define _SHLIB_COMPAT_H 1
21
0269750c 22#if defined DO_VERSIONING
9aae89ce
RM
23/* Since there is just one set of .d files generated, we need to
24 include this unconditionally to have the dependency noticed properly. */
25#include <abi-versions.h> /* header generated by abi-versions.awk */
9ee80c52 26#endif
361742ed 27
0269750c 28#if defined SHARED && defined DO_VERSIONING
361742ed
RM
29
30/* The file abi-versions.h (generated by scripts/abi-versions.awk) defines
cb832354
RM
31 symbols like `ABI_libm_GLIBC_2_0' for each version set in the source
32 code for each library. For a version set that is subsumed by a later
33 version set, the definition gives the subsuming set, i.e. if GLIBC_2_0
34 is subsumed by GLIBC_2_1, then ABI_libm_GLIBC_2_0 == ABI_libm_GLIBC_2_1.
35 Each version set that is to be distinctly defined in the output has an
36 unique positive integer value, increasing with newer versions. Thus,
37 evaluating two ABI_* symbols reduces to integer values that differ only
38 when the two version sets named are in fact two different ABIs we are
39 supporting. If these do not differ, then there is no need to compile in
40 extra code to support this version set where it has been superseded by a
41 newer version. The compatibility code should be conditionalized with
42 e.g. `#if SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_2)' for code introduced
43 in the GLIBC_2.0 version and obsoleted in the GLIBC_2.2 version. */
44
ce460d04 45# define SHLIB_COMPAT(lib, introduced, obsoleted) \
11bf311e
UD
46 _SHLIB_COMPAT (lib, introduced, obsoleted)
47# define _SHLIB_COMPAT(lib, introduced, obsoleted) \
ce460d04
RM
48 ((IS_IN_##lib - 0) \
49 && (!(ABI_##lib##_##obsoleted - 0) \
50 || ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0))))
51
52# ifndef NOT_IN_libc
53# define IS_IN_libc 1
54# endif
361742ed
RM
55
56/* That header also defines symbols like `VERSION_libm_GLIBC_2_1' to
57 the version set name to use for e.g. symbols first introduced into
58 libm in the GLIBC_2.1 version. Definitions of symbols with explicit
59 versions should look like:
60 versioned_symbol (libm, new_foo, foo, GLIBC_2_1);
61 This will define the symbol `foo' with the appropriate default version,
62 i.e. either GLIBC_2.1 or the "earliest version" specified in
63 shlib-versions if that is newer. */
64
cb162e13 65# define versioned_symbol(lib, local, symbol, version) \
11bf311e
UD
66 versioned_symbol_1 (lib, local, symbol, version)
67# define versioned_symbol_1(lib, local, symbol, version) \
68 versioned_symbol_2 (local, symbol, VERSION_##lib##_##version)
69# define versioned_symbol_2(local, symbol, name) \
cb162e13 70 default_symbol_version (local, symbol, name)
361742ed 71
2ae13e20 72# define compat_symbol(lib, local, symbol, version) \
11bf311e
UD
73 compat_symbol_1 (lib, local, symbol, version)
74# define compat_symbol_1(lib, local, symbol, version) \
75 compat_symbol_2 (local, symbol, VERSION_##lib##_##version)
76# define compat_symbol_2(local, symbol, name) \
2ae13e20
RM
77 symbol_version (local, symbol, name)
78
361742ed
RM
79#else
80
81/* Not compiling ELF shared libraries at all, so never any old versions. */
cb832354 82# define SHLIB_COMPAT(lib, introduced, obsoleted) 0
361742ed
RM
83
84/* No versions to worry about, just make this the global definition. */
cb162e13 85# define versioned_symbol(lib, local, symbol, version) \
361742ed
RM
86 weak_alias (local, symbol)
87
2ae13e20
RM
88/* This should not appear outside `#if SHLIB_COMPAT (...)'. */
89# define compat_symbol(lib, local, symbol, version) ...
90
361742ed
RM
91#endif
92
93
94#endif /* shlib-compat.h */