1 dnl @synopsis FP_READDIR_EOF_ERRNO
3 dnl Check what readdir() sets 'errno' to upon reaching
4 dnl end of directory; not setting it is the correct thing to do,
5 dnl but mingw based versions have set it to ENOENT until recently
9 AC_DEFUN(FP_READDIR_EOF_ERRNO,
10 [AC_CACHE_CHECK([what readdir sets errno to upon EOF], fptools_cv_readdir_eof_errno,
11 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <dirent.h>
19 FILE *f=fopen("conftestval", "w");
20 #if defined(__MINGW32__)
21 int fd = mkdir("testdir");
23 int fd = mkdir("testdir", 0666);
31 fprintf(stderr,"unable to create directory; quitting.\n");
35 dp = opendir("testdir");
37 fprintf(stderr,"unable to browse directory; quitting.\n");
42 /* the assumption here is that readdir() will only return NULL
43 * due to reaching the end of the directory.
45 while (de = readdir(dp)) {
54 }]])],[fptools_cv_readdir_eof_errno=`cat conftestval`],[fptools_cv_readdir_eof_errno=bogus],[fptools_cv_readdir_eof_errno=0])])
55 dnl the cross value is somewhat bogus.
56 AC_DEFINE_UNQUOTED([READDIR_ERRNO_EOF], [$fptools_cv_readdir_eof_errno], [readdir() sets errno to this upon EOF])
59 dnl @synopsis FP_DIRENT_FLAT_LAYOUT
61 dnl Check whether 'struct dirent' (in dirent.h) has d_name defined
62 dnl as being the final field in a struct, or a pointer to somewhere
63 dnl else. The former is the standardly thing to do, but mingw defns
64 dnl have for the longest time gone for the latter. They no longer do,
65 dnl hence the need to configure test for this.
68 AC_DEFUN(FP_DIRENT_FLAT_LAYOUT,
69 [AC_CACHE_CHECK([if struct dirent layout is flat], fptools_cv_dirent_flat_layout,
70 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <dirent.h>
80 * Check whether d_name is defined as
81 * struct dirent { .... ; char d_name[..]; }
83 * struct dirent { .... ; char* d_name; }
85 * Returns 0 if the former.
87 memset(&de,0,sizeof(struct dirent));
88 return ((int)de.d_name == 0);
89 }]])],[fptools_cv_dirent_flat_layout=yes],[fptools_cv_dirent_flat_layout=no],[fptools_cv_dirent_flat_layout=yes])])
90 dnl the cross value is somewhat bogus.
91 if test "$fptools_cv_dirent_flat_layout" = yes; then
92 AC_DEFINE([STRUCT_DIRENT_FLAT_LAYOUT], [1], [Define to 1 if struct dirent is a flat structure])