Esempio n. 1
0
int __wrap_clock_gettime(clockid_t clock_id, struct timespec *tp)
{
	int err;
#ifdef CONFIG_XENO_HW_DIRECT_TSC
	if (clock_id == CLOCK_MONOTONIC && sysinfo.tickval == 1) {
		unsigned long long tsc;
		unsigned long rem;

		tsc = __xn_rdtsc();
		tp->tv_sec = xnarch_ulldiv(tsc, sysinfo.cpufreq, &rem);
		/* Next line is 64 bits safe, since rem is less than
		   sysinfo.cpufreq hence fits on 32 bits. */
		tp->tv_nsec = xnarch_imuldiv(rem, 1000000000, sysinfo.cpufreq);
		return 0;
	}
#endif /* CONFIG_XENO_HW_DIRECT_TSC */

	err = -XENOMAI_SKINCALL2(__pse51_muxid,
				 __pse51_clock_gettime,
				 clock_id,
				 tp);

	if (!err)
		return 0;

	errno = err;
	return -1;
}
Esempio n. 2
0
static inline long long slldiv(long long s, unsigned d)
{
	return s >= 0 ? xnarch_ulldiv(s, d, NULL) : -xnarch_ulldiv(-s, d, NULL);
}
Esempio n. 3
0
unsigned long long xnclock_divrem_billion(unsigned long long value,
					  unsigned long *rem)
{
	return xnarch_ulldiv(value, 1000000000, rem);

}
Esempio n. 4
0
sticks_t clockobj_ns_to_ticks(struct clockobj *clkobj, sticks_t ns)
{
	/* Cobalt has optimized arith ops, use them. */
	return xnarch_ulldiv(ns, clkobj->resolution, NULL);
}
Esempio n. 5
0
xnticks_t xntbase_ns2ticks_ceil(xntbase_t *base, xntime_t t)
{
	return xnarch_ulldiv(t + xntbase_get_tickval(base) - 1,
			     xntbase_get_tickval(base), NULL);
}