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.11+e6b503e/src/cl_device_id.c
===================================================================
--- beignet-0.0.0+git2013.04.11+e6b503e.orig/src/cl_device_id.c	2013-04-12 08:13:48.000000000 +0200
+++ beignet-0.0.0+git2013.04.11+e6b503e/src/cl_device_id.c	2013-04-15 18:34:02.220354446 +0200
@@ -131,21 +131,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;
 
@@ -282,8 +286,6 @@
   if (UNLIKELY(device != &intel_ivb_gt1_device &&
                device != &intel_ivb_gt2_device))
     return CL_INVALID_DEVICE;
-  if (UNLIKELY(param_value == NULL))
-    return CL_INVALID_VALUE;
 
   switch (param_name) {
     DECL_FIELD(WORK_GROUP_SIZE, wg_sz)
