[filesystem] dirent::d_type extension availability?

The directory iterator value type objects now caches status information. Performance is much better (6 times, in one test). This optimization is present for the Windows API, and for POSIX systems which support the BSD dirent::d_type extension. Currently this is detected by the __USE_BSD macro. Please report other macros which indicate it is safe to turn on this feature. IIRC, someone indicated that Linux also supports the feature, but perhaps only on later versions. If that is the case, what is the correct macros to be tested for what values? Also, Apple OS X supplies the dirent::d_type extension, but the value isn't actually set. Any ideas on how to activate it? --Beman PS: If you want to experiment, the #if test to hack is line 65 of .../boost/filesystem/config.hpp, current CVS head.

Beman Dawes wrote:
The directory iterator value type objects now caches status information. Performance is much better (6 times, in one test).
This optimization is present for the Windows API, and for POSIX systems which support the BSD dirent::d_type extension. Currently this is detected by the __USE_BSD macro. Please report other macros which indicate it is safe to turn on this feature.
IIRC, someone indicated that Linux also supports the feature, but perhaps only on later versions. If that is the case, what is the correct macros to be tested for what values?
Also, Apple OS X supplies the dirent::d_type extension, but the value isn't actually set. Any ideas on how to activate it?
--Beman
PS: If you want to experiment, the #if test to hack is line 65 of .../boost/filesystem/config.hpp, current CVS head.
You'd be using readdir, then? Well man readdir says: According to POSIX, the dirent structure contains a field char d_name[] of unspecified size, with at most NAME_MAX characters preceding the terminating null character. Use of other fields will harm the porta- bility of your programs. POSIX 1003.1-2001 also documents the field ino_t d_ino as an XSI extension. OTOH, the glibc header dirent.h says: /* This file defines `struct dirent'. It defines the macro `_DIRENT_HAVE_D_NAMLEN' iff there is a `d_namlen' member that gives the length of `d_name'. It defines the macro `_DIRENT_HAVE_D_RECLEN' iff there is a `d_reclen' member that gives the size of the entire directory entry. It defines the macro `_DIRENT_HAVE_D_OFF' iff there is a `d_off' member that gives the file offset of the next directory entry. It defines the macro `_DIRENT_HAVE_D_TYPE' iff there is a `d_type' member that gives the type of the file. */

Neal Becker wrote:
Beman Dawes wrote:
The directory iterator value type objects now caches status information. Performance is much better (6 times, in one test).
This optimization is present for the Windows API, and for POSIX systems which support the BSD dirent::d_type extension. Currently this is detected by the __USE_BSD macro. Please report other macros which indicate it is safe to turn on this feature.
IIRC, someone indicated that Linux also supports the feature, but perhaps only on later versions. If that is the case, what is the correct macros to be tested for what values?
To be more precise: this is not a feature of Linux - it's a feature of the c lib. Linux systems ususally use glibc, but small embedded systems may use other clibs, such as ulibc. This is why lots of people gave up on "guess the macro" years ago and changed to some kind of autoconf. There are too many variables.

"Neal Becker" <ndbecker2@gmail.com> wrote in message news:do10iu$dj1$1@sea.gmane.org...
Neal Becker wrote:
Beman Dawes wrote:
The directory iterator value type objects now caches status information. Performance is much better (6 times, in one test).
This optimization is present for the Windows API, and for POSIX systems which support the BSD dirent::d_type extension. Currently this is detected by the __USE_BSD macro. Please report other macros which indicate it is safe to turn on this feature.
IIRC, someone indicated that Linux also supports the feature, but perhaps only on later versions. If that is the case, what is the correct macros to be tested for what values?
To be more precise: this is not a feature of Linux - it's a feature of the c lib. Linux systems ususally use glibc, but small embedded systems may use other clibs, such as ulibc. This is why lots of people gave up on "guess the macro" years ago and changed to some kind of autoconf. There are too many variables.
Yes, I can see the advantages of that approach. Probably because I don't have any autoconf experience, I have trouble seeing how we could make use of that approach for Boost. Any ideas? --Beman
participants (2)
-
Beman Dawes
-
Neal Becker