/* Specification. */
#include <dirent.h>
+#include <errno.h>
+#include <stddef.h>
+
#if HAVE_OPENDIR
/* Override opendir(), to keep track of the open file descriptors.
#else
-# include <errno.h>
-# include <stddef.h>
# include <stdlib.h>
# include "dirent-private.h"
#endif
+#if REPLACE_FCHDIR
+# include <unistd.h>
+#endif
+
DIR *
opendir (const char *dir_name)
{