summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-10 17:26:58 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-10 17:26:58 +0000
commit91de3d6539ca93366cf5f5de0a26b4474ccecab2 (patch)
treecb55186ebd1f798232d7665e1dd2fb0a3f74d255 /file.c
parent4cfc1aa9591714b0d9ccc9a8f5ce4461a82db899 (diff)
support 128bit ino on Windows (if available)
* win32/win32.c, include/ruby/win32.h (stati128, rb_{,u,l,ul}stati128): rename from stati64ns, change the type of st_ino to 64bit and added st_inohigh. * dir.c, file.c (stat, lstat): follow above changes. * file.c (rb_stat_ino): support 128bit ino. * win32/win32.c (rb_{,u,l,ul}stati128): ditto. [Feature #13731] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/file.c b/file.c
index a2039c6639..5fa6f7e1b3 100644
--- a/file.c
+++ b/file.c
@@ -91,9 +91,9 @@ int flock(int, int);
/* define system APIs */
#ifdef _WIN32
#include "win32/file.h"
-#define STAT(p, s) rb_w32_ustati64ns((p), (s))
+#define STAT(p, s) rb_w32_ustati128((p), (s))
#undef lstat
-#define lstat(p, s) rb_w32_ulstati64ns((p), (s))
+#define lstat(p, s) rb_w32_ulstati128((p), (s))
#undef access
#define access(p, m) rb_w32_uaccess((p), (m))
#undef truncate
@@ -611,17 +611,12 @@ rb_stat_dev_minor(VALUE self)
static VALUE
rb_stat_ino(VALUE self)
{
-#ifdef _WIN32
- struct stat *st = get_stat(self);
- unsigned short *p2 = (unsigned short *)st;
- unsigned int *p4 = (unsigned int *)st;
- uint64_t r;
- r = p2[2];
- r <<= 16;
- r |= p2[7];
- r <<= 32;
- r |= p4[5];
- return ULL2NUM(r);
+#ifdef HAVE_STRUCT_STAT_ST_INOHIGH
+ /* assume INTEGER_PACK_LSWORD_FIRST and st_inohigh is just next of st_ino */
+ return rb_integer_unpack(&get_stat(self)->st_ino, 2,
+ SIZEOF_STRUCT_STAT_ST_INO, 0,
+ INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER|
+ INTEGER_PACK_2COMP);
#elif SIZEOF_STRUCT_STAT_ST_INO > SIZEOF_LONG
return ULL2NUM(get_stat(self)->st_ino);
#else