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_FUNCTION_VERSIONING_H_ 7 #define _RTE_FUNCTION_VERSIONING_H_ 8 #include <rte_common.h> 9 10 #ifndef RTE_USE_FUNCTION_VERSIONING 11 #error Use of function versioning disabled, is "use_function_versioning=true" in meson.build? 12 #endif 13 14 #ifdef RTE_BUILD_SHARED_LIB 15 16 /* 17 * Provides backwards compatibility when updating exported functions. 18 * When a symbol is exported from a library to provide an API, it also provides a 19 * calling convention (ABI) that is embodied in its name, return type, 20 * arguments, etc. On occasion that function may need to change to accommodate 21 * new functionality, behavior, etc. When that occurs, it is desirable to 22 * allow for backwards compatibility for a time with older binaries that are 23 * dynamically linked to the dpdk. To support that, the __vsym and 24 * VERSION_SYMBOL macros are created. They, in conjunction with the 25 * version.map file for a given library allow for multiple versions of 26 * a symbol to exist in a shared library so that older binaries need not be 27 * immediately recompiled. 28 * 29 * Refer to the guidelines document in the docs subdirectory for details on the 30 * use of these macros 31 */ 32 33 /* 34 * Macro Parameters: 35 * b - function base name 36 * e - function version extension, to be concatenated with base name 37 * n - function symbol version string to be applied 38 * f - function prototype 39 * p - full function symbol name 40 */ 41 42 /* 43 * VERSION_SYMBOL 44 * Creates a symbol version table entry binding symbol <b>@DPDK_<n> to the internal 45 * function name <b><e> 46 */ 47 #define VERSION_SYMBOL(b, e, n) __asm__(".symver " RTE_STR(b) RTE_STR(e) ", " RTE_STR(b) "@DPDK_" RTE_STR(n)) 48 49 /* 50 * VERSION_SYMBOL_EXPERIMENTAL 51 * Creates a symbol version table entry binding the symbol <b>@EXPERIMENTAL to the internal 52 * function name <b><e>. The macro is used when a symbol matures to become part of the stable ABI, 53 * to provide an alias to experimental for some time. 54 */ 55 #define VERSION_SYMBOL_EXPERIMENTAL(b, e) __asm__(".symver " RTE_STR(b) RTE_STR(e) ", " RTE_STR(b) "@EXPERIMENTAL") 56 57 /* 58 * BIND_DEFAULT_SYMBOL 59 * Creates a symbol version entry instructing the linker to bind references to 60 * symbol <b> to the internal symbol <b><e> 61 */ 62 #define BIND_DEFAULT_SYMBOL(b, e, n) __asm__(".symver " RTE_STR(b) RTE_STR(e) ", " RTE_STR(b) "@@DPDK_" RTE_STR(n)) 63 64 /* 65 * __vsym 66 * Annotation to be used in declaration of the internal symbol <b><e> to signal 67 * that it is being used as an implementation of a particular version of symbol 68 * <b>. 69 */ 70 #define __vsym __rte_used 71 72 /* 73 * MAP_STATIC_SYMBOL 74 * If a function has been bifurcated into multiple versions, none of which 75 * are defined as the exported symbol name in the map file, this macro can be 76 * used to alias a specific version of the symbol to its exported name. For 77 * example, if you have 2 versions of a function foo_v1 and foo_v2, where the 78 * former is mapped to foo@DPDK_1 and the latter is mapped to foo@DPDK_2 when 79 * building a shared library, this macro can be used to map either foo_v1 or 80 * foo_v2 to the symbol foo when building a static library, e.g.: 81 * MAP_STATIC_SYMBOL(void foo(), foo_v2); 82 */ 83 #define MAP_STATIC_SYMBOL(f, p) 84 85 #else 86 /* 87 * No symbol versioning in use 88 */ 89 #define VERSION_SYMBOL(b, e, n) 90 #define VERSION_SYMBOL_EXPERIMENTAL(b, e) 91 #define __vsym 92 #define BIND_DEFAULT_SYMBOL(b, e, n) 93 #define MAP_STATIC_SYMBOL(f, p) f __attribute__((alias(RTE_STR(p)))) 94 /* 95 * RTE_BUILD_SHARED_LIB=n 96 */ 97 #endif 98 99 #endif /* _RTE_FUNCTION_VERSIONING_H_ */ 100