Commit 6a02b5cd4e916dad82917cb5b454f62472ec0866

Thomas de Grivel 2018-06-17T17:09:42

use _STAT_VER under Linux

diff --git a/cffi-stat.lisp b/cffi-stat.lisp
index fc50cbf..dd5417e 100644
--- a/cffi-stat.lisp
+++ b/cffi-stat.lisp
@@ -88,7 +88,7 @@
          (sb (:pointer (:struct stat))))
        (defmacro with-fstat ((var &optional (error-p t)) fd &body body)
          `(with-foreign-object (,var '(:struct stat))
-            (cond ((= 0 (c-__fxstat 3 ,fd ,var))
+            (cond ((= 0 (c-__fxstat +stat-ver+ ,fd ,var))
                    (locally ,@body))
                   ,@(when error-p
                       `((t (error-errno "__fxstat")))))))))
@@ -110,7 +110,7 @@
          (sb (:pointer (:struct stat))))
        (defmacro with-stat ((var &optional (error-p t)) path &body body)
          `(with-foreign-object (,var '(:struct stat))
-            (cond ((= 0 (the fixnum (c-__xstat 3 ,path ,var)))
+            (cond ((= 0 (the fixnum (c-__xstat +stat-ver+ ,path ,var)))
                    (locally ,@body))
                   ,@(when error-p
                       `((t (error-errno "__xstat")))))))))
@@ -132,7 +132,7 @@
          (sb (:pointer (:struct stat))))
        (defmacro with-lstat ((var &optional (error-p t)) path &body body)
          `(with-foreign-object (,var '(:struct stat))
-            (cond ((= 0 (c-__lxstat 3 ,path ,var))
+            (cond ((= 0 (c-__lxstat +stat-ver+ ,path ,var))
                    (locally ,@body))
                   ,@(when error-p
                       `((t (error-errno "__lxstat")))))))))
diff --git a/grovel-stat.lisp b/grovel-stat.lisp
index a917fbe..128b8a8 100644
--- a/grovel-stat.lisp
+++ b/grovel-stat.lisp
@@ -40,6 +40,9 @@
          (tv-nsec "tv_nsec" :type :long))
 
 #+linux
+(constant (+stat-ver+ "_STAT_VER"))
+
+#+linux
 (cstruct stat "struct stat"
          (st-mode "st_mode" :type mode-t)
          (st-dev "st_dev" :type dev-t)