Merge commit 'a39d4083cab589d7cd6a13e8a4b8db8875261d75'
[gnulib.git] / lib / opendir.c
index cb7f67c..c67f2e5 100644 (file)
@@ -1,5 +1,5 @@
 /* Start reading the entries of a directory.
-   Copyright (C) 2006-2011 Free Software Foundation, Inc.
+   Copyright (C) 2006-2014 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -19,6 +19,9 @@
 /* Specification.  */
 #include <dirent.h>
 
+#include <errno.h>
+#include <stddef.h>
+
 #if HAVE_OPENDIR
 
 /* Override opendir(), to keep track of the open file descriptors.
@@ -26,8 +29,6 @@
 
 #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)
 {