Skip to content

fmemopen.c: portability fix around funopen()#368

Merged
timg236 merged 1 commit intoraspberrypi:masterfrom
DeforaNetworks:khorben/funopen
Apr 1, 2026
Merged

fmemopen.c: portability fix around funopen()#368
timg236 merged 1 commit intoraspberrypi:masterfrom
DeforaNetworks:khorben/funopen

Conversation

@khorben
Copy link
Copy Markdown
Contributor

@khorben khorben commented Mar 31, 2026

As noted in main.c, funopen() is used when fmemopen() is not available. Unfortunately, funopen() is not portable and its definition is not stable across Operating Systems (Darwin/macOS uses fpos_t while NetBSD uses off_t).

This change fixes the build on NetBSD, where fpos_t is an opaque type and does not support arithmetic. To be fair, even macOS' manual page for funopen() mentions it erroneously assumes that fpos_t is an integral type, and invites to read fseek(3) for a discussion of this issue. Therefore, arguably the default should be off_t instead, but I did not want to possibly break functionality anywhere else.

As noted in main.c, funopen() is used when fmemopen() is not available.
Unfortunately, funopen() is not portable and its definition is not
stable across Operating Systems (Darwin/macOS uses fpos_t while NetBSD
uses off_t).

This change fixes the build on NetBSD, where fpos_t is an opaque type
and does not support arithmetic. To be fair, even macOS' manual page for
funopen() mentions it erroneously assumes that fpos_t is an integral
type, and invites to read fseek(3) for a discussion of this issue.
Therefore, arguably the default should be off_t instead, but I did not
want to possibly break functionality anywhere else.
Copy link
Copy Markdown
Collaborator

@timg236 timg236 left a comment

Choose a reason for hiding this comment

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

I think this is ok, but NETBSD should be regarded as community maintained i.e. nobody at PiTowers is likely to build for this platform.

@khorben
Copy link
Copy Markdown
Contributor Author

khorben commented Mar 31, 2026

I think this is ok, but NETBSD should be regarded as community maintained i.e. nobody at PiTowers is likely to build for this platform.

That's perfectly fine; thank you!

@timg236 timg236 merged commit 88465e6 into raspberrypi:master Apr 1, 2026
1 check passed
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