Pread, readv equivalents for SDL?

Howdy folks,

I was wondering if the SDL community would be open to the idea of SDL_RWops functions that mirror the functionality of the UNIX syscalls pread() and readv(). pread() reads from a file at a particular offset atomically without modifying the file pointer (avoiding the issue of two threads seeking and reading on the same file at the same time), and readv() implements scatter-gather IO.

These functions have a lot of useful functionality, they are implemented by all of the major operating systems, and they are easy to implement on any system where they aren’t provided by the OS. I know I have been missing these in an SDL based project of mine.

I am willing to go through the work of implementing these (and their pwrite(), writev() cousins) on every SDL-supported platform I can get my hands on if you guys think it might be useful. Basically it would boil down to adding four more function pointers to the SDL_RWops struct and providing implementations for SDL_RWFromFile, FromMem, etc…

Thanks,
Sam Payson

Are these things that C++ provides in cross platform fashion? I know the
file opening and reading and manipulation of data is very robust and simple
to use.On Sat, Jul 7, 2012 at 2:30 PM, Samuel Payson wrote:

Howdy folks,

I was wondering if the SDL community would be open to the idea of
SDL_RWops functions that mirror the functionality of the UNIX syscalls
pread() and readv(). pread() reads from a file at a particular offset
atomically without modifying the file pointer (avoiding the issue of two
threads seeking and reading on the same file at the same time), and readv()
implements scatter-gather IO.

These functions have a lot of useful functionality, they are implemented
by all of the major operating systems, and they are easy to implement on
any system where they aren’t provided by the OS. I know I have been missing
these in an SDL based project of mine.

I am willing to go through the work of implementing these (and their
pwrite(), writev() cousins) on every SDL-supported platform I can get my
hands on if you guys think it might be useful. Basically it would boil down
to adding four more function pointers to the SDL_RWops struct and providing
implementations for SDL_RWFromFile, FromMem, etc…

Thanks,
Sam Payson


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Message-ID: <86B52FD9-FC1D-4A0E-BDE6-3B3FA66FC870 at gmail.com>
Content-Type: text/plain; charset=us-ascii

Howdy folks,

I was wondering if the SDL community would be open to the idea of SDL_RWops
functions that mirror the functionality of the UNIX syscalls pread() and
readv(). pread() reads from a file at a particular offset atomically without
modifying the file pointer (avoiding the issue of two threads seeking and
reading on the same file at the same time), and readv() implements
scatter-gather IO.

These functions have a lot of useful functionality, they are implemented by
all of the major operating systems, and they are easy to implement on any
system where they aren’t provided by the OS. I know I have been missing
these in an SDL based project of mine.

I am willing to go through the work of implementing these (and their
pwrite(), writev() cousins) on every SDL-supported platform I can get my
hands on if you guys think it might be useful. Basically it would boil down
to adding four more function pointers to the SDL_RWops struct and providing
implementations for SDL_RWFromFile, FromMem, etc…

Thanks,
Sam Payson

If you want to build up a selection of these, I can donate a
mostly-done SDL_RWops for the fork/exec idiom. I know that Windows has
a version, and probably all of the major multi-process OSes have some
equivalent.> Date: Sat, 7 Jul 2012 14:30:51 -0500

From: Samuel Payson
To: sdl at lists.libsdl.org
Subject: [SDL] pread, readv equivalents for SDL?

I don’t know that c++ explicitly supports scatter/gather techniques, though you could implement one somewhat simply (using std::copy, std::istream_iterator, and some class for iterating over scattered arrays).

SDL is a C library though, so standard C++ doesn’t really help anyone using it from pure C. The main argument for SDL_RWops is that it allows the user to implement their own backend. It is basically a cross-platform BSD funopen() or GNU fopencookie().On Jul 7, 2012, at 9:10 PM, R Manard wrote:

Are these things that C++ provides in cross platform fashion? I know the file opening and reading and manipulation of data is very robust and simple to use.

On Sat, Jul 7, 2012 at 2:30 PM, Samuel Payson <@Samuel_Payson> wrote:
Howdy folks,

I was wondering if the SDL community would be open to the idea of SDL_RWops functions that mirror the functionality of the UNIX syscalls pread() and readv(). pread() reads from a file at a particular offset atomically without modifying the file pointer (avoiding the issue of two threads seeking and reading on the same file at the same time), and readv() implements scatter-gather IO.

These functions have a lot of useful functionality, they are implemented by all of the major operating systems, and they are easy to implement on any system where they aren’t provided by the OS. I know I have been missing these in an SDL based project of mine.

I am willing to go through the work of implementing these (and their pwrite(), writev() cousins) on every SDL-supported platform I can get my hands on if you guys think it might be useful. Basically it would boil down to adding four more function pointers to the SDL_RWops struct and providing implementations for SDL_RWFromFile, FromMem, etc…

Thanks,
Sam Payson


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Ok, so you are saying since I use c/c++ insead of pure c that it’s of no
use to me I guess. It looks like some thing that would make a good lib like
sdl_mixer is good for sound. It’s not hard to open and close files in pure
c either but if one person has a use for it then I’m sure someone else will
want it too rite?
I think sdl is a cross platform c/c++ lib written in c though if we want to
be proper.On Sun, Jul 8, 2012 at 12:49 AM, Samuel Payson wrote:

I don’t know that c++ explicitly supports scatter/gather techniques,
though you could implement one somewhat simply (using std::copy,
std::istream_iterator, and some class for iterating over scattered arrays).

SDL is a C library though, so standard C++ doesn’t really help anyone
using it from pure C. The main argument for SDL_RWops is that it allows the
user to implement their own backend. It is basically a cross-platform BSD
funopen() or GNU fopencookie().

On Jul 7, 2012, at 9:10 PM, R Manard wrote:

Are these things that C++ provides in cross platform fashion? I know the
file opening and reading and manipulation of data is very robust and simple
to use.

On Sat, Jul 7, 2012 at 2:30 PM, Samuel Payson wrote:

Howdy folks,

I was wondering if the SDL community would be open to the idea of
SDL_RWops functions that mirror the functionality of the UNIX syscalls
pread() and readv(). pread() reads from a file at a particular offset
atomically without modifying the file pointer (avoiding the issue of two
threads seeking and reading on the same file at the same time), and readv()
implements scatter-gather IO.

These functions have a lot of useful functionality, they are implemented
by all of the major operating systems, and they are easy to implement on
any system where they aren’t provided by the OS. I know I have been missing
these in an SDL based project of mine.

I am willing to go through the work of implementing these (and their
pwrite(), writev() cousins) on every SDL-supported platform I can get my
hands on if you guys think it might be useful. Basically it would boil down
to adding four more function pointers to the SDL_RWops struct and providing
implementations for SDL_RWFromFile, FromMem, etc…

Thanks,
Sam Payson


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Like I said, the main point is for non-file uses. SDL_RWops can be backed by anything, not just a file. It could be a media codec, a custom archive file format, a compressed stream, the network, memory… That is why people use SDL_RWops instead of cstdio, it allows a common interface to multiple backends. In this sense it is of use to both C and C++ users. If you wanted to achieve the same thing by extending the convoluted mess that is std::iostreams… good luck =P.On Jul 9, 2012, at 5:47 PM, R Manard wrote:

Ok, so you are saying since I use c/c++ insead of pure c that it’s of no use to me I guess. It looks like some thing that would make a good lib like sdl_mixer is good for sound. It’s not hard to open and close files in pure c either but if one person has a use for it then I’m sure someone else will want it too rite?
I think sdl is a cross platform c/c++ lib written in c though if we want to be proper.

On Sun, Jul 8, 2012 at 12:49 AM, Samuel Payson <@Samuel_Payson> wrote:
I don’t know that c++ explicitly supports scatter/gather techniques, though you could implement one somewhat simply (using std::copy, std::istream_iterator, and some class for iterating over scattered arrays).

SDL is a C library though, so standard C++ doesn’t really help anyone using it from pure C. The main argument for SDL_RWops is that it allows the user to implement their own backend. It is basically a cross-platform BSD funopen() or GNU fopencookie().

On Jul 7, 2012, at 9:10 PM, R Manard wrote:

Are these things that C++ provides in cross platform fashion? I know the file opening and reading and manipulation of data is very robust and simple to use.

On Sat, Jul 7, 2012 at 2:30 PM, Samuel Payson <@Samuel_Payson> wrote:
Howdy folks,

I was wondering if the SDL community would be open to the idea of SDL_RWops functions that mirror the functionality of the UNIX syscalls pread() and readv(). pread() reads from a file at a particular offset atomically without modifying the file pointer (avoiding the issue of two threads seeking and reading on the same file at the same time), and readv() implements scatter-gather IO.

These functions have a lot of useful functionality, they are implemented by all of the major operating systems, and they are easy to implement on any system where they aren’t provided by the OS. I know I have been missing these in an SDL based project of mine.

I am willing to go through the work of implementing these (and their pwrite(), writev() cousins) on every SDL-supported platform I can get my hands on if you guys think it might be useful. Basically it would boil down to adding four more function pointers to the SDL_RWops struct and providing implementations for SDL_RWFromFile, FromMem, etc…

Thanks,
Sam Payson


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Make a lib, make an example, show me how useful it can be. As for
"functions that mirror the functionality of the UNIX syscalls" I don’t want
any, but if there is something I can use, then maybe. I honestly can’t say
the idea is good or bad.
I don’t want to make you mad. I just can’t envision what, if anything, I’m
missing out on.On Mon, Jul 9, 2012 at 8:02 PM, Samuel Payson wrote:

Like I said, the main point is for non-file uses. SDL_RWops can be backed
by anything, not just a file. It could be a media codec, a custom archive
file format, a compressed stream, the network, memory… That is why people
use SDL_RWops instead of cstdio, it allows a common interface to multiple
backends. In this sense it is of use to both C and C++ users. If you wanted
to achieve the same thing by extending the convoluted mess that is
std::iostreams… good luck =P.

On Jul 9, 2012, at 5:47 PM, R Manard wrote:

Ok, so you are saying since I use c/c++ insead of pure c that it’s of no
use to me I guess. It looks like some thing that would make a good lib like
sdl_mixer is good for sound. It’s not hard to open and close files in pure
c either but if one person has a use for it then I’m sure someone else will
want it too rite?
I think sdl is a cross platform c/c++ lib written in c though if we want
to be proper.

On Sun, Jul 8, 2012 at 12:49 AM, Samuel Payson wrote:

I don’t know that c++ explicitly supports scatter/gather techniques,
though you could implement one somewhat simply (using std::copy,
std::istream_iterator, and some class for iterating over scattered arrays).

SDL is a C library though, so standard C++ doesn’t really help anyone
using it from pure C. The main argument for SDL_RWops is that it allows the
user to implement their own backend. It is basically a cross-platform BSD
funopen() or GNU fopencookie().

On Jul 7, 2012, at 9:10 PM, R Manard wrote:

Are these things that C++ provides in cross platform fashion? I know the
file opening and reading and manipulation of data is very robust and simple
to use.

On Sat, Jul 7, 2012 at 2:30 PM, Samuel Payson wrote:

Howdy folks,

I was wondering if the SDL community would be open to the idea of
SDL_RWops functions that mirror the functionality of the UNIX syscalls
pread() and readv(). pread() reads from a file at a particular offset
atomically without modifying the file pointer (avoiding the issue of two
threads seeking and reading on the same file at the same time), and readv()
implements scatter-gather IO.

These functions have a lot of useful functionality, they are implemented
by all of the major operating systems, and they are easy to implement on
any system where they aren’t provided by the OS. I know I have been missing
these in an SDL based project of mine.

I am willing to go through the work of implementing these (and their
pwrite(), writev() cousins) on every SDL-supported platform I can get my
hands on if you guys think it might be useful. Basically it would boil down
to adding four more function pointers to the SDL_RWops struct and providing
implementations for SDL_RWFromFile, FromMem, etc…

Thanks,
Sam Payson


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org