return utc ? gmtime_r(t, tm) : localtime_r(t, tm);
}
-unsigned long usec_to_jiffies(usec_t u) {
- static thread_local unsigned long hz = 0;
+static uint32_t sysconf_clock_ticks_cached(void) {
+ static thread_local uint32_t hz = 0;
long r;
if (hz == 0) {
hz = r;
}
- return DIV_ROUND_UP(u , USEC_PER_SEC / hz);
+ return hz;
+}
+
+uint32_t usec_to_jiffies(usec_t u) {
+ uint32_t hz = sysconf_clock_ticks_cached();
+ return DIV_ROUND_UP(u, USEC_PER_SEC / hz);
+}
+
+usec_t jiffies_to_usec(uint32_t j) {
+ uint32_t hz = sysconf_clock_ticks_cached();
+ return DIV_ROUND_UP(j * USEC_PER_SEC, hz);
}
usec_t usec_shift_clock(usec_t x, clockid_t from, clockid_t to) {
time_t mktime_or_timegm(struct tm *tm, bool utc);
struct tm *localtime_or_gmtime_r(const time_t *t, struct tm *tm, bool utc);
-unsigned long usec_to_jiffies(usec_t usec);
+uint32_t usec_to_jiffies(usec_t usec);
+usec_t jiffies_to_usec(uint32_t jiffies);
bool in_utc_timezone(void);