gallium: Remove unused util_ringbuffer
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Wed, 12 Jun 2019 23:14:52 +0000 (16:14 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Mon, 17 Jun 2019 20:02:44 +0000 (13:02 -0700)
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/auxiliary/Makefile.sources
src/gallium/auxiliary/meson.build
src/gallium/auxiliary/util/u_ringbuffer.c [deleted file]
src/gallium/auxiliary/util/u_ringbuffer.h [deleted file]

index f9c0b5360269461e4703166c2200186c134173f7..e9ef327fdcc9f8ad106c18a67616b25d19f30ac2 100644 (file)
@@ -301,8 +301,6 @@ C_SOURCES := \
        util/u_rect.h \
        util/u_resource.c \
        util/u_resource.h \
-       util/u_ringbuffer.c \
-       util/u_ringbuffer.h \
        util/u_sampler.c \
        util/u_sampler.h \
        util/u_screen.c \
index 1b8d32d128b3d619ecd7e7bca2877d2a12e79077..4a0f69845e9d4eea9e743286b10eb3e8cbcf12fd 100644 (file)
@@ -321,8 +321,6 @@ files_libgallium = files(
   'util/u_rect.h',
   'util/u_resource.c',
   'util/u_resource.h',
-  'util/u_ringbuffer.c',
-  'util/u_ringbuffer.h',
   'util/u_sampler.c',
   'util/u_sampler.h',
   'util/u_screen.c',
diff --git a/src/gallium/auxiliary/util/u_ringbuffer.c b/src/gallium/auxiliary/util/u_ringbuffer.c
deleted file mode 100644 (file)
index f6bb910..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-
-#include "os/os_thread.h"
-#include "pipe/p_defines.h"
-#include "util/u_ringbuffer.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-
-/* Generic ringbuffer: 
- */
-struct util_ringbuffer 
-{
-   struct util_packet *buf;
-   unsigned mask;
-
-   /* Can this be done with atomic variables??
-    */
-   unsigned head;
-   unsigned tail;
-   cnd_t change;
-   mtx_t mutex;
-};
-
-
-struct util_ringbuffer *util_ringbuffer_create( unsigned dwords )
-{
-   struct util_ringbuffer *ring = CALLOC_STRUCT(util_ringbuffer);
-   if (!ring)
-      return NULL;
-
-   assert(util_is_power_of_two_or_zero(dwords));
-   
-   ring->buf = MALLOC( dwords * sizeof(unsigned) );
-   if (ring->buf == NULL)
-      goto fail;
-
-   ring->mask = dwords - 1;
-
-   cnd_init(&ring->change);
-   (void) mtx_init(&ring->mutex, mtx_plain);
-   return ring;
-
-fail:
-   FREE(ring->buf);
-   FREE(ring);
-   return NULL;
-}
-
-void util_ringbuffer_destroy( struct util_ringbuffer *ring )
-{
-   cnd_destroy(&ring->change);
-   mtx_destroy(&ring->mutex);
-   FREE(ring->buf);
-   FREE(ring);
-}
-
-/**
- * Return number of free entries in the ring
- */
-static inline unsigned util_ringbuffer_space( const struct util_ringbuffer *ring )
-{
-   return (ring->tail - (ring->head + 1)) & ring->mask;
-}
-
-/**
- * Is the ring buffer empty?
- */
-static inline boolean util_ringbuffer_empty( const struct util_ringbuffer *ring )
-{
-   return util_ringbuffer_space(ring) == ring->mask;
-}
-
-void util_ringbuffer_enqueue( struct util_ringbuffer *ring,
-                              const struct util_packet *packet )
-{
-   unsigned i;
-
-   /* XXX: over-reliance on mutexes, etc:
-    */
-   mtx_lock(&ring->mutex);
-
-   /* make sure we don't request an impossible amount of space
-    */
-   assert(packet->dwords <= ring->mask);
-
-   /* Wait for free space:
-    */
-   while (util_ringbuffer_space(ring) < packet->dwords)
-      cnd_wait(&ring->change, &ring->mutex);
-
-   /* Copy data to ring:
-    */
-   for (i = 0; i < packet->dwords; i++) {
-
-      /* Copy all dwords of the packet.  Note we're abusing the
-       * typesystem a little - we're being passed a pointer to
-       * something, but probably not an array of packet structs:
-       */
-      ring->buf[ring->head] = packet[i];
-      ring->head++;
-      ring->head &= ring->mask;
-   }
-
-   /* Signal change:
-    */
-   cnd_signal(&ring->change);
-   mtx_unlock(&ring->mutex);
-}
-
-enum pipe_error util_ringbuffer_dequeue( struct util_ringbuffer *ring,
-                                         struct util_packet *packet,
-                                         unsigned max_dwords,
-                                         boolean wait )
-{
-   const struct util_packet *ring_packet;
-   unsigned i;
-   int ret = PIPE_OK;
-
-   /* XXX: over-reliance on mutexes, etc:
-    */
-   mtx_lock(&ring->mutex);
-
-   /* Get next ring entry:
-    */
-   if (wait) {
-      while (util_ringbuffer_empty(ring))
-         cnd_wait(&ring->change, &ring->mutex);
-   }
-   else {
-      if (util_ringbuffer_empty(ring)) {
-         ret = PIPE_ERROR_OUT_OF_MEMORY;
-         goto out;
-      }
-   }
-
-   ring_packet = &ring->buf[ring->tail];
-
-   /* Both of these are considered bugs.  Raise an assert on debug builds.
-    */
-   if (ring_packet->dwords > ring->mask + 1 - util_ringbuffer_space(ring) ||
-       ring_packet->dwords > max_dwords) {
-      assert(0);
-      ret = PIPE_ERROR_BAD_INPUT;
-      goto out;
-   }
-
-   /* Copy data from ring:
-    */
-   for (i = 0; i < ring_packet->dwords; i++) {
-      packet[i] = ring->buf[ring->tail];
-      ring->tail++;
-      ring->tail &= ring->mask;
-   }
-
-out:
-   /* Signal change:
-    */
-   cnd_signal(&ring->change);
-   mtx_unlock(&ring->mutex);
-   return ret;
-}
diff --git a/src/gallium/auxiliary/util/u_ringbuffer.h b/src/gallium/auxiliary/util/u_ringbuffer.h
deleted file mode 100644 (file)
index 85f0ad6..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-
-#ifndef UTIL_RINGBUFFER_H
-#define UTIL_RINGBUFFER_H
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_defines.h"       /* only for pipe_error! */
-
-/* Generic header
- */
-struct util_packet {
-   unsigned dwords:8;
-   unsigned data24:24;
-};
-
-struct util_ringbuffer;
-
-struct util_ringbuffer *util_ringbuffer_create( unsigned dwords );
-
-void util_ringbuffer_destroy( struct util_ringbuffer *ring );
-
-void util_ringbuffer_enqueue( struct util_ringbuffer *ring,
-                              const struct util_packet *packet );
-
-enum pipe_error util_ringbuffer_dequeue( struct util_ringbuffer *ring,
-                                         struct util_packet *packet,
-                                         unsigned max_dwords,
-                                         boolean wait );
-
-#endif