Skip to content

Commit 71e2ffc

Browse files
authored
core.sys.posix.dirent: Add dirfd (#22750)
1 parent 25c8466 commit 71e2ffc

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

druntime/src/core/sys/posix/dirent.d

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,26 @@ else
441441
static assert(false, "Unsupported platform");
442442
}
443443

444+
//
445+
// POSIX.1-2008
446+
//
447+
/*
448+
int dirfd(DIR*);
449+
*/
450+
version (NetBSD)
451+
{
452+
// On NetBSD, this is a macro in dirent.h, not a function.
453+
extern (D) int dirfd()(DIR* dir) nothrow @nogc
454+
{
455+
// ABI guarantees dd_fd remains the first field
456+
return *(cast(int*) dir);
457+
}
458+
}
459+
else
460+
{
461+
nothrow @nogc int dirfd(DIR* dir);
462+
}
463+
444464
// Only OS X out of the Darwin family needs special treatment. Other Darwins
445465
// (iOS, TVOS, WatchOS) are fine with normal symbol names for these functions
446466
// in else below.

0 commit comments

Comments
 (0)