Updated to fedora-glibc-20090416T0610
[glibc/history.git] / include / shlib-compat.h
blob79246dff25c5d91d08d22330a1bf7ba9fad7e888
1 /* Macros for managing ABI-compatibility definitions using ELF symbol versions.
2 Copyright (C) 2000, 2002, 2006 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #ifndef _SHLIB_COMPAT_H
21 #define _SHLIB_COMPAT_H 1
23 #if defined HAVE_ELF && defined DO_VERSIONING
24 /* Since there is just one set of .d files generated, we need to
25 include this unconditionally to have the dependency noticed properly. */
26 #include <abi-versions.h> /* header generated by abi-versions.awk */
27 #endif
29 #if defined HAVE_ELF && defined SHARED && defined DO_VERSIONING
31 /* The file abi-versions.h (generated by scripts/abi-versions.awk) defines
32 symbols like `ABI_libm_GLIBC_2_0' for each version set in the source
33 code for each library. For a version set that is subsumed by a later
34 version set, the definition gives the subsuming set, i.e. if GLIBC_2_0
35 is subsumed by GLIBC_2_1, then ABI_libm_GLIBC_2_0 == ABI_libm_GLIBC_2_1.
36 Each version set that is to be distinctly defined in the output has an
37 unique positive integer value, increasing with newer versions. Thus,
38 evaluating two ABI_* symbols reduces to integer values that differ only
39 when the two version sets named are in fact two different ABIs we are
40 supporting. If these do not differ, then there is no need to compile in
41 extra code to support this version set where it has been superseded by a
42 newer version. The compatibility code should be conditionalized with
43 e.g. `#if SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_2)' for code introduced
44 in the GLIBC_2.0 version and obsoleted in the GLIBC_2.2 version. */
46 # define SHLIB_COMPAT(lib, introduced, obsoleted) \
47 _SHLIB_COMPAT (lib, introduced, obsoleted)
48 # define _SHLIB_COMPAT(lib, introduced, obsoleted) \
49 ((IS_IN_##lib - 0) \
50 && (!(ABI_##lib##_##obsoleted - 0) \
51 || ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0))))
53 # ifndef NOT_IN_libc
54 # define IS_IN_libc 1
55 # endif
57 /* That header also defines symbols like `VERSION_libm_GLIBC_2_1' to
58 the version set name to use for e.g. symbols first introduced into
59 libm in the GLIBC_2.1 version. Definitions of symbols with explicit
60 versions should look like:
61 versioned_symbol (libm, new_foo, foo, GLIBC_2_1);
62 This will define the symbol `foo' with the appropriate default version,
63 i.e. either GLIBC_2.1 or the "earliest version" specified in
64 shlib-versions if that is newer. */
66 # define versioned_symbol(lib, local, symbol, version) \
67 versioned_symbol_1 (lib, local, symbol, version)
68 # define versioned_symbol_1(lib, local, symbol, version) \
69 versioned_symbol_2 (local, symbol, VERSION_##lib##_##version)
70 # define versioned_symbol_2(local, symbol, name) \
71 default_symbol_version (local, symbol, name)
73 # define compat_symbol(lib, local, symbol, version) \
74 compat_symbol_1 (lib, local, symbol, version)
75 # define compat_symbol_1(lib, local, symbol, version) \
76 compat_symbol_2 (local, symbol, VERSION_##lib##_##version)
77 # define compat_symbol_2(local, symbol, name) \
78 symbol_version (local, symbol, name)
80 #else
82 /* Not compiling ELF shared libraries at all, so never any old versions. */
83 # define SHLIB_COMPAT(lib, introduced, obsoleted) 0
85 /* No versions to worry about, just make this the global definition. */
86 # define versioned_symbol(lib, local, symbol, version) \
87 weak_alias (local, symbol)
89 /* This should not appear outside `#if SHLIB_COMPAT (...)'. */
90 # define compat_symbol(lib, local, symbol, version) ...
92 #endif
95 #endif /* shlib-compat.h */