Improved error handling.

This commit is contained in:
XMRig 2019-10-27 19:51:21 +07:00
parent c9f7cbae09
commit 0e224abb0a
6 changed files with 45 additions and 18 deletions

View file

@ -55,6 +55,7 @@ static const char *kDeviceName = "deviceName";
static const char *kDeviceUint = "deviceUint";
static const char *kDeviceUlong = "deviceUlong";
static const char *kInit = "init";
static const char *kLastError = "lastError";
static const char *kPluginVersion = "pluginVersion";
static const char *kRelease = "release";
static const char *kSetJob = "setJob";
@ -72,6 +73,7 @@ using deviceName_t = const char * (*)(nvid_
using deviceUint_t = uint32_t (*)(nvid_ctx *, CudaLib::DeviceProperty);
using deviceUlong_t = uint64_t (*)(nvid_ctx *, CudaLib::DeviceProperty);
using init_t = void (*)();
using lastError_t = const char * (*)(nvid_ctx *);
using pluginVersion_t = const char * (*)();
using release_t = void (*)(nvid_ctx *);
using setJob_t = bool (*)(nvid_ctx *, const void *, size_t, int32_t);
@ -88,6 +90,7 @@ static deviceName_t pDeviceName = nullptr;
static deviceUint_t pDeviceUint = nullptr;
static deviceUlong_t pDeviceUlong = nullptr;
static init_t pInit = nullptr;
static lastError_t pLastError = nullptr;
static pluginVersion_t pPluginVersion = nullptr;
static release_t pRelease = nullptr;
static setJob_t pSetJob = nullptr;
@ -117,7 +120,7 @@ bool xmrig::CudaLib::init(const char *fileName)
}
const char *xmrig::CudaLib::lastError()
const char *xmrig::CudaLib::lastError() noexcept
{
return uv_dlerror(&cudaLib);
}
@ -153,6 +156,12 @@ const char *xmrig::CudaLib::deviceName(nvid_ctx *ctx) noexcept
}
const char *xmrig::CudaLib::lastError(nvid_ctx *ctx) noexcept
{
return pLastError(ctx);
}
const char *xmrig::CudaLib::pluginVersion() noexcept
{
return pPluginVersion();
@ -255,6 +264,7 @@ bool xmrig::CudaLib::load()
DLSYM(DeviceUint);
DLSYM(DeviceUlong);
DLSYM(Init);
DLSYM(LastError);
DLSYM(PluginVersion);
DLSYM(Release);
DLSYM(SetJob);

View file

@ -64,7 +64,7 @@ public:
};
static bool init(const char *fileName = nullptr);
static const char *lastError();
static const char *lastError() noexcept;
static void close();
static inline bool isInitialized() { return m_initialized; }
@ -74,6 +74,7 @@ public:
static bool deviceInit(nvid_ctx *ctx) noexcept;
static bool setJob(nvid_ctx *ctx, const void *data, size_t size, const Algorithm &algorithm) noexcept;
static const char *deviceName(nvid_ctx *ctx) noexcept;
static const char *lastError(nvid_ctx *ctx) noexcept;
static const char *pluginVersion() noexcept;
static int deviceInfo(nvid_ctx *ctx, int32_t blocks, int32_t threads, const Algorithm &algorithm) noexcept;
static int32_t deviceInt(nvid_ctx *ctx, DeviceProperty property) noexcept;