This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Avoid local PLT for dirfd


It appears it is indeed just for libc, since the dirstream type is opaque
in public.  I think it's just the case that the macro version of dirfd in
dirent.h predates the practice of include/foo.h defining libc-private
versions of things.  So it would be the right cleanup to take that out of
dirent/dirent.h and put it in include/dirent.h, where it can just do
#include <dirstream.h> to ensure it's always defined.

It appears the only places that benefit from the short-circuit dirfd at all
are fts, ftw, glob, and nscd.

There is no Hurd definition of the macro because Hurd's struct __dirstream
doesn't hold the fd as an integer, and hence the dirfd implementation is
nontrivial.  It's probably a worthwhile optimization on Hurd that it holds
the direct pointer.  But there's no real reason it couldn't cache the int
there too, to optimize dirfd.  It's already the case that close(dirfd(dir))
causes readdir(dir) to fail with EBADF just as on Unix.


Thanks,
Roland


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]