mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 11:59:17 +08:00
Merge pull request #2627 from mcharleb/posix_whitespace_fixes
POSIX: code format changes
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
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()
|
||||
*/
|
||||
|
||||
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()
|
||||
*/
|
||||
|
||||
hrt_work_unlock();
|
||||
|
||||
if (!worker) {
|
||||
PX4_ERR("MESSED UP: worker = 0");
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
worker(arg);
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
/* 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[])
|
||||
{
|
||||
/* 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).
|
||||
@@ -250,7 +249,7 @@ void hrt_work_queue_init(void)
|
||||
SCHED_PRIORITY_MAX,
|
||||
2000,
|
||||
work_hrtthread,
|
||||
(char* const*)NULL);
|
||||
(char *const *)NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
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)
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
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)
|
||||
*/
|
||||
|
||||
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)
|
||||
*/
|
||||
|
||||
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)
|
||||
*/
|
||||
|
||||
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)
|
||||
{
|
||||
remaining = USEC_PER_TICK * (work->delay - elapsed);
|
||||
|
||||
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)
|
||||
|
||||
/* Then try the next in the list. */
|
||||
|
||||
work = (FAR struct work_s *)work->dq.flink;
|
||||
work = (struct work_s *)work->dq.flink;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,10 +196,10 @@ void work_queues_init(void)
|
||||
// Create high priority worker thread
|
||||
g_work[HPWORK].pid = px4_task_spawn_cmd("wkr_high",
|
||||
SCHED_DEFAULT,
|
||||
SCHED_PRIORITY_MAX-1,
|
||||
SCHED_PRIORITY_MAX - 1,
|
||||
2000,
|
||||
work_hpthread,
|
||||
(char* const*)NULL);
|
||||
(char *const *)NULL);
|
||||
|
||||
// Create low priority worker thread
|
||||
g_work[LPWORK].pid = px4_task_spawn_cmd("wkr_low",
|
||||
@@ -206,7 +207,7 @@ void work_queues_init(void)
|
||||
SCHED_PRIORITY_MIN,
|
||||
2000,
|
||||
work_lpthread,
|
||||
(char* const*)NULL);
|
||||
(char *const *)NULL);
|
||||
|
||||
}
|
||||
|
||||
@@ -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[])
|
||||
{
|
||||
/* 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[])
|
||||
{
|
||||
/* Loop forever */
|
||||
|
||||
for (;;)
|
||||
{
|
||||
for (;;) {
|
||||
/* Then process queued work. We need to keep interrupts disabled while
|
||||
* we process items in the work list.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user