|
7 | 7 | *
|
8 | 8 | */
|
9 | 9 |
|
10 |
| -#include <assert.h> |
| 10 | +#ifndef _WIN32 |
11 | 11 | #include <dlfcn.h>
|
12 | 12 | #include <pthread.h>
|
| 13 | +#endif |
| 14 | + |
| 15 | +#include <assert.h> |
13 | 16 | #include <stdbool.h>
|
14 | 17 | #include <stdint.h>
|
15 | 18 | #include <stdio.h>
|
@@ -62,11 +65,20 @@ static struct tbb_callbacks g_tbb_ops;
|
62 | 65 | static UTIL_ONCE_FLAG tbb_is_initialized = UTIL_ONCE_FLAG_INIT;
|
63 | 66 | static bool Init_tbb_global_state_failed;
|
64 | 67 |
|
| 68 | +#ifdef _WIN32 |
| 69 | +#define dlsym(handle, symbol) GetProcAddress(handle, symbol) |
| 70 | +#define dlclose(handle) (void)(handle) |
| 71 | +#endif |
| 72 | + |
65 | 73 | static void init_tbb_global_state(void) {
|
66 |
| - const char so_name[] = "libtbbmalloc.so.2"; |
67 |
| - void *tbb_handle = dlopen(so_name, RTLD_LAZY); |
| 74 | + const char lib_name[] = "libtbbmalloc.so.2"; |
| 75 | +#ifdef _WIN32 |
| 76 | + HMODULE tbb_handle = LoadLibrary(TEXT(lib_name)); |
| 77 | +#else |
| 78 | + void *tbb_handle = dlopen(lib_name, RTLD_LAZY); |
| 79 | +#endif |
68 | 80 | if (!tbb_handle) {
|
69 |
| - fprintf(stderr, "%s not found.\n", so_name); |
| 81 | + fprintf(stderr, "%s not found.\n", lib_name); |
70 | 82 | Init_tbb_global_state_failed = true;
|
71 | 83 | return;
|
72 | 84 | }
|
@@ -95,7 +107,7 @@ static void init_tbb_global_state(void) {
|
95 | 107 | !tbb_ops.pool_aligned_malloc || !tbb_ops.pool_free ||
|
96 | 108 | !tbb_ops.pool_create_v1 || !tbb_ops.pool_destroy ||
|
97 | 109 | !tbb_ops.pool_identify) {
|
98 |
| - fprintf(stderr, "Could not find symbols in %s.\n", so_name); |
| 110 | + fprintf(stderr, "Could not find symbols in %s.\n", lib_name); |
99 | 111 | dlclose(tbb_handle);
|
100 | 112 | Init_tbb_global_state_failed = true;
|
101 | 113 | return;
|
|
0 commit comments