Browse Source

Merge pull request #2627 from mcharleb/posix_whitespace_fixes

POSIX: code format changes
sbg
Lorenz Meier 10 years ago
parent
commit
ff1c9da390
  1. 10
      src/platforms/posix/work_queue/dq_addlast.c
  2. 22
      src/platforms/posix/work_queue/dq_rem.c
  3. 18
      src/platforms/posix/work_queue/dq_remfirst.c
  4. 35
      src/platforms/posix/work_queue/hrt_thread.c
  5. 10
      src/platforms/posix/work_queue/hrt_work_cancel.c
  6. 36
      src/platforms/posix/work_queue/queue.c
  7. 10
      src/platforms/posix/work_queue/sq_addafter.c
  8. 11
      src/platforms/posix/work_queue/sq_addlast.c
  9. 11
      src/platforms/posix/work_queue/sq_remfirst.c
  10. 10
      src/platforms/posix/work_queue/work_cancel.c
  11. 44
      src/platforms/posix/work_queue/work_thread.c

10
src/platforms/posix/work_queue/dq_addlast.c

@ -56,18 +56,16 @@ @@ -56,18 +56,16 @@
*
************************************************************/
void dq_addlast(FAR dq_entry_t *node, dq_queue_t *queue)
void dq_addlast(dq_entry_t *node, dq_queue_t *queue)
{
node->flink = NULL;
node->blink = queue->tail;
if (!queue->head)
{
if (!queue->head) {
queue->head = node;
queue->tail = node;
}
else
{
} else {
queue->tail->flink = node;
queue->tail = node;
}

22
src/platforms/posix/work_queue/dq_rem.c

@ -56,26 +56,22 @@ @@ -56,26 +56,22 @@
*
************************************************************/
void dq_rem(FAR dq_entry_t *node, dq_queue_t *queue)
void dq_rem(dq_entry_t *node, dq_queue_t *queue)
{
FAR dq_entry_t *prev = node->blink;
FAR dq_entry_t *next = node->flink;
dq_entry_t *prev = node->blink;
dq_entry_t *next = node->flink;
if (!prev)
{
if (!prev) {
queue->head = next;
}
else
{
} else {
prev->flink = next;
}
if (!next)
{
if (!next) {
queue->tail = prev;
}
else
{
} else {
next->blink = prev;
}

18
src/platforms/posix/work_queue/dq_remfirst.c

@ -56,20 +56,18 @@ @@ -56,20 +56,18 @@
*
************************************************************/
FAR dq_entry_t *dq_remfirst(dq_queue_t *queue)
dq_entry_t *dq_remfirst(dq_queue_t *queue)
{
FAR dq_entry_t *ret = queue->head;
dq_entry_t *ret = queue->head;
if (ret)
{
FAR dq_entry_t *next = ret->flink;
if (!next)
{
if (ret) {
dq_entry_t *next = ret->flink;
if (!next) {
queue->head = NULL;
queue->tail = NULL;
}
else
{
} else {
queue->head = next;
next->blink = NULL;
}

35
src/platforms/posix/work_queue/hrt_thread.c

@ -90,9 +90,9 @@ static void hrt_work_process(void); @@ -90,9 +90,9 @@ static void hrt_work_process(void);
static void hrt_work_process()
{
struct wqueue_s *wqueue = &g_hrt_work;
volatile FAR struct work_s *work;
volatile struct work_s *work;
worker_t worker;
FAR void *arg;
void *arg;
uint64_t elapsed;
uint32_t remaining;
uint32_t next;
@ -106,9 +106,9 @@ static void hrt_work_process() @@ -106,9 +106,9 @@ static void hrt_work_process()
hrt_work_lock();
work = (FAR struct work_s *)wqueue->q.head;
while (work)
{
work = (struct work_s *)wqueue->q.head;
while (work) {
/* Is this work ready? It is ready if there is no delay or if
* the delay has elapsed. qtime is the time that the work was added
* to the work queue. It will always be greater than or equal to
@ -116,9 +116,9 @@ static void hrt_work_process() @@ -116,9 +116,9 @@ static void hrt_work_process()
*/
elapsed = hrt_absolute_time() - work->qtime;
//PX4_INFO("hrt work_process: in usec elapsed=%lu delay=%u work=%p", elapsed, work->delay, work);
if (elapsed >= work->delay)
{
if (elapsed >= work->delay) {
/* Remove the ready-to-execute work from the list */
(void)dq_rem((struct dq_entry_s *)work, &wqueue->q);
@ -140,10 +140,11 @@ static void hrt_work_process() @@ -140,10 +140,11 @@ static void hrt_work_process()
*/
hrt_work_unlock();
if (!worker) {
PX4_ERR("MESSED UP: worker = 0");
}
else {
} else {
worker(arg);
}
@ -153,19 +154,18 @@ static void hrt_work_process() @@ -153,19 +154,18 @@ static void hrt_work_process()
*/
hrt_work_lock();
work = (FAR struct work_s *)wqueue->q.head;
}
else
{
work = (struct work_s *)wqueue->q.head;
} else {
/* This one is not ready.. will it be ready before the next
* scheduled wakeup interval?
*/
/* Here: elapsed < work->delay */
remaining = work->delay - elapsed;
//PX4_INFO("remaining=%u delay=%u elapsed=%lu", remaining, work->delay, elapsed);
if (remaining < next)
{
if (remaining < next) {
/* Yes.. Then schedule to wake up when the work is ready */
next = remaining;
@ -173,7 +173,7 @@ static void hrt_work_process() @@ -173,7 +173,7 @@ static void hrt_work_process()
/* Then try the next in the list. */
work = (FAR struct work_s *)work->dq.flink;
work = (struct work_s *)work->dq.flink;
//PX4_INFO("next %u work %p", next, work);
}
}
@ -217,8 +217,7 @@ static int work_hrtthread(int argc, char *argv[]) @@ -217,8 +217,7 @@ static int work_hrtthread(int argc, char *argv[])
{
/* Loop forever */
for (;;)
{
for (;;) {
/* First, perform garbage collection. This cleans-up memory de-allocations
* that were queued because they could not be freed in that execution
* context (for example, if the memory was freed from an interrupt handler).

10
src/platforms/posix/work_queue/hrt_work_cancel.c

@ -92,18 +92,18 @@ void hrt_work_cancel(struct work_s *work) @@ -92,18 +92,18 @@ void hrt_work_cancel(struct work_s *work)
*/
hrt_work_lock();
if (work->worker != NULL)
{
if (work->worker != NULL) {
/* A little test of the integrity of the work queue */
//DEBUGASSERT(work->dq.flink ||(FAR dq_entry_t *)work == wqueue->q.tail);
//DEBUGASSERT(work->dq.blink ||(FAR dq_entry_t *)work == wqueue->q.head);
//DEBUGASSERT(work->dq.flink ||(dq_entry_t *)work == wqueue->q.tail);
//DEBUGASSERT(work->dq.blink ||(dq_entry_t *)work == wqueue->q.head);
/* Remove the entry from the work queue and make sure that it is
* mark as availalbe (i.e., the worker field is nullified).
*/
dq_rem((FAR dq_entry_t *)work, &wqueue->q);
dq_rem((dq_entry_t *)work, &wqueue->q);
work->worker = NULL;
}

36
src/platforms/posix/work_queue/queue.c

@ -42,25 +42,22 @@ __EXPORT void sq_rem(sq_entry_t *node, sq_queue_t *queue); @@ -42,25 +42,22 @@ __EXPORT void sq_rem(sq_entry_t *node, sq_queue_t *queue);
sq_entry_t *sq_remafter(sq_entry_t *node, sq_queue_t *queue);
void sq_rem(sq_entry_t *node, sq_queue_t *queue)
{
if (queue->head && node)
{
if (node == queue->head)
{
if (queue->head && node) {
if (node == queue->head) {
queue->head = node->flink;
if (node == queue->tail)
{
if (node == queue->tail) {
queue->tail = NULL;
}
}
else
{
} else {
sq_entry_t *prev;
for (prev = (sq_entry_t *)queue->head;
prev && prev->flink != node;
prev = prev->flink);
if (prev)
{
if (prev) {
sq_remafter(prev, queue);
}
}
@ -70,15 +67,13 @@ void sq_rem(sq_entry_t *node, sq_queue_t *queue) @@ -70,15 +67,13 @@ void sq_rem(sq_entry_t *node, sq_queue_t *queue)
sq_entry_t *sq_remafter(sq_entry_t *node, sq_queue_t *queue)
{
sq_entry_t *ret = node->flink;
if (queue->head && ret)
{
if (queue->tail == ret)
{
if (queue->head && ret) {
if (queue->tail == ret) {
queue->tail = node;
node->flink = NULL;
}
else
{
} else {
node->flink = ret->flink;
}
@ -92,10 +87,11 @@ __EXPORT void sq_addfirst(sq_entry_t *node, sq_queue_t *queue); @@ -92,10 +87,11 @@ __EXPORT void sq_addfirst(sq_entry_t *node, sq_queue_t *queue);
void sq_addfirst(sq_entry_t *node, sq_queue_t *queue)
{
node->flink = queue->head;
if (!queue->head)
{
if (!queue->head) {
queue->tail = node;
}
queue->head = node;
}

10
src/platforms/posix/work_queue/sq_addafter.c

@ -56,15 +56,13 @@ @@ -56,15 +56,13 @@
*
************************************************************/
void sq_addafter(FAR sq_entry_t *prev, FAR sq_entry_t *node,
void sq_addafter(sq_entry_t *prev, sq_entry_t *node,
sq_queue_t *queue)
{
if (!queue->head || prev == queue->tail)
{
if (!queue->head || prev == queue->tail) {
sq_addlast(node, queue);
}
else
{
} else {
node->flink = prev->flink;
prev->flink = node;
}

11
src/platforms/posix/work_queue/sq_addlast.c

@ -56,16 +56,15 @@ @@ -56,16 +56,15 @@
* the 'queue'
************************************************************/
void sq_addlast(FAR sq_entry_t *node, sq_queue_t *queue)
void sq_addlast(sq_entry_t *node, sq_queue_t *queue)
{
node->flink = NULL;
if (!queue->head)
{
if (!queue->head) {
queue->head = node;
queue->tail = node;
}
else
{
} else {
queue->tail->flink = node;
queue->tail = node;
}

11
src/platforms/posix/work_queue/sq_remfirst.c

@ -57,15 +57,14 @@ @@ -57,15 +57,14 @@
*
************************************************************/
FAR sq_entry_t *sq_remfirst(sq_queue_t *queue)
sq_entry_t *sq_remfirst(sq_queue_t *queue)
{
FAR sq_entry_t *ret = queue->head;
sq_entry_t *ret = queue->head;
if (ret)
{
if (ret) {
queue->head = ret->flink;
if (!queue->head)
{
if (!queue->head) {
queue->tail = NULL;
}

10
src/platforms/posix/work_queue/work_cancel.c

@ -98,18 +98,18 @@ int work_cancel(int qid, struct work_s *work) @@ -98,18 +98,18 @@ int work_cancel(int qid, struct work_s *work)
*/
work_lock(qid);
if (work->worker != NULL)
{
if (work->worker != NULL) {
/* A little test of the integrity of the work queue */
//DEBUGASSERT(work->dq.flink ||(FAR dq_entry_t *)work == wqueue->q.tail);
//DEBUGASSERT(work->dq.blink ||(FAR dq_entry_t *)work == wqueue->q.head);
//DEBUGASSERT(work->dq.flink ||(dq_entry_t *)work == wqueue->q.tail);
//DEBUGASSERT(work->dq.blink ||(dq_entry_t *)work == wqueue->q.head);
/* Remove the entry from the work queue and make sure that it is
* mark as availalbe (i.e., the worker field is nullified).
*/
dq_rem((FAR dq_entry_t *)work, &wqueue->q);
dq_rem((dq_entry_t *)work, &wqueue->q);
work->worker = NULL;
}

44
src/platforms/posix/work_queue/work_thread.c

@ -88,11 +88,11 @@ sem_t _work_lock[NWORKERS]; @@ -88,11 +88,11 @@ sem_t _work_lock[NWORKERS];
*
****************************************************************************/
static void work_process(FAR struct wqueue_s *wqueue, int lock_id)
static void work_process(struct wqueue_s *wqueue, int lock_id)
{
volatile FAR struct work_s *work;
volatile struct work_s *work;
worker_t worker;
FAR void *arg;
void *arg;
uint64_t elapsed;
uint32_t remaining;
uint32_t next;
@ -105,9 +105,9 @@ static void work_process(FAR struct wqueue_s *wqueue, int lock_id) @@ -105,9 +105,9 @@ static void work_process(FAR struct wqueue_s *wqueue, int lock_id)
work_lock(lock_id);
work = (FAR struct work_s *)wqueue->q.head;
while (work)
{
work = (struct work_s *)wqueue->q.head;
while (work) {
/* Is this work ready? It is ready if there is no delay or if
* the delay has elapsed. qtime is the time that the work was added
* to the work queue. It will always be greater than or equal to
@ -115,9 +115,9 @@ static void work_process(FAR struct wqueue_s *wqueue, int lock_id) @@ -115,9 +115,9 @@ static void work_process(FAR struct wqueue_s *wqueue, int lock_id)
*/
elapsed = USEC2TICK(clock_systimer() - work->qtime);
//printf("work_process: in ticks elapsed=%lu delay=%u\n", elapsed, work->delay);
if (elapsed >= work->delay)
{
if (elapsed >= work->delay) {
/* Remove the ready-to-execute work from the list */
(void)dq_rem((struct dq_entry_s *)work, &wqueue->q);
@ -138,11 +138,13 @@ static void work_process(FAR struct wqueue_s *wqueue, int lock_id) @@ -138,11 +138,13 @@ static void work_process(FAR struct wqueue_s *wqueue, int lock_id)
*/
work_unlock(lock_id);
if (!worker) {
PX4_WARN("MESSED UP: worker = 0\n");
}
else
} else {
worker(arg);
}
/* Now, unfortunately, since we re-enabled interrupts we don't
* know the state of the work list and we will have to start
@ -150,18 +152,17 @@ static void work_process(FAR struct wqueue_s *wqueue, int lock_id) @@ -150,18 +152,17 @@ static void work_process(FAR struct wqueue_s *wqueue, int lock_id)
*/
work_lock(lock_id);
work = (FAR struct work_s *)wqueue->q.head;
}
else
{
work = (struct work_s *)wqueue->q.head;
} else {
/* This one is not ready.. will it be ready before the next
* scheduled wakeup interval?
*/
/* Here: elapsed < work->delay */
remaining = USEC_PER_TICK * (work->delay - elapsed);
if (remaining < next)
{
if (remaining < next) {
/* Yes.. Then schedule to wake up when the work is ready */
next = remaining;
@ -169,7 +170,7 @@ static void work_process(FAR struct wqueue_s *wqueue, int lock_id) @@ -169,7 +170,7 @@ static void work_process(FAR struct wqueue_s *wqueue, int lock_id)
/* Then try the next in the list. */
work = (FAR struct work_s *)work->dq.flink;
work = (struct work_s *)work->dq.flink;
}
}
@ -247,8 +248,7 @@ int work_hpthread(int argc, char *argv[]) @@ -247,8 +248,7 @@ int work_hpthread(int argc, char *argv[])
{
/* Loop forever */
for (;;)
{
for (;;) {
/* First, perform garbage collection. This cleans-up memory de-allocations
* that were queued because they could not be freed in that execution
* context (for example, if the memory was freed from an interrupt handler).
@ -276,8 +276,7 @@ int work_lpthread(int argc, char *argv[]) @@ -276,8 +276,7 @@ int work_lpthread(int argc, char *argv[])
{
/* Loop forever */
for (;;)
{
for (;;) {
/* First, perform garbage collection. This cleans-up memory de-allocations
* that were queued because they could not be freed in that execution
* context (for example, if the memory was freed from an interrupt handler).
@ -306,8 +305,7 @@ int work_usrthread(int argc, char *argv[]) @@ -306,8 +305,7 @@ int work_usrthread(int argc, char *argv[])
{
/* Loop forever */
for (;;)
{
for (;;) {
/* Then process queued work. We need to keep interrupts disabled while
* we process items in the work list.
*/

Loading…
Cancel
Save