summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/os/os_stream.h
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2010-02-14 16:55:04 +0000
committerJosé Fonseca <jfonseca@vmware.com>2010-02-14 23:25:33 +0000
commit2b4575f16d24a212b9a43cbd4a9966b3668e4b32 (patch)
tree6d6eb6a87e5641fb48c9e76181893a711e01d43b /src/gallium/auxiliary/os/os_stream.h
parente7660a54423c69fe352e21eedd2a082d9c7aeac0 (diff)
os: Make streams abstract.
Also replace windows kernel stream with null implementation. It was severely limited and no easy means to test it now.
Diffstat (limited to 'src/gallium/auxiliary/os/os_stream.h')
-rw-r--r--src/gallium/auxiliary/os/os_stream.h55
1 files changed, 42 insertions, 13 deletions
diff --git a/src/gallium/auxiliary/os/os_stream.h b/src/gallium/auxiliary/os/os_stream.h
index bf30e6542d..8232b0f158 100644
--- a/src/gallium/auxiliary/os/os_stream.h
+++ b/src/gallium/auxiliary/os/os_stream.h
@@ -37,25 +37,54 @@
#include "pipe/p_compiler.h"
-struct os_stream;
-
-
/**
- * Create a stream
- * @param filename relative or absolute path (necessary for windows)
- * @param optional maximum file size (0 for a growable size).
+ * 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);
+};
+
+
+static INLINE void
+os_stream_close(struct os_stream *stream)
+{
+ stream->close(stream);
+}
+
+
+static INLINE boolean
+os_stream_write(struct os_stream *stream, const void *data, size_t size)
+{
+ return stream->write(stream, data, size);
+}
+
+
+static INLINE void
+os_stream_flush(struct os_stream *stream)
+{
+ stream->flush(stream);
+}
+
+
struct os_stream *
-os_stream_create(const char *filename, size_t max_size);
+os_file_stream_create(const char *filename);
+
-boolean
-os_stream_write(struct os_stream *stream, const void *data, size_t size);
+struct os_stream *
+os_null_stream_create(void);
-void
-os_stream_flush(struct os_stream *stream);
-void
-os_stream_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_ */