]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/lib/librte_eal/common/include/rte_compat.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / dpdk / lib / librte_eal / common / include / rte_compat.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015 Neil Horman <nhorman@tuxdriver.com>.
3 * All rights reserved.
4 */
5
6 #ifndef _RTE_COMPAT_H_
7 #define _RTE_COMPAT_H_
8 #include <rte_common.h>
9
10 #ifdef RTE_BUILD_SHARED_LIB
11
12 /*
13 * Provides backwards compatibility when updating exported functions.
14 * When a symol is exported from a library to provide an API, it also provides a
15 * calling convention (ABI) that is embodied in its name, return type,
16 * arguments, etc. On occasion that function may need to change to accommodate
17 * new functionality, behavior, etc. When that occurs, it is desirable to
18 * allow for backwards compatibility for a time with older binaries that are
19 * dynamically linked to the dpdk. To support that, the __vsym and
20 * VERSION_SYMBOL macros are created. They, in conjunction with the
21 * <library>_version.map file for a given library allow for multiple versions of
22 * a symbol to exist in a shared library so that older binaries need not be
23 * immediately recompiled.
24 *
25 * Refer to the guidelines document in the docs subdirectory for details on the
26 * use of these macros
27 */
28
29 /*
30 * Macro Parameters:
31 * b - function base name
32 * e - function version extension, to be concatenated with base name
33 * n - function symbol version string to be applied
34 * f - function prototype
35 * p - full function symbol name
36 */
37
38 /*
39 * VERSION_SYMBOL
40 * Creates a symbol version table entry binding symbol <b>@DPDK_<n> to the internal
41 * function name <b>_<e>
42 */
43 #define VERSION_SYMBOL(b, e, n) __asm__(".symver " RTE_STR(b) RTE_STR(e) ", " RTE_STR(b) "@DPDK_" RTE_STR(n))
44
45 /*
46 * BIND_DEFAULT_SYMBOL
47 * Creates a symbol version entry instructing the linker to bind references to
48 * symbol <b> to the internal symbol <b>_<e>
49 */
50 #define BIND_DEFAULT_SYMBOL(b, e, n) __asm__(".symver " RTE_STR(b) RTE_STR(e) ", " RTE_STR(b) "@@DPDK_" RTE_STR(n))
51 #define __vsym __attribute__((used))
52
53 /*
54 * MAP_STATIC_SYMBOL
55 * If a function has been bifurcated into multiple versions, none of which
56 * are defined as the exported symbol name in the map file, this macro can be
57 * used to alias a specific version of the symbol to its exported name. For
58 * example, if you have 2 versions of a function foo_v1 and foo_v2, where the
59 * former is mapped to foo@DPDK_1 and the latter is mapped to foo@DPDK_2 when
60 * building a shared library, this macro can be used to map either foo_v1 or
61 * foo_v2 to the symbol foo when building a static library, e.g.:
62 * MAP_STATIC_SYMBOL(void foo(), foo_v2);
63 */
64 #define MAP_STATIC_SYMBOL(f, p)
65
66 #else
67 /*
68 * No symbol versioning in use
69 */
70 #define VERSION_SYMBOL(b, e, n)
71 #define __vsym
72 #define BIND_DEFAULT_SYMBOL(b, e, n)
73 #define MAP_STATIC_SYMBOL(f, p) f __attribute__((alias(RTE_STR(p))))
74 /*
75 * RTE_BUILD_SHARED_LIB=n
76 */
77 #endif
78
79 #ifndef ALLOW_EXPERIMENTAL_API
80
81 #define __rte_experimental \
82 __attribute__((deprecated("Symbol is not yet part of stable ABI"), \
83 section(".text.experimental")))
84
85 #else
86
87 #define __rte_experimental \
88 __attribute__((section(".text.experimental")))
89
90 #endif
91
92 #endif /* _RTE_COMPAT_H_ */