jit_linker.cpp
来自「orange源码 数据挖掘技术」· C++ 代码 · 共 81 行
CPP
81 行
#include "jit_linker.hpp"
#if defined _MSC_VER
#include <direct.h>
#define getcwd _getcwd
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
int jit_link(const char *dllname, TJitLink *functions, TDefaultFunc deffunc)
{
TJitLink *function = functions;
HINSTANCE jitDll = LoadLibrary(dllname);
if (jitDll) {
for(; function->address; function++) {
void *sym = GetProcAddress(jitDll, function->funcname);
if (!sym)
break;
*function->address = sym;
}
}
if (function->address) {
for(function = functions; function->address; function++)
*function->address = deffunc;
if (jitDll) {
FreeLibrary(jitDll);
return -1;
}
else
return -2;
}
return 0;
}
#elif defined LINUX || defined FREEBSD || defined DARWIN
#include <dlfcn.h>
#include <unistd.h>
int jit_link(const char *dllname, TJitLink *functions, TDefaultFunc deffunc)
{
TJitLink *function = functions;
void *jitDll = dlopen(dllname, 0);
if (jitDll) {
for(; function->address; function++) {
void *sym = dlsym(jitDll, function->funcname);
if (!sym)
break;
*function->address = sym;
}
}
if (function->address) {
for(function = functions; function->address; function++)
*function->address = deffunc;
if (jitDll) {
dlclose(jitDll);
return -1;
}
else
return -2;
}
return 0;
}
#else
void dynloadC45(char [])
{ raiseErrorWho("C45Loader", "c45 is not supported on this platform"); }
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?