Home ⌂Doc Index ◂Up ▴
Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
dynamic_link.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2005-2020 Intel Corporation
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 #ifndef __TBB_dynamic_link
18 #define __TBB_dynamic_link
19 
20 // Support for dynamic loading entry points from other shared libraries.
21 
22 #include "tbb/tbb_stddef.h"
23 
24 #ifdef LIBRARY_ASSERT
25  #undef __TBB_ASSERT
26  #define __TBB_ASSERT(x,y) LIBRARY_ASSERT(x,y)
27 #else
28  #define LIBRARY_ASSERT(x,y) __TBB_ASSERT_EX(x,y)
29 #endif /* !LIBRARY_ASSERT */
30 
34 #ifndef OPEN_INTERNAL_NAMESPACE
35 #define OPEN_INTERNAL_NAMESPACE namespace tbb { namespace internal {
36 #define CLOSE_INTERNAL_NAMESPACE }}
37 #endif /* OPEN_INTERNAL_NAMESPACE */
38 
39 #include <stddef.h>
40 #if _WIN32
42 #endif /* _WIN32 */
43 
45 
47 typedef void (*pointer_to_handler)();
48 
50 // Double cast through the void* in DLD macro is necessary to
51 // prevent warnings from some compilers (g++ 4.1)
52 #if __TBB_WEAK_SYMBOLS_PRESENT
53 #define DLD(s,h) {#s, (pointer_to_handler*)(void*)(&h), (pointer_to_handler)&s}
54 #define DLD_NOWEAK(s,h) {#s, (pointer_to_handler*)(void*)(&h), NULL}
55 #else
56 #define DLD(s,h) {#s, (pointer_to_handler*)(void*)(&h)}
57 #define DLD_NOWEAK(s,h) DLD(s,h)
58 #endif /* __TBB_WEAK_SYMBOLS_PRESENT */
62  const char* name;
65 #if __TBB_WEAK_SYMBOLS_PRESENT
68 #endif
69 };
70 
71 #if _WIN32
72 typedef HMODULE dynamic_link_handle;
73 #else
74 typedef void* dynamic_link_handle;
75 #endif /* _WIN32 */
76 
77 const int DYNAMIC_LINK_GLOBAL = 0x01;
78 const int DYNAMIC_LINK_LOAD = 0x02;
79 const int DYNAMIC_LINK_WEAK = 0x04;
81 
83 
98 bool dynamic_link( const char* library,
99  const dynamic_link_descriptor descriptors[],
100  size_t required,
101  dynamic_link_handle* handle = 0,
102  int flags = DYNAMIC_LINK_ALL );
103 
104 void dynamic_unlink( dynamic_link_handle handle );
105 
106 void dynamic_unlink_all();
107 
110  dl_lib_not_found, // char const * lib, dlerr_t err
111  dl_sym_not_found, // char const * sym, dlerr_t err
112  // Note: dlerr_t depends on OS: it is char const * on Linux* and macOS*, int on Windows*.
113  dl_sys_fail, // char const * func, int err
115 }; // dynamic_link_error_t
116 
118 
119 #endif /* __TBB_dynamic_link */
pointer_to_handler * handler
Pointer to the handler.
Definition: dynamic_link.h:64
dynamic_link_error_t
Definition: dynamic_link.h:108
void dynamic_unlink(dynamic_link_handle handle)
void dynamic_unlink_all()
const int DYNAMIC_LINK_WEAK
Definition: dynamic_link.h:79
Association between a handler name and location of pointer to it.
Definition: dynamic_link.h:60
const int DYNAMIC_LINK_GLOBAL
Definition: dynamic_link.h:77
void * dynamic_link_handle
Definition: dynamic_link.h:74
const int DYNAMIC_LINK_ALL
Definition: dynamic_link.h:80
bool dynamic_link(const char *library, const dynamic_link_descriptor descriptors[], size_t required, dynamic_link_handle *handle=0, int flags=DYNAMIC_LINK_ALL)
Fill in dynamically linked handlers.
OPEN_INTERNAL_NAMESPACE typedef void(* pointer_to_handler)()
Type definition for a pointer to a void somefunc(void)
Definition: dynamic_link.h:47
#define CLOSE_INTERNAL_NAMESPACE
Definition: dynamic_link.h:36
const char * name
Name of the handler.
Definition: dynamic_link.h:62
#define OPEN_INTERNAL_NAMESPACE
Definition: dynamic_link.h:35
const int DYNAMIC_LINK_LOAD
Definition: dynamic_link.h:78

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.