On Mon, 27 Dec 2021 15:18:38 -0600, Joe Nelson wrote:

> I recently discovered the funopen function, and was confused by its
> declaration. Specifically, one of its arguments is
>
>       fpos_t (*seekfn)(void *, fpos_t, int)
>
> I wondered how seekfn would be able to return an error code, since the
> C99 standard section 7.19.1 specifies fpos_t as an opaque type, not one
> the user can construct. Only after some research did I learn that fpos_t
> is actually a typedef for off_t on OpenBSD.

You are correct, fpos_t is not guaranteed to be an integral type.
For instance, it may be struct on some systems.

> I propose we change the declaration to take this argument instead:
>
>       off_t (*seekfn)(void *, off_t, int)
>
> This shouldn't cause any backward incompatibility, right, because
> they're in fact the same type? Using off_t clearly communicates that
> we're dealing with a signed integer type.
>
> FWIW, NetBSD uses off_t. https://man.netbsd.org/funopen.3

That seems like the best approach.  FWIW, funopen() emulation
in the Linux libbsd uses off_t for the same reason.

 - todd

Reply via email to