pike.git/
src/
builtin.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2011-11-16
2011-11-16 22:52:20 by Tobias S. Josefowitz <tobij@tobij.de>
f01020a08a9356ad2acce17dd451e166d854d6af (
48
lines) (+
28
/-
20
)
[
Show
|
Annotate
]
Branch:
7.9
Change in internal timehandling; ability to invalidate current_time.
3223:
PIKEFUN int `sec() {
-
extern
struct timeval
current_time
;
+
struct timeval
now
;
if( THIS->hard_update )
-
GETTIMEOFDAY( &
current
_
time
);
+
ACCURATE_
GETTIMEOFDAY( &
now );
+
else
+
INACCURATE
_
GETTIMEOFDAY(
&now
);
-
RETURN
current_time
.tv_sec;
+
RETURN
now
.tv_sec;
} PIKEFUN int `usec() {
-
extern
struct timeval
current_time
;
+
struct timeval
now
;
if( THIS->hard_update )
-
GETTIMEOFDAY( &
current
_
time
);
+
ACCURATE_
GETTIMEOFDAY( &
now );
+
else
+
INACCURATE
_
GETTIMEOFDAY(
&now
);
-
RETURN
current_time
.tv_usec;
+
RETURN
now
.tv_usec;
} /*! @decl int usec_full
3250:
PIKEFUN int `usec_full() {
-
extern
struct timeval
current_time
;
+
struct timeval
now
;
if( THIS->hard_update )
-
GETTIMEOFDAY( &
current
_
time
);
+
ACCURATE_
GETTIMEOFDAY( &
now );
+
else
+
INACCURATE
_
GETTIMEOFDAY(
&now
);
#ifdef AUTO_BIGNUM
-
push_int(
current_time
.tv_sec );
+
push_int(
now
.tv_sec );
push_int( 1000000 ); f_multiply( 2 );
-
push_int(
current_time
.tv_usec );
+
push_int(
now
.tv_usec );
f_add( 2 ); return; #else
-
RETURN (
current_time
.tv_sec * 1000000 +
current_time
.tv_usec);
+
RETURN (
now
.tv_sec * 1000000 +
now
.tv_usec);
#endif }
3297:
*/ PIKEFUN float peek( ) {
-
extern
struct timeval
current_time
;
+
struct timeval
now
;
FLOAT_TYPE res; if( THIS->hard_update )
-
GETTIMEOFDAY( &
current
_
time
);
-
res =
current_time
.tv_sec-THIS->last_time.tv_sec +
-
(
current_time
.tv_usec-THIS->last_time.tv_usec)/(FLOAT_TYPE) 1000000.0;
+
ACCURATE_
GETTIMEOFDAY( &
now );
+
else
+
INACCURATE
_
GETTIMEOFDAY(
&now
);
+
res =
now
.tv_sec-THIS->last_time.tv_sec +
+
(
now
.tv_usec-THIS->last_time.tv_usec)/(FLOAT_TYPE) 1000000.0;
RETURN res; }
3313:
*/ PIKEFUN float get( ) {
-
extern struct timeval current_time;
+
f_Timer_peek( 0 );
-
THIS->last_time
= current_time
;
+
INACCURATE_GETTIMEOFDAY(&
THIS->last_time
)
;
return; }
3332:
PIKEFUN void create( int|zero|void fast ) flags ID_PROTECTED; {
-
extern struct timeval current_time;
+
THIS->hard_update = !fast; if( THIS->hard_update )
-
GETTIMEOFDAY( &
current
_time );
-
THIS->last_time
= current_time
;
+
ACCURATE_
GETTIMEOFDAY( &
THIS->last
_time );
+
else
+
INACCURATE_GETTIMEOFDAY( &
THIS->last_time
)
;
} }