Back to index

glibc  2.9
shlib-compat.h
Go to the documentation of this file.
00001 /* Macros for managing ABI-compatibility definitions using ELF symbol versions.
00002    Copyright (C) 2000, 2002, 2006 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef _SHLIB_COMPAT_H
00021 #define _SHLIB_COMPAT_H     1
00022 
00023 #if defined HAVE_ELF && defined DO_VERSIONING
00024 /* Since there is just one set of .d files generated, we need to
00025    include this unconditionally to have the dependency noticed properly.  */
00026 #include <abi-versions.h>   /* header generated by abi-versions.awk */
00027 #endif
00028 
00029 #if defined HAVE_ELF && defined SHARED && defined DO_VERSIONING
00030 
00031 /* The file abi-versions.h (generated by scripts/abi-versions.awk) defines
00032    symbols like `ABI_libm_GLIBC_2_0' for each version set in the source
00033    code for each library.  For a version set that is subsumed by a later
00034    version set, the definition gives the subsuming set, i.e. if GLIBC_2_0
00035    is subsumed by GLIBC_2_1, then ABI_libm_GLIBC_2_0 == ABI_libm_GLIBC_2_1.
00036    Each version set that is to be distinctly defined in the output has an
00037    unique positive integer value, increasing with newer versions.  Thus,
00038    evaluating two ABI_* symbols reduces to integer values that differ only
00039    when the two version sets named are in fact two different ABIs we are
00040    supporting.  If these do not differ, then there is no need to compile in
00041    extra code to support this version set where it has been superseded by a
00042    newer version.  The compatibility code should be conditionalized with
00043    e.g. `#if SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_2)' for code introduced
00044    in the GLIBC_2.0 version and obsoleted in the GLIBC_2.2 version.  */
00045 
00046 # define SHLIB_COMPAT(lib, introduced, obsoleted)                           \
00047   _SHLIB_COMPAT (lib, introduced, obsoleted)
00048 # define _SHLIB_COMPAT(lib, introduced, obsoleted)                          \
00049   ((IS_IN_##lib - 0)                                                 \
00050    && (!(ABI_##lib##_##obsoleted - 0)                                       \
00051        || ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0))))
00052 
00053 # ifndef NOT_IN_libc
00054 #  define IS_IN_libc 1
00055 # endif
00056 
00057 /* That header also defines symbols like `VERSION_libm_GLIBC_2_1' to
00058    the version set name to use for e.g. symbols first introduced into
00059    libm in the GLIBC_2.1 version.  Definitions of symbols with explicit
00060    versions should look like:
00061        versioned_symbol (libm, new_foo, foo, GLIBC_2_1);
00062    This will define the symbol `foo' with the appropriate default version,
00063    i.e. either GLIBC_2.1 or the "earliest version" specified in
00064    shlib-versions if that is newer.  */
00065 
00066 # define versioned_symbol(lib, local, symbol, version) \
00067   versioned_symbol_1 (lib, local, symbol, version)
00068 # define versioned_symbol_1(lib, local, symbol, version) \
00069   versioned_symbol_2 (local, symbol, VERSION_##lib##_##version)
00070 # define versioned_symbol_2(local, symbol, name) \
00071   default_symbol_version (local, symbol, name)
00072 
00073 # define compat_symbol(lib, local, symbol, version) \
00074   compat_symbol_1 (lib, local, symbol, version)
00075 # define compat_symbol_1(lib, local, symbol, version) \
00076   compat_symbol_2 (local, symbol, VERSION_##lib##_##version)
00077 # define compat_symbol_2(local, symbol, name) \
00078   symbol_version (local, symbol, name)
00079 
00080 #else
00081 
00082 /* Not compiling ELF shared libraries at all, so never any old versions.  */
00083 # define SHLIB_COMPAT(lib, introduced, obsoleted)       0
00084 
00085 /* No versions to worry about, just make this the global definition.  */
00086 # define versioned_symbol(lib, local, symbol, version) \
00087   weak_alias (local, symbol)
00088 
00089 /* This should not appear outside `#if SHLIB_COMPAT (...)'.  */
00090 # define compat_symbol(lib, local, symbol, version) ...
00091 
00092 #endif
00093 
00094 
00095 #endif /* shlib-compat.h */