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
41
#include "
tbb/machine/windows_api.h
"
42
#endif
/* _WIN32 */
43
44
OPEN_INTERNAL_NAMESPACE
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 */
59
struct
dynamic_link_descriptor
{
62
const
char
*
name
;
64
pointer_to_handler
*
handler
;
65
#if __TBB_WEAK_SYMBOLS_PRESENT
66
pointer_to_handler
ptr;
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;
80
const
int
DYNAMIC_LINK_ALL
=
DYNAMIC_LINK_GLOBAL
|
DYNAMIC_LINK_LOAD
|
DYNAMIC_LINK_WEAK
;
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
108
enum
dynamic_link_error_t
{
109
dl_success
= 0,
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
114
dl_buff_too_small
// none
115
};
// dynamic_link_error_t
116
117
CLOSE_INTERNAL_NAMESPACE
118
119
#endif
/* __TBB_dynamic_link */
void
void
Definition:
ittnotify_static.h:91
dl_sym_not_found
@ dl_sym_not_found
Definition:
dynamic_link.h:111
DYNAMIC_LINK_LOAD
const int DYNAMIC_LINK_LOAD
Definition:
dynamic_link.h:78
CLOSE_INTERNAL_NAMESPACE
#define CLOSE_INTERNAL_NAMESPACE
Definition:
dynamic_link.h:36
DYNAMIC_LINK_GLOBAL
const int DYNAMIC_LINK_GLOBAL
Definition:
dynamic_link.h:77
dynamic_unlink
void dynamic_unlink(dynamic_link_handle handle)
Definition:
dynamic_link.cpp:569
dynamic_link_descriptor
Association between a handler name and location of pointer to it.
Definition:
dynamic_link.h:60
dl_lib_not_found
@ dl_lib_not_found
Definition:
dynamic_link.h:110
windows_api.h
pointer_to_handler
OPEN_INTERNAL_NAMESPACE typedef void(* pointer_to_handler)()
Type definition for a pointer to a void somefunc(void)
Definition:
dynamic_link.h:47
dynamic_link_descriptor::name
const char * name
Name of the handler.
Definition:
dynamic_link.h:62
dl_sys_fail
@ dl_sys_fail
Definition:
dynamic_link.h:113
DYNAMIC_LINK_ALL
const int DYNAMIC_LINK_ALL
Definition:
dynamic_link.h:80
dynamic_unlink_all
void dynamic_unlink_all()
Definition:
dynamic_link.cpp:570
dynamic_link
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.
dynamic_link_handle
void * dynamic_link_handle
Definition:
dynamic_link.h:74
dynamic_link_descriptor::handler
pointer_to_handler * handler
Pointer to the handler.
Definition:
dynamic_link.h:64
OPEN_INTERNAL_NAMESPACE
#define OPEN_INTERNAL_NAMESPACE
Definition:
dynamic_link.h:35
dl_success
@ dl_success
Definition:
dynamic_link.h:109
tbb_stddef.h
dynamic_link_error_t
dynamic_link_error_t
Definition:
dynamic_link.h:108
dl_buff_too_small
@ dl_buff_too_small
Definition:
dynamic_link.h:114
DYNAMIC_LINK_WEAK
const int DYNAMIC_LINK_WEAK
Definition:
dynamic_link.h:79
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.