[arrayfire] 128/284: Using getEnvVar instead of getenv
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Sun Feb 7 18:59:26 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/experimental
in repository arrayfire.
commit e19a6bef84ae8c2740385167ea0f8aef2dda7c86
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date: Thu Dec 31 11:02:15 2015 -0500
Using getEnvVar instead of getenv
---
src/api/c/err_common.cpp | 7 ++++---
src/api/c/graphics_common.cpp | 5 +++--
src/backend/cuda/interopManager.cu | 9 +++++----
src/backend/cuda/memory.cpp | 8 +++++---
src/backend/cuda/platform.cpp | 5 +++--
src/backend/opencl/platform.cpp | 9 +++++----
src/backend/opencl/program.hpp | 5 +++--
7 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/src/api/c/err_common.cpp b/src/api/c/err_common.cpp
index 9ff731f..b9fa492 100644
--- a/src/api/c/err_common.cpp
+++ b/src/api/c/err_common.cpp
@@ -11,6 +11,7 @@
#include <af/device.h>
#include <err_common.hpp>
#include <type_util.hpp>
+#include <util.hpp>
#include <string>
#include <sstream>
#include <cstring>
@@ -155,9 +156,9 @@ static std::string global_err_string;
void
print_error(const string &msg)
{
- const char* perr = getenv("AF_PRINT_ERRORS");
- if(perr != nullptr) {
- if(std::strncmp(perr, "0", 1) != 0)
+ std::string perr = getEnvVar("AF_PRINT_ERRORS");
+ if(!perr.empty()) {
+ if(perr != "0")
fprintf(stderr, "%s\n", msg.c_str());
}
global_err_string = msg;
diff --git a/src/api/c/graphics_common.cpp b/src/api/c/graphics_common.cpp
index a4132b5..291bf84 100644
--- a/src/api/c/graphics_common.cpp
+++ b/src/api/c/graphics_common.cpp
@@ -13,6 +13,7 @@
#include <err_common.hpp>
#include <backend.hpp>
#include <platform.hpp>
+#include <util.hpp>
using namespace std;
@@ -145,8 +146,8 @@ fg::Window* ForgeManager::getMainWindow(const bool dontCreate)
static fg::Window* wnd = NULL;
// Define AF_DISABLE_GRAPHICS with any value to disable initialization
- const char* noGraphicsENV = getenv("AF_DISABLE_GRAPHICS");
- if(!noGraphicsENV) { // If AF_DISABLE_GRAPHICS is not defined
+ std::string noGraphicsENV = getEnvVar("AF_DISABLE_GRAPHICS");
+ if(!noGraphicsENV.empty()) { // If AF_DISABLE_GRAPHICS is not defined
if (flag && !dontCreate) {
wnd = new fg::Window(WIDTH, HEIGHT, "ArrayFire", NULL, true);
CheckGL("End ForgeManager::getMainWindow");
diff --git a/src/backend/cuda/interopManager.cu b/src/backend/cuda/interopManager.cu
index b492a5e..a6e2fcf 100644
--- a/src/backend/cuda/interopManager.cu
+++ b/src/backend/cuda/interopManager.cu
@@ -14,6 +14,7 @@
#include <interopManager.hpp>
#include <err_cuda.hpp>
+#include <util.hpp>
#include <cstdio>
namespace cuda
@@ -36,10 +37,10 @@ InteropManager::~InteropManager()
}
} catch (AfError &ex) {
- const char* perr = getenv("AF_PRINT_ERRORS");
-
- if(perr && perr[0] != '0') {
- fprintf(stderr, "%s\n", ex.what());
+ std::string perr = getEnvVar("AF_PRINT_ERRORS");
+ if(!perr.empty()) {
+ if(perr != "0")
+ fprintf(stderr, "%s\n", ex.what());
}
}
}
diff --git a/src/backend/cuda/memory.cpp b/src/backend/cuda/memory.cpp
index 9b3d731..2632a0a 100644
--- a/src/backend/cuda/memory.cpp
+++ b/src/backend/cuda/memory.cpp
@@ -12,6 +12,7 @@
#include <cuda_runtime_api.h>
#include <cuda_runtime.h>
#include <err_cuda.hpp>
+#include <util.hpp>
#include <types.hpp>
#include <map>
#include <dispatch.hpp>
@@ -123,9 +124,10 @@ namespace cuda
} catch (AfError &ex) {
- const char* perr = getenv("AF_PRINT_ERRORS");
- if(perr && perr[0] != '0') {
- fprintf(stderr, "%s\n", ex.what());
+ std::string perr = getEnvVar("AF_PRINT_ERRORS");
+ if(!perr.empty()) {
+ if(perr != "0")
+ fprintf(stderr, "%s\n", ex.what());
}
}
}
diff --git a/src/backend/cuda/platform.cpp b/src/backend/cuda/platform.cpp
index 6854535..f5f6599 100644
--- a/src/backend/cuda/platform.cpp
+++ b/src/backend/cuda/platform.cpp
@@ -11,6 +11,7 @@
#include <af/cuda.h>
#include <platform.hpp>
#include <defines.hpp>
+#include <util.hpp>
#include <version.hpp>
#include <driver.h>
#include <vector>
@@ -348,8 +349,8 @@ DeviceManager::DeviceManager()
for(int i = 0; i < (int)MAX_DEVICES; i++)
streams[i] = (cudaStream_t)0;
- const char* deviceENV = getenv("AF_CUDA_DEFAULT_DEVICE");
- if(!deviceENV) {
+ std::string deviceENV = getEnvVar("AF_CUDA_DEFAULT_DEVICE");
+ if(deviceENV.empty()) {
setActiveDevice(0, cuDevices[0].nativeId);
} else {
stringstream s(deviceENV);
diff --git a/src/backend/opencl/platform.cpp b/src/backend/opencl/platform.cpp
index 57726d2..8d77e24 100644
--- a/src/backend/opencl/platform.cpp
+++ b/src/backend/opencl/platform.cpp
@@ -29,6 +29,7 @@
#include <defines.hpp>
#include <version.hpp>
#include <platform.hpp>
+#include <util.hpp>
#include <functional>
#include <algorithm>
#include <cctype>
@@ -153,8 +154,8 @@ DeviceManager::DeviceManager()
}
}
- const char* deviceENV = getenv("AF_OPENCL_DEFAULT_DEVICE");
- if(deviceENV) {
+ std::string deviceENV = getEnvVar("AF_OPENCL_DEFAULT_DEVICE");
+ if(!deviceENV.empty()) {
std::stringstream s(deviceENV);
int def_device = -1;
s >> def_device;
@@ -172,8 +173,8 @@ DeviceManager::DeviceManager()
* OpenGL shared contexts whereever applicable */
#if defined(WITH_GRAPHICS)
// Define AF_DISABLE_GRAPHICS with any value to disable initialization
- const char* noGraphicsENV = getenv("AF_DISABLE_GRAPHICS");
- if(!noGraphicsENV) { // If AF_DISABLE_GRAPHICS is not defined
+ std::string noGraphicsENV = getEnvVar("AF_DISABLE_GRAPHICS");
+ if(!noGraphicsENV.empty()) { // If AF_DISABLE_GRAPHICS is not defined
try {
int devCount = mDevices.size();
fg::Window* wHandle = graphics::ForgeManager::getInstance().getMainWindow();
diff --git a/src/backend/opencl/program.hpp b/src/backend/opencl/program.hpp
index 1b76a75..6a2af45 100644
--- a/src/backend/opencl/program.hpp
+++ b/src/backend/opencl/program.hpp
@@ -9,6 +9,7 @@
#pragma once
#include <platform.hpp>
+#include <util.hpp>
#include <string>
#include <mutex>
@@ -35,8 +36,8 @@ using std::string;
#if defined(NDEBUG)
#define SHOW_BUILD_INFO(PROG) do { \
- const char *info = getenv("AF_OPENCL_SHOW_BUILD_INFO"); \
- if (info != nullptr && std::strncmp(info,"0", 1) != 0) { \
+ std::string info = getEnvVar("AF_OPENCL_SHOW_BUILD_INFO"); \
+ if (!info.empty() && info != "0") { \
SHOW_DEBUG_BUILD_INFO(prog); \
} \
} while(0)
--
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