gallium/rbug: replace simple_list.h with list.h
authorDylan Baker <dylan.c.baker@intel.com>
Wed, 16 Feb 2022 22:45:43 +0000 (14:45 -0800)
committerDylan Baker <dylan.c.baker@intel.com>
Fri, 22 Apr 2022 16:39:43 +0000 (09:39 -0700)
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15418>

src/gallium/auxiliary/driver_rbug/rbug_context.c
src/gallium/auxiliary/driver_rbug/rbug_context.h
src/gallium/auxiliary/driver_rbug/rbug_core.c
src/gallium/auxiliary/driver_rbug/rbug_objects.c
src/gallium/auxiliary/driver_rbug/rbug_objects.h
src/gallium/auxiliary/driver_rbug/rbug_screen.c
src/gallium/auxiliary/driver_rbug/rbug_screen.h

index b0c283d..46d78ad 100644 (file)
@@ -29,7 +29,6 @@
 #include "pipe/p_context.h"
 #include "util/u_memory.h"
 #include "util/u_inlines.h"
-#include "util/simple_list.h"
 
 #include "rbug/rbug_context.h"
 
@@ -1287,7 +1286,7 @@ rbug_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    cnd_init(&rb_pipe->draw_cond);
    (void) mtx_init(&rb_pipe->call_mutex, mtx_plain);
    (void) mtx_init(&rb_pipe->list_mutex, mtx_plain);
-   make_empty_list(&rb_pipe->shaders);
+   list_inithead(&rb_pipe->shaders);
 
    rb_pipe->base.screen = _screen;
    rb_pipe->base.priv = pipe->priv; /* expose wrapped data */
index e89c6ea..0ec556b 100644 (file)
@@ -39,7 +39,7 @@ struct rbug_context {
 
    struct pipe_context *pipe;
 
-   struct rbug_list list;
+   struct list_head list;
 
    /* call locking */
    mtx_t call_mutex;
@@ -76,7 +76,7 @@ struct rbug_context {
    /* list of state objects */
    mtx_t list_mutex;
    unsigned num_shaders;
-   struct rbug_list shaders;
+   struct list_head shaders;
 };
 
 static inline struct rbug_context *
index aad4487..ac5262c 100644 (file)
@@ -31,7 +31,6 @@
 #include "util/u_string.h"
 #include "util/u_inlines.h"
 #include "util/u_memory.h"
-#include "util/simple_list.h"
 #include "util/u_network.h"
 #include "util/os_time.h"
 
@@ -67,11 +66,9 @@ rbug_thread(void *void_rbug);
 static struct rbug_context *
 rbug_get_context_locked(struct rbug_screen *rb_screen, rbug_context_t ctx)
 {
-   struct rbug_context *rb_context = NULL;
-   struct rbug_list *ptr;
+   struct rbug_context *rb_context;
 
-   foreach(ptr, &rb_screen->contexts) {
-      rb_context = container_of(ptr, struct rbug_context, list);
+   LIST_FOR_EACH_ENTRY(rb_context, &rb_screen->contexts, list) {
       if (ctx == VOID2U64(rb_context))
          break;
       rb_context = NULL;
@@ -83,11 +80,9 @@ rbug_get_context_locked(struct rbug_screen *rb_screen, rbug_context_t ctx)
 static struct rbug_shader *
 rbug_get_shader_locked(struct rbug_context *rb_context, rbug_shader_t shdr)
 {
-   struct rbug_shader *tr_shdr = NULL;
-   struct rbug_list *ptr;
+   struct rbug_shader *tr_shdr;
 
-   foreach(ptr, &rb_context->shaders) {
-      tr_shdr = container_of(ptr, struct rbug_shader, list);
+   LIST_FOR_EACH_ENTRY(tr_shdr, &rb_context->shaders, list) {
       if (shdr == VOID2U64(tr_shdr))
          break;
       tr_shdr = NULL;
@@ -175,15 +170,13 @@ static int
 rbug_texture_list(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
 {
    struct rbug_screen *rb_screen = tr_rbug->rb_screen;
-   struct rbug_resource *tr_tex = NULL;
-   struct rbug_list *ptr;
+   struct rbug_resource *tr_tex;
    rbug_texture_t *texs;
    int i = 0;
 
    mtx_lock(&rb_screen->list_mutex);
    texs = MALLOC(rb_screen->num_resources * sizeof(rbug_texture_t));
-   foreach(ptr, &rb_screen->resources) {
-      tr_tex = container_of(ptr, struct rbug_resource, list);
+   LIST_FOR_EACH_ENTRY(tr_tex, &rb_screen->resources, list) {
       texs[i++] = VOID2U64(tr_tex);
    }
    mtx_unlock(&rb_screen->list_mutex);
@@ -198,15 +191,13 @@ static int
 rbug_texture_info(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
 {
    struct rbug_screen *rb_screen = tr_rbug->rb_screen;
-   struct rbug_resource *tr_tex = NULL;
+   struct rbug_resource *tr_tex;
    struct rbug_proto_texture_info *gpti = (struct rbug_proto_texture_info *)header;
-   struct rbug_list *ptr;
    struct pipe_resource *t;
    uint16_t num_layers;
 
    mtx_lock(&rb_screen->list_mutex);
-   foreach(ptr, &rb_screen->resources) {
-      tr_tex = container_of(ptr, struct rbug_resource, list);
+   LIST_FOR_EACH_ENTRY(tr_tex, &rb_screen->resources, list) {
       if (gpti->texture == VOID2U64(tr_tex))
          break;
       tr_tex = NULL;
@@ -244,8 +235,7 @@ rbug_texture_read(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_
    struct rbug_proto_texture_read *gptr = (struct rbug_proto_texture_read *)header;
 
    struct rbug_screen *rb_screen = tr_rbug->rb_screen;
-   struct rbug_resource *tr_tex = NULL;
-   struct rbug_list *ptr;
+   struct rbug_resource *tr_tex;
 
    struct pipe_context *context = rb_screen->private_context;
    struct pipe_resource *tex;
@@ -254,8 +244,7 @@ rbug_texture_read(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_
    void *map;
 
    mtx_lock(&rb_screen->list_mutex);
-   foreach(ptr, &rb_screen->resources) {
-      tr_tex = container_of(ptr, struct rbug_resource, list);
+   LIST_FOR_EACH_ENTRY(tr_tex, &rb_screen->resources, list) {
       if (gptr->texture == VOID2U64(tr_tex))
          break;
       tr_tex = NULL;
@@ -294,15 +283,13 @@ static int
 rbug_context_list(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
 {
    struct rbug_screen *rb_screen = tr_rbug->rb_screen;
-   struct rbug_list *ptr;
-   struct rbug_context *rb_context = NULL;
+   struct rbug_context *rb_context, *next;
    rbug_context_t *ctxs;
    int i = 0;
 
    mtx_lock(&rb_screen->list_mutex);
    ctxs = MALLOC(rb_screen->num_contexts * sizeof(rbug_context_t));
-   foreach(ptr, &rb_screen->contexts) {
-      rb_context = container_of(ptr, struct rbug_context, list);
+   LIST_FOR_EACH_ENTRY_SAFE(rb_context, next, &rb_screen->contexts, list) {
       ctxs[i++] = VOID2U64(rb_context);
    }
    mtx_unlock(&rb_screen->list_mutex);
@@ -513,8 +500,7 @@ rbug_shader_list(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t
 
    struct rbug_screen *rb_screen = tr_rbug->rb_screen;
    struct rbug_context *rb_context = NULL;
-   struct rbug_shader *tr_shdr = NULL;
-   struct rbug_list *ptr;
+   struct rbug_shader *tr_shdr, *next;
    rbug_shader_t *shdrs;
    int i = 0;
 
@@ -528,8 +514,7 @@ rbug_shader_list(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t
 
    mtx_lock(&rb_context->list_mutex);
    shdrs = MALLOC(rb_context->num_shaders * sizeof(rbug_shader_t));
-   foreach(ptr, &rb_context->shaders) {
-      tr_shdr = container_of(ptr, struct rbug_shader, list);
+   LIST_FOR_EACH_ENTRY_SAFE(tr_shdr, next, &rb_context->shaders, list) {
       shdrs[i++] = VOID2U64(tr_shdr);
    }
 
index 09455cf..8d1bf86 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "util/u_inlines.h"
 #include "util/u_memory.h"
-#include "util/simple_list.h"
 
 #include "tgsi/tgsi_parse.h"
 
index 1a16eb4..32375a0 100644 (file)
@@ -43,7 +43,7 @@ struct rbug_resource
 
    struct pipe_resource *resource;
 
-   struct rbug_list list;
+   struct list_head list;
 };
 
 
@@ -56,7 +56,7 @@ enum rbug_shader_type
 
 struct rbug_shader
 {
-   struct rbug_list list;
+   struct list_head list;
 
    void *shader;
    void *tokens;
index 9ddb6df..3c78e6c 100644 (file)
@@ -30,7 +30,6 @@
 #include "pipe/p_state.h"
 #include "util/u_memory.h"
 #include "util/u_debug.h"
-#include "util/simple_list.h"
 
 #include "rbug_public.h"
 #include "rbug_screen.h"
@@ -452,10 +451,10 @@ rbug_screen_create(struct pipe_screen *screen)
       return screen;
 
    (void) mtx_init(&rb_screen->list_mutex, mtx_plain);
-   make_empty_list(&rb_screen->contexts);
-   make_empty_list(&rb_screen->resources);
-   make_empty_list(&rb_screen->surfaces);
-   make_empty_list(&rb_screen->transfers);
+   list_inithead(&rb_screen->contexts);
+   list_inithead(&rb_screen->resources);
+   list_inithead(&rb_screen->surfaces);
+   list_inithead(&rb_screen->transfers);
 
 #define SCR_INIT(_member) \
    rb_screen->base._member = screen->_member ? rbug_screen_##_member : NULL
index 1972005..bfa0e77 100644 (file)
 
 #include "pipe/p_screen.h"
 #include "pipe/p_defines.h"
+#include "util/list.h"
 
 #include "os/os_thread.h"
 
-struct rbug_list {
-   struct rbug_list *next;
-   struct rbug_list *prev;
-};
-
 
 struct rbug_screen
 {
@@ -54,10 +50,10 @@ struct rbug_screen
    int num_resources;
    int num_surfaces;
    int num_transfers;
-   struct rbug_list contexts;
-   struct rbug_list resources;
-   struct rbug_list surfaces;
-   struct rbug_list transfers;
+   struct list_head contexts;
+   struct list_head resources;
+   struct list_head surfaces;
+   struct list_head transfers;
 };
 
 static inline struct rbug_screen *
@@ -69,7 +65,7 @@ rbug_screen(struct pipe_screen *screen)
 #define rbug_screen_add_to_list(scr, name, obj) \
    do {                                          \
       mtx_lock(&scr->list_mutex);          \
-      insert_at_head(&scr->name, &obj->list);    \
+      list_add(&scr->name, &obj->list);    \
       scr->num_##name++;                         \
       mtx_unlock(&scr->list_mutex);        \
    } while (0)
@@ -77,7 +73,7 @@ rbug_screen(struct pipe_screen *screen)
 #define rbug_screen_remove_from_list(scr, name, obj) \
    do {                                               \
       mtx_lock(&scr->list_mutex);               \
-      remove_from_list(&obj->list);                   \
+      list_del(&obj->list);                   \
       scr->num_##name--;                              \
       mtx_unlock(&scr->list_mutex);             \
    } while (0)