Add PIL_check_seconds_timer_i to avoid casting

note, win32 casts still casts from double.
This commit is contained in:
Campbell Barton 2015-02-01 01:57:45 +11:00
parent 9e9cd77b8d
commit f90891d87e
4 changed files with 25 additions and 4 deletions

View File

@ -860,14 +860,14 @@ void BKE_image_memorypack(Image *ima)
void BKE_image_tag_time(Image *ima)
{
ima->lastused = (int)PIL_check_seconds_timer();
ima->lastused = PIL_check_seconds_timer_i();
}
#if 0
static void tag_all_images_time()
{
Image *ima;
int ctime = (int)PIL_check_seconds_timer();
int ctime = PIL_check_seconds_timer_i();
ima = G.main->image.first;
while (ima) {

View File

@ -37,7 +37,7 @@
extern "C" {
#endif
extern
extern
/** Return an indication of time, expressed as
* seconds since some fixed point. Successive calls
* are guaranteed to generate values greater than or
@ -45,6 +45,12 @@ extern
*/
double PIL_check_seconds_timer(void);
extern
/**
* int version of #PIL_check_seconds_timer
*/
long int PIL_check_seconds_timer_i(void);
/**
* Platform-independent sleep function.
* \param ms Number of milliseconds to sleep

View File

@ -70,6 +70,11 @@ double PIL_check_seconds_timer(void)
}
}
long int PIL_check_seconds_timer_i(void)
{
return (long int)PIL_check_seconds_timer();
}
void PIL_sleep_ms(int ms)
{
Sleep(ms);
@ -90,6 +95,16 @@ double PIL_check_seconds_timer(void)
return ((double) tv.tv_sec + tv.tv_usec / 1000000.0);
}
long int PIL_check_seconds_timer_i(void)
{
struct timeval tv;
struct timezone tz;
gettimeofday(&tv, &tz);
return tv.tv_sec;
}
void PIL_sleep_ms(int ms)
{
if (ms >= 1000) {

View File

@ -1324,7 +1324,7 @@ void GPU_free_images_old(void)
{
Image *ima;
static int lasttime = 0;
int ctime = (int)PIL_check_seconds_timer();
int ctime = PIL_check_seconds_timer_i();
/*
* Run garbage collector once for every collecting period of time