2.3.3-65
[glibc.git] / include / shlib-compat.h
blob1e6d1782d925d0dd89cfa5b592e9c63d05ff690d
1 /* Macros for managing ABI-compatibility definitions using ELF symbol versions.
2 Copyright (C) 2000, 2002 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 ((IS_IN_##lib - 0) \
48 && (!(ABI_##lib##_##obsoleted - 0) \
49 || ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0))))
51 # ifndef NOT_IN_libc
52 # define IS_IN_libc 1
53 # endif
55 /* That header also defines symbols like `VERSION_libm_GLIBC_2_1' to
56 the version set name to use for e.g. symbols first introduced into
57 libm in the GLIBC_2.1 version. Definitions of symbols with explicit
58 versions should look like:
59 versioned_symbol (libm, new_foo, foo, GLIBC_2_1);
60 This will define the symbol `foo' with the appropriate default version,
61 i.e. either GLIBC_2.1 or the "earliest version" specified in
62 shlib-versions if that is newer. */
64 # define versioned_symbol(lib, local, symbol, version) \
65 versioned_symbol_1 (local, symbol, VERSION_##lib##_##version)
66 # define versioned_symbol_1(local, symbol, name) \
67 default_symbol_version (local, symbol, name)
69 # define compat_symbol(lib, local, symbol, version) \
70 compat_symbol_1 (local, symbol, VERSION_##lib##_##version)
71 # define compat_symbol_1(local, symbol, name) \
72 symbol_version (local, symbol, name)
74 #else
76 /* Not compiling ELF shared libraries at all, so never any old versions. */
77 # define SHLIB_COMPAT(lib, introduced, obsoleted) 0
79 /* No versions to worry about, just make this the global definition. */
80 # define versioned_symbol(lib, local, symbol, version) \
81 weak_alias (local, symbol)
83 /* This should not appear outside `#if SHLIB_COMPAT (...)'. */
84 # define compat_symbol(lib, local, symbol, version) ...
86 #endif
89 #endif /* shlib-compat.h */