Skip to content

Add avif_off_t and avif_fseeko() and avif_ftello()#3094

Open
wantehchang wants to merge 1 commit intoAOMediaCodec:mainfrom
wantehchang:add-avif_off_t
Open

Add avif_off_t and avif_fseeko() and avif_ftello()#3094
wantehchang wants to merge 1 commit intoAOMediaCodec:mainfrom
wantehchang:add-avif_off_t

Conversation

@wantehchang
Copy link
Collaborator

Add simple wrappers around POSIX's fseeko() and ftello() and Windows' _fseeki64() and _ftelli64().

Add simple wrappers around POSIX's fseeko() and ftello() and Windows'
_fseeki64() and _ftelli64().
@wantehchang wantehchang requested a review from jzern March 11, 2026 01:46

if (size > 0) {
if (offset > LONG_MAX) {
if (offset > INT64_MAX) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

James: This is the only weakness of this pull request. There is no symbolic constant such as OFF_MAX for the maximum value of the off_t type. So here we assume without checking that off_t is 64 bits. (off_t is a signed integer by definition.)

This check ensures that it is safe to cast offset to avif_off_t at line 147.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing common anyway. I see gcc/clang report #define __OFF_T_MATCHES_OFF64_T 1. I wonder if it's worth adding a compile time assert in the posix path for sizeof(off_t) == 8?

// Copyright 2020 Joe Drago. All rights reserved.
// SPDX-License-Identifier: BSD-2-Clause

#if !defined(_WIN32)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking cygwin/mingw might support this, but they should also support the windows specifics you added. We can test this if the toolchains are covered by the presubmit.


if (size > 0) {
if (offset > LONG_MAX) {
if (offset > INT64_MAX) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing common anyway. I see gcc/clang report #define __OFF_T_MATCHES_OFF64_T 1. I wonder if it's worth adding a compile time assert in the posix path for sizeof(off_t) == 8?

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

Successfully merging this pull request may close these issues.

2 participants