From: Brian Norris Date: Tue, 13 Mar 2012 18:37:45 +0000 (-0700) Subject: stricter typing of function pointers for makecontext() X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ca20a05be41491f67bd5c40517bed08f5a7328ba;p=c11tester.git stricter typing of function pointers for makecontext() We need to use functions with no arguments (i.e., 'void (*)()') in order to retain strict type-checking with makecontext(). Of course, we still circumvent this type checking with casting, but we should straighten this out sometime... --- diff --git a/libthreads.c b/libthreads.c index 1b7f3db6..ca310675 100644 --- a/libthreads.c +++ b/libthreads.c @@ -100,7 +100,7 @@ static void thread_wait_finish(void) /* * User program API functions */ -int thread_create(struct thread *t, void (*start_routine), void *arg) +int thread_create(struct thread *t, void (*start_routine)(), void *arg) { int ret = 0; diff --git a/libthreads.h b/libthreads.h index 08488337..aa7faf44 100644 --- a/libthreads.h +++ b/libthreads.h @@ -11,7 +11,7 @@ typedef enum thread_state { } thread_state; struct thread { - void (*start_routine); + void (*start_routine)(); void *arg; ucontext_t context; void *stack; @@ -19,7 +19,7 @@ struct thread { thread_state state; }; -int thread_create(struct thread *t, void (*start_routine), void *arg); +int thread_create(struct thread *t, void (*start_routine)(), void *arg); void thread_join(struct thread *t); int thread_yield(void); struct thread *thread_current(void); diff --git a/userprog.c b/userprog.c index c27c7015..1837fc98 100644 --- a/userprog.c +++ b/userprog.c @@ -20,8 +20,8 @@ void user_main() atomic_int obj; printf("%s() creating 2 threads\n", __func__); - thread_create(&t1, &a, &obj); - thread_create(&t2, &a, &obj); + thread_create(&t1, (void (*)())&a, &obj); + thread_create(&t2, (void (*)())&a, &obj); thread_join(&t1); thread_join(&t2);