]> Savannah Git Hosting - gnulib.git/commitdiff
same-inode: Adapt for windows-stat-inodes.
authorBruno Haible <bruno@clisp.org>
Sun, 14 May 2017 15:33:37 +0000 (17:33 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 14 May 2017 15:38:24 +0000 (17:38 +0200)
* lib/same-inode.h: Include <sys/types.h>.
(SAME_INODE) [_GL_WINDOWS_STAT_INODES]: Define specifically.
* modules/same-inode (Depends-on): Add sys_types.

ChangeLog
lib/same-inode.h
modules/same-inode

index 488d25894c1c28ea820ce2cd455f6f8f266344b9..a7a3968e9861511da46c6badf5670ed158a7bf3e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-05-14  Bruno Haible  <bruno@clisp.org>
+
+       same-inode: Adapt for windows-stat-inodes.
+       * lib/same-inode.h: Include <sys/types.h>.
+       (SAME_INODE) [_GL_WINDOWS_STAT_INODES]: Define specifically.
+       * modules/same-inode (Depends-on): Add sys_types.
+
 2017-05-14  Bruno Haible  <bruno@clisp.org>
 
        windows-stat-inodes: New module.
index 7cece6dda5b1fe7f75820546e02d998a59488fa4..a08bc4ec0d1960421ec8ad9303d45252f6501c87 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef SAME_INODE_H
 # define SAME_INODE_H 1
 
+# include <sys/types.h>
+
 # ifdef __VMS
 #  define SAME_INODE(a, b)             \
     ((a).st_ino[0] == (b).st_ino[0]    \
      && (a).st_ino[2] == (b).st_ino[2] \
      && (a).st_dev == (b).st_dev)
 # elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-/* On MinGW, struct stat lacks necessary info, so always return 0.
-   Callers can use !a.st_ino to deduce that the information is unknown.  */
-#  define SAME_INODE(a, b) 0
+   /* Native Windows.  */
+#  if _GL_WINDOWS_STAT_INODES
+    /* stat() and fstat() set st_dev and st_ino to 0 if information about
+       the inode is not available.  */
+#   define SAME_INODE(a, b) \
+     (!((a).st_ino == 0 && (a).st_dev == 0) \
+      && (a).st_ino == (b).st_ino && (a).st_dev == (b).st_dev)
+#  else
+    /* stat() and fstat() set st_ino to 0 always.  */
+#   define SAME_INODE(a, b) 0
+#  endif
 # else
 #  define SAME_INODE(a, b)    \
     ((a).st_ino == (b).st_ino \
index 27da5d24646468e079bb4f0649c8a87eb6c32d37..53964d0409d2998501729ff431c487250e417fea 100644 (file)
@@ -5,6 +5,7 @@ Files:
 lib/same-inode.h
 
 Depends-on:
+sys_types
 
 configure.ac: