From 57f8e26ca87a2846f192682c84eccbf8b4500bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 9 Nov 2011 07:02:27 +0000 Subject: gallium/auxiliary: Remove os_stream. XP kernel mode was the only subsystem lacking stdio FILES. Reviewed-by: Brian Paul --- 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 ------------------------------ 6 files changed, 652 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 (limited to 'src/gallium/auxiliary/os') 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 -#include - -#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; -} -- cgit v1.1