2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
5 * This file is part of LVM2.
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
9 * of the GNU Lesser General Public License v.2.1.
11 * You should have received a copy of the GNU Lesser General Public License
12 * along with this program; if not, write to the Free Software Foundation,
13 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 * This file must be included first by every library source file.
23 * Symbol export control macros
25 * DM_EXPORT_NEW_SYMBOL(rettype, func, ver)
26 * DM_EXPORT_SYMBOL(func,ver)
27 * DM_EXPORT_SYMBOL_BASE(func,ver)
29 * For functions that have multiple implementations these macros control
30 * symbol export and versioning.
32 * Function definitions that exist in only one version never need to use
35 * Backwards compatible implementations must include a version tag of
36 * the form "_v1_02_104" as a suffix to the function name and use the
37 * macro DM_EXPORT_SYMBOL to export the function and bind it to the
38 * specified version string.
40 * Since versioning is only available when compiling with GCC the entire
41 * compatibility version should be enclosed in '#if defined(GNU_SYMVER)',
44 * DM_EXPORT_NEW_SYMBOL(int, dm_foo, 1_02_107)(int bar)
49 * #if defined(GNU_SYMVER)
50 * // Backward compatible dm_foo() version 1.02.104
51 * DM_EXPORT_SYMBOL(dm_foo,1_02_104)
52 * int dm_foo_v1_02_104(void);
53 * int dm_foo_v1_02_104(void)
59 * A prototype for the compatibility version is required as these
60 * functions must not be declared static.
62 * The DM_EXPORT_SYMBOL_BASE macro is only used to export the base
63 * versions of library symbols prior to the introduction of symbol
64 * versioning: it must never be used for new symbols.
66 #if defined(GNU_SYMVER)
67 # ifdef __has_attribute
68 # if __has_attribute(symver)
69 # define DM_EXPORT_NEW_SYMBOL(rettype, func, ver) \
70 __attribute__((__symver__( #func "@@DM_" #ver ))) \
71 __typeof__(func) func ##_v ##ver; \
72 rettype func ##_v ##ver
73 # define DM_EXPORT_SYMBOL(func, ver) \
74 __attribute__((__symver__( #func "@DM_" #ver )))
75 # define DM_EXPORT_SYMBOL_BASE(func) \
76 __attribute__((__symver__( #func "@Base" )))
79 #ifndef DM_EXPORT_NEW_SYMBOL
80 #define DM_EXPORT_NEW_SYMBOL(rettype, func, ver) \
81 __typeof__(func) func ##_v ##ver; \
82 __asm__(".symver " #func "_v" #ver ", " #func "@@DM_" #ver ); \
83 rettype func ##_v ##ver
84 #define DM_EXPORT_SYMBOL(func, ver) \
85 __asm__(".symver " #func "_v" #ver ", " #func "@DM_" #ver );
86 #define DM_EXPORT_SYMBOL_BASE(func) \
87 __asm__(".symver " #func "_base, " #func "@Base" );
90 #define DM_EXPORT_NEW_SYMBOL(rettype, func, ver) rettype func
91 #define DM_EXPORT_SYMBOL(func, ver)
92 #define DM_EXPORT_SYMBOL_BASE(func)
95 #include "libdm/dm-tools/util.h"
97 #include "libdm/libdevmapper.h"
98 #include "libdm/misc/dm-logging.h"