Skip to content

Implement dup-family functions #832

Merged
alexcrichton merged 1 commit into
WebAssembly:mainfrom
alexcrichton:dup
Jul 17, 2026
Merged

Implement dup-family functions #832
alexcrichton merged 1 commit into
WebAssembly:mainfrom
alexcrichton:dup

Conversation

@alexcrichton

@alexcrichton alexcrichton commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

This commit builds on the work of #822 to implement dup-style
functions. Notably dup, dup2, dup3, and F_DUPFD{,_CLOEXEC} are
now implemented for wasip2/wasip3 targets. The wasip1 target is left
unmodified here. The goal of this commit is to unblock more tests being
run in Python upstream where a number rely on these functions. With the
reference counting in #822 the functions are relatively easy to
implement, although this required refactoring the descriptor table
itself to support these operations.

Previously the descriptor table allocated in a LIFO manner but this has
been replaced with a POSIX-compliant lowest-value-returned instead.

Closes #802

Note: this is built on #822

This commit builds on the work of WebAssembly#822 to implement `dup`-style
functions. Notably `dup`, `dup2`, `dup3`, and `F_DUPFD{,_CLOEXEC}` are
now implemented for wasip2/wasip3 targets. The wasip1 target is left
unmodified here. The goal of this commit is to unblock more tests being
run in Python upstream where a number rely on these functions. With the
reference counting in WebAssembly#822 the functions are relatively easy to
implement, although this required refactoring the descriptor table
itself to support these operations.

Previously the descriptor table allocated in a LIFO manner but this has
been replaced with a POSIX-compliant lowest-value-returned instead.

Closes WebAssembly#802
@alexcrichton
alexcrichton merged commit d30f0ae into WebAssembly:main Jul 17, 2026
35 checks passed
@alexcrichton
alexcrichton deleted the dup branch July 17, 2026 17:56
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.

F_DUPFD (+ others) need definition, else gnulib defines them for you and blows up

2 participants