Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/linux/jiffies.h
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | usecs_to_jiffies(uint64_t usec) | ||||
return ((int)result); | return ((int)result); | ||||
} | } | ||||
static inline uint64_t | static inline uint64_t | ||||
nsecs_to_jiffies64(uint64_t nsec) | nsecs_to_jiffies64(uint64_t nsec) | ||||
{ | { | ||||
uint64_t nsec_max, result; | uint64_t nsec_max, result; | ||||
/* Extend range (avoid multiplying by hz) for the common case. | |||||
* drm syncobj actually needs this as it's called by Mesa with INT64_MAX. */ | |||||
if (NSEC_PER_SEC % (uint64_t)hz == 0) { | |||||
return (div_u64(nsec, NSEC_PER_SEC / hz)); | |||||
} | |||||
nsec_max = -1ULL / (uint64_t)hz; | nsec_max = -1ULL / (uint64_t)hz; | ||||
if (nsec > nsec_max) | if (nsec > nsec_max) | ||||
nsec = nsec_max; | nsec = nsec_max; | ||||
result = howmany(nsec * (uint64_t)hz, 1000000000ULL); | result = howmany(nsec * (uint64_t)hz, 1000000000ULL); | ||||
if (result > MAX_JIFFY_OFFSET) | if (result > MAX_JIFFY_OFFSET) | ||||
result = MAX_JIFFY_OFFSET; | result = MAX_JIFFY_OFFSET; | ||||
return (result); | return (result); | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |