vulkan/util: Get rid of VK_OUTARRAY_MAKE()
authorBoris Brezillon <boris.brezillon@collabora.com>
Wed, 23 Mar 2022 13:09:50 +0000 (14:09 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 25 Mar 2022 11:00:03 +0000 (11:00 +0000)
Get rid of VK_OUTARRAY_MAKE() so people don't get tempted to
use it and produce code that doesn't compile with MSVC, which
doesn't support typeof().

Suggested-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15522>

src/vulkan/util/vk_util.h

index 386e9e4..9c7ce6c 100644 (file)
@@ -58,15 +58,16 @@ extern "C" {
  *       uint32_t*                  pQueueFamilyPropertyCount,
  *       VkQueueFamilyProperties*   pQueueFamilyProperties)
  *    {
- *       VK_OUTARRAY_MAKE(props, pQueueFamilyProperties,
- *                         pQueueFamilyPropertyCount);
+ *       VK_OUTARRAY_MAKE_TYPED(VkQueueFamilyProperties, props,
+ *                              pQueueFamilyProperties,
+ *                              pQueueFamilyPropertyCount);
  *
- *       vk_outarray_append(&props, p) {
+ *       vk_outarray_append_typed(VkQueueFamilyProperties, &props, p) {
  *          p->queueFlags = ...;
  *          p->queueCount = ...;
  *       }
  *
- *       vk_outarray_append(&props, p) {
+ *       vk_outarray_append_typed(VkQueueFamilyProperties, &props, p) {
  *          p->queueFlags = ...;
  *          p->queueCount = ...;
  *       }
@@ -151,8 +152,6 @@ __vk_outarray_next(struct __vk_outarray *a, size_t elem_size)
 #define vk_outarray_init(a, data, len) \
    __vk_outarray_init(&(a)->base, (data), (len))
 
-#define VK_OUTARRAY_MAKE(name, data, len) \
-   VK_OUTARRAY_MAKE_TYPED(__typeof__((data)[0]), name, data, len)
 #define VK_OUTARRAY_MAKE_TYPED(type, name, data, len) \
    vk_outarray(type) name; \
    vk_outarray_init(&name, (data), (len))
@@ -171,13 +170,13 @@ __vk_outarray_next(struct __vk_outarray *a, size_t elem_size)
  *
  * This is a block-based macro. For example:
  *
- *    vk_outarray_append(&a, elem) {
+ *    vk_outarray_append_typed(T, &a, elem) {
  *       elem->foo = ...;
  *       elem->bar = ...;
  *    }
  *
  * The array `a` has type `vk_outarray(elem_t) *`. It is usually declared with
- * VK_OUTARRAY_MAKE(). The variable `elem` is block-scoped and has type
+ * VK_OUTARRAY_MAKE_TYPED(). The variable `elem` is block-scoped and has type
  * `elem_t *`.
  *
  * The macro unconditionally increments the array's `wanted_len`. If the array
@@ -185,8 +184,6 @@ __vk_outarray_next(struct __vk_outarray *a, size_t elem_size)
  * executes the block. When the block is executed, `elem` is non-null and
  * points to the newly appended element.
  */
-#define vk_outarray_append(a, elem) \
-   vk_outarray_append_typed(vk_outarray_typeof_elem(a), a, elem)
 #define vk_outarray_append_typed(type, a, elem) \
    for (type *elem = vk_outarray_next_typed(type, a); \
         elem != NULL; elem = NULL)