Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL assumes RW_SEEK_SET == SEEK_SET #3416

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Closed

SDL assumes RW_SEEK_SET == SEEK_SET #3416

SDLBugzilla opened this issue Feb 11, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: HG 2.1
Reported for operating system, platform: Other, All

Comments on the original bug report:

On 2019-10-08 14:19:15 +0000, Dan Gohman wrote:

SDL defines its own constants for RW_SEEK_SET etc., and then assumes that they have the same values as the host SEEK_SET etc. However, while the values SDL uses are common, they are not universal; for example cloudlibc uses different values:

https://github.com/NuxiNL/cloudlibc/blob/master/src/include/stdio.h#L88

Specifically, include/SDL_rwops.h defines RW_SEEK_SET etc. like this:

#define RW_SEEK_SET 0 /< Seek from the beginning of data */
#define RW_SEEK_CUR 1 /
< Seek relative to current read point */
#define RW_SEEK_END 2 /**< Seek relative to the end of data */

http://hg.libsdl.org/SDL/file/db9d0d0b7ebc/include/SDL_rwops.h#l174

And then passes them to the host fseek:

http://hg.libsdl.org/SDL/file/db9d0d0b7ebc/src/file/SDL_rwops.c#l370

Ideally, SDL should remap RW_SEEK_SET etc. to SEEK_SET etc., which compilers would likely be able to optimize away on hosts where they are the same.

On 2019-10-10 15:25:55 +0000, Sylvain wrote:

Thanks,
Fixed https://hg.libsdl.org/SDL/rev/efa5fe44e4e8

(done the same way as window_seek, mem_seek, etc..)

Just notice, since linux 3.1, there are also: SEEK_DATA, SEEK_HOLE ...
that would have worked before, but I am not seek this is used.
I think not in SDL_mixer/ttf/image externals libs

Seeking file data and holes
Since version 3.1, Linux supports the following additional values for
whence:

   SEEK_DATA
          Adjust the file offset to the next location in the file
          greater than or equal to offset containing data.  If offset
          points to data, then the file offset is set to offset.

   SEEK_HOLE
          Adjust the file offset to the next hole in the file greater
          than or equal to offset.  If offset points into the middle of
          a hole, then the file offset is set to offset.  If there is no
          hole past offset, then the file offset is adjusted to the end
          of the file (i.e., there is an implicit hole at the end of any
          file).

http://man7.org/linux/man-pages/man2/lseek.2.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant