[Mesa-dev] [PATCH] clover: Use a non-NULL value to represent the platform_id

Tom Stellard tom at stellard.net
Fri Apr 5 13:32:46 PDT 2013


From: Tom Stellard <thomas.stellard at amd.com>

Using a NULL value for the platform_id is legal according to the spec,
however, passing a NULL value as the platform parameter to
clGetPlatformInfo() results in implementation defined behavior.

In order to avoid implementation defined behavior some apps require that
the platfrom_id is non-NULL.  To statisfy this requirement, we just need
to hard-code clover's platform_id to something other than NULL.
---
 src/gallium/state_trackers/clover/api/platform.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/platform.cpp b/src/gallium/state_trackers/clover/api/platform.cpp
index f99b694..6457a4d 100644
--- a/src/gallium/state_trackers/clover/api/platform.cpp
+++ b/src/gallium/state_trackers/clover/api/platform.cpp
@@ -24,6 +24,8 @@
 
 using namespace clover;
 
+static cl_platform_id mesa_platform = (cl_platform_id)0xc1c1c1c1;
+
 PUBLIC cl_int
 clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms,
                  cl_uint *num_platforms) {
@@ -34,7 +36,7 @@ clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms,
    if (num_platforms)
       *num_platforms = 1;
    if (platforms)
-      *platforms = NULL;
+      *platforms = mesa_platform;
 
    return CL_SUCCESS;
 }
@@ -42,7 +44,7 @@ clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms,
 PUBLIC cl_int
 clGetPlatformInfo(cl_platform_id platform, cl_platform_info param_name,
                   size_t size, void *buf, size_t *size_ret) {
-   if (platform != NULL)
+   if (platform != mesa_platform)
       return CL_INVALID_PLATFORM;
 
    switch (param_name) {
-- 
1.7.11.4



More information about the mesa-dev mailing list