summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2017-05-14 17:33:37 +0200
committerBruno Haible <bruno@clisp.org>2017-05-14 17:38:24 +0200
commit0e9b97cffc239000d07cc51c16eda56cf87f5195 (patch)
treec4aa4bf45c253d15cab4dd4f5c24f336c4479ee8
parent8123b614e616eaa951d842f10730ba7b914f75b3 (diff)
downloadgnulib-0e9b97cffc239000d07cc51c16eda56cf87f5195.tar.gz
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.
-rw-r--r--ChangeLog7
-rw-r--r--lib/same-inode.h16
-rw-r--r--modules/same-inode1
3 files changed, 21 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 488d25894c..a7a3968e98 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
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.
* m4/windows-stat-inodes.m4: New file.
* m4/sys_types_h.m4 (gl_SYS_TYPES_H): Set WINDOWS_STAT_INODES.
diff --git a/lib/same-inode.h b/lib/same-inode.h
index 7cece6dda5..a08bc4ec0d 100644
--- a/lib/same-inode.h
+++ b/lib/same-inode.h
@@ -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] \
@@ -25,9 +27,17 @@
&& (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 \
diff --git a/modules/same-inode b/modules/same-inode
index 27da5d2464..53964d0409 100644
--- a/modules/same-inode
+++ b/modules/same-inode
@@ -5,6 +5,7 @@ Files:
lib/same-inode.h
Depends-on:
+sys_types
configure.ac: