Debian Codegraph @

src/vendorcode/cavium/include/bdk/libbdk-arch/bdk-require.h

raw symbols SCIP
1 #ifndef __CB_BDK_REQUIRE_H__
2 #define __CB_BDK_REQUIRE_H__
3 /***********************license start***********************************
4 * Copyright (c) 2003-2017 Cavium Inc. ([email protected]). All rights
5 * reserved.
6 *
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials provided
18 * with the distribution.
19 *
20 * * Neither the name of Cavium Inc. nor the names of
21 * its contributors may be used to endorse or promote products
22 * derived from this software without specific prior written
23 * permission.
24 *
25 * This Software, including technical data, may be subject to U.S. export
26 * control laws, including the U.S. Export Administration Act and its
27 * associated regulations, and may be subject to export or import
28 * regulations in other countries.
29 *
30 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
31 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
32 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT
33 * TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
34 * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
35 * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
36 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
37 * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT,
38 * QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK
39 * ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
40 ***********************license end**************************************/
41
42 /**
43 * @file
44 *
45 * Functions and macros to control what parts of the BDK are linked in
46 *
47 * <hr>$Revision: 49448 $<hr>
48 * @defgroup require Component linking control
49 * @{
50 */
51
52 /**
53 * Optional parts of the BDK code are pulled in by adding
54 * BDK_REQUIRE() lines to the function bdk_require_depends().
55 * Component symbols are defined as weak so that they are not
56 * linked in unless a BDK_REQUIRE() pulls them in.
57 */
58 #define BDK_REQUIRE(component) \
59 do \
60 { \
61 extern char __bdk_require_symbol_##component; \
62 bdk_warn_if(__bdk_require_symbol_##component, \
63 "Require of %s failed\n", #component); \
64 } while (0)
65
66 /**
67 * The following macro defines a special symbol in a C file to
68 * define it as a require component. Referencing this symbol
69 * causes all objects defined in the C file to be pulled in. This
70 * symbol should only be referenced by using the BDK_REQUIRE()
71 * macro in the function bdk_require_depends().
72 */
73 #define BDK_REQUIRE_DEFINE(component) \
74 char __bdk_require_symbol_##component; \
75 char __bdk_is_required_symbol_##component
76
77 /**
78 * Return if a component has been required. Useful for if
79 * statements around referencing of weak symbols.
80 */
81 #define BDK_IS_REQUIRED(component) \
82 ({int is_required; \
83 do \
84 { \
85 extern char __bdk_is_required_symbol_##component __attribute__((weak));\
86 is_required = (&__bdk_is_required_symbol_##component != NULL); \
87 } while (0); \
88 is_required;})
89
90
91 /**
92 * The require macros use weak symbols to control if components
93 * are linked in. All directly referenced symbols in a component
94 * must be defined a weak. This causes the component to only be
95 * pulled in by the linker if the symbol defined by
96 * BDK_REQUIRE_DEFINE is used.
97 */
98 #define BDK_WEAK __attribute__((weak))
99
100 /**
101 * This function is not defined by the BDK libraries. It must be
102 * defined by all BDK applications. It should be empty except for
103 * containing BDK_REQUIRE() lines. The bdk-init code has a strong
104 * reference to bdk_requires_depends() which then contains strong
105 * references to all needed components.
106 */
107 // FIXME(dhendrix): leave it out if possible */
108 //extern void __bdk_require_depends(void);
109
110 /** @} */
111 #endif