Skip to content

core.sys.posix.dirent: Add dirfd#22750

Merged
thewilsonator merged 4 commits intodlang:masterfrom
dd86k:dd86k/dirent-dirfd2
Mar 17, 2026
Merged

core.sys.posix.dirent: Add dirfd#22750
thewilsonator merged 4 commits intodlang:masterfrom
dd86k:dd86k/dirent-dirfd2

Conversation

@dd86k
Copy link
Contributor

@dd86k dd86k commented Mar 17, 2026

This commit adds the definition of dirfd, a POSIX function.

The pragma is left as-is, as it was (erroneously) defined in Phobos.

extern (D) added because the entire module is otherwise affected by extern (C).

(Take 2, switching branches everywhere gets a little messy, my bad.)

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @dd86k! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#22750"

@dd86k dd86k changed the title core.sys.posix.sys.dirent: Add dirfd core.sys.posix.dirent: Add dirfd Mar 17, 2026
}
else
{
pragma(mangle, "dirfd")
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't extern(C) already mangle it as dirfd?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, at least on most platforms (at least POSIX), but I left this as-is because the C extern definition in Phobos (std.process) had it, and I'd hate to break anything here.

Related: dlang/phobos#10976

Copy link
Contributor

@dkorpel dkorpel Mar 17, 2026

Choose a reason for hiding this comment

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

The reason Phobos had it is because it was defined in a function scope, where extern(C) would only affect the ABI and not the mangle. Here it would be more risky to have a special mangle override for this one function rather than make it consistent with the rest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair, I'll remove it

@ibuclaw
Copy link
Member

ibuclaw commented Mar 17, 2026

Did you mean to put the declaration in the middle of a section declaring other functions?

Perhaps add the declaration immediately before Thread-Safe Functions (TSF) ?

dd86k and others added 2 commits March 17, 2026 13:44
Co-authored-by: Iain Buclaw <ibuclaw@gdcproject.org>
Co-authored-by: Iain Buclaw <ibuclaw@gdcproject.org>
@dd86k
Copy link
Contributor Author

dd86k commented Mar 17, 2026

Did you mean to put the declaration in the middle of a section declaring other functions?
Perhaps add the declaration immediately before Thread-Safe Functions (TSF) ?

Oh, yeah, I see that I accidentally put that in-between readdir/closedir.

dirfd is neither TSF or XSI, so I'll move it higher, since it's typically defined rather high up.

It is still POSIX-1.2008, though.

@dd86k
Copy link
Contributor Author

dd86k commented Mar 17, 2026

On second thought.. I did define it after struct DIR; declarations, since NetBSD stuff is the only exception.

Up to anyone if it's preferred to have the binding on every version scope.

@ibuclaw
Copy link
Member

ibuclaw commented Mar 17, 2026

On second thought.. I did define it after struct DIR; declarations, since NetBSD stuff is the only exception.

D doesn't care about order of declarations / forward references. Move it higher up if that makes more sense.

@thewilsonator thewilsonator merged commit 71e2ffc into dlang:master Mar 17, 2026
42 checks 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.

5 participants