[arrayfire] 48/248: Added error display strings for unified api error codes
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Nov 17 15:53:53 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch dfsg-clean
in repository arrayfire.
commit a884c966ffe3d8a972c5becb6d653e476b4ddbcb
Author: pradeep <pradeep at arrayfire.com>
Date: Tue Sep 8 14:22:40 2015 -0400
Added error display strings for unified api error codes
Also, fixed some typos
---
include/af/defines.h | 2 +-
src/api/c/err_common.cpp | 2 ++
src/api/unified/symbol_manager.cpp | 7 +++++++
src/api/unified/symbol_manager.hpp | 4 +++-
4 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/include/af/defines.h b/include/af/defines.h
index 8d6dbd0..641a929 100644
--- a/include/af/defines.h
+++ b/include/af/defines.h
@@ -152,7 +152,7 @@ typedef enum {
// 500-599 Errors specific to heterogenous API
AF_ERR_LOAD_LIB = 501,
- AF_ERR_SYM_LOAD = 502,
+ AF_ERR_LOAD_SYM = 502,
// 900-999 Errors from upstream libraries and runtimes
diff --git a/src/api/c/err_common.cpp b/src/api/c/err_common.cpp
index 4fa4bbb..371bbd9 100644
--- a/src/api/c/err_common.cpp
+++ b/src/api/c/err_common.cpp
@@ -179,6 +179,8 @@ const char *af_err_to_string(const af_err err)
case AF_ERR_NOT_CONFIGURED: return "Function not configured to build";
case AF_ERR_TYPE: return "Function does not support this data type";
case AF_ERR_NO_DBL: return "Double precision not supported for this device";
+ case AF_ERR_LOAD_LIB: return "Failed to load dynamic library";
+ case AF_ERR_LOAD_SYM: return "Failed to load symbol";
case AF_ERR_UNKNOWN:
default:
return "Unknown error";
diff --git a/src/api/unified/symbol_manager.cpp b/src/api/unified/symbol_manager.cpp
index 0aa5369..752e007 100644
--- a/src/api/unified/symbol_manager.cpp
+++ b/src/api/unified/symbol_manager.cpp
@@ -68,6 +68,8 @@ LibHandle openDynLibrary(const int bknd_idx, int flag=RTLD_LAZY)
// in the event that dlopen returns NULL, search for the lib
// ub hard coded paths based on the environment variables
// defined in the constant string array LIB_AF_PATHS
+ string show_flag = getEnvVar("AF_SHOW_LOAD_PATH");
+ bool show_load_path = show_flag=="1";
if (retVal == NULL) {
for (int i=0; i<NUM_ENV_VARS; ++i) {
string abs_path = getEnvVar(LIB_AF_ENVARS[i])
@@ -81,12 +83,17 @@ LibHandle openDynLibrary(const int bknd_idx, int flag=RTLD_LAZY)
retVal = dlopen(abs_path.c_str(), flag);
#endif
if (retVal!=NULL) {
+ if (show_load_path)
+ printf("Using %s\n", abs_path.c_str());
// if the current absolute path based dlopen
// search is a success, then abandon search
// and proceed for compute
break;
}
}
+ } else {
+ if (show_load_path)
+ printf("Using %s from system path\n", bkndName.c_str());
}
return retVal;
}
diff --git a/src/api/unified/symbol_manager.hpp b/src/api/unified/symbol_manager.hpp
index 3ce5ec4..34bae58 100644
--- a/src/api/unified/symbol_manager.hpp
+++ b/src/api/unified/symbol_manager.hpp
@@ -33,6 +33,8 @@ class AFSymbolManager {
template<typename... CalleeArgs>
af_err call(const char* symbolName, CalleeArgs... args) {
+ if (!activeHandle)
+ return AF_ERR_LOAD_LIB;
typedef af_err(*af_func)(CalleeArgs...);
af_func funcHandle;
#if defined(OS_WIN)
@@ -41,7 +43,7 @@ class AFSymbolManager {
funcHandle = (af_func)dlsym(activeHandle, symbolName);
#endif
if (!funcHandle) {
- return AF_ERR_SYM_LOAD;
+ return AF_ERR_LOAD_SYM;
}
return funcHandle(args...);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git
More information about the debian-science-commits
mailing list