[Mesa-dev] [PATCH 1/2] gallium/auxiliary: Remove os_stream.

jfonseca at vmware.com jfonseca at vmware.com
Tue Nov 29 08:04:19 PST 2011


From: José Fonseca <jose.r.fonseca at gmail.com>

XP kernel mode was the only subsystem lacking stdio FILES.
---
 src/gallium/auxiliary/Makefile.sources      |    5 -
 src/gallium/auxiliary/os/os_stream.c        |   58 ---------
 src/gallium/auxiliary/os/os_stream.h        |  145 -----------------------
 src/gallium/auxiliary/os/os_stream_log.c    |   82 -------------
 src/gallium/auxiliary/os/os_stream_null.c   |   78 -------------
 src/gallium/auxiliary/os/os_stream_stdc.c   |  122 -------------------
 src/gallium/auxiliary/os/os_stream_str.c    |  167 ---------------------------
 src/gallium/auxiliary/util/u_debug.c        |   14 +-
 src/gallium/auxiliary/util/u_debug_refcnt.c |   22 ++--
 src/gallium/auxiliary/util/u_dump.h         |   48 ++++-----
 src/gallium/auxiliary/util/u_dump_state.c   |  103 ++++++++--------
 src/gallium/drivers/trace/tr_dump.c         |   17 ++--
 12 files changed, 99 insertions(+), 762 deletions(-)
 delete mode 100644 src/gallium/auxiliary/os/os_stream.c
 delete mode 100644 src/gallium/auxiliary/os/os_stream.h
 delete mode 100644 src/gallium/auxiliary/os/os_stream_log.c
 delete mode 100644 src/gallium/auxiliary/os/os_stream_null.c
 delete mode 100644 src/gallium/auxiliary/os/os_stream_stdc.c
 delete mode 100644 src/gallium/auxiliary/os/os_stream_str.c

diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources
index f1f3696..15de20c 100644
--- a/src/gallium/auxiliary/Makefile.sources
+++ b/src/gallium/auxiliary/Makefile.sources
@@ -37,11 +37,6 @@ C_SOURCES := \
 	draw/draw_vs_ppc.c \
 	draw/draw_vs_variant.c \
 	os/os_misc.c \
-	os/os_stream.c \
-	os/os_stream_log.c \
-	os/os_stream_null.c \
-	os/os_stream_stdc.c \
-	os/os_stream_str.c \
 	os/os_time.c \
 	pipebuffer/pb_buffer_fenced.c \
 	pipebuffer/pb_buffer_malloc.c \
diff --git a/src/gallium/auxiliary/os/os_stream.c b/src/gallium/auxiliary/os/os_stream.c
deleted file mode 100644
index 3c55fc0..0000000
--- a/src/gallium/auxiliary/os/os_stream.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Luca Barbieri
- *
- * 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, sublicense, 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 above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * 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 NONINFRINGEMENT.
- * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) 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.
- *
- **************************************************************************/
-
-#include "pipe/p_config.h"
-
-#include "os_stream.h"
-#include "util/u_memory.h"
-#include "util/u_string.h"
-
-int
-os_default_stream_vprintf (struct os_stream* stream, const char *format, va_list ap)
-{
-   char buf[1024];
-   int retval;
-   va_list ap2;
-   va_copy(ap2, ap);
-   retval = util_vsnprintf(buf, sizeof(buf), format, ap2);
-   va_end(ap2);
-   if(retval <= 0)
-   {}
-   else if(retval < sizeof(buf))
-      stream->write(stream, buf, retval);
-   else
-   {
-      char* str = MALLOC(retval + 1);
-      if(!str)
-         return -1;
-      retval = util_vsnprintf(str, retval + 1, format, ap);
-      if(retval > 0)
-         stream->write(stream, str, retval);
-      FREE(str);
-   }
-
-   return retval;
-}
diff --git a/src/gallium/auxiliary/os/os_stream.h b/src/gallium/auxiliary/os/os_stream.h
deleted file mode 100644
index 6c6050b..0000000
--- a/src/gallium/auxiliary/os/os_stream.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008-2010 VMware, Inc.
- * 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 above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-/**
- * @file
- * Cross-platform sequential access stream abstraction.
- */
-
-#ifndef _OS_STREAM_H_
-#define _OS_STREAM_H_
-
-
-#include "pipe/p_compiler.h"
-
-
-/**
- * OS stream (FILE, socket, etc) abstraction.
- */
-struct os_stream
-{
-   void
-   (*close)(struct os_stream *stream);
-
-   boolean
-   (*write)(struct os_stream *stream, const void *data, size_t size);
-
-   void
-   (*flush)(struct os_stream *stream);
-
-   int
-   (*vprintf)(struct os_stream *stream, const char* format, va_list ap);
-};
-
-
-static INLINE void
-os_stream_close(struct os_stream *stream)
-{
-   if (!stream)
-      return;
-
-   stream->close(stream);
-}
-
-
-static INLINE boolean
-os_stream_write(struct os_stream *stream, const void *data, size_t size)
-{
-   if (!stream)
-      return FALSE;
-   return stream->write(stream, data, size);
-}
-
-
-static INLINE boolean
-os_stream_write_str(struct os_stream *stream, const char *str)
-{
-   size_t size;
-   if (!stream)
-      return FALSE;
-   for(size = 0; str[size]; ++size)
-      ;
-   return stream->write(stream, str, size);
-}
-
-
-static INLINE void
-os_stream_flush(struct os_stream *stream)
-{
-   stream->flush(stream);
-}
-
-int
-os_default_stream_vprintf (struct os_stream* stream, const char *format, va_list ap);
-
-static INLINE int
-os_stream_vprintf (struct os_stream* stream, const char *format, va_list ap)
-{
-   return stream->vprintf(stream, format, ap);
-}
-
-static INLINE int
-os_stream_printf (struct os_stream* stream, const char *format, ...)
-{
-   int retval;
-   va_list args;
-
-   va_start (args, format);
-   retval = stream->vprintf(stream, format, args);
-   va_end (args);
-
-   return retval;
-}
-
-struct os_stream *
-os_file_stream_create(const char *filename);
-
-
-struct os_stream *
-os_null_stream_create(void);
-
-
-extern struct os_stream *
-os_log_stream;
-
-
-struct os_stream *
-os_str_stream_create(size_t initial_size);
-
-
-const char *
-os_str_stream_get(struct os_stream *stream);
-
-char *
-os_str_stream_get_and_close(struct os_stream *stream);
-
-
-#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
-#define os_file_stream_create(_filename) os_null_stream_create()
-#endif
-
-#endif /* _OS_STREAM_H_ */
diff --git a/src/gallium/auxiliary/os/os_stream_log.c b/src/gallium/auxiliary/os/os_stream_log.c
deleted file mode 100644
index b01377c..0000000
--- a/src/gallium/auxiliary/os/os_stream_log.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008-2010 VMware, Inc.
- * 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 above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-/**
- * @file
- * Debug logging stream implementation.
- */
-
-#include "os_memory.h"
-#include "os_misc.h"
-#include "os_stream.h"
-
-
-static void
-os_log_stream_close(struct os_stream *stream)
-{
-   (void)stream;
-}
-
-
-static boolean
-os_log_stream_write(struct os_stream *stream, const void *data, size_t size)
-{
-   char *str;
-
-   str = os_malloc(size + 1);
-   if (!str)
-      return FALSE;
-
-   memcpy(str, data, size);
-   str[size] = 0;
-
-   os_log_message(str);
-
-   os_free(str);
-
-   return TRUE;
-}
-
-
-static void
-os_log_stream_flush(struct os_stream *stream)
-{
-   (void)stream;
-}
-
-
-static struct os_stream
-os_log_stream_struct = {
-   &os_log_stream_close,
-   &os_log_stream_write,
-   &os_log_stream_flush,
-   &os_default_stream_vprintf,
-};
-
-
-struct os_stream *
-os_log_stream = &os_log_stream_struct;
diff --git a/src/gallium/auxiliary/os/os_stream_null.c b/src/gallium/auxiliary/os/os_stream_null.c
deleted file mode 100644
index a549a78..0000000
--- a/src/gallium/auxiliary/os/os_stream_null.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008-2010 VMware, Inc.
- * 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 above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-/**
- * @file
- * Null stream implementation.
- */
-
-#include "os_memory.h"
-#include "os_stream.h"
-
-
-static void
-os_null_stream_close(struct os_stream *stream)
-{
-   (void)stream;
-}
-
-
-static boolean
-os_null_stream_write(struct os_stream *stream, const void *data, size_t size)
-{
-   (void)data;
-   (void)size;
-   return TRUE;
-}
-
-
-static void
-os_null_stream_flush(struct os_stream *stream)
-{
-   (void)stream;
-}
-
-static int
-os_null_stream_vprintf (struct os_stream* stream, const char *format, va_list ap)
-{
-   return 0;
-}
-
-static struct os_stream
-os_null_stream = {
-   &os_null_stream_close,
-   &os_null_stream_write,
-   &os_null_stream_flush,
-   &os_null_stream_vprintf
-};
-
-
-struct os_stream *
-os_null_stream_create()
-{
-   return &os_null_stream;
-}
diff --git a/src/gallium/auxiliary/os/os_stream_stdc.c b/src/gallium/auxiliary/os/os_stream_stdc.c
deleted file mode 100644
index afd3ff6..0000000
--- a/src/gallium/auxiliary/os/os_stream_stdc.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008-2010 VMware, Inc.
- * 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 above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-/**
- * @file
- * Stream implementation based on the Standard C Library.
- */
-
-#include "pipe/p_config.h"
-
-#if defined(PIPE_OS_UNIX) || defined(PIPE_SUBSYSTEM_WINDOWS_USER)
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "os_stream.h"
-
-
-struct os_stdc_stream
-{
-   struct os_stream base;
-
-   FILE *file;
-};
-
-
-static INLINE struct os_stdc_stream *
-os_stdc_stream(struct os_stream *stream)
-{
-   return (struct os_stdc_stream *)stream;
-}
-
-
-static void
-os_stdc_stream_close(struct os_stream *_stream)
-{
-   struct os_stdc_stream *stream = os_stdc_stream(_stream);
-
-   fclose(stream->file);
-
-   free(stream);
-}
-
-
-static boolean
-os_stdc_stream_write(struct os_stream *_stream, const void *data, size_t size)
-{
-   struct os_stdc_stream *stream = os_stdc_stream(_stream);
-
-   return fwrite(data, size, 1, stream->file) == size ? TRUE : FALSE;
-}
-
-
-static void
-os_stdc_stream_flush(struct os_stream *_stream)
-{
-   struct os_stdc_stream *stream = os_stdc_stream(_stream);
-
-   fflush(stream->file);
-}
-
-static int
-os_stdc_stream_vprintf (struct os_stream* _stream, const char *format, va_list ap)
-{
-   struct os_stdc_stream *stream = os_stdc_stream(_stream);
-
-   return vfprintf(stream->file, format, ap);
-}
-
-
-struct os_stream *
-os_file_stream_create(const char *filename)
-{
-   struct os_stdc_stream *stream;
-
-   stream = (struct os_stdc_stream *)calloc(1, sizeof(*stream));
-   if(!stream)
-      goto no_stream;
-
-   stream->base.close = &os_stdc_stream_close;
-   stream->base.write = &os_stdc_stream_write;
-   stream->base.flush = &os_stdc_stream_flush;
-   stream->base.vprintf = &os_stdc_stream_vprintf;
-
-   stream->file = fopen(filename, "wb");
-   if(!stream->file)
-      goto no_file;
-
-   return &stream->base;
-
-no_file:
-   free(stream);
-no_stream:
-   return NULL;
-}
-
-
-#endif
diff --git a/src/gallium/auxiliary/os/os_stream_str.c b/src/gallium/auxiliary/os/os_stream_str.c
deleted file mode 100644
index be9478b..0000000
--- a/src/gallium/auxiliary/os/os_stream_str.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008-2010 VMware, Inc.
- * 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 above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-/**
- * @file
- * Malloc string stream implementation.
- */
-
-#include "pipe/p_config.h"
-
-#include "os_memory.h"
-#include "os_stream.h"
-
-
-struct os_str_stream
-{
-   struct os_stream base;
-
-   char *str;
-
-   size_t size;
-   size_t written;
-};
-
-
-static INLINE struct os_str_stream *
-os_str_stream(struct os_stream *stream)
-{
-   return (struct os_str_stream *)stream;
-}
-
-
-static void
-os_str_stream_close(struct os_stream *_stream)
-{
-   struct os_str_stream *stream = os_str_stream(_stream);
-
-   os_free(stream->str);
-
-   os_free(stream);
-}
-
-
-static boolean
-os_str_stream_write(struct os_stream *_stream, const void *data, size_t size)
-{
-   struct os_str_stream *stream = os_str_stream(_stream);
-   size_t minimum_size;
-   boolean ret = TRUE;
-
-   minimum_size = stream->written + size + 1;
-   if (stream->size < minimum_size) {
-      size_t new_size = stream->size;
-      char * new_str;
-
-      do {
-         new_size *= 2;
-      } while (new_size < minimum_size);
-
-      new_str = os_realloc(stream->str, stream->size, new_size);
-      if (new_str) {
-         stream->str = new_str;
-         stream->size = new_size;
-      }
-      else {
-         size = stream->size - stream->written - 1;
-         ret = FALSE;
-      }
-   }
-
-   memcpy(stream->str + stream->written, data, size);
-   stream->written += size;
-
-   return ret;
-}
-
-
-static void
-os_str_stream_flush(struct os_stream *stream)
-{
-   (void)stream;
-}
-
-
-struct os_stream *
-os_str_stream_create(size_t size)
-{
-   struct os_str_stream *stream;
-
-   stream = (struct os_str_stream *)os_calloc(1, sizeof(*stream));
-   if(!stream)
-      goto no_stream;
-
-   stream->base.close = &os_str_stream_close;
-   stream->base.write = &os_str_stream_write;
-   stream->base.flush = &os_str_stream_flush;
-   stream->base.vprintf = &os_default_stream_vprintf;
-
-   stream->str = os_malloc(size);
-   if(!stream->str)
-      goto no_str;
-
-   stream->size = size;
-
-   return &stream->base;
-
-no_str:
-   os_free(stream);
-no_stream:
-   return NULL;
-}
-
-
-const char *
-os_str_stream_get(struct os_stream *_stream)
-{
-   struct os_str_stream *stream = os_str_stream(_stream);
-
-   if (!stream)
-      return NULL;
-
-   stream->str[stream->written] = 0;
-   return stream->str;
-}
-
-
-char *
-os_str_stream_get_and_close(struct os_stream *_stream)
-{
-   struct os_str_stream *stream = os_str_stream(_stream);
-   char *str;
-
-   if (!stream)
-      return NULL;
-
-   str = stream->str;
-
-   str[stream->written] = 0;
-
-   os_free(stream);
-
-   return str;
-}
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
index 2d61930..b3a30ad 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -30,7 +30,6 @@
 #include "pipe/p_config.h" 
 
 #include "pipe/p_compiler.h"
-#include "os/os_stream.h"
 #include "util/u_debug.h" 
 #include "pipe/p_format.h" 
 #include "pipe/p_state.h" 
@@ -43,6 +42,7 @@
 #include "util/u_prim.h"
 #include "util/u_surface.h"
 
+#include <stdio.h>
 #include <limits.h> /* CHAR_BIT */
 #include <ctype.h> /* isalnum */
 
@@ -688,7 +688,7 @@ debug_dump_float_rgba_bmp(const char *filename,
                           float *rgba, unsigned stride)
 {
 #ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT
-   struct os_stream *stream;
+   FILE *stream;
    struct bmp_file_header bmfh;
    struct bmp_info_header bmih;
    unsigned x, y;
@@ -714,12 +714,12 @@ debug_dump_float_rgba_bmp(const char *filename,
    bmih.biClrUsed = 0;
    bmih.biClrImportant = 0;
 
-   stream = os_file_stream_create(filename);
+   stream = fopen(filename, "wb");
    if(!stream)
       goto error1;
 
-   os_stream_write(stream, &bmfh, 14);
-   os_stream_write(stream, &bmih, 40);
+   fwrite(&bmfh, 14, 1, stream);
+   fwrite(&bmih, 40, 1, stream);
 
    y = height;
    while(y--) {
@@ -731,11 +731,11 @@ debug_dump_float_rgba_bmp(const char *filename,
          pixel.rgbGreen = float_to_ubyte(ptr[x*4 + 1]);
          pixel.rgbBlue  = float_to_ubyte(ptr[x*4 + 2]);
          pixel.rgbAlpha = float_to_ubyte(ptr[x*4 + 3]);
-         os_stream_write(stream, &pixel, 4);
+         fwrite(&pixel, 1, 4, stream);
       }
    }
 
-   os_stream_close(stream);
+   fclose(stream);
 error1:
    ;
 #endif
diff --git a/src/gallium/auxiliary/util/u_debug_refcnt.c b/src/gallium/auxiliary/util/u_debug_refcnt.c
index b3e3894..2679932 100644
--- a/src/gallium/auxiliary/util/u_debug_refcnt.c
+++ b/src/gallium/auxiliary/util/u_debug_refcnt.c
@@ -29,6 +29,9 @@
 /* see http://www.mozilla.org/performance/refcnt-balancer.html for what do with the output
  * on Linux, use tools/addr2line.sh to postprocess it before anything else
  **/
+
+#include <stdio.h>
+
 #include "util/u_debug.h"
 #include "util/u_debug_refcnt.h"
 #include "util/u_debug_stack.h"
@@ -36,11 +39,10 @@
 #include "util/u_string.h"
 #include "util/u_hash_table.h"
 #include "os/os_thread.h"
-#include "os/os_stream.h"
 
 int debug_refcnt_state;
 
-struct os_stream* stream;
+FILE* stream;
 
 /* TODO: maybe move this serial machinery to a stand-alone module and expose it? */
 pipe_static_mutex(serials_mutex);
@@ -115,9 +117,9 @@ static void dump_stack(const char* symbols[STACK_LEN])
    for(i = 0; i < STACK_LEN; ++i)
    {
       if(symbols[i])
-         os_stream_printf(stream, "%s\n", symbols[i]);
+         fprintf(stream, "%s\n", symbols[i]);
    }
-   os_stream_write(stream, "\n", 1);
+   fprintf(stream, "\n");
 }
 
 void debug_reference_slowpath(const struct pipe_reference* p, debug_reference_descriptor get_desc, int change)
@@ -129,7 +131,7 @@ void debug_reference_slowpath(const struct pipe_reference* p, debug_reference_de
    {
       const char* filename = debug_get_option("GALLIUM_REFCNT_LOG", NULL);
       if(filename && filename[0])
-         stream = os_file_stream_create(filename);
+         stream = fopen(filename, "wt");
 
       if(stream)
          debug_refcnt_state = 1;
@@ -161,31 +163,31 @@ void debug_reference_slowpath(const struct pipe_reference* p, debug_reference_de
 
       if(!existing)
       {
-         os_stream_printf(stream, "<%s> %p %u Create\n", buf, p, serial);
+         fprintf(stream, "<%s> %p %u Create\n", buf, p, serial);
          dump_stack(symbols);
 
          /* this is there to provide a gradual change even if we don't see the initialization */
          for(i = 1; i <= refcnt - change; ++i)
          {
-            os_stream_printf(stream, "<%s> %p %u AddRef %u\n", buf, p, serial, i);
+            fprintf(stream, "<%s> %p %u AddRef %u\n", buf, p, serial, i);
             dump_stack(symbols);
          }
       }
 
       if(change)
       {
-         os_stream_printf(stream, "<%s> %p %u %s %u\n", buf, p, serial, change > 0 ? "AddRef" : "Release", refcnt);
+         fprintf(stream, "<%s> %p %u %s %u\n", buf, p, serial, change > 0 ? "AddRef" : "Release", refcnt);
          dump_stack(symbols);
       }
 
       if(!refcnt)
       {
          debug_serial_delete((void*)p);
-         os_stream_printf(stream, "<%s> %p %u Destroy\n", buf, p, serial);
+         fprintf(stream, "<%s> %p %u Destroy\n", buf, p, serial);
          dump_stack(symbols);
       }
 
-      os_stream_flush(stream);
+      fflush(stream);
    }
 }
 #endif
diff --git a/src/gallium/auxiliary/util/u_dump.h b/src/gallium/auxiliary/util/u_dump.h
index 49536c0..3890b3b 100644
--- a/src/gallium/auxiliary/util/u_dump.h
+++ b/src/gallium/auxiliary/util/u_dump.h
@@ -39,6 +39,8 @@
 #include "pipe/p_compiler.h"
 #include "pipe/p_state.h"
 
+#include <stdio.h>
+
 
 #ifdef	__cplusplus
 extern "C" {
@@ -48,14 +50,6 @@ extern "C" {
 #define UTIL_DUMP_INVALID_NAME "<invalid>"
 
 
-struct os_stream;
-
-
-/* Duplicated here for convenience */
-extern struct os_stream *
-os_log_stream;
-
-
 /*
  * p_defines.h
  *
@@ -93,79 +87,79 @@ util_dump_tex_filter(unsigned value, boolean shortened);
 
 
 /*
- * p_state.h, through an os_stream
+ * p_state.h, through a FILE
  */
 
 void
-util_dump_template(struct os_stream *stream,
+util_dump_template(FILE *stream,
                    const struct pipe_resource *templat);
 
 void
-util_dump_rasterizer_state(struct os_stream *stream,
+util_dump_rasterizer_state(FILE *stream,
                            const struct pipe_rasterizer_state *state);
 
 void
-util_dump_poly_stipple(struct os_stream *stream,
+util_dump_poly_stipple(FILE *stream,
                        const struct pipe_poly_stipple *state);
 
 void
-util_dump_viewport_state(struct os_stream *stream,
+util_dump_viewport_state(FILE *stream,
                          const struct pipe_viewport_state *state);
 
 void
-util_dump_scissor_state(struct os_stream *stream,
+util_dump_scissor_state(FILE *stream,
                         const struct pipe_scissor_state *state);
 
 void
-util_dump_clip_state(struct os_stream *stream,
+util_dump_clip_state(FILE *stream,
                      const struct pipe_clip_state *state);
 
 void
-util_dump_shader_state(struct os_stream *stream,
+util_dump_shader_state(FILE *stream,
                        const struct pipe_shader_state *state);
 
 void
-util_dump_depth_stencil_alpha_state(struct os_stream *stream,
+util_dump_depth_stencil_alpha_state(FILE *stream,
                                     const struct pipe_depth_stencil_alpha_state *state);
 
 void
-util_dump_rt_blend_state(struct os_stream *stream,
+util_dump_rt_blend_state(FILE *stream,
                          const struct pipe_rt_blend_state *state);
 
 void
-util_dump_blend_state(struct os_stream *stream,
+util_dump_blend_state(FILE *stream,
                       const struct pipe_blend_state *state);
 
 void
-util_dump_blend_color(struct os_stream *stream,
+util_dump_blend_color(FILE *stream,
                       const struct pipe_blend_color *state);
 
 void
-util_dump_stencil_ref(struct os_stream *stream,
+util_dump_stencil_ref(FILE *stream,
                       const struct pipe_stencil_ref *state);
 
 void
-util_dump_framebuffer_state(struct os_stream *stream,
+util_dump_framebuffer_state(FILE *stream,
                             const struct pipe_framebuffer_state *state);
 
 void
-util_dump_sampler_state(struct os_stream *stream,
+util_dump_sampler_state(FILE *stream,
                         const struct pipe_sampler_state *state);
 
 void
-util_dump_surface(struct os_stream *stream,
+util_dump_surface(FILE *stream,
                   const struct pipe_surface *state);
 
 void
-util_dump_transfer(struct os_stream *stream,
+util_dump_transfer(FILE *stream,
                    const struct pipe_transfer *state);
 
 void
-util_dump_vertex_buffer(struct os_stream *stream,
+util_dump_vertex_buffer(FILE *stream,
                         const struct pipe_vertex_buffer *state);
 
 void
-util_dump_vertex_element(struct os_stream *stream,
+util_dump_vertex_element(FILE *stream,
                          const struct pipe_vertex_element *state);
 
 
diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c
index 8a7ec58..917d7cd 100644
--- a/src/gallium/auxiliary/util/u_dump_state.c
+++ b/src/gallium/auxiliary/util/u_dump_state.c
@@ -27,7 +27,6 @@
 
 
 #include "pipe/p_compiler.h"
-#include "os/os_stream.h"
 #include "util/u_memory.h"
 #include "util/u_string.h"
 #include "util/u_format.h"
@@ -41,7 +40,7 @@
  */
 
 static INLINE void
-util_stream_writef(struct os_stream *stream, const char *format, ...)
+util_stream_writef(FILE *stream, const char *format, ...)
 {
    static char buf[1024];
    unsigned len;
@@ -49,102 +48,102 @@ util_stream_writef(struct os_stream *stream, const char *format, ...)
    va_start(ap, format);
    len = util_vsnprintf(buf, sizeof(buf), format, ap);
    va_end(ap);
-   os_stream_write(stream, buf, len);
+   fwrite(buf, len, 1, stream);
 }
 
 static void
-util_dump_bool(struct os_stream *stream, int value)
+util_dump_bool(FILE *stream, int value)
 {
    util_stream_writef(stream, "%c", value ? '1' : '0');
 }
 
 static void
-util_dump_int(struct os_stream *stream, long long int value)
+util_dump_int(FILE *stream, long long int value)
 {
    util_stream_writef(stream, "%lli", value);
 }
 
 static void
-util_dump_uint(struct os_stream *stream, long long unsigned value)
+util_dump_uint(FILE *stream, long long unsigned value)
 {
    util_stream_writef(stream, "%llu", value);
 }
 
 static void
-util_dump_float(struct os_stream *stream, double value)
+util_dump_float(FILE *stream, double value)
 {
    util_stream_writef(stream, "%g", value);
 }
 
 static void
-util_dump_string(struct os_stream *stream, const char *str)
+util_dump_string(FILE *stream, const char *str)
 {
-   os_stream_write_str(stream, "\"");
-   os_stream_write_str(stream, str);
-   os_stream_write_str(stream, "\"");
+   fputs("\"", stream);
+   fputs(str, stream);
+   fputs("\"", stream);
 }
 
 static void
-util_dump_enum(struct os_stream *stream, const char *value)
+util_dump_enum(FILE *stream, const char *value)
 {
-   os_stream_write_str(stream, value);
+   fputs(value, stream);
 }
 
 static void
-util_dump_array_begin(struct os_stream *stream)
+util_dump_array_begin(FILE *stream)
 {
-   os_stream_write_str(stream, "{");
+   fputs("{", stream);
 }
 
 static void
-util_dump_array_end(struct os_stream *stream)
+util_dump_array_end(FILE *stream)
 {
-   os_stream_write_str(stream, "}");
+   fputs("}", stream);
 }
 
 static void
-util_dump_elem_begin(struct os_stream *stream)
+util_dump_elem_begin(FILE *stream)
 {
 }
 
 static void
-util_dump_elem_end(struct os_stream *stream)
+util_dump_elem_end(FILE *stream)
 {
-   os_stream_write_str(stream, ", ");
+   fputs(", ", stream);
 }
 
 static void
-util_dump_struct_begin(struct os_stream *stream, const char *name)
+util_dump_struct_begin(FILE *stream, const char *name)
 {
-   os_stream_write_str(stream, "{");
+   fputs("{", stream);
 }
 
 static void
-util_dump_struct_end(struct os_stream *stream)
+util_dump_struct_end(FILE *stream)
 {
-   os_stream_write_str(stream, "}");
+   fputs("}", stream);
 }
 
 static void
-util_dump_member_begin(struct os_stream *stream, const char *name)
+util_dump_member_begin(FILE *stream, const char *name)
 {
    util_stream_writef(stream, "%s = ", name);
 }
 
 static void
-util_dump_member_end(struct os_stream *stream)
+util_dump_member_end(FILE *stream)
 {
-   os_stream_write_str(stream, ", ");
+   fputs(", ", stream);
 }
 
 static void
-util_dump_null(struct os_stream *stream)
+util_dump_null(FILE *stream)
 {
-   os_stream_write_str(stream, "NULL");
+   fputs("NULL", stream);
 }
 
 static void
-util_dump_ptr(struct os_stream *stream, const void *value)
+util_dump_ptr(FILE *stream, const void *value)
 {
    if(value)
       util_stream_writef(stream, "0x%08lx", (unsigned long)(uintptr_t)value);
@@ -224,26 +223,26 @@ util_dump_ptr(struct os_stream *stream, const void *value)
 
 
 static void
-util_dump_format(struct os_stream *stream, enum pipe_format format)
+util_dump_format(FILE *stream, enum pipe_format format)
 {
    util_dump_enum(stream, util_format_name(format));
 }
 
 
 static void
-util_dump_enum_blend_factor(struct os_stream *stream, unsigned value)
+util_dump_enum_blend_factor(FILE *stream, unsigned value)
 {
    util_dump_enum(stream, util_dump_blend_factor(value, TRUE));
 }
 
 static void
-util_dump_enum_blend_func(struct os_stream *stream, unsigned value)
+util_dump_enum_blend_func(FILE *stream, unsigned value)
 {
    util_dump_enum(stream, util_dump_blend_func(value, TRUE));
 }
 
 static void
-util_dump_enum_func(struct os_stream *stream, unsigned value)
+util_dump_enum_func(FILE *stream, unsigned value)
 {
    util_dump_enum(stream, util_dump_func(value, TRUE));
 }
@@ -255,7 +254,7 @@ util_dump_enum_func(struct os_stream *stream, unsigned value)
 
 
 void
-util_dump_template(struct os_stream *stream, const struct pipe_resource *templat)
+util_dump_template(FILE *stream, const struct pipe_resource *templat)
 {
    if(!templat) {
       util_dump_null(stream);
@@ -293,7 +292,7 @@ util_dump_template(struct os_stream *stream, const struct pipe_resource *templat
 
 
 void
-util_dump_rasterizer_state(struct os_stream *stream, const struct pipe_rasterizer_state *state)
+util_dump_rasterizer_state(FILE *stream, const struct pipe_rasterizer_state *state)
 {
    if(!state) {
       util_dump_null(stream);
@@ -339,7 +338,7 @@ util_dump_rasterizer_state(struct os_stream *stream, const struct pipe_rasterize
 
 
 void
-util_dump_poly_stipple(struct os_stream *stream, const struct pipe_poly_stipple *state)
+util_dump_poly_stipple(FILE *stream, const struct pipe_poly_stipple *state)
 {
    if(!state) {
       util_dump_null(stream);
@@ -357,7 +356,7 @@ util_dump_poly_stipple(struct os_stream *stream, const struct pipe_poly_stipple
 
 
 void
-util_dump_viewport_state(struct os_stream *stream, const struct pipe_viewport_state *state)
+util_dump_viewport_state(FILE *stream, const struct pipe_viewport_state *state)
 {
    if(!state) {
       util_dump_null(stream);
@@ -374,7 +373,7 @@ util_dump_viewport_state(struct os_stream *stream, const struct pipe_viewport_st
 
 
 void
-util_dump_scissor_state(struct os_stream *stream, const struct pipe_scissor_state *state)
+util_dump_scissor_state(FILE *stream, const struct pipe_scissor_state *state)
 {
    if(!state) {
       util_dump_null(stream);
@@ -393,7 +392,7 @@ util_dump_scissor_state(struct os_stream *stream, const struct pipe_scissor_stat
 
 
 void
-util_dump_clip_state(struct os_stream *stream, const struct pipe_clip_state *state)
+util_dump_clip_state(FILE *stream, const struct pipe_clip_state *state)
 {
    unsigned i;
 
@@ -421,7 +420,7 @@ util_dump_clip_state(struct os_stream *stream, const struct pipe_clip_state *sta
 
 
 void
-util_dump_shader_state(struct os_stream *stream, const struct pipe_shader_state *state)
+util_dump_shader_state(FILE *stream, const struct pipe_shader_state *state)
 {
    char str[8192];
 
@@ -443,7 +442,7 @@ util_dump_shader_state(struct os_stream *stream, const struct pipe_shader_state
 
 
 void
-util_dump_depth_stencil_alpha_state(struct os_stream *stream, const struct pipe_depth_stencil_alpha_state *state)
+util_dump_depth_stencil_alpha_state(FILE *stream, const struct pipe_depth_stencil_alpha_state *state)
 {
    unsigned i;
 
@@ -498,7 +497,7 @@ util_dump_depth_stencil_alpha_state(struct os_stream *stream, const struct pipe_
 }
 
 void
-util_dump_rt_blend_state(struct os_stream *stream, const struct pipe_rt_blend_state *state)
+util_dump_rt_blend_state(FILE *stream, const struct pipe_rt_blend_state *state)
 {
    util_dump_struct_begin(stream, "pipe_rt_blend_state");
 
@@ -519,7 +518,7 @@ util_dump_rt_blend_state(struct os_stream *stream, const struct pipe_rt_blend_st
 }
 
 void
-util_dump_blend_state(struct os_stream *stream, const struct pipe_blend_state *state)
+util_dump_blend_state(FILE *stream, const struct pipe_blend_state *state)
 {
    unsigned valid_entries = 1;
 
@@ -551,7 +550,7 @@ util_dump_blend_state(struct os_stream *stream, const struct pipe_blend_state *s
 
 
 void
-util_dump_blend_color(struct os_stream *stream, const struct pipe_blend_color *state)
+util_dump_blend_color(FILE *stream, const struct pipe_blend_color *state)
 {
    if(!state) {
       util_dump_null(stream);
@@ -566,7 +565,7 @@ util_dump_blend_color(struct os_stream *stream, const struct pipe_blend_color *s
 }
 
 void
-util_dump_stencil_ref(struct os_stream *stream, const struct pipe_stencil_ref *state)
+util_dump_stencil_ref(FILE *stream, const struct pipe_stencil_ref *state)
 {
    if(!state) {
       util_dump_null(stream);
@@ -581,7 +580,7 @@ util_dump_stencil_ref(struct os_stream *stream, const struct pipe_stencil_ref *s
 }
 
 void
-util_dump_framebuffer_state(struct os_stream *stream, const struct pipe_framebuffer_state *state)
+util_dump_framebuffer_state(FILE *stream, const struct pipe_framebuffer_state *state)
 {
    util_dump_struct_begin(stream, "pipe_framebuffer_state");
 
@@ -596,7 +595,7 @@ util_dump_framebuffer_state(struct os_stream *stream, const struct pipe_framebuf
 
 
 void
-util_dump_sampler_state(struct os_stream *stream, const struct pipe_sampler_state *state)
+util_dump_sampler_state(FILE *stream, const struct pipe_sampler_state *state)
 {
    if(!state) {
       util_dump_null(stream);
@@ -625,7 +624,7 @@ util_dump_sampler_state(struct os_stream *stream, const struct pipe_sampler_stat
 
 
 void
-util_dump_surface(struct os_stream *stream, const struct pipe_surface *state)
+util_dump_surface(FILE *stream, const struct pipe_surface *state)
 {
    if(!state) {
       util_dump_null(stream);
@@ -650,7 +649,7 @@ util_dump_surface(struct os_stream *stream, const struct pipe_surface *state)
 
 
 void
-util_dump_transfer(struct os_stream *stream, const struct pipe_transfer *state)
+util_dump_transfer(FILE *stream, const struct pipe_transfer *state)
 {
    if(!state) {
       util_dump_null(stream);
@@ -672,7 +671,7 @@ util_dump_transfer(struct os_stream *stream, const struct pipe_transfer *state)
 
 
 void
-util_dump_vertex_buffer(struct os_stream *stream, const struct pipe_vertex_buffer *state)
+util_dump_vertex_buffer(FILE *stream, const struct pipe_vertex_buffer *state)
 {
    if(!state) {
       util_dump_null(stream);
@@ -690,7 +689,7 @@ util_dump_vertex_buffer(struct os_stream *stream, const struct pipe_vertex_buffe
 
 
 void
-util_dump_vertex_element(struct os_stream *stream, const struct pipe_vertex_element *state)
+util_dump_vertex_element(FILE *stream, const struct pipe_vertex_element *state)
 {
    if(!state) {
       util_dump_null(stream);
diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c
index 8a4ec20..ecc5bbc 100644
--- a/src/gallium/drivers/trace/tr_dump.c
+++ b/src/gallium/drivers/trace/tr_dump.c
@@ -40,13 +40,11 @@
 
 #include "pipe/p_config.h"
 
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE)
+#include <stdio.h>
 #include <stdlib.h>
-#endif
 
 #include "pipe/p_compiler.h"
 #include "os/os_thread.h"
-#include "os/os_stream.h"
 #include "util/u_debug.h"
 #include "util/u_memory.h"
 #include "util/u_string.h"
@@ -58,7 +56,7 @@
 #include "tr_texture.h"
 
 
-static struct os_stream *stream = NULL;
+static FILE *stream = NULL;
 static unsigned refcount = 0;
 pipe_static_mutex(call_mutex);
 static long unsigned call_no = 0;
@@ -68,8 +66,9 @@ static boolean dumping = FALSE;
 static INLINE void
 trace_dump_write(const char *buf, size_t size)
 {
-   if(stream)
-      os_stream_write(stream, buf, size);
+   if (stream) {
+      fwrite(buf, size, 1, stream);
+   }
 }
 
 
@@ -220,7 +219,7 @@ trace_dump_trace_close(void)
 {
    if(stream) {
       trace_dump_writes("</trace>\n");
-      os_stream_close(stream);
+      fclose(stream);
       stream = NULL;
       refcount = 0;
       call_no = 0;
@@ -237,7 +236,7 @@ boolean trace_dump_trace_begin()
 
    if(!stream) {
 
-      stream = os_file_stream_create(filename);
+      stream = fopen(filename, "wt");
       if(!stream)
          return FALSE;
 
@@ -354,7 +353,7 @@ void trace_dump_call_end_locked(void)
    trace_dump_indent(1);
    trace_dump_tag_end("call");
    trace_dump_newline();
-   os_stream_flush(stream);
+   fflush(stream);
 }
 
 void trace_dump_call_begin(const char *klass, const char *method)
-- 
1.7.7.3



More information about the mesa-dev mailing list