aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-02-20 06:54:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-02-20 06:54:23 +0000
commit15a98ab42838be248a5b59ca342033ee338357ad (patch)
tree54d37b82280acbc3dc0dc10017b7470a77135c23 /file.c
parentd034fcb13f04b096f99d1824d5e7dd8ed256713e (diff)
downloadruby-15a98ab42838be248a5b59ca342033ee338357ad.tar.gz
Try statx syscall
* file.c (rb_file_s_birthtime): export for pathname to check if birthtime is supported. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/file.c b/file.c
index c00c43e5d4..513bde5c65 100644
--- a/file.c
+++ b/file.c
@@ -1113,6 +1113,24 @@ stat_without_gvl(const char *path, struct stat *st)
}
#ifdef HAVE_STATX
+
+# if HAVE_STATX == 0
+# ifdef HAVE_SYSCALL_H
+# include <syscall.h>
+# elif defined HAVE_SYS_SYSCALL_H
+# include <sys/syscall.h>
+# endif
+# if defined __linux__
+# include <linux/stat.h>
+static inline int
+statx(int dirfd, const char *pathname, int flags,
+ unsigned int mask, struct statx *statxbuf)
+{
+ return syscall(__NR_statx, dirfd, pathname, flags, mask, statxbuf);
+}
+# endif
+# endif
+
typedef struct no_gvl_statx_data {
struct statx *stx;
int fd;
@@ -2360,9 +2378,10 @@ rb_file_ctime(VALUE obj)
*
*/
-#if defined(HAVE_STAT_BIRTHTIME)
-static VALUE
+#if defined(HAVE_STAT_BIRTHTIME) || defined(HAVE_STATX)
+RUBY_FUNC_EXPORTED VALUE
rb_file_s_birthtime(VALUE klass, VALUE fname)
+# if defined(HAVE_STAT_BIRTHTIME)
{
struct stat st;
@@ -2373,9 +2392,7 @@ rb_file_s_birthtime(VALUE klass, VALUE fname)
}
return stat_birthtime(&st);
}
-#elif defined(HAVE_STATX)
-static VALUE
-rb_file_s_birthtime(VALUE klass, VALUE fname)
+# elif defined(HAVE_STATX)
{
struct statx stx;
@@ -2390,6 +2407,9 @@ rb_file_s_birthtime(VALUE klass, VALUE fname)
}
return statx_birthtime(&stx);
}
+# else
+# error Not implemented
+# endif
#else
# define rb_file_s_birthtime rb_f_notimplement
#endif