struct clock {
clockid_t id; /* CLOCK_MONOTONIC or CLOCK_REALTIME. */
- pthread_rwlock_t rwlock; /* Mutual exclusion for 'cache'. */
+ struct ovs_rwlock rwlock; /* Mutual exclusion for 'cache'. */
/* Features for use by unit tests. Protected by 'rwlock'. */
struct timespec warp; /* Offset added for unit tests. */
/* Monotonic time, in milliseconds, at which the last call to time_poll() woke
* up. */
-DEFINE_PER_THREAD_DATA(long long int, last_wakeup, 0);
+DEFINE_STATIC_PER_THREAD_DATA(long long int, last_wakeup, 0);
static void set_up_timer(void);
static void set_up_signal(int flags);
{
memset(c, 0, sizeof *c);
c->id = id;
- xpthread_rwlock_init(&c->rwlock, NULL);
+ ovs_rwlock_init(&c->rwlock);
xclock_gettime(c->id, &c->cache);
}
for (;;) {
/* Use the cached time by preference, but fall through if there's been
* a clock tick. */
- xpthread_rwlock_rdlock(&c->rwlock);
+ ovs_rwlock_rdlock(&c->rwlock);
if (c->stopped || !c->tick) {
timespec_add(ts, &c->cache, &c->warp);
- xpthread_rwlock_unlock(&c->rwlock);
+ ovs_rwlock_unlock(&c->rwlock);
return;
}
- xpthread_rwlock_unlock(&c->rwlock);
+ ovs_rwlock_unlock(&c->rwlock);
/* Refresh the cache. */
- xpthread_rwlock_wrlock(&c->rwlock);
+ ovs_rwlock_wrlock(&c->rwlock);
if (c->tick) {
c->tick = false;
xclock_gettime(c->id, &c->cache);
}
- xpthread_rwlock_unlock(&c->rwlock);
+ ovs_rwlock_unlock(&c->rwlock);
}
}
int argc OVS_UNUSED, const char *argv[] OVS_UNUSED,
void *aux OVS_UNUSED)
{
- xpthread_rwlock_wrlock(&monotonic_clock.rwlock);
+ ovs_rwlock_wrlock(&monotonic_clock.rwlock);
monotonic_clock.stopped = true;
- xpthread_rwlock_unlock(&monotonic_clock.rwlock);
+ ovs_rwlock_unlock(&monotonic_clock.rwlock);
unixctl_command_reply(conn, NULL);
}
ts.tv_sec = msecs / 1000;
ts.tv_nsec = (msecs % 1000) * 1000 * 1000;
- xpthread_rwlock_wrlock(&monotonic_clock.rwlock);
+ ovs_rwlock_wrlock(&monotonic_clock.rwlock);
timespec_add(&monotonic_clock.warp, &monotonic_clock.warp, &ts);
- xpthread_rwlock_unlock(&monotonic_clock.rwlock);
+ ovs_rwlock_unlock(&monotonic_clock.rwlock);
unixctl_command_reply(conn, "warped");
}