Prefix CONTAINER_OF with UC_

This commit is contained in:
Nils O. Selåsdal
2013-09-28 23:45:51 +02:00
parent ff0fd32ae1
commit dd517a5d85
8 changed files with 29 additions and 19 deletions
+2 -2
View File
@@ -32,7 +32,7 @@ static void uc_cached_clock_now(struct UCoreClock *uclock,
struct timeval *tv)
{
struct UCoreCachedClock *cached_clock;
cached_clock = CONTAINER_OF(uclock, struct UCoreCachedClock, clock),
cached_clock = UC_CONTAINER_OF(uclock, struct UCoreCachedClock, clock),
*tv = cached_clock->cache;
}
@@ -55,7 +55,7 @@ void uc_cached_clock_update(struct UCoreCachedClock *uclock)
static void uc_settable_clock_now(struct UCoreClock *uclock, struct timeval *tv)
{
struct UCoreSettableClock *cached_clock;
cached_clock = CONTAINER_OF(uclock, struct UCoreSettableClock, clock),
cached_clock = UC_CONTAINER_OF(uclock, struct UCoreSettableClock, clock),
*tv = cached_clock->now;
}
+17 -7
View File
@@ -57,7 +57,9 @@ int uc_thread_queue_init(struct uc_threadqueue *queue, long max_elements)
return rc;
}
int uc_thread_queue_tryadd(struct uc_threadqueue *queue, const struct timespec *timeout, struct uc_threadmsg *msg)
int uc_thread_queue_tryadd(struct uc_threadqueue *queue,
const struct timespec *timeout,
struct uc_threadmsg *msg)
{
int rc = 0;
struct timespec abstimeout;
@@ -81,7 +83,8 @@ int uc_thread_queue_tryadd(struct uc_threadqueue *queue, const struct timespec *
if(timeout->tv_sec == 0 && timeout->tv_nsec == 0) {
rc = ETIMEDOUT;
} else {
rc = pthread_cond_timedwait(&queue->write_cond, &queue->mutex, &abstimeout);
rc = pthread_cond_timedwait(&queue->write_cond, &queue->mutex,
&abstimeout);
}
} else {
@@ -127,7 +130,9 @@ int uc_thread_queue_tryadd(struct uc_threadqueue *queue, const struct timespec *
}
int uc_thread_queue_tryget(struct uc_threadqueue *queue, const struct timespec *timeout, struct uc_threadmsg **msg)
int uc_thread_queue_tryget(struct uc_threadqueue *queue,
const struct timespec *timeout,
struct uc_threadmsg **msg)
{
int rc = 0;
struct timespec abstimeout;
@@ -153,7 +158,8 @@ int uc_thread_queue_tryget(struct uc_threadqueue *queue, const struct timespec *
if(timeout->tv_sec == 0 && timeout->tv_nsec == 0) {
rc = ETIMEDOUT;
} else {
rc = pthread_cond_timedwait(&queue->read_cond, &queue->mutex, &abstimeout);
rc = pthread_cond_timedwait(&queue->read_cond, &queue->mutex,
&abstimeout);
}
} else {
pthread_cond_wait(&queue->read_cond, &queue->mutex);
@@ -192,17 +198,20 @@ int uc_thread_queue_tryget(struct uc_threadqueue *queue, const struct timespec *
return 0;
}
static void uc_thread_queue_walk_unlocked(struct uc_threadqueue *queue, uc_thread_queue_walk_func walk_func)
static void uc_thread_queue_walk_unlocked(struct uc_threadqueue *queue,
uc_thread_queue_walk_func walk_func)
{
struct uc_threadmsg *p;
struct uc_threadmsg *next;
for(p = queue->first; p; p = next) {
next = p->next;
walk_func(p);
}
}
int uc_thread_queue_walk(struct uc_threadqueue *queue, uc_thread_queue_walk_func walk_func)
int uc_thread_queue_walk(struct uc_threadqueue *queue,
uc_thread_queue_walk_func walk_func)
{
if (queue == NULL || !walk_func) {
return EINVAL;
@@ -217,7 +226,8 @@ int uc_thread_queue_walk(struct uc_threadqueue *queue, uc_thread_queue_walk_func
return 0;
}
int uc_thread_queue_destroy(struct uc_threadqueue *queue, uc_thread_queue_walk_func free_func)
int uc_thread_queue_destroy(struct uc_threadqueue *queue,
uc_thread_queue_walk_func free_func)
{
int rc;
+2 -2
View File
@@ -6,8 +6,8 @@
static int timers_cmp(const RBNode *a_, const RBNode *b_)
{
const struct UCTimer *a = CONST_CONTAINER_OF(a_, struct UCTimer, rb_node);
const struct UCTimer *b = CONST_CONTAINER_OF(b_, struct UCTimer, rb_node);
const struct UCTimer *a = UC_CONST_CONTAINER_OF(a_, struct UCTimer, rb_node);
const struct UCTimer *b = UC_CONST_CONTAINER_OF(b_, struct UCTimer, rb_node);
if (timercmp(&a->timeout, &b->timeout, <)) {
return -1;