File tree Expand file tree Collapse file tree 5 files changed +98
-1
lines changed Expand file tree Collapse file tree 5 files changed +98
-1
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ SUBDIRS(bc7)
52
52
#ENDIF(CG_FOUND)
53
53
54
54
# CUDA
55
- # FIND_PACKAGE(CUDA)
55
+ FIND_PACKAGE (CUDA )
56
56
IF (CUDA_FOUND )
57
57
IF (MINGW )
58
58
MESSAGE (STATUS "Looking for CUDA - not supported on MinGW" )
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ SET(CORE_SRCS
10
10
DefsVcWin32.h
11
11
FileSystem.h FileSystem.cpp
12
12
ForEach .h
13
+ Library.h Library.cpp
13
14
Memory.h Memory.cpp
14
15
Ptr.h
15
16
RefCounted.h
Original file line number Diff line number Diff line change
1
+ #include " Library.h"
2
+ #include " Debug.h"
3
+
4
+ #if NV_OS_WIN32
5
+ #define WIN32_LEAN_AND_MEAN
6
+ #define VC_EXTRALEAN
7
+ #include < windows.h>
8
+ #elif NV_OS_XBOX
9
+ #include < Xtl.h>
10
+ #else
11
+ #include < dlfcn.h>
12
+ #endif
13
+
14
+
15
+
16
+ void * nvLoadLibrary (const char * name)
17
+ {
18
+ #if NV_OS_WIN32
19
+ return (void *)LoadLibraryExA ( name, NULL , 0 );
20
+ #elif NV_OS_XBOX
21
+ return (void *)LoadLibraryA ( name );
22
+ #else
23
+ return dlopen (name, RTLD_LAZY);
24
+ #endif
25
+ }
26
+
27
+ void nvUnloadLibrary (void * handle)
28
+ {
29
+ nvDebugCheck (handle != NULL );
30
+ #if NV_OS_WIN32 || NV_OS_XBOX
31
+ FreeLibrary ((HMODULE)handle);
32
+ #else
33
+ dlclose (handle);
34
+ #endif
35
+ }
36
+
37
+ void * nvBindSymbol (void * handle, const char * symbol)
38
+ {
39
+ #if NV_OS_WIN32 || NV_OS_XBOX
40
+ return (void *)GetProcAddress ((HMODULE)handle, symbol);
41
+ #else
42
+ return (void *)dlsym (handle, symbol);
43
+ #endif
44
+ }
Original file line number Diff line number Diff line change
1
+ // This code is in the public domain -- [email protected]
2
+
3
+ #pragma once
4
+ #ifndef NV_CORE_LIBRARY_H
5
+ #define NV_CORE_LIBRARY_H
6
+
7
+ #include " nvcore.h"
8
+
9
+ #if NV_OS_WIN32
10
+ #define LIBRARY_NAME (name ) #name " .dll"
11
+ #elif NV_OS_DARWIN
12
+ #define NV_LIBRARY_NAME (name ) " lib" #name " .dylib"
13
+ #else
14
+ #define NV_LIBRARY_NAME (name ) " lib" #name " .so"
15
+ #endif
16
+
17
+ NVCORE_API void * nvLoadLibrary (const char * name);
18
+ NVCORE_API void nvUnloadLibrary (void * lib);
19
+ NVCORE_API void * nvBindSymbol (void * lib, const char * symbol);
20
+
21
+ class NVCORE_CLASS Library
22
+ {
23
+ public:
24
+ Library (const char * name)
25
+ {
26
+ handle = nvLoadLibrary (name);
27
+ }
28
+ ~Library ()
29
+ {
30
+ if (isValid ())
31
+ {
32
+ nvUnloadLibrary (handle);
33
+ }
34
+ }
35
+
36
+ bool isValid () const
37
+ {
38
+ return handle != NULL ;
39
+ }
40
+
41
+ void * bindSymbol (const char * symbol)
42
+ {
43
+ return nvBindSymbol (handle, symbol);
44
+ }
45
+
46
+ private:
47
+ void * handle;
48
+ };
49
+
50
+
51
+ #endif // NV_CORE_LIBRARY_H
Original file line number Diff line number Diff line change 23
23
// OTHER DEALINGS IN THE SOFTWARE.
24
24
25
25
#include " nvcore/Debug.h"
26
+ #include " nvcore/Library.h"
26
27
#include " CudaUtils.h"
27
28
28
29
#if defined HAVE_CUDA
You can’t perform that action at this time.
0 commit comments