[clinfo] 25/55: Update Windows support
Andreas Beckmann
anbe at moszumanska.debian.org
Sat Jan 13 14:40:00 UTC 2018
This is an automated email from the git hooks/post-receive script.
anbe pushed a commit to branch master
in repository clinfo.
commit 86e20dffda703bff3013a84fa0716adab6feba58
Author: Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
Date: Fri Feb 10 11:47:16 2017 +0100
Update Windows support
Particularly concerning the OpenCL ICD version retrieval.
---
src/clinfo.c | 28 ++++++++++++++++++----------
src/fmtmacros.h | 13 +++++++------
src/ms_support.h | 12 +++++++++++-
3 files changed, 36 insertions(+), 17 deletions(-)
diff --git a/src/clinfo.c b/src/clinfo.c
index e277791..04ed634 100644
--- a/src/clinfo.c
+++ b/src/clinfo.c
@@ -4,10 +4,18 @@
#include <time.h>
#include <string.h>
-#include <dlfcn.h>
-#ifndef RTLD_DEFAULT
-#define RTLD_DEFAULT ((void*)0)
+/* We will want to check for symbols in the OpenCL library.
+ * On Windows, we must get the module handle for it, on Unix-like
+ * systems we can just use RTLD_DEFAULT
+ */
+#ifdef _MSC_VER
+# include <windows.h>
+# define dlsym GetProcAddress
+# define DL_MODULE GetModuleHandle("OpenCL")
+#else
+# include <dlfcn.h>
+# define DL_MODULE ((void*)0) /* This would be RTLD_DEFAULT */
#endif
/* ISO C forbids assignments between function pointers and void pointers,
@@ -22,7 +30,7 @@
*/
#include "fmtmacros.h"
-// Support for the horrible MS C compiler
+// More support for the horrible MS C compiler
#ifdef _MSC_VER
#include "ms_support.h"
#endif
@@ -33,7 +41,10 @@
#include "strbuf.h"
#define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(*ar))
+
+#ifndef UNUSED
#define UNUSED(x) x __attribute__((unused))
+#endif
struct platform_data {
char *pname; /* CL_PLATFORM_NAME */
@@ -2568,7 +2579,7 @@ void oclIcdProps(void)
struct icd_loader_test check = icd_loader_tests[i];
if (check.symbol == NULL)
break;
- if (dlsym(RTLD_DEFAULT, check.symbol) == NULL)
+ if (dlsym(DL_MODULE, check.symbol) == NULL)
break;
icdl_ocl_version_found = check.version;
++i;
@@ -2586,8 +2597,7 @@ void oclIcdProps(void)
*/
#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4996)
+#pragma warning(suppress : 4996)
#elif defined __GNUC__ && ((__GNUC__*10 + __GNUC_MINOR__) >= 46)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
@@ -2595,9 +2605,7 @@ void oclIcdProps(void)
PTR_FUNC_PTR clGetICDLoaderInfoOCLICD = clGetExtensionFunctionAddress("clGetICDLoaderInfoOCLICD");
-#ifdef _MSC_VER
-#pragma warning(pop)
-#elif defined __GNUC__ && ((__GNUC__*10 + __GNUC_MINOR__) >= 46)
+#if defined __GNUC__ && ((__GNUC__*10 + __GNUC_MINOR__) >= 46)
#pragma GCC diagnostic pop
#endif
diff --git a/src/fmtmacros.h b/src/fmtmacros.h
index 0660583..ae6161c 100644
--- a/src/fmtmacros.h
+++ b/src/fmtmacros.h
@@ -9,12 +9,13 @@
#define _FMT_MACROS_H
#ifdef _WIN32
-# include <stdint.h>
-# include <stddef.h> // size_t
-# define PRIu64 "I64u"
-# define PRIX64 "I64x"
-# define PRIXPTR "p"
-# define PRIuS "Iu"
+/* TODO FIXME WIN64 support */
+# include <stdint.h>
+# include <stddef.h> // size_t
+# define PRIu64 "I64u"
+# define PRIX64 "I64x"
+# define PRIXPTR "p"
+# define PRIuS "Iu"
#else
# define __STDC_FORMAT_MACROS
# include <inttypes.h>
diff --git a/src/ms_support.h b/src/ms_support.h
index 2a8a129..3551124 100644
--- a/src/ms_support.h
+++ b/src/ms_support.h
@@ -4,8 +4,18 @@
* TODO could be improved by version-checking for C99 support
*/
-// also disable strncpy vs strncpy_s warning
+// disable warning about unsafe strncpy vs strncpy_s usage
#pragma warning(disable : 4996)
+// disable warning about constant conditional expressions
+#pragma warning(disable : 4127)
+// disable warning about non-constant aggregate initializer
+#pragma warning(disable: 4204)
+
+// Suppress warning about unused parameters. The macro definition
+// _should_ work, but it doesn't on VS2012 (cl 17), may be a version thing
+#define UNUSED(x) x __pragma(warning(suppress: 4100))
+// TODO FIXME remove full-blown warning removal where not needed
+#pragma warning(disable: 4100)
// No inline in MS C
#define inline __inline
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opencl/clinfo.git
More information about the Pkg-opencl-commits
mailing list