Skip to content

crunch: use _FILE_OFFSET_BITS 64 with fopen/fseek/ftell outside of Linux #38

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

Merged
merged 1 commit into from
Feb 14, 2023

Conversation

illwieckz
Copy link
Member

@illwieckz illwieckz commented Feb 13, 2023

crunch: use _FILE_OFFSET_BITS 64 with fopen/fseek/ftell outside of Linux.

It seems to work on macOS and FreeBSD without requiring specific #ifdef for any them. It also works on Linux but
we may still prefer *64 variants to avoid ambiguity.

Note: If needed, minizip/ioapi.h is known to provide more compatibility code for old MSVC too, but what we have looks good enough on that part.

It seems to work on macOS and FreeBSD without requiring
specific #ifdef for any them. It also works on Linux but
we may still prefer *64 variants to avoid ambiguity.

Note: If needed, minizip/ioapi.h is known to provide more
compatibility code for old MSVC too, but what we have looks
good enough on that part.
@illwieckz illwieckz added the enhancement New feature or request label Feb 13, 2023
@illwieckz illwieckz changed the title crunch: use _FILE_OFFSET_BITS 64 with fopen/fseek/ftell instead of linux-specific fopen64/seeko64/ftell64 crunch: use _FILE_OFFSET_BITS 64 with fopen/fseek/ftell outside of Linux Feb 13, 2023
@slipher
Copy link
Member

slipher commented Feb 13, 2023

Why do we need to go out of the way for 64-bit functions anyway? It's not like anyone needs to load a 4-gigabyte image onto the GPU

@illwieckz
Copy link
Member Author

Why do we need to go out of the way for 64-bit functions anyway? It's not like anyone needs to load a 4-gigabyte image onto the GPU

I don't know. But the tool was doing that so I see no reason to silently regress on that part.

@turol
Copy link

turol commented Feb 13, 2023

This also changes the inode number in struct stat to 64-bit. This is required on some filesystems (XFS I think) or stat calls will fail for 32-bit programs because the inode number doesn't fit.

@illwieckz
Copy link
Member Author

This also changes the inode number in struct stat to 64-bit. This is required on some filesystems (XFS I think) or stat calls will fail for 32-bit programs because the inode number doesn't fit.

Ah, that's good to know! Would it be needed to set such define on Linux even when using *64 function variants?

@illwieckz
Copy link
Member Author

This looks good enough so let's merge it.

@turol do you know if there would be some need to also set _FILE_OFFSET_BITS 64 on Linux for some uses case, even if using functions like fopen64 ?

@illwieckz illwieckz merged commit eca5c36 into master Feb 14, 2023
@turol
Copy link

turol commented Feb 14, 2023

I don't know exactly what effect this has on 64-bit or how it affects stat64/open64 functions.

Inspecting the generated code it seems that it controls at least whether the call is to _xstat or _xstat64 function.

@necessarily-equal necessarily-equal deleted the illwieckz/fopen branch February 14, 2023 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants