[Python-checkins] python/dist/src/Modules posixmodule.c, 2.337, 2.338
loewis@users.sourceforge.net
loewis at users.sourceforge.net
Tue Aug 9 17:01:04 CEST 2005
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2103/Modules
Modified Files:
posixmodule.c
Log Message:
Patch #1180695: Implement nanosecond stat resolution on FreeBSD,
add st_gen, st_birthtime.
Index: posixmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.337
retrieving revision 2.338
diff -u -d -r2.337 -r2.338
--- posixmodule.c 5 Jul 2005 15:21:58 -0000 2.337
+++ posixmodule.c 9 Aug 2005 15:00:59 -0000 2.338
@@ -706,6 +706,12 @@
#ifdef HAVE_STRUCT_STAT_ST_FLAGS
{"st_flags", "user defined flags for file"},
#endif
+#ifdef HAVE_STRUCT_STAT_ST_GEN
+ {"st_gen", "generation number"},
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME
+ {"st_birthtime", "time of creation"},
+#endif
{0}
};
@@ -733,6 +739,18 @@
#define ST_FLAGS_IDX ST_RDEV_IDX
#endif
+#ifdef HAVE_STRUCT_STAT_ST_GEN
+#define ST_GEN_IDX (ST_RDEV_IDX+1)
+#else
+#define ST_GEN_IDX ST_RDEV_IDX
+#endif
+
+#ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME
+#define ST_BIRTHTIME_IDX (ST_GEN_IDX+1)
+#else
+#define ST_BIRTHTIME_IDX ST_GEN_IDX
+#endif
+
static PyStructSequence_Desc stat_result_desc = {
"stat_result", /* name */
stat_result__doc__, /* doc */
@@ -878,8 +896,14 @@
mnsec = st.st_mtim.tv_nsec;
cnsec = st.st_ctim.tv_nsec;
#else
+#ifdef HAVE_STAT_TV_NSEC2
+ ansec = st.st_atimespec.tv_nsec;
+ mnsec = st.st_mtimespec.tv_nsec;
+ cnsec = st.st_ctimespec.tv_nsec;
+#else
ansec = mnsec = cnsec = 0;
#endif
+#endif
fill_time(v, 7, st.st_atime, ansec);
fill_time(v, 8, st.st_mtime, mnsec);
fill_time(v, 9, st.st_ctime, cnsec);
@@ -896,6 +920,29 @@
PyStructSequence_SET_ITEM(v, ST_RDEV_IDX,
PyInt_FromLong((long)st.st_rdev));
#endif
+#ifdef HAVE_STRUCT_STAT_ST_GEN
+ PyStructSequence_SET_ITEM(v, ST_GEN_IDX,
+ PyInt_FromLong((long)st.st_gen));
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME
+ {
+ PyObject *val;
+ unsigned long bsec,bnsec;
+ bsec = (long)st.st_birthtime;
+#ifdef HAVE_STAT_TV_NSEC2
+ bnsec = st.st_birthtimespec.tv_nsec;
+#else
+ bnsec = 0;
+#endif
+ if (_stat_float_times) {
+ val = PyFloat_FromDouble(bsec + 1e-9*bnsec);
+ } else {
+ val = PyInt_FromLong((long)bsec);
+ }
+ PyStructSequence_SET_ITEM(v, ST_BIRTHTIME_IDX,
+ val);
+ }
+#endif
#ifdef HAVE_STRUCT_STAT_ST_FLAGS
PyStructSequence_SET_ITEM(v, ST_FLAGS_IDX,
PyInt_FromLong((long)st.st_flags));
More information about the Python-checkins
mailing list