Skip to content

Fix calls to varargs C function fcntl - #494

Closed
nrdmn wants to merge 1 commit into
haskell:masterfrom
nrdmn:master
Closed

nrdmn wants to merge 1 commit into
haskell:masterfrom
nrdmn:master

Conversation

@nrdmn

@nrdmn nrdmn commented Jan 5, 2021 •

Copy link
Copy Markdown

The ccall calling convention doesn't support varargs functions, so
switch to capi instead. See
https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/ffi.html#varargs-not-supported-by-ccall-calling-convention

Related PR: haskellari/lukko#23

@kazu-yamamoto
kazu-yamamoto self-requested a review January 13, 2021 00:22

@kazu-yamamoto kazu-yamamoto left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good catch.
May I ask you to add a comment like "varargs requires capi instead of ccall"?

@kazu-yamamoto

Copy link
Copy Markdown
Collaborator

It seems to me that capi breaks doctest:

bytecode compiler can't handle some foreign calling conventions

@eborden

eborden commented May 18, 2021

Copy link
Copy Markdown
Collaborator

@nrdmn do you have an interest in fixing this PR?

kazu-yamamoto added a commit that referenced this pull request Nov 13, 2026
ccall cannot call a variadic C function portably.  The only uses are
F_GETFD and F_GETFL, which take no argument, so the wrapper takes none.
Unlike capi (#494), this keeps doctest working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kazu-yamamoto

Copy link
Copy Markdown
Collaborator

Thank you for spotting this. capi broke doctest, so #634 fixes it another way: fcntl is now called through a small non-variadic C wrapper, hsnet_fcntl_get, since the only uses (F_GETFD and F_GETFL) take no third argument. Closing in favour of #634.

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.

3 participants