Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
c52c6a6e
Commit
c52c6a6e
authored
Oct 13, 2014
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:cython/cython
parents
432f1df2
670e786a
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
154 additions
and
147 deletions
+154
-147
CHANGES.rst
CHANGES.rst
+3
-3
Cython/Includes/libc/time.pxd
Cython/Includes/libc/time.pxd
+46
-0
Cython/Includes/posix/resource.pxd
Cython/Includes/posix/resource.pxd
+1
-1
Cython/Includes/posix/sys_time.pxd
Cython/Includes/posix/sys_time.pxd
+0
-25
Cython/Includes/posix/time.pxd
Cython/Includes/posix/time.pxd
+33
-46
Cython/Includes/posix/types.pxd
Cython/Includes/posix/types.pxd
+0
-1
tests/run/libc_time.pyx
tests/run/libc_time.pyx
+47
-0
tests/run/posix_sys_time.pyx
tests/run/posix_sys_time.pyx
+0
-33
tests/run/posix_time.pyx
tests/run/posix_time.pyx
+24
-38
No files found.
CHANGES.rst
View file @
c52c6a6e
...
@@ -34,9 +34,9 @@ Bugs fixed
...
@@ -34,9 +34,9 @@ Bugs fixed
* Reference leak for non-simple Python expressions in boolean and/or expressions.
* Reference leak for non-simple Python expressions in boolean and/or expressions.
*
``getitimer()``, ``setitimer()``, ``gettimeofday()`` and related type/constant
*
To fix a name collision and to reflect availability on host platforms,
definitions were moved from ``posix/time.pxd`` to ``posix/sys_time.pxd`` to
standard C declarations [ clock(), time(), struct tm and tm* functions ]
fix a naming collision
.
were moved from posix/time.pxd to a new libc/time.pxd
.
* Rerunning unmodified modules in IPython's cython support failed.
* Rerunning unmodified modules in IPython's cython support failed.
Patch by Matthias Bussonier.
Patch by Matthias Bussonier.
...
...
Cython/Includes/libc/time.pxd
0 → 100644
View file @
c52c6a6e
# http://en.wikipedia.org/wiki/C_date_and_time_functions
from
libc.stddef
cimport
wchar_t
cdef
extern
from
"time.h"
nogil
:
ctypedef
long
clock_t
ctypedef
long
time_t
enum
:
CLOCKS_PER_SEC
clock_t
clock
()
# CPU time
time_t
time
(
time_t
*
)
# wall clock time since Unix epoch
cdef
struct
tm
:
int
tm_sec
int
tm_min
int
tm_hour
int
tm_mday
int
tm_mon
int
tm_year
int
tm_wday
int
tm_yday
int
tm_isdst
char
*
tm_zone
long
tm_gmtoff
int
daylight
# global state
long
timezone
char
*
tzname
[
2
]
void
tzset
()
char
*
asctime
(
const
tm
*
)
char
*
asctime_r
(
const
tm
*
,
char
*
)
char
*
ctime
(
const
time_t
*
)
char
*
ctime_r
(
const
time_t
*
,
char
*
)
double
difftime
(
time_t
,
time_t
)
tm
*
getdate
(
const
char
*
)
tm
*
gmtime
(
const
time_t
*
)
tm
*
gmtime_r
(
const
time_t
*
,
tm
*
)
tm
*
localtime
(
const
time_t
*
)
tm
*
localtime_r
(
const
time_t
*
,
tm
*
)
time_t
mktime
(
tm
*
)
size_t
strftime
(
char
*
,
size_t
,
const
char
*
,
const
tm
*
)
size_t
wcsftime
(
wchar_t
*
str
,
size_t
cnt
,
const
wchar_t
*
fmt
,
tm
*
time
)
# POSIX not stdC
char
*
strptime
(
const
char
*
,
const
char
*
,
tm
*
)
Cython/Includes/posix/resource.pxd
View file @
c52c6a6e
# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/resource.h.html
# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/resource.h.html
from
posix.
sys_time
cimport
timeval
from
posix.
time
cimport
timeval
from
posix.types
cimport
id_t
from
posix.types
cimport
id_t
cdef
extern
from
"sys/resource.h"
nogil
:
cdef
extern
from
"sys/resource.h"
nogil
:
...
...
Cython/Includes/posix/sys_time.pxd
deleted
100644 → 0
View file @
432f1df2
# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/time.h.html
from
posix.types
cimport
suseconds_t
,
time_t
cdef
extern
from
"sys/time.h"
nogil
:
enum
:
ITIMER_REAL
enum
:
ITIMER_VIRTUAL
enum
:
ITIMER_PROF
cdef
struct
timezone
:
int
tz_minuteswest
int
dsttime
cdef
struct
timeval
:
time_t
tv_sec
suseconds_t
tv_usec
cdef
struct
itimerval
:
timeval
it_interval
timeval
it_value
int
getitimer
(
int
,
itimerval
*
)
int
gettimeofday
(
timeval
*
tp
,
timezone
*
tzp
)
int
setitimer
(
int
,
const
itimerval
*
,
itimerval
*
)
Cython/Includes/posix/time.pxd
View file @
c52c6a6e
# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/time.h.html
# http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/time.h.html
from
posix.types
cimport
suseconds_t
,
time_t
,
clockid_t
,
timer_t
from
posix.signal
cimport
sigevent
from
posix.signal
cimport
sigevent
from
posix.types
cimport
clock_t
,
clockid_t
,
suseconds_t
,
time_t
,
timer_t
cdef
extern
from
"time.h"
nogil
:
cdef
extern
from
"sys/time.h"
nogil
:
enum
:
CLOCKS_PER_SEC
enum
:
CLOCK_PROCESS_CPUTIME_ID
enum
:
CLOCK_PROCESS_CPUTIME_ID
enum
:
CLOCK_THREAD_CPUTIME_ID
enum
:
CLOCK_THREAD_CPUTIME_ID
...
@@ -33,55 +31,44 @@ cdef extern from "time.h" nogil:
...
@@ -33,55 +31,44 @@ cdef extern from "time.h" nogil:
enum
:
CLOCK_REALTIME_ALARM
enum
:
CLOCK_REALTIME_ALARM
enum
:
CLOCK_BOOTTIME_ALARM
enum
:
CLOCK_BOOTTIME_ALARM
enum
:
ITIMER_REAL
enum
:
ITIMER_VIRTUAL
enum
:
ITIMER_PROF
cdef
struct
timezone
:
int
tz_minuteswest
int
dsttime
cdef
struct
timeval
:
time_t
tv_sec
suseconds_t
tv_usec
cdef
struct
timespec
:
cdef
struct
timespec
:
time_t
tv_sec
time_t
tv_sec
long
tv_nsec
long
tv_nsec
cdef
struct
itimerval
:
timeval
it_interval
timeval
it_value
cdef
struct
itimerspec
:
cdef
struct
itimerspec
:
timespec
it_interval
timespec
it_interval
timespec
it_value
timespec
it_value
cdef
struct
tm
:
int
nanosleep
(
const
timespec
*
,
timespec
*
)
int
tm_sec
int
tm_min
int
getitimer
(
int
,
itimerval
*
)
int
tm_hour
int
gettimeofday
(
timeval
*
tp
,
timezone
*
tzp
)
int
tm_mday
int
setitimer
(
int
,
const
itimerval
*
,
itimerval
*
)
int
tm_mon
int
tm_year
int
tm_wday
int
tm_yday
int
tm_isdst
char
*
tm_zone
long
tm_gmtoff
char
*
asctime
(
const
tm
*
)
char
*
asctime_r
(
const
tm
*
,
char
*
)
clock_t
clock
()
int
clock_getcpuclockid
(
pid_t
,
clockid_t
*
)
int
clock_getcpuclockid
(
pid_t
,
clockid_t
*
)
int
clock_getres
(
clockid_t
,
timespec
*
)
int
clock_getres
(
clockid_t
,
timespec
*
)
int
clock_gettime
(
clockid_t
,
timespec
*
)
int
clock_gettime
(
clockid_t
,
timespec
*
)
int
clock_nanosleep
(
clockid_t
,
int
,
const
timespec
*
,
timespec
*
)
int
clock_nanosleep
(
clockid_t
,
int
,
const
timespec
*
,
timespec
*
)
int
clock_settime
(
clockid_t
,
const
timespec
*
)
int
clock_settime
(
clockid_t
,
const
timespec
*
)
char
*
ctime
(
const
time_t
*
)
char
*
ctime_r
(
const
time_t
*
,
char
*
)
double
difftime
(
time_t
,
time_t
)
tm
*
getdate
(
const
char
*
)
tm
*
gmtime
(
const
time_t
*
)
tm
*
gmtime_r
(
const
time_t
*
,
tm
*
)
tm
*
localtime
(
const
time_t
*
)
tm
*
localtime_r
(
const
time_t
*
,
tm
*
)
time_t
mktime
(
tm
*
)
int
nanosleep
(
const
timespec
*
,
timespec
*
)
size_t
strftime
(
char
*
,
size_t
,
const
char
*
,
const
tm
*
)
char
*
strptime
(
const
char
*
,
const
char
*
,
tm
*
)
time_t
time
(
time_t
*
)
int
timer_create
(
clockid_t
,
sigevent
*
,
timer_t
*
)
int
timer_create
(
clockid_t
,
sigevent
*
,
timer_t
*
)
int
timer_delete
(
timer_t
)
int
timer_delete
(
timer_t
)
int
timer_gettime
(
timer_t
,
itimerspec
*
)
int
timer_gettime
(
timer_t
,
itimerspec
*
)
int
timer_getoverrun
(
timer_t
)
int
timer_getoverrun
(
timer_t
)
int
timer_settime
(
timer_t
,
int
,
const
itimerspec
*
,
itimerspec
*
)
int
timer_settime
(
timer_t
,
int
,
const
itimerspec
*
,
itimerspec
*
)
void
tzset
()
int
daylight
long
timezone
char
*
tzname
[
2
]
Cython/Includes/posix/types.pxd
View file @
c52c6a6e
cdef
extern
from
"sys/types.h"
:
cdef
extern
from
"sys/types.h"
:
ctypedef
long
blkcnt_t
ctypedef
long
blkcnt_t
ctypedef
long
blksize_t
ctypedef
long
blksize_t
ctypedef
long
clock_t
ctypedef
long
clockid_t
ctypedef
long
clockid_t
ctypedef
long
dev_t
ctypedef
long
dev_t
ctypedef
long
gid_t
ctypedef
long
gid_t
...
...
tests/run/libc_time.pyx
0 → 100644
View file @
c52c6a6e
# tag: posix
from
libc.stdlib
cimport
getenv
from
posix.stdlib
cimport
setenv
,
unsetenv
from
libc.time
cimport
*
def
test_time
():
"""
>>> test_time()
"""
cdef
time_t
t1
,
t2
t1
=
time
(
NULL
)
assert
t1
!=
0
t1
=
time
(
&
t2
)
assert
t1
==
t2
def
test_mktime
():
"""
>>> test_mktime() # doctest:+ELLIPSIS
(986138177, ...'Sun Apr 1 15:16:17 2001
\
\
n')
"""
cdef
tm
t
,
gmt
cdef
time_t
tt
cdef
char
*
ct
cdef
char
*
tz
tz
=
getenv
(
"TZ"
)
setenv
(
"TZ"
,
"UTC"
,
1
)
tzset
()
t
.
tm_sec
=
17
t
.
tm_min
=
16
t
.
tm_hour
=
15
t
.
tm_year
=
101
t
.
tm_mon
=
3
t
.
tm_mday
=
1
t
.
tm_isdst
=
0
tt
=
mktime
(
&
t
)
assert
tt
!=
-
1
ct
=
ctime
(
&
tt
)
assert
ct
!=
NULL
if
tz
:
setenv
(
"TZ"
,
tz
,
1
)
else
:
unsetenv
(
"TZ"
)
tzset
()
return
tt
,
ct
tests/run/posix_sys_time.pyx
deleted
100644 → 0
View file @
432f1df2
# tag: posix
from
posix.sys_time
cimport
*
def
test_itimer
(
sec
,
usec
):
"""
>>> test_itimer(10, 2)
(10, 2)
"""
cdef
itimerval
t
,
gtime
t
.
it_interval
.
tv_sec
=
sec
t
.
it_interval
.
tv_usec
=
usec
t
.
it_value
.
tv_sec
=
sec
t
.
it_value
.
tv_usec
=
usec
ret
=
setitimer
(
ITIMER_REAL
,
&
t
,
NULL
)
assert
ret
==
0
ret
=
getitimer
(
ITIMER_REAL
,
&
gtime
)
assert
ret
==
0
t
.
it_interval
.
tv_sec
=
0
t
.
it_interval
.
tv_usec
=
0
t
.
it_value
.
tv_sec
=
0
t
.
it_value
.
tv_usec
=
0
ret
=
setitimer
(
ITIMER_REAL
,
&
t
,
NULL
)
return
gtime
.
it_interval
.
tv_sec
,
gtime
.
it_interval
.
tv_usec
def
test_gettimeofday
():
"""
>>> test_gettimeofday()
"""
cdef
timeval
t
ret
=
gettimeofday
(
&
t
,
NULL
)
assert
ret
==
0
tests/run/posix_time.pyx
View file @
c52c6a6e
# tag: posix
# tag: posix
from
libc.stdlib
cimport
getenv
from
posix.stdlib
cimport
setenv
,
unsetenv
from
posix.time
cimport
*
from
posix.time
cimport
*
def
test_
time
(
):
def
test_
itimer
(
sec
,
usec
):
"""
"""
>>> test_time()
>>> test_itimer(10, 2)
(10, 2)
"""
"""
cdef
time_t
t1
,
t2
cdef
itimerval
t
,
gtime
t1
=
time
(
NULL
)
assert
t1
!=
0
t1
=
time
(
&
t2
)
assert
t1
==
t2
t
.
it_interval
.
tv_sec
=
sec
t
.
it_interval
.
tv_usec
=
usec
t
.
it_value
.
tv_sec
=
sec
t
.
it_value
.
tv_usec
=
usec
ret
=
setitimer
(
ITIMER_REAL
,
&
t
,
NULL
)
assert
ret
==
0
ret
=
getitimer
(
ITIMER_REAL
,
&
gtime
)
assert
ret
==
0
t
.
it_interval
.
tv_sec
=
0
t
.
it_interval
.
tv_usec
=
0
t
.
it_value
.
tv_sec
=
0
t
.
it_value
.
tv_usec
=
0
ret
=
setitimer
(
ITIMER_REAL
,
&
t
,
NULL
)
return
gtime
.
it_interval
.
tv_sec
,
gtime
.
it_interval
.
tv_usec
def
test_
mktime
():
def
test_
gettimeofday
():
"""
"""
>>> test_mktime() # doctest:+ELLIPSIS
>>> test_gettimeofday()
(986138177, ...'Sun Apr 1 15:16:17 2001
\
\
n')
"""
"""
cdef
tm
t
,
gmt
cdef
timeval
t
cdef
time_t
tt
ret
=
gettimeofday
(
&
t
,
NULL
)
cdef
char
*
ct
assert
ret
==
0
cdef
char
*
tz
tz
=
getenv
(
"TZ"
)
setenv
(
"TZ"
,
"UTC"
,
1
)
tzset
()
t
.
tm_sec
=
17
t
.
tm_min
=
16
t
.
tm_hour
=
15
t
.
tm_year
=
101
t
.
tm_mon
=
3
t
.
tm_mday
=
1
t
.
tm_isdst
=
0
tt
=
mktime
(
&
t
)
assert
tt
!=
-
1
ct
=
ctime
(
&
tt
)
assert
ct
!=
NULL
if
tz
:
setenv
(
"TZ"
,
tz
,
1
)
else
:
unsetenv
(
"TZ"
)
tzset
()
return
tt
,
ct
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