commit ab7af52f7e9cd4d6b5a7f1fce4552c3e97b49099
Author: Simon Richter <Simon.Richter@hogyros.de>
Date:   Thu Apr 11 13:59:30 2013 +0200

    Allow size queries in device_id accessors
    
    Query functions with variable output length can be called with an output
    buffer length and address of zero to find out the number of elements
    available.

Index: beignet-0.0.0+git2013.04.01+d1b234c/src/cl_device_id.c
===================================================================
--- beignet-0.0.0+git2013.04.01+d1b234c.orig/src/cl_device_id.c	2013-04-11 14:38:02.730759888 +0200
+++ beignet-0.0.0+git2013.04.01+d1b234c/src/cl_device_id.c	2013-04-11 14:38:25.486758873 +0200
@@ -128,21 +128,25 @@
 
 #define DECL_FIELD(CASE,FIELD)                                      \
   case JOIN(CL_DEVICE_,CASE):                                       \
-      if (param_value_size < sizeof(((cl_device_id)NULL)->FIELD))   \
-        return CL_INVALID_VALUE;                                    \
       if (param_value_size_ret != NULL)                             \
         *param_value_size_ret = sizeof(((cl_device_id)NULL)->FIELD);\
+      if (param_value == NULL)                                      \
+        return CL_SUCCESS;                                          \
+      if (param_value_size < sizeof(((cl_device_id)NULL)->FIELD))   \
+        return CL_INVALID_VALUE;                                    \
       memcpy(param_value,                                           \
              &device->FIELD,                                        \
              sizeof(((cl_device_id)NULL)->FIELD));                  \
-        return CL_SUCCESS;
+      return CL_SUCCESS;
 
 #define DECL_STRING_FIELD(CASE,FIELD)                               \
   case JOIN(CL_DEVICE_,CASE):                                       \
-    if (param_value_size < device->JOIN(FIELD,_sz))                 \
-      return CL_INVALID_VALUE;                                      \
     if (param_value_size_ret != NULL)                               \
       *param_value_size_ret = device->JOIN(FIELD,_sz);              \
+    if (param_value == NULL)                                        \
+      return CL_SUCCESS;                                            \
+    if (param_value_size < device->JOIN(FIELD,_sz))                 \
+      return CL_INVALID_VALUE;                                      \
     memcpy(param_value, device->FIELD, device->JOIN(FIELD,_sz));    \
     return CL_SUCCESS;
 
@@ -157,8 +161,6 @@
                device != &intel_ivb_gt2_device &&
                device != &intel_hsw_device))
     return CL_INVALID_DEVICE;
-  if (UNLIKELY(param_value == NULL))
-    return CL_INVALID_VALUE;
 
   /* Find the correct parameter */
   switch (param_name) {
