plastimatch
Loading...
Searching...
No Matches
cuda_delayload.h
Go to the documentation of this file.
1/* -----------------------------------------------------------------------
2 See COPYRIGHT.TXT and LICENSE.TXT for copyright and license information
3 ----------------------------------------------------------------------- */
4#ifndef _cuda_delayload_h_
5#define _cuda_delayload_h_
6
7#include "plmsys_config.h"
8#ifndef _WIN32
9#include <dlfcn.h>
10#endif
11#include <stdlib.h>
12
13// Needed for delay loading windows DLLs
14#if _WIN32
15 #pragma comment(lib, "delayimp")
16 #pragma comment(lib, "user32")
17#endif
18
19// Note: if lib contains a null pointer here
20// (see above note), this will return a
21// null function pointer. Be careful pls.
22#if _WIN32
23 #define LOAD_SYMBOL(sym, lib) \
24 ;
25#else
26 #define LOAD_SYMBOL(sym, lib) \
27 sym##_##t* sym = (sym##_##t*) dlsym (lib, #sym);
28#endif
29
30// JAS 2012.03.29
31// ------------------------------------------------------------
32// Now that plastimatch is officially C++, we can now safely
33// define this macro, which reduces programmer error. This
34// should be used instead of LOAD_LIBRARY
35#if _WIN32
36 #define LOAD_LIBRARY_SAFE(lib) \
37 if (!delayload_##lib()) { exit (0); } \
38 ;
39#else
40 #define LOAD_LIBRARY_SAFE(lib) \
41 if (!delayload_##lib()) { exit (0); } \
42 void* lib = dlopen_ex (#lib".so");
43#endif
44
45// JAS 2010.12.09
46// Despite what the man pages say, dlclose()ing NULL
47// was resulting in segfaults! So, now we check 1st.
48#if !defined(_WIN32) && defined(PLM_USE_GPU_PLUGINS)
49 #define UNLOAD_LIBRARY(lib) \
50 if (lib != NULL) { \
51 dlclose (lib); \
52 }
53#else
54 #define UNLOAD_LIBRARY(lib) \
55 ;
56#endif
57
58#define DELAYLOAD_WRAP(f, ...) \
59 f (__VA_ARGS__); typedef f##_t(__VA_ARGS__);
60
65PLMSYS_C_API void* dlopen_ex (const char* lib);
66
67#endif
EXTERNC int delayload_libplmcuda(void)
Definition cuda_delayload.cxx:194
EXTERNC int delayload_libplmreconstructcuda(void)
Definition cuda_delayload.cxx:200
EXTERNC int delayload_libplmregistercuda(void)
Definition cuda_delayload.cxx:207
EXTERNC int delayload_libplmopencl(void)
Definition cuda_delayload.cxx:215
EXTERNC void * dlopen_ex(const char *lib)
Definition cuda_delayload.cxx:64
#define PLMSYS_C_API
Definition plmsys_config.h:18