Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
580ef134
Kaydet (Commit)
580ef134
authored
Mar 20, 2015
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Cleanup pytime.c: add XXX_TO_YYY constants (ex: SEC_TO_US)
üst
9a8089b3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
+19
-13
pytime.c
Python/pytime.c
+19
-13
No files found.
Python/pytime.c
Dosyayı görüntüle @
580ef134
...
@@ -7,6 +7,12 @@
...
@@ -7,6 +7,12 @@
#include <mach/mach_time.h>
/* mach_absolute_time(), mach_timebase_info() */
#include <mach/mach_time.h>
/* mach_absolute_time(), mach_timebase_info() */
#endif
#endif
#define SEC_TO_MS 1000
#define MS_TO_US 1000
#define US_TO_NS 1000
#define SEC_TO_US (SEC_TO_MS * MS_TO_US)
static
int
static
int
pygettimeofday
(
_PyTime_timeval
*
tp
,
_Py_clock_info_t
*
info
,
int
raise
)
pygettimeofday
(
_PyTime_timeval
*
tp
,
_Py_clock_info_t
*
info
,
int
raise
)
{
{
...
@@ -24,8 +30,8 @@ pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
...
@@ -24,8 +30,8 @@ pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
the 1st january 1601 and the 1st january 1970 (369 years + 89 leap
the 1st january 1601 and the 1st january 1970 (369 years + 89 leap
days). */
days). */
microseconds
=
large
.
QuadPart
/
10
-
11644473600000000
;
microseconds
=
large
.
QuadPart
/
10
-
11644473600000000
;
tp
->
tv_sec
=
microseconds
/
1000000
;
tp
->
tv_sec
=
microseconds
/
SEC_TO_US
;
tp
->
tv_usec
=
microseconds
%
1000000
;
tp
->
tv_usec
=
microseconds
%
SEC_TO_US
;
if
(
info
)
{
if
(
info
)
{
DWORD
timeAdjustment
,
timeIncrement
;
DWORD
timeAdjustment
,
timeIncrement
;
BOOL
isTimeAdjustmentDisabled
,
ok
;
BOOL
isTimeAdjustmentDisabled
,
ok
;
...
@@ -58,7 +64,7 @@ pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
...
@@ -58,7 +64,7 @@ pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
return
-
1
;
return
-
1
;
}
}
tp
->
tv_sec
=
ts
.
tv_sec
;
tp
->
tv_sec
=
ts
.
tv_sec
;
tp
->
tv_usec
=
ts
.
tv_nsec
/
1000
;
tp
->
tv_usec
=
ts
.
tv_nsec
/
US_TO_NS
;
if
(
info
)
{
if
(
info
)
{
struct
timespec
res
;
struct
timespec
res
;
...
@@ -92,7 +98,7 @@ pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
...
@@ -92,7 +98,7 @@ pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
}
}
#endif
/* !HAVE_CLOCK_GETTIME */
#endif
/* !HAVE_CLOCK_GETTIME */
#endif
/* !MS_WINDOWS */
#endif
/* !MS_WINDOWS */
assert
(
0
<=
tp
->
tv_usec
&&
tp
->
tv_usec
<
1000
*
1000
);
assert
(
0
<=
tp
->
tv_usec
&&
tp
->
tv_usec
<
SEC_TO_US
);
return
0
;
return
0
;
}
}
...
@@ -126,8 +132,8 @@ pymonotonic(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
...
@@ -126,8 +132,8 @@ pymonotonic(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
result
=
GetTickCount64
();
result
=
GetTickCount64
();
tp
->
tv_sec
=
result
/
1000
;
tp
->
tv_sec
=
result
/
SEC_TO_MS
;
tp
->
tv_usec
=
(
result
%
1000
)
*
1000
;
tp
->
tv_usec
=
(
result
%
SEC_TO_MS
)
*
MS_TO_US
;
if
(
info
)
{
if
(
info
)
{
DWORD
timeAdjustment
,
timeIncrement
;
DWORD
timeAdjustment
,
timeIncrement
;
...
@@ -157,12 +163,12 @@ pymonotonic(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
...
@@ -157,12 +163,12 @@ pymonotonic(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
time
=
mach_absolute_time
();
time
=
mach_absolute_time
();
/* nanoseconds => microseconds */
/* nanoseconds => microseconds */
time
/=
1000
;
time
/=
US_TO_NS
;
/* apply timebase factor */
/* apply timebase factor */
time
*=
timebase
.
numer
;
time
*=
timebase
.
numer
;
time
/=
timebase
.
denom
;
time
/=
timebase
.
denom
;
tp
->
tv_sec
=
time
/
(
1000
*
1000
)
;
tp
->
tv_sec
=
time
/
SEC_TO_US
;
tp
->
tv_usec
=
time
%
(
1000
*
1000
)
;
tp
->
tv_usec
=
time
%
SEC_TO_US
;
if
(
info
)
{
if
(
info
)
{
info
->
implementation
=
"mach_absolute_time()"
;
info
->
implementation
=
"mach_absolute_time()"
;
...
@@ -205,9 +211,9 @@ pymonotonic(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
...
@@ -205,9 +211,9 @@ pymonotonic(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
info
->
resolution
=
res
.
tv_sec
+
res
.
tv_nsec
*
1e-9
;
info
->
resolution
=
res
.
tv_sec
+
res
.
tv_nsec
*
1e-9
;
}
}
tp
->
tv_sec
=
ts
.
tv_sec
;
tp
->
tv_sec
=
ts
.
tv_sec
;
tp
->
tv_usec
=
ts
.
tv_nsec
/
1000
;
tp
->
tv_usec
=
ts
.
tv_nsec
/
US_TO_NS
;
#endif
#endif
assert
(
0
<=
tp
->
tv_usec
&&
tp
->
tv_usec
<
1000
*
1000
);
assert
(
0
<=
tp
->
tv_usec
&&
tp
->
tv_usec
<
SEC_TO_US
);
#ifdef Py_DEBUG
#ifdef Py_DEBUG
/* monotonic clock cannot go backward */
/* monotonic clock cannot go backward */
assert
(
last
.
tv_usec
==
-
1
assert
(
last
.
tv_usec
==
-
1
...
@@ -380,8 +386,8 @@ _PyTime_AddDouble(_PyTime_timeval *tv, double interval, _PyTime_round_t round)
...
@@ -380,8 +386,8 @@ _PyTime_AddDouble(_PyTime_timeval *tv, double interval, _PyTime_round_t round)
tv
->
tv_sec
+=
tv2
.
tv_sec
;
tv
->
tv_sec
+=
tv2
.
tv_sec
;
tv
->
tv_usec
+=
tv2
.
tv_usec
;
tv
->
tv_usec
+=
tv2
.
tv_usec
;
tv
->
tv_sec
+=
(
time_t
)(
tv
->
tv_usec
/
1000000
);
tv
->
tv_sec
+=
(
time_t
)(
tv
->
tv_usec
/
SEC_TO_US
);
tv
->
tv_usec
%=
1000000
;
tv
->
tv_usec
%=
SEC_TO_US
;
}
}
int
int
...
...
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