XP kernel mode was the only subsystem lacking stdio FILES.
Reviewed-by: Brian Paul <brianp@vmware.com>
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 \
+++ /dev/null
-/**************************************************************************
- *
- * 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;
-}
+++ /dev/null
-/**************************************************************************
- *
- * 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_ */
+++ /dev/null
-/**************************************************************************
- *
- * 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;
+++ /dev/null
-/**************************************************************************
- *
- * 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;
-}
+++ /dev/null
-/**************************************************************************
- *
- * 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
+++ /dev/null
-/**************************************************************************
- *
- * 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;
-}
#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"
#include "util/u_prim.h"
#include "util/u_surface.h"
+#include <stdio.h>
#include <limits.h> /* CHAR_BIT */
#include <ctype.h> /* isalnum */
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;
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--) {
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
/* 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"
#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);
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)
{
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;
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
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
+#include <stdio.h>
+
#ifdef __cplusplus
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
*
/*
- * 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);
#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"
*/
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;
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);
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));
}
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);
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);
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);
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);
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);
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;
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];
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;
}
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");
}
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;
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);
}
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);
}
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");
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);
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);
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);
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);
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);
#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"
#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;
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);
+ }
}
{
if(stream) {
trace_dump_writes("</trace>\n");
- os_stream_close(stream);
+ fclose(stream);
stream = NULL;
refcount = 0;
call_no = 0;
if(!stream) {
- stream = os_file_stream_create(filename);
+ stream = fopen(filename, "wt");
if(!stream)
return FALSE;
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)