示例#1
0
文件: timesupp.c 项目: comex/libogc
int clock_gettime(struct timespec *tp)
{
	u32 gctime;
#if defined(HW_RVL)
	u32 wii_bias = 0;
#endif

	if(!tp) return -1;

	if(!__SYS_GetRTC(&gctime)) return -1;

#if defined(HW_DOL)
	syssram* sram = __SYS_LockSram();
	gctime += sram->counter_bias;
	__SYS_UnlockSram(0);
#else
	if(CONF_GetCounterBias(&wii_bias)>=0) gctime += wii_bias;
#endif
	gctime += 946684800;

	tp->tv_sec = gctime;
	tp->tv_nsec = ticks_to_nanosecs(gettick());

	return 0;
}
示例#2
0
文件: timesupp.c 项目: comex/libogc
u32 diff_nsec(long long start,long long end)
{
	u64 diff;

	diff = diff_ticks(start,end);
	return ticks_to_nanosecs(diff);
}
示例#3
0
// high-resolution timers for profiling
uint64_t getu64ticks(void)
{
# if defined _WIN32
    return win_getu64ticks();
# elif defined __APPLE__
    return mach_absolute_time();
# elif _POSIX_TIMERS>0 && defined _POSIX_MONOTONIC_CLOCK
    // This is SDL HG's SDL_GetPerformanceCounter() when clock_gettime() is
    // available.
    uint64_t ticks;
    struct timespec now;

    clock_gettime(CLOCK_MONOTONIC, &now);
    ticks = now.tv_sec;
    ticks *= 1000000000;
    ticks += now.tv_nsec;
    return ticks;
# elif defined GEKKO
    return ticks_to_nanosecs(gettime());
# else
    // Blar. This pragma is unsupported on earlier GCC versions.
    // At least we'll get a warning and a reference to this line...
#  pragma message "Using low-resolution (1ms) timer for getu64ticks. Profiling will work badly."
    return SDL_GetTicks();
# endif
}