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
b3b45440
Commit
b3b45440
authored
Mar 28, 2015
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #22117: Use the _PyTime_t API for time.clock_settime()
Remove also the now unused _PyTime_AddDouble() function.
parent
c337838a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
27 deletions
+5
-27
Include/pytime.h
Include/pytime.h
+0
-5
Modules/timemodule.c
Modules/timemodule.c
+5
-5
Python/pytime.c
Python/pytime.c
+0
-17
No files found.
Include/pytime.h
View file @
b3b45440
...
...
@@ -74,11 +74,6 @@ PyAPI_FUNC(int) _PyTime_ObjectToTimespec(
long
*
nsec
,
_PyTime_round_t
);
/* Add interval seconds to tv */
PyAPI_FUNC
(
void
)
_PyTime_AddDouble
(
_PyTime_timeval
*
tv
,
double
interval
,
_PyTime_round_t
round
);
/* Initialize time.
Return 0 on success, raise an exception and return -1 on error. */
PyAPI_FUNC
(
int
)
_PyTime_Init
(
void
);
...
...
Modules/timemodule.c
View file @
b3b45440
...
...
@@ -166,18 +166,18 @@ time_clock_settime(PyObject *self, PyObject *args)
{
int
clk_id
;
PyObject
*
obj
;
time_t
tv_sec
;
long
tv_nsec
;
_PyTime_t
t
;
struct
timespec
tp
;
int
ret
;
if
(
!
PyArg_ParseTuple
(
args
,
"iO:clock_settime"
,
&
clk_id
,
&
obj
))
return
NULL
;
if
(
_PyTime_ObjectToTimespec
(
obj
,
&
tv_sec
,
&
tv_nsec
,
_PyTime_ROUND_DOWN
)
==
-
1
)
if
(
_PyTime_FromSecondsObject
(
&
t
,
obj
,
_PyTime_ROUND_DOWN
)
<
0
)
return
NULL
;
if
(
_PyTime_AsTimespec
(
t
,
&
tp
)
==
-
1
)
return
NULL
;
tp
.
tv_sec
=
tv_sec
;
tp
.
tv_nsec
=
tv_nsec
;
ret
=
clock_settime
((
clockid_t
)
clk_id
,
&
tp
);
if
(
ret
!=
0
)
{
...
...
Python/pytime.c
View file @
b3b45440
...
...
@@ -251,23 +251,6 @@ _PyTime_ObjectToTimeval(PyObject *obj, time_t *sec, long *usec,
return
_PyTime_ObjectToDenominator
(
obj
,
sec
,
usec
,
1e6
,
round
);
}
void
_PyTime_AddDouble
(
_PyTime_timeval
*
tv
,
double
interval
,
_PyTime_round_t
round
)
{
_PyTime_timeval
tv2
;
double
frac
;
frac
=
fmod
(
interval
,
1
.
0
);
interval
=
floor
(
interval
);
tv2
.
tv_sec
=
(
long
)
interval
;
tv2
.
tv_usec
=
(
long
)(
frac
*
1e6
);
tv
->
tv_sec
+=
tv2
.
tv_sec
;
tv
->
tv_usec
+=
tv2
.
tv_usec
;
tv
->
tv_sec
+=
(
time_t
)(
tv
->
tv_usec
/
SEC_TO_US
);
tv
->
tv_usec
%=
SEC_TO_US
;
}
/****************** NEW _PyTime_t API **********************/
static
void
...
...
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