long GetTicks(void)
{
#ifndef _ANDROID_

#ifdef PS3PORT

	//#warning "GetTick PS3\n"

	unsigned long	ticks_micro;
	uint64_t secs;
	uint64_t nsecs;

	sys_time_get_current_time(&secs, &nsecs);
	ticks_micro =  secs * 1000000UL + (nsecs / 1000);

	return ticks_micro;
#else
   	struct timeval tv;
   	gettimeofday (&tv, NULL);
   	return tv.tv_sec*1000000 + tv.tv_usec;
#endif

#else

    	struct timespec now;
    	clock_gettime(CLOCK_MONOTONIC, &now);
    	return now.tv_sec*1000000 + now.tv_nsec/1000;
#endif
                                                                              
} 
Exemple #2
0
bool scond_wait_timeout(scond_t *cond, slock_t *lock, int64_t timeout_us)
{
    struct timespec now = {0};

#ifdef __MACH__ // OSX doesn't have clock_gettime ... :(
    clock_serv_t cclock;
    mach_timespec_t mts;
    host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
    clock_get_time(cclock, &mts);
    mach_port_deallocate(mach_task_self(), cclock);
    now.tv_sec = mts.tv_sec;
    now.tv_nsec = mts.tv_nsec;
#elif defined(__CELLOS_LV2__)
    sys_time_sec_t s;
    sys_time_nsec_t n;
    sys_time_get_current_time(&s, &n);
    now.tv_sec  = s;
    now.tv_nsec = n;
#elif !defined(GEKKO) // timeout on libogc is duration, not end time
    clock_gettime(CLOCK_REALTIME, &now);
#endif

    now.tv_sec += timeout_us / 1000000LL;
    now.tv_nsec += timeout_us * 1000LL;

    now.tv_sec += now.tv_nsec / 1000000000LL;
    now.tv_nsec = now.tv_nsec % 1000000000LL;

    int ret = pthread_cond_timedwait(&cond->cond, &lock->lock, &now);
    return ret == 0;
}
long GetTicks(void)
{ // in MSec
#ifndef _ANDROID_

#ifdef __CELLOS_LV2__

   //#warning "GetTick PS3\n"

   unsigned long	ticks_micro;
   uint64_t secs;
   uint64_t nsecs;

   sys_time_get_current_time(&secs, &nsecs);
   ticks_micro =  secs * 1000000UL + (nsecs / 1000);

   return ticks_micro;///1000;
#elif defined(WIIU)
return (cpu_features_get_time_usec());///1000;
#else
   struct timeval tv;
   gettimeofday (&tv, NULL);
   return (tv.tv_sec*1000000 + tv.tv_usec);///1000;

#endif

#else

   struct timespec now;
   clock_gettime(CLOCK_MONOTONIC, &now);
   return (now.tv_sec*1000000 + now.tv_nsec/1000);///1000;
#endif

}