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-2019 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 
18 
19 */
20 
21 #ifndef __TBB_dynamic_link
22 #define __TBB_dynamic_link
23 
24 // Support for dynamic loading entry points from other shared libraries.
25 
26 #include "tbb/tbb_stddef.h"
27 
28 #ifdef LIBRARY_ASSERT
29  #undef __TBB_ASSERT
30  #define __TBB_ASSERT(x,y) LIBRARY_ASSERT(x,y)
31 #else
32  #define LIBRARY_ASSERT(x,y) __TBB_ASSERT_EX(x,y)
33 #endif /* !LIBRARY_ASSERT */
34 
38 #ifndef OPEN_INTERNAL_NAMESPACE
39 #define OPEN_INTERNAL_NAMESPACE namespace tbb { namespace internal {
40 #define CLOSE_INTERNAL_NAMESPACE }}
41 #endif /* OPEN_INTERNAL_NAMESPACE */
42 
43 #include <stddef.h>
44 #if _WIN32
46 #endif /* _WIN32 */
47 
49 
51 typedef void (*pointer_to_handler)();
52 
54 // Double cast through the void* in DLD macro is necessary to
55 // prevent warnings from some compilers (g++ 4.1)
56 #if __TBB_WEAK_SYMBOLS_PRESENT
57 #define DLD(s,h) {#s, (pointer_to_handler*)(void*)(&h), (pointer_to_handler)&s}
58 #define DLD_NOWEAK(s,h) {#s, (pointer_to_handler*)(void*)(&h), NULL}
59 #else
60 #define DLD(s,h) {#s, (pointer_to_handler*)(void*)(&h)}
61 #define DLD_NOWEAK(s,h) DLD(s,h)
62 #endif /* __TBB_WEAK_SYMBOLS_PRESENT */
66  const char* name;
69 #if __TBB_WEAK_SYMBOLS_PRESENT
72 #endif
73 };
74 
75 #if _WIN32
76 typedef HMODULE dynamic_link_handle;
77 #else
78 typedef void* dynamic_link_handle;
79 #endif /* _WIN32 */
80 
81 const int DYNAMIC_LINK_GLOBAL = 0x01;
82 const int DYNAMIC_LINK_LOAD = 0x02;
83 const int DYNAMIC_LINK_WEAK = 0x04;
85 
87 
102 bool dynamic_link( const char* library,
103  const dynamic_link_descriptor descriptors[],
104  size_t required,
105  dynamic_link_handle* handle = 0,
106  int flags = DYNAMIC_LINK_ALL );
107 
108 void dynamic_unlink( dynamic_link_handle handle );
109 
110 void dynamic_unlink_all();
111 
114  dl_lib_not_found, // char const * lib, dlerr_t err
115  dl_sym_not_found, // char const * sym, dlerr_t err
116  // Note: dlerr_t depends on OS: it is char const * on Linux* and macOS*, int on Windows*.
117  dl_sys_fail, // char const * func, int err
119 }; // dynamic_link_error_t
120 
122 
123 #endif /* __TBB_dynamic_link */
const char * name
Name of the handler.
Definition: dynamic_link.h:66
#define CLOSE_INTERNAL_NAMESPACE
Definition: dynamic_link.h:40
Association between a handler name and location of pointer to it.
Definition: dynamic_link.h:64
void dynamic_unlink(dynamic_link_handle handle)
const int DYNAMIC_LINK_ALL
Definition: dynamic_link.h:84
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.
void dynamic_unlink_all()
const int DYNAMIC_LINK_WEAK
Definition: dynamic_link.h:83
#define OPEN_INTERNAL_NAMESPACE
Definition: dynamic_link.h:39
const int DYNAMIC_LINK_LOAD
Definition: dynamic_link.h:82
void * dynamic_link_handle
Definition: dynamic_link.h:78
const int DYNAMIC_LINK_GLOBAL
Definition: dynamic_link.h:81
pointer_to_handler * handler
Pointer to the handler.
Definition: dynamic_link.h:68
OPEN_INTERNAL_NAMESPACE typedef void(* pointer_to_handler)()
Type definition for a pointer to a void somefunc(void)
Definition: dynamic_link.h:51
dynamic_link_error_t
Definition: dynamic_link.h:112

Copyright © 2005-2019 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.