util: Move gallium's linked list to util
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 28 Apr 2015 00:41:27 +0000 (17:41 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 9 May 2015 00:16:13 +0000 (17:16 -0700)
The linked list in gallium is pretty much the kernel list and we would like
to have a C-based linked list for all of mesa.  Let's not duplicate and
just steal the gallium one.

Acked-by: Connor Abbott <cwabbott0@gmail.com>
Reviewed-by: Rob Clark <robclark@freedesktop.org>
45 files changed:
src/gallium/auxiliary/Makefile.sources
src/gallium/auxiliary/hud/hud_private.h
src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
src/gallium/auxiliary/util/u_debug_flush.c
src/gallium/auxiliary/util/u_debug_memory.c
src/gallium/auxiliary/util/u_dirty_surfaces.h
src/gallium/auxiliary/util/u_double_list.h [deleted file]
src/gallium/drivers/freedreno/freedreno_context.h
src/gallium/drivers/freedreno/freedreno_query_hw.h
src/gallium/drivers/freedreno/freedreno_resource.h
src/gallium/drivers/ilo/core/ilo_core.h
src/gallium/drivers/nouveau/nouveau_buffer.h
src/gallium/drivers/nouveau/nouveau_fence.c
src/gallium/drivers/nouveau/nouveau_fence.h
src/gallium/drivers/nouveau/nouveau_mm.c
src/gallium/drivers/nouveau/nv30/nv30_screen.h
src/gallium/drivers/nouveau/nv50/nv50_resource.h
src/gallium/drivers/r600/compute_memory_pool.c
src/gallium/drivers/r600/evergreen_compute.c
src/gallium/drivers/r600/r600_llvm.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeon/radeon_vce.h
src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_resource_buffer.h
src/gallium/drivers/svga/svga_resource_buffer_upload.c
src/gallium/drivers/svga/svga_screen_cache.h
src/gallium/state_trackers/nine/basetexture9.h
src/gallium/state_trackers/nine/device9.h
src/gallium/state_trackers/nine/nine_state.h
src/gallium/state_trackers/nine/surface9.h
src/gallium/state_trackers/omx/vid_dec.h
src/gallium/state_trackers/omx/vid_enc.h
src/gallium/winsys/radeon/drm/radeon_drm_bo.c
src/gallium/winsys/svga/drm/pb_buffer_simple_fenced.c
src/gallium/winsys/svga/drm/vmw_fence.c
src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
src/mesa/state_tracker/st_cb_perfmon.h
src/util/Makefile.sources
src/util/list.h [new file with mode: 0644]

index ec7547cad994b118ebdd7e4807978ba7621e4832..62e6b94cab84ab3faacef466b11e72387f3e74a1 100644 (file)
@@ -197,7 +197,6 @@ C_SOURCES := \
        util/u_dirty_surfaces.h \
        util/u_dl.c \
        util/u_dl.h \
-       util/u_double_list.h \
        util/u_draw.c \
        util/u_draw.h \
        util/u_draw_quad.c \
index 230f0266445934eebf2139fd2be88cfa3eaaa3e5..632926b87f56c6cc3f2cd3d27b5762c4e5a1fbbf 100644 (file)
@@ -29,7 +29,7 @@
 #define HUD_PRIVATE_H
 
 #include "pipe/p_context.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 struct hud_graph {
    /* initialized by common code */
index 0d1b4b3426a64d8216fae8b2af35ce4c3bdca4f2..3bd9cd70ae37280251f46d49fc123331a9e6126b 100644 (file)
@@ -46,7 +46,7 @@
 #include "util/u_debug.h"
 #include "os/os_thread.h"
 #include "util/u_memory.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 #include "pb_buffer.h"
 #include "pb_buffer_fenced.h"
index 5eb8d06a09186e10a59e5b11e89946163178b693..5023687ec04d037f142eb5b50f75ab7b81751c52 100644 (file)
@@ -38,7 +38,7 @@
 #include "util/u_debug.h"
 #include "os/os_thread.h"
 #include "util/u_memory.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_time.h"
 
 #include "pb_buffer.h"
index e5d81182918410452e06a031a0df3c4efa5b1550..6236afb70d121ef046f165b7cd6bd7011e8bbf75 100644 (file)
@@ -38,7 +38,7 @@
 #include "os/os_thread.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_time.h"
 #include "util/u_debug_stack.h"
 
index aa989073324c7337b8f1637e59921d79d2a4b7fc..84eb6edda3450871456a08fc7943586a4b2c0eaa 100644 (file)
@@ -37,7 +37,7 @@
 #include "util/u_debug.h"
 #include "os/os_thread.h"
 #include "util/u_memory.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_mm.h"
 #include "pb_buffer.h"
 #include "pb_bufmgr.h"
index f2ff2d8aab7ea041f0c4ec124d9b39148f21f2c4..51525b0f97cdb4080f634753a72d24a2dc271ddf 100644 (file)
@@ -40,7 +40,7 @@
 #include "os/os_thread.h"
 #include "pipe/p_defines.h"
 #include "util/u_memory.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 #include "pb_buffer.h"
 #include "pb_bufmgr.h"
index 00a1deea430e65689845c468c2dc51a438c6600c..6a62b4f5fdb85d143b7befa31c44eb7dc5468b35 100644 (file)
@@ -41,7 +41,7 @@
 #include "os/os_thread.h"
 #include "pipe/p_defines.h"
 #include "util/u_memory.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_time.h"
 
 #include "pb_buffer.h"
index cdefca2fb11b3b0c674f651a8e63011b10408f4c..52e72cd6d88579ef70b7ac83a945370de7aba626 100644 (file)
@@ -44,7 +44,7 @@
 #include "util/u_memory.h"
 #include "util/u_debug_flush.h"
 #include "util/u_hash_table.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_inlines.h"
 #include "util/u_string.h"
 #include "os/os_thread.h"
index 1ad0e72208c72f26d1c355d766f859d718893ebc..747837cd14876d9cdf5534a6f13deb70e37701f4 100644 (file)
@@ -42,7 +42,7 @@
 
 #include "util/u_debug.h" 
 #include "util/u_debug_stack.h" 
-#include "util/u_double_list.h" 
+#include "util/list.h"
 
 
 #define DEBUG_MEMORY_MAGIC 0x6e34090aU 
index f3618d9be74b080cad2209e44c8adf4d76ff4b33..d31f8b9170a306f53265316802dc1f988d0036d7 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "pipe/p_state.h"
 
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_math.h"
 
 struct pipe_context;
diff --git a/src/gallium/auxiliary/util/u_double_list.h b/src/gallium/auxiliary/util/u_double_list.h
deleted file mode 100644 (file)
index e808333..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 VMware, Inc., Bismarck, ND. USA.
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- **************************************************************************/
-
-/**
- * \file
- * List macros heavily inspired by the Linux kernel
- * list handling. No list looping yet.
- * 
- * Is not threadsafe, so common operations need to
- * be protected using an external mutex.
- */
-
-#ifndef _U_DOUBLE_LIST_H_
-#define _U_DOUBLE_LIST_H_
-
-
-#include <stddef.h>
-
-
-struct list_head
-{
-    struct list_head *prev;
-    struct list_head *next;
-};
-
-static inline void list_inithead(struct list_head *item)
-{
-    item->prev = item;
-    item->next = item;
-}
-
-static inline void list_add(struct list_head *item, struct list_head *list)
-{
-    item->prev = list;
-    item->next = list->next;
-    list->next->prev = item;
-    list->next = item;
-}
-
-static inline void list_addtail(struct list_head *item, struct list_head *list)
-{
-    item->next = list;
-    item->prev = list->prev;
-    list->prev->next = item;
-    list->prev = item;
-}
-
-static inline void list_replace(struct list_head *from, struct list_head *to)
-{
-    to->prev = from->prev;
-    to->next = from->next;
-    from->next->prev = to;
-    from->prev->next = to;
-}
-
-static inline void list_del(struct list_head *item)
-{
-    item->prev->next = item->next;
-    item->next->prev = item->prev;
-    item->prev = item->next = NULL;
-}
-
-static inline void list_delinit(struct list_head *item)
-{
-    item->prev->next = item->next;
-    item->next->prev = item->prev;
-    item->next = item;
-    item->prev = item;
-}
-
-#define LIST_INITHEAD(__item) list_inithead(__item)
-#define LIST_ADD(__item, __list) list_add(__item, __list)
-#define LIST_ADDTAIL(__item, __list) list_addtail(__item, __list)
-#define LIST_REPLACE(__from, __to) list_replace(__from, __to)
-#define LIST_DEL(__item) list_del(__item)
-#define LIST_DELINIT(__item) list_delinit(__item)
-
-#define LIST_ENTRY(__type, __item, __field)   \
-    ((__type *)(((char *)(__item)) - offsetof(__type, __field)))
-
-#define LIST_IS_EMPTY(__list)                   \
-    ((__list)->next == (__list))
-
-/**
- * Cast from a pointer to a member of a struct back to the containing struct.
- *
- * 'sample' MUST be initialized, or else the result is undefined!
- */
-#ifndef container_of
-#define container_of(ptr, sample, member)                              \
-    (void *)((char *)(ptr)                                             \
-            - ((char *)&(sample)->member - (char *)(sample)))
-#endif
-
-#define LIST_FOR_EACH_ENTRY(pos, head, member)                         \
-   for (pos = NULL, pos = container_of((head)->next, pos, member);     \
-       &pos->member != (head);                                         \
-       pos = container_of(pos->member.next, pos, member))
-
-#define LIST_FOR_EACH_ENTRY_SAFE(pos, storage, head, member)   \
-   for (pos = NULL, pos = container_of((head)->next, pos, member),     \
-       storage = container_of(pos->member.next, pos, member);  \
-       &pos->member != (head);                                         \
-       pos = storage, storage = container_of(storage->member.next, storage, member))
-
-#define LIST_FOR_EACH_ENTRY_SAFE_REV(pos, storage, head, member)       \
-   for (pos = NULL, pos = container_of((head)->prev, pos, member),     \
-       storage = container_of(pos->member.prev, pos, member);          \
-       &pos->member != (head);                                         \
-       pos = storage, storage = container_of(storage->member.prev, storage, member))
-
-#define LIST_FOR_EACH_ENTRY_FROM(pos, start, head, member)             \
-   for (pos = NULL, pos = container_of((start), pos, member);          \
-       &pos->member != (head);                                         \
-       pos = container_of(pos->member.next, pos, member))
-
-#define LIST_FOR_EACH_ENTRY_FROM_REV(pos, start, head, member)         \
-   for (pos = NULL, pos = container_of((start), pos, member);          \
-       &pos->member != (head);                                         \
-       pos = container_of(pos->member.prev, pos, member))
-
-#endif /*_U_DOUBLE_LIST_H_*/
index e6a5f01d4129c0867f4758ef9b8b55aaa5747a3b..2c816b4b1f649371299826a021b873df0f88580a 100644 (file)
@@ -32,7 +32,7 @@
 #include "pipe/p_context.h"
 #include "indices/u_primconvert.h"
 #include "util/u_blitter.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_slab.h"
 #include "util/u_string.h"
 
index 62baa3ac5b507967b28344f92fdfd5877411992a..8f4b1f58ee53beb37a3a48a4e9b3768923d1e374 100644 (file)
@@ -29,7 +29,7 @@
 #ifndef FREEDRENO_QUERY_HW_H_
 #define FREEDRENO_QUERY_HW_H_
 
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 #include "freedreno_query.h"
 #include "freedreno_context.h"
index fdf3b8c7d7a6325b78bf712662d4195e5c11d8a7..0634923fcb2675e89373a8a9444ac4fec384e548 100644 (file)
@@ -29,7 +29,7 @@
 #ifndef FREEDRENO_RESOURCE_H_
 #define FREEDRENO_RESOURCE_H_
 
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_range.h"
 #include "util/u_transfer.h"
 
index 1db8c4bf4fd4c75f0c69d917c8b04b23cf3c3e0d..3587d3930f3757feb15612507aa2c5ccd71b277d 100644 (file)
@@ -33,7 +33,7 @@
 #include "pipe/p_format.h"
 
 #include "util/u_debug.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_format.h"
 #include "util/u_inlines.h"
 #include "util/u_math.h"
index f881adc80d93ed8f5bd44fc38a06e945a2953a0c..de77f481da392f146f11b5824b6123f4af0838c0 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "util/u_range.h"
 #include "util/u_transfer.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 struct pipe_resource;
 struct nouveau_context;
index a9448a4c721c4bb70fce0ce46ef09a05e9d12144..17a5174594d862a0e462a9aceafc82d63d0571a9 100644 (file)
@@ -20,8 +20,6 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#include "util/u_double_list.h"
-
 #include "nouveau_screen.h"
 #include "nouveau_winsys.h"
 #include "nouveau_fence.h"
index 3984a9a942d213c9a5986f151750e1072d2f5c46..7bb132a5d15c1487e4c41b120c616a6d06941607 100644 (file)
@@ -3,7 +3,7 @@
 #define __NOUVEAU_FENCE_H__
 
 #include "util/u_inlines.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 #define NOUVEAU_FENCE_STATE_AVAILABLE 0
 #define NOUVEAU_FENCE_STATE_EMITTING  1
index 87f2f460a9d0f9385778d3771870fd7105140d15..9c454c56db013e7c091198c608ccd049f664a7ea 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "util/u_inlines.h"
 #include "util/u_memory.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 #include "nouveau_winsys.h"
 #include "nouveau_screen.h"
index 0b3bbbbb9d8062958f22eebc788fa80303ec4e8d..3f2e47fec996628b5eb836201ce1fc1b856ea4d2 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <stdio.h>
 
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 #include "nouveau_debug.h"
 #include "nouveau_screen.h"
index 36d70d812f1c84a6537b4c5334f7ada2a4c11736..f7ee1354a92c21764c0f6cbd94f0fb3dc47b6f10 100644 (file)
@@ -3,7 +3,7 @@
 #define __NV50_RESOURCE_H__
 
 #include "util/u_transfer.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 #include "nouveau_winsys.h"
 #include "nouveau_buffer.h"
index 30b77a4ae89a5422758b50d60ad01f92a5b2d4e7..413aa3d7c59b6eb64f67711dbe803475f34af4dd 100644 (file)
@@ -26,7 +26,7 @@
 #include "pipe/p_state.h"
 #include "pipe/p_context.h"
 #include "util/u_blitter.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_transfer.h"
 #include "util/u_surface.h"
 #include "util/u_pack_color.h"
index 90fdd79ab96a3d8df0016657a89ff75232bb24e1..4c3c34cd6642ef42b4cf0fb03fa464fd67e5b491 100644 (file)
@@ -30,7 +30,7 @@
 #include "pipe/p_state.h"
 #include "pipe/p_context.h"
 #include "util/u_blitter.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_transfer.h"
 #include "util/u_surface.h"
 #include "util/u_pack_color.h"
index af4604435a3bed498f66be0364185ee0b61da661..72e2dc42f7ebdb65b983dc9cf7a74dd83a76c353 100644 (file)
@@ -4,7 +4,7 @@
 #include "gallivm/lp_bld_intr.h"
 #include "gallivm/lp_bld_gather.h"
 #include "tgsi/tgsi_parse.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_memory.h"
 
 #include "evergreend.h"
index ac698950434730a1860c33bf31d2b4aa6e1f2f54..4ea270d3839630e078014cf06320c170a069d702 100644 (file)
@@ -33,7 +33,7 @@
 #include "r600_public.h"
 
 #include "util/u_suballoc.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_transfer.h"
 
 #define R600_NUM_ATOMS 73
index 8d885ab9836e02669f49ab8bb0e2ff14093d6ceb..6ce81d33ddd087fbf03bd5e6a884fdb4f4ccb2a5 100644 (file)
@@ -37,7 +37,7 @@
 #include "radeon/radeon_winsys.h"
 
 #include "util/u_blitter.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_range.h"
 #include "util/u_slab.h"
 #include "util/u_suballoc.h"
index 5c6317a972ff791105c45eba40e04cee9c004a88..1cf018006a887cd013f26488c519d5df59502fda 100644 (file)
@@ -34,7 +34,7 @@
 #ifndef RADEON_VCE_H
 #define RADEON_VCE_H
 
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 #define RVCE_RELOC(buf, usage, domain) (enc->ws->cs_add_reloc(enc->cs, (buf), (usage), domain, RADEON_PRIO_MIN))
 
index a75f2a8b570100cd3328d0e5c1914768d5702b16..630f5f77d66f73716f480a81719964071b67f996 100644 (file)
@@ -32,7 +32,7 @@
 #include "pipe/p_state.h"
 
 #include "util/u_blitter.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 #include "tgsi/tgsi_scan.h"
 
index 36467cfdfdffafec7a43880747bc51d9f9498e4d..83b3d342aec2d42e1ba4b711b90bb9adfdc35e9b 100644 (file)
@@ -31,8 +31,6 @@
 #include "pipe/p_state.h"
 #include "util/u_transfer.h"
 
-#include "util/u_double_list.h"
-
 #include "svga_screen_cache.h"
 #include "svga_screen.h"
 #include "svga_cmd.h"
index 3fc14f83c11d3a5d9415dec16c7ba8cf9b72b54f..5686531f988faebf5614ffeff5b0a52023ece32b 100644 (file)
@@ -30,7 +30,6 @@
 #include "util/u_inlines.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
-#include "util/u_double_list.h"
 
 #include "svga_cmd.h"
 #include "svga_context.h"
index 96e1e9c52e28496beb218c5ac797b9cf7e3fe991..56ac62b39c1cfa58e6f31503eddbf9376a77e8b8 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "os/os_thread.h"
 
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 
 /* Guess the storage size of cached surfaces and try and keep it under
index 7a091bf2578c42e082da1a3d07551b8fd65f0dcb..c803280decd59f35fd9215b404f4e26f83bb350a 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "resource9.h"
 #include "util/u_inlines.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 struct NineBaseTexture9
 {
index d662f839d88761e61e73bdc648ec5fb9a63e8519..c66a273bf2e88b99da8c35975cf143da38d0a767 100644 (file)
@@ -42,7 +42,7 @@ struct u_upload_mgr;
 struct NineSwapChain9;
 struct NineStateBlock9;
 
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 struct NineDevice9
 {
index 191695953388206286cf67889bbc6cf0915c59d6..2bf3f637f931177720a7578df7315382184f2cca 100644 (file)
@@ -26,7 +26,7 @@
 #include "d3d9.h"
 #include "nine_defines.h"
 #include "pipe/p_state.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 #define NINED3DSAMP_MINLOD (D3DSAMP_DMAPOFFSET + 1)
 #define NINED3DSAMP_SHADOW (D3DSAMP_DMAPOFFSET + 2)
index 0e527fe003afe601160df1313a1c3d2c860966a2..2e409558609d87c5366a3888ce9cf0a876bdc1a1 100644 (file)
@@ -26,7 +26,7 @@
 #include "resource9.h"
 
 #include "pipe/p_state.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "util/u_rect.h"
 #include "util/u_inlines.h"
 
index 1c51f9c6d78be3de6ab331a42b3eae3c679109e7..3b39826b8a7c597bbf639c04f4f01db5b1e13742 100644 (file)
@@ -49,7 +49,7 @@
 #include "pipe/p_video_state.h"
 #include "state_tracker/drm_driver.h"
 #include "os/os_thread.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 #define OMX_VID_DEC_BASE_NAME "OMX.mesa.video_decoder"
 
index ca6ee910dc712e5ffc7fb7b9eafea475b66c93ec..c8d192b9c60010a01ff2e0dc6f0173cd81d617f3 100644 (file)
@@ -41,7 +41,7 @@
 #include <bellagio/st_static_component_loader.h>
 #include <bellagio/omx_base_filter.h>
 
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 #include "vl/vl_defines.h"
 #include "vl/vl_compositor.h"
index 061c814ae61b0cc6b17989231ca3358dd6daca1f..fe98870967a1ee87478d0fd95ccbc43c689b07c4 100644 (file)
@@ -29,7 +29,7 @@
 #include "util/u_hash_table.h"
 #include "util/u_memory.h"
 #include "util/simple_list.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "os/os_thread.h"
 #include "os/os_mman.h"
 #include "os/os_time.h"
index b17dabc6ce56e353609697786d403e5d9f04ecd1..fceb089705809776860b8b2ff864c8cb706a6ec3 100644 (file)
@@ -46,7 +46,7 @@
 #include "util/u_debug.h"
 #include "os/os_thread.h"
 #include "util/u_memory.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 #include "pipebuffer/pb_buffer.h"
 #include "pipebuffer/pb_bufmgr.h"
index 8af2250b7ea67029083ccc551a7ca8ac8efb0431..1b24239a7ce98e0267526f723d98d651519d1d25 100644 (file)
@@ -24,7 +24,7 @@
  **********************************************************/
 #include "util/u_memory.h"
 #include "util/u_atomic.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 #include "os/os_thread.h"
 
 #include "pipebuffer/pb_buffer_fenced.h"
index e61a1732387fa2168fc720d7d097d9f5d6ebb213..740b920114040f7d0cb4f9cdc80d4c487ad71c98 100644 (file)
@@ -47,7 +47,7 @@
 #include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 #include "state_tracker/sw_winsys.h"
 #include "state_tracker/drm_driver.h"
index 4902abcf4701710c87fba46233bb00e9888d2cb3..13d3627de5dcce203d02bc5309679372c8eef98c 100644 (file)
@@ -24,7 +24,7 @@
 #ifndef ST_CB_PERFMON_H
 #define ST_CB_PERFMON_H
 
-#include "util/u_double_list.h"
+#include "util/list.h"
 
 /**
  * Subclass of gl_perf_monitor_object
index 3e0d02bad1e651d90aa51798dcfd234a91e0e14b..dc559391823282756949cb5f5ef4bfb1fd65eadf 100644 (file)
@@ -7,6 +7,7 @@ MESA_UTIL_FILES :=      \
        format_srgb.h \
        hash_table.c    \
        hash_table.h \
+       list.h \
        macros.h \
        ralloc.c \
        ralloc.h \
diff --git a/src/util/list.h b/src/util/list.h
new file mode 100644 (file)
index 0000000..191030c
--- /dev/null
@@ -0,0 +1,146 @@
+/**************************************************************************
+ *
+ * Copyright 2006 VMware, Inc., Bismarck, ND. USA.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ **************************************************************************/
+
+/**
+ * \file
+ * List macros heavily inspired by the Linux kernel
+ * list handling. No list looping yet.
+ *
+ * Is not threadsafe, so common operations need to
+ * be protected using an external mutex.
+ */
+
+#ifndef _UTIL_LIST_H_
+#define _UTIL_LIST_H_
+
+
+#include <stddef.h>
+
+
+struct list_head
+{
+    struct list_head *prev;
+    struct list_head *next;
+};
+
+static inline void list_inithead(struct list_head *item)
+{
+    item->prev = item;
+    item->next = item;
+}
+
+static inline void list_add(struct list_head *item, struct list_head *list)
+{
+    item->prev = list;
+    item->next = list->next;
+    list->next->prev = item;
+    list->next = item;
+}
+
+static inline void list_addtail(struct list_head *item, struct list_head *list)
+{
+    item->next = list;
+    item->prev = list->prev;
+    list->prev->next = item;
+    list->prev = item;
+}
+
+static inline void list_replace(struct list_head *from, struct list_head *to)
+{
+    to->prev = from->prev;
+    to->next = from->next;
+    from->next->prev = to;
+    from->prev->next = to;
+}
+
+static inline void list_del(struct list_head *item)
+{
+    item->prev->next = item->next;
+    item->next->prev = item->prev;
+    item->prev = item->next = NULL;
+}
+
+static inline void list_delinit(struct list_head *item)
+{
+    item->prev->next = item->next;
+    item->next->prev = item->prev;
+    item->next = item;
+    item->prev = item;
+}
+
+#define LIST_INITHEAD(__item) list_inithead(__item)
+#define LIST_ADD(__item, __list) list_add(__item, __list)
+#define LIST_ADDTAIL(__item, __list) list_addtail(__item, __list)
+#define LIST_REPLACE(__from, __to) list_replace(__from, __to)
+#define LIST_DEL(__item) list_del(__item)
+#define LIST_DELINIT(__item) list_delinit(__item)
+
+#define LIST_ENTRY(__type, __item, __field)   \
+    ((__type *)(((char *)(__item)) - offsetof(__type, __field)))
+
+#define LIST_IS_EMPTY(__list)                   \
+    ((__list)->next == (__list))
+
+/**
+ * Cast from a pointer to a member of a struct back to the containing struct.
+ *
+ * 'sample' MUST be initialized, or else the result is undefined!
+ */
+#ifndef container_of
+#define container_of(ptr, sample, member)                              \
+    (void *)((char *)(ptr)                                             \
+            - ((char *)&(sample)->member - (char *)(sample)))
+#endif
+
+#define LIST_FOR_EACH_ENTRY(pos, head, member)                         \
+   for (pos = NULL, pos = container_of((head)->next, pos, member);     \
+       &pos->member != (head);                                         \
+       pos = container_of(pos->member.next, pos, member))
+
+#define LIST_FOR_EACH_ENTRY_SAFE(pos, storage, head, member)   \
+   for (pos = NULL, pos = container_of((head)->next, pos, member),     \
+       storage = container_of(pos->member.next, pos, member);  \
+       &pos->member != (head);                                         \
+       pos = storage, storage = container_of(storage->member.next, storage, member))
+
+#define LIST_FOR_EACH_ENTRY_SAFE_REV(pos, storage, head, member)       \
+   for (pos = NULL, pos = container_of((head)->prev, pos, member),     \
+       storage = container_of(pos->member.prev, pos, member);          \
+       &pos->member != (head);                                         \
+       pos = storage, storage = container_of(storage->member.prev, storage, member))
+
+#define LIST_FOR_EACH_ENTRY_FROM(pos, start, head, member)             \
+   for (pos = NULL, pos = container_of((start), pos, member);          \
+       &pos->member != (head);                                         \
+       pos = container_of(pos->member.next, pos, member))
+
+#define LIST_FOR_EACH_ENTRY_FROM_REV(pos, start, head, member)         \
+   for (pos = NULL, pos = container_of((start), pos, member);          \
+       &pos->member != (head);                                         \
+       pos = container_of(pos->member.prev, pos, member))
+
+#endif /*_UTIL_LIST_H_*/