stricter typing of function pointers for makecontext()
authorBrian Norris <banorris@uci.edu>
Tue, 13 Mar 2012 18:37:45 +0000 (11:37 -0700)
committerBrian Norris <banorris@uci.edu>
Tue, 13 Mar 2012 18:41:34 +0000 (11:41 -0700)
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...

libthreads.c
libthreads.h
userprog.c

index 1b7f3db6ac79d37afc20b954f3423b4bd95dfae5..ca310675f3abe5dd747b3f8426cd7e9307b47bc1 100644 (file)
@@ -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;
 
index 084883376f9f020b414cdcd4a41a4bb55c0a0f73..aa7faf44d255452c172e2db2cf40919e4453b555 100644 (file)
@@ -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);
index c27c701591115f9ec903c6a771263bfc3b1bef98..1837fc98c68d2a995d664dee2408fa05bc0d2c33 100644 (file)
@@ -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);