blkdeactivate.sh: Add PATH environment variable into script
[platform/upstream/device-mapper.git] / libdm / misc / dmlib.h
1 /*
2  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.  
3  * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
4  *
5  * This file is part of LVM2.
6  *
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.
10  *
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
14  */
15
16 /*
17  * This file must be included first by every library source file.
18  */
19 #ifndef _DM_LIB_H
20 #define _DM_LIB_H
21
22 /*
23  * Symbol export control macros
24  *
25  *   DM_EXPORT_NEW_SYMBOL(rettype, func, ver)
26  *   DM_EXPORT_SYMBOL(func,ver)
27  *   DM_EXPORT_SYMBOL_BASE(func,ver)
28  *
29  * For functions that have multiple implementations these macros control
30  * symbol export and versioning.
31  *
32  * Function definitions that exist in only one version never need to use
33  * these macros.
34  *
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.
39  *
40  * Since versioning is only available when compiling with GCC the entire
41  * compatibility version should be enclosed in '#if defined(GNU_SYMVER)',
42  * for example:
43  *
44  *   DM_EXPORT_NEW_SYMBOL(int, dm_foo, 1_02_107)(int bar)
45  *   {
46  *     return bar;
47  *   }
48  *
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)
54  *   {
55  *     return 0;
56  *   }
57  *   #endif
58  *
59  * A prototype for the compatibility version is required as these
60  * functions must not be declared static.
61  *
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.
65  */
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" )))
77 #  endif
78 # endif
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" );
88 #endif
89 #else
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)
93 #endif
94
95 #include "libdm/dm-tools/util.h"
96
97 #include "libdm/libdevmapper.h"
98 #include "libdm/misc/dm-logging.h"
99
100 #include <unistd.h>
101
102 #endif