From c801b183dc8e5da885a3e1df92fd42e036b56a87 Mon Sep 17 00:00:00 2001 From: Moritz Bitsch Date: Fri, 27 Jul 2018 10:45:00 +0200 Subject: [PATCH] Reformat code run astyle --style=linux on source files --- coio.c | 36 +++++++++++++++++------------------- coio.h | 20 ++++++++++---------- coio_glib.c | 6 ++---- coioimpl.h | 16 ++++++++-------- testdelay.c | 4 ++-- testyield.c | 6 +++--- 6 files changed, 42 insertions(+), 46 deletions(-) diff --git a/coio.c b/coio.c index ade89f1..a33bb33 100644 --- a/coio.c +++ b/coio.c @@ -31,14 +31,14 @@ CoioTaskList coio_ready_list = {0, 0}; CoioTaskList coio_sleeping = {0, 0}; coro_context coio_sched_ctx; -CoioTask *coio_current; +CoioTask* coio_current; unsigned long coio_taskcount = 0; static int msleep(uvlong ms) { struct timespec req, rem; - if(ms > 999) { + if (ms > 999) { req.tv_sec = (int)(ms / 1000); req.tv_nsec = (ms - ((long)req.tv_sec * 1000)) * 1000000; } else { @@ -46,7 +46,7 @@ static int msleep(uvlong ms) req.tv_nsec = ms * 1000000; } - return nanosleep(&req , &rem); + return nanosleep(&req, &rem); } static void @@ -54,7 +54,7 @@ _process_events() { uvlong now; int ms = 5; - CoioTask *t; + CoioTask* t; if ((t = coio_sleeping.head) != NULL && t->timeout != 0) { now = coio_now(); @@ -111,9 +111,9 @@ coio_main() } static void -_coio_entry(void *arg) +_coio_entry(void* arg) { - CoioTask *task = (CoioTask *) arg; + CoioTask* task = (CoioTask*) arg; task->func(task->arg); @@ -122,15 +122,15 @@ _coio_entry(void *arg) } int -coio_create(const char* name, coio_func f, void *arg, unsigned int stacksize) +coio_create(const char* name, coio_func f, void* arg, unsigned int stacksize) { - CoioTask *task; + CoioTask* task; task = calloc(1, sizeof(*task)); if (!task) return -1; - if (!coro_stack_alloc(&task->stk, stacksize / sizeof(void *))) { + if (!coro_stack_alloc(&task->stk, stacksize / sizeof(void*))) { free(task); return -1; } @@ -147,9 +147,9 @@ coio_create(const char* name, coio_func f, void *arg, unsigned int stacksize) } uvlong -coio_timeout(CoioTask * task, int ms) +coio_timeout(CoioTask* task, int ms) { - CoioTask *t; + CoioTask* t; if (ms >= 0) { task->timeout = coio_now() + (ms * 1000000); @@ -201,7 +201,7 @@ coio_yield() } void -coio_add(CoioTaskList * lst, CoioTask * task) +coio_add(CoioTaskList* lst, CoioTask* task) { if (lst->tail) { lst->tail->next = task; @@ -215,7 +215,7 @@ coio_add(CoioTaskList * lst, CoioTask * task) } void -coio_del(CoioTaskList * lst, CoioTask * task) +coio_del(CoioTaskList* lst, CoioTask* task) { if (task->prev) { task->prev->next = task->next; @@ -231,7 +231,7 @@ coio_del(CoioTaskList * lst, CoioTask * task) } void -coio_ready(CoioTask * task) +coio_ready(CoioTask* task) { task->timeout = 0; if (!task->ready) { @@ -272,19 +272,17 @@ coio_now() void coio_debug() { - CoioTask *t; + CoioTask* t; fprintf(stderr, ">>>\nCurrent tasks: %s\n", coio_current->name); fprintf(stderr, "Sleeping tasks: "); - for (t = coio_sleeping.head; t != NULL; t = t->next) - { + for (t = coio_sleeping.head; t != NULL; t = t->next) { fprintf(stderr, "%s ", t->name); } fprintf(stderr, "\nReady tasks: "); - for (t = coio_ready_list.head; t != NULL; t = t->next) - { + for (t = coio_ready_list.head; t != NULL; t = t->next) { fprintf(stderr, "%s ", t->name); } fprintf(stderr, "\n"); diff --git a/coio.h b/coio.h index 1b7aaf9..de236b9 100644 --- a/coio.h +++ b/coio.h @@ -20,18 +20,18 @@ extern "C" { #endif - typedef struct CoioTask CoioTask; - typedef void (*coio_func) (void *arg); - typedef unsigned long long uvlong; +typedef struct CoioTask CoioTask; +typedef void (*coio_func)(void* arg); +typedef unsigned long long uvlong; - extern CoioTask *coio_current; +extern CoioTask* coio_current; - int coio_main (); - int coio_create(const char* name, coio_func f, void *arg, unsigned int stacksize); - void coio_yield(); - uvlong coio_now(); - int coio_delay(int ms); - void coio_ready(CoioTask * task); +int coio_main(); +int coio_create(const char* name, coio_func f, void* arg, unsigned int stacksize); +void coio_yield(); +uvlong coio_now(); +int coio_delay(int ms); +void coio_ready(CoioTask* task); #ifdef __cplusplus } diff --git a/coio_glib.c b/coio_glib.c index 6e90256..e152fef 100644 --- a/coio_glib.c +++ b/coio_glib.c @@ -20,8 +20,7 @@ #include -struct coio_source -{ +struct coio_source { GSource base; }; @@ -116,8 +115,7 @@ GSource* coio_gsource_create() { coro_create(&coio_sched_ctx, NULL, NULL, NULL, 0); - static GSourceFuncs funcs = - { + static GSourceFuncs funcs = { coio_source_prepare, coio_source_check, coio_source_dispatch, diff --git a/coioimpl.h b/coioimpl.h index 1039702..2f7320b 100644 --- a/coioimpl.h +++ b/coioimpl.h @@ -25,22 +25,22 @@ struct CoioTask { coro_context ctx; struct coro_stack stk; - const char *name; + const char* name; coio_func func; - void *arg; + void* arg; uvlong timeout; int ready; int done; /* linked list support */ - CoioTask *next; - CoioTask *prev; + CoioTask* next; + CoioTask* prev; }; struct CoioTaskList { - CoioTask *head; - CoioTask *tail; + CoioTask* head; + CoioTask* tail; }; extern CoioTaskList coio_ready_list; @@ -48,8 +48,8 @@ extern CoioTaskList coio_sleeping; extern coro_context coio_sched_ctx; extern unsigned long coio_taskcount; -void coio_add (CoioTaskList * lst, CoioTask * task); -void coio_del (CoioTaskList * lst, CoioTask * task); +void coio_add(CoioTaskList* lst, CoioTask* task); +void coio_del(CoioTaskList* lst, CoioTask* task); void coio_transfer(); void coio_debug(); diff --git a/testdelay.c b/testdelay.c index eb42587..d25b491 100644 --- a/testdelay.c +++ b/testdelay.c @@ -17,7 +17,7 @@ #include "coio.h" void -_t1(void *arg) +_t1(void* arg) { printf("going to sleep 1000ms (1s)\n"); coio_delay(1000); @@ -25,7 +25,7 @@ _t1(void *arg) } int -main(int argc, char **argv) +main(int argc, char** argv) { (void) argc; (void) argv; diff --git a/testyield.c b/testyield.c index 776b357..ac1b4a2 100644 --- a/testyield.c +++ b/testyield.c @@ -17,7 +17,7 @@ #include "coio.h" void -_t1(void *arg) +_t1(void* arg) { printf("Hello 1 from _t1\n"); coio_yield(); @@ -25,7 +25,7 @@ _t1(void *arg) } void -_t2(void *arg) +_t2(void* arg) { printf("Hello 1 from _t2\n"); coio_yield(); @@ -33,7 +33,7 @@ _t2(void *arg) } int -main(int argc, char **argv) +main(int argc, char** argv) { (void) argc; (void) argv;