Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
94717ed1
Commit
94717ed1
authored
Sep 09, 2002
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #606592: Subsecond timestamps in stat_result.
parent
df453fd0
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
112 additions
and
11 deletions
+112
-11
Doc/lib/libos.tex
Doc/lib/libos.tex
+3
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/posixmodule.c
Modules/posixmodule.c
+26
-10
configure
configure
+60
-1
configure.in
configure.in
+17
-0
pyconfig.h.in
pyconfig.h.in
+3
-0
No files found.
Doc/lib/libos.tex
View file @
94717ed1
...
...
@@ -859,6 +859,9 @@ order
More items may be added at the end by some implementations. Note that
on the Mac OS, the time values are floating point values, like all
time values on the Mac OS.
\versionchanged
[On other systems, the values are floats if the system reports
fractions of a second]
{
2.3
}
The standard module
\refmodule
{
stat
}
\refstmodindex
{
stat
}
defines
functions and constants that are useful for extracting information
from a
\ctype
{
stat
}
structure.
...
...
Misc/NEWS
View file @
94717ed1
...
...
@@ -274,6 +274,9 @@ Core and builtins
Extension modules
- The time stamps in os.stat_result are floating point numbers now if
the system supports that.
- If the size passed to mmap.mmap() is larger than the length of the
file on non-Windows platforms, a ValueError is raised. [SF bug 585792]
...
...
Modules/posixmodule.c
View file @
94717ed1
...
...
@@ -612,11 +612,28 @@ static PyStructSequence_Desc statvfs_result_desc = {
static
PyTypeObject
StatResultType
;
static
PyTypeObject
StatVFSResultType
;
static
void
fill_time
(
PyObject
*
v
,
int
index
,
time_t
sec
,
unsigned
long
nsec
)
{
PyObject
*
val
;
if
(
nsec
)
{
val
=
PyFloat_FromDouble
(
sec
+
1e-9
*
nsec
);
}
else
{
#if SIZEOF_TIME_T > SIZEOF_LONG
val
=
PyLong_FromLongLong
((
LONG_LONG
)
sec
);
#else
val
=
PyInt_FromLong
((
long
)
sec
);
#endif
}
PyStructSequence_SET_ITEM
(
v
,
index
,
val
);
}
/* pack a system stat C structure into the Python stat tuple
(used by posix_stat() and posix_fstat()) */
static
PyObject
*
_pystat_fromstructstat
(
STRUCT_STAT
st
)
{
unsigned
long
ansec
,
mnsec
,
cnsec
;
PyObject
*
v
=
PyStructSequence_New
(
&
StatResultType
);
if
(
v
==
NULL
)
return
NULL
;
...
...
@@ -643,18 +660,17 @@ _pystat_fromstructstat(STRUCT_STAT st)
#else
PyStructSequence_SET_ITEM
(
v
,
6
,
PyInt_FromLong
(
st
.
st_size
));
#endif
#if SIZEOF_TIME_T > SIZEOF_LONG
PyStructSequence_SET_ITEM
(
v
,
7
,
PyLong_FromLongLong
((
LONG_LONG
)
st
.
st_atime
));
PyStructSequence_SET_ITEM
(
v
,
8
,
PyLong_FromLongLong
((
LONG_LONG
)
st
.
st_mtime
));
PyStructSequence_SET_ITEM
(
v
,
9
,
PyLong_FromLongLong
((
LONG_LONG
)
st
.
st_ctime
));
#ifdef HAVE_STAT_TV_NSEC
ansec
=
st
.
st_atim
.
tv_nsec
;
mnsec
=
st
.
st_mtim
.
tv_nsec
;
cnsec
=
st
.
st_ctim
.
tv_nsec
;
#else
PyStructSequence_SET_ITEM
(
v
,
7
,
PyInt_FromLong
((
long
)
st
.
st_atime
));
PyStructSequence_SET_ITEM
(
v
,
8
,
PyInt_FromLong
((
long
)
st
.
st_mtime
));
PyStructSequence_SET_ITEM
(
v
,
9
,
PyInt_FromLong
((
long
)
st
.
st_ctime
));
ansec
=
mnsec
=
cnsec
=
0
;
#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
);
#ifdef HAVE_ST_BLKSIZE
PyStructSequence_SET_ITEM
(
v
,
ST_BLKSIZE_IDX
,
...
...
configure
View file @
94717ed1
#! /bin/sh
# From configure.in Revision: 1.3
39
.
# From configure.in Revision: 1.3
41
.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.53.
#
...
...
@@ -15699,6 +15699,65 @@ _ACEOF
fi
# Look for subsecond timestamps in struct stat
echo
"
$as_me
:
$LINENO
: checking for tv_nsec in struct stat"
>
&5
echo
$ECHO_N
"checking for tv_nsec in struct stat...
$ECHO_C
"
>
&6
if
test
"
${
ac_cv_stat_tv_nsec
+set
}
"
=
set
;
then
echo
$ECHO_N
"(cached)
$ECHO_C
"
>
&6
else
cat
>
conftest.
$ac_ext
<<
_ACEOF
#line
$LINENO
"configure"
#include "confdefs.h"
#include <sys/stat.h>
#ifdef F77_DUMMY_MAIN
# ifdef __cplusplus
extern "C"
# endif
int F77_DUMMY_MAIN() { return 1; }
#endif
int
main ()
{
struct stat st;
st.st_mtim.tv_nsec = 1;
;
return 0;
}
_ACEOF
rm
-f
conftest.
$ac_objext
if
{
(
eval echo
"
$as_me
:
$LINENO
:
\"
$ac_compile
\"
"
)
>
&5
(
eval
$ac_compile
)
2>&5
ac_status
=
$?
echo
"
$as_me
:
$LINENO
:
\$
? =
$ac_status
"
>
&5
(
exit
$ac_status
)
;
}
&&
{
ac_try
=
'test -s conftest.$ac_objext'
{
(
eval echo
"
$as_me
:
$LINENO
:
\"
$ac_try
\"
"
)
>
&5
(
eval
$ac_try
)
2>&5
ac_status
=
$?
echo
"
$as_me
:
$LINENO
:
\$
? =
$ac_status
"
>
&5
(
exit
$ac_status
)
;
}
;
}
;
then
ac_cv_stat_tv_nsec
=
yes
else
echo
"
$as_me
: failed program was:"
>
&5
cat
conftest.
$ac_ext
>
&5
ac_cv_stat_tv_nsec
=
no
fi
rm
-f
conftest.
$ac_objext
conftest.
$ac_ext
fi
echo
"
$as_me
:
$LINENO
: result:
$ac_cv_stat_tv_nsec
"
>
&5
echo
"
${
ECHO_T
}
$ac_cv_stat_tv_nsec
"
>
&6
if
test
"
$ac_cv_stat_tv_nsec
"
=
yes
then
cat
>>
confdefs.h
<<
\
_ACEOF
#define HAVE_STAT_TV_NSEC 1
_ACEOF
fi
# On HP/UX 11.0, mvwdelch is a block with a return statement
echo
"
$as_me
:
$LINENO
: checking whether mvwdelch is an expression"
>
&5
echo
$ECHO_N
"checking whether mvwdelch is an expression...
$ECHO_C
"
>
&6
...
...
configure.in
View file @
94717ed1
...
...
@@ -2240,6 +2240,23 @@ then
[Define if nice() returns success/failure instead of the new priority.])
fi
# Look for subsecond timestamps in struct stat
AC_MSG_CHECKING(for tv_nsec in struct stat)
AC_CACHE_VAL(ac_cv_stat_tv_nsec,
AC_TRY_COMPILE([#include <sys/stat.h>], [
struct stat st;
st.st_mtim.tv_nsec = 1;
],
ac_cv_stat_tv_nsec = yes,
ac_cv_stat_tv_nsec=no,
ac_cv_stat_tv_nsec=no))
AC_MSG_RESULT($ac_cv_stat_tv_nsec)
if test "$ac_cv_stat_tv_nsec" = yes
then
AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
[Define if you have struct stat.st_mtim.tv_nsec])
fi
# On HP/UX 11.0, mvwdelch is a block with a return statement
AC_MSG_CHECKING(whether mvwdelch is an expression)
AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
...
...
pyconfig.h.in
View file @
94717ed1
...
...
@@ -388,6 +388,9 @@
/* Define to 1 if you have the `statvfs' function. */
#undef HAVE_STATVFS
/* Define if you have struct stat.st_mtim.tv_nsec */
#undef HAVE_STAT_TV_NSEC
/* Define to 1 if you have the <stdarg.h> header file. */
#undef HAVE_STDARG_H
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment