From 3c0e634aee9b7e7245d80e8ce12a0b37640d7eef Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 20 Feb 2007 22:39:56 +0000 Subject: [PATCH] Eliminating GCC dependencies git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@14 42af7a65-404d-4744-a932-0658087f49c3 --- arch/c5471/src/up_initialize.c | 1 + arch/c5471/src/up_internal.h | 4 ++ examples/ostest/cancel.c | 100 ++++++++++++++-------------- examples/ostest/cond.c | 66 +++++++++--------- examples/ostest/dev_null.c | 10 +-- examples/ostest/main.c | 20 +++--- examples/ostest/mqueue.c | 67 +++++++++---------- examples/ostest/mutex.c | 14 ++-- examples/ostest/ostest.h | 4 ++ examples/ostest/sem.c | 66 +++++++++--------- examples/ostest/sighand.c | 72 ++++++++++---------- examples/ostest/timedwait.c | 42 ++++++------ include/ctype.h | 84 +++++++---------------- include/debug.h | 17 ++++- include/nuttx/arch.h | 2 +- include/nuttx/compiler.h | 2 +- include/nuttx/irq.h | 6 +- include/pthread.h | 19 +++--- include/signal.h | 5 ++ include/stdio.h | 4 ++ include/stdlib.h | 2 +- include/sys/types.h | 7 ++ include/unistd.h | 3 +- lib/lib_libvsprintf.c | 4 +- lib/lib_rand.c | 22 +++--- lib/lib_rint.c | 8 +-- lib/lib_sscanf.c | 6 +- mm/mm_memalign.c | 2 - mm/mm_sem.c | 12 ++-- sched/Makefile | 3 +- sched/clock_getres.c | 7 +- sched/clock_gettime.c | 10 +-- sched/clock_settime.c | 7 +- sched/gmtime_r.c | 6 +- sched/irq_dispatch.c | 4 +- sched/irq_internal.h | 2 +- sched/irq_unexpectedisr.c | 2 +- sched/mktime.c | 6 +- sched/mq_internal.h | 4 -- sched/mq_send.c | 2 +- sched/os_start.c | 6 +- sched/pthread_attrdestroy.c | 4 +- sched/pthread_attrgetinheritsched.c | 5 +- sched/pthread_attrgetschedparam.c | 4 +- sched/pthread_attrgetschedpolicy.c | 4 +- sched/pthread_attrgetstacksize.c | 4 +- sched/pthread_attrinit.c | 4 +- sched/pthread_attrsetinheritsched.c | 4 +- sched/pthread_attrsetschedparam.c | 4 +- sched/pthread_attrsetschedpolicy.c | 4 +- sched/pthread_attrsetstacksize.c | 5 +- sched/pthread_cancel.c | 8 +-- sched/pthread_completejoin.c | 6 +- sched/pthread_condattrdestroy.c | 4 +- sched/pthread_condattrinit.c | 4 +- sched/pthread_condbroadcast.c | 4 +- sched/pthread_conddestroy.c | 4 +- sched/pthread_condinit.c | 4 +- sched/pthread_condsignal.c | 8 +-- sched/pthread_condtimedwait.c | 11 ++- sched/pthread_condwait.c | 8 +-- sched/pthread_create.c | 4 +- sched/pthread_detach.c | 10 +-- sched/pthread_exit.c | 2 +- sched/pthread_findjoininfo.c | 4 +- sched/pthread_getschedparam.c | 9 ++- sched/pthread_internal.h | 4 +- sched/pthread_join.c | 22 +++--- sched/pthread_mutexattrdestroy.c | 4 +- sched/pthread_mutexattrgetpshared.c | 4 +- sched/pthread_mutexattrinit.c | 4 +- sched/pthread_mutexattrsetpshared.c | 4 +- sched/pthread_mutexdestroy.c | 4 +- sched/pthread_mutexinit.c | 4 +- sched/pthread_mutexlock.c | 6 +- sched/pthread_mutextrylock.c | 4 +- sched/pthread_mutexunlock.c | 6 +- sched/pthread_removejoininfo.c | 4 +- sched/pthread_self.c | 91 ------------------------- sched/pthread_setschedparam.c | 10 +-- sched/sched_getscheduler.c | 2 +- sched/sem_internal.h | 2 +- sched/task_create.c | 6 -- sched/wd_internal.h | 1 - 84 files changed, 461 insertions(+), 583 deletions(-) delete mode 100644 sched/pthread_self.c diff --git a/arch/c5471/src/up_initialize.c b/arch/c5471/src/up_initialize.c index 8b85ecd719..bae36548bb 100644 --- a/arch/c5471/src/up_initialize.c +++ b/arch/c5471/src/up_initialize.c @@ -41,6 +41,7 @@ #include #include #include +#include #include "up_internal.h" /************************************************************ diff --git a/arch/c5471/src/up_internal.h b/arch/c5471/src/up_internal.h index 88ed459f3c..b1256130e3 100644 --- a/arch/c5471/src/up_internal.h +++ b/arch/c5471/src/up_internal.h @@ -110,6 +110,10 @@ extern void up_serialinit(void); extern void up_timerinit(void); +/* Defined in up_irq.c */ + +extern void up_maskack_irq(int irq); + #endif /* __ASSEMBLY__ */ #endif /* __UP_INTERNAL_H */ diff --git a/examples/ostest/cancel.c b/examples/ostest/cancel.c index d52c596fcf..1fda4166c9 100644 --- a/examples/ostest/cancel.c +++ b/examples/ostest/cancel.c @@ -48,24 +48,24 @@ static void *thread_waiter(void *parameter) /* Take the mutex */ - printf("%s: Taking mutex\n", __FUNCTION__); + printf("thread_waiter: Taking mutex\n"); status = pthread_mutex_lock(&mutex); if (status != 0) { - printf("%s: ERROR pthread_mutex_lock failed, status=%d\n", __FUNCTION__, status); + printf("thread_waiter: ERROR pthread_mutex_lock failed, status=%d\n", status); } - printf("%s: Starting wait for condition\n", __FUNCTION__); + printf("thread_waiter: Starting wait for condition\n"); /* Are we a non-cancelable thread? Yes, set the non-cancelable state */ if (!parameter) { - printf("%s: Setting non-cancelable\n", __FUNCTION__); + printf("thread_waiter: Setting non-cancelable\n"); status = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); if (status != 0) { - printf("%s: ERROR pthread_setcancelstate failed, status=%d\n", __FUNCTION__, status); + printf("thread_waiter: ERROR pthread_setcancelstate failed, status=%d\n", status); } } @@ -74,28 +74,28 @@ static void *thread_waiter(void *parameter) status = pthread_cond_wait(&cond, &mutex); if (status != 0) { - printf("%s: ERROR pthread_cond_wait failed, status=%d\n", __FUNCTION__, status); + printf("thread_waiter: ERROR pthread_cond_wait failed, status=%d\n", status); } /* Release the mutex */ - printf("%s: Releasing mutex\n", __FUNCTION__); + printf("thread_waiter: Releasing mutex\n"); status = pthread_mutex_unlock(&mutex); if (status != 0) { - printf("%s: ERROR pthread_mutex_unlock failed, status=%d\n", __FUNCTION__, status); + printf("thread_waiter: ERROR pthread_mutex_unlock failed, status=%d\n", status); } /* Set the cancelable state */ - printf("%s: Setting cancelable\n", __FUNCTION__); + printf("thread_waiter: Setting cancelable\n"); status = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); if (status != 0) { - printf("%s: ERROR pthread_setcancelstate failed, status=%d\n", __FUNCTION__, status); + printf("thread_waiter: ERROR pthread_setcancelstate failed, status=%d\n", status); } - printf("%s: Exit with status 0x12345678\n", __FUNCTION__); + printf("thread_waiter: Exit with status 0x12345678\n"); pthread_exit((void*)0x12345678); return NULL; } @@ -107,20 +107,20 @@ static void start_thread(pthread_t *waiter, int cancelable) /* Initialize the mutex */ - printf("%s: Initializing mutex\n", __FUNCTION__); + printf("start_thread: Initializing mutex\n"); status = pthread_mutex_init(&mutex, NULL); if (status != 0) { - printf("%s: ERROR pthread_mutex_init failed, status=%d\n", __FUNCTION__, status); + printf("start_thread: ERROR pthread_mutex_init failed, status=%d\n", status); } /* Initialize the condition variable */ - printf("%s: Initializing cond\n", __FUNCTION__); + printf("start_thread: Initializing cond\n"); status = pthread_cond_init(&cond, NULL); if (status != 0) { - printf("%s: ERROR pthread_cond_init failed, status=%d\n", __FUNCTION__, status); + printf("start_thread: ERROR pthread_cond_init failed, status=%d\n", status); } /* Set up attributes */ @@ -128,27 +128,27 @@ static void start_thread(pthread_t *waiter, int cancelable) status = pthread_attr_init(&attr); if (status != 0) { - printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status); + printf("start_thread: pthread_attr_init failed, status=%d\n", status); } status = pthread_attr_setstacksize(&attr, 16384); if (status != 0) { - printf("%s: pthread_attr_setstacksize failed, status=%d\n", __FUNCTION__, status); + printf("start_thread: pthread_attr_setstacksize failed, status=%d\n", status); } /* Start the waiter thread */ - printf("%s: Starting thread\n", __FUNCTION__); + printf("start_thread: Starting thread\n"); status = pthread_create(waiter, NULL, thread_waiter, (void*)cancelable); if (status != 0) { - printf("%s: ERROR pthread_create failed, status=%d\n", __FUNCTION__, status); + printf("start_thread: ERROR pthread_create failed, status=%d\n", status); } /* Make sure that the waiter thread gets a chance to run */ - printf("%s: Yielding\n", __FUNCTION__); + printf("start_thread: Yielding\n"); pthread_yield(); } @@ -159,25 +159,25 @@ static void restart_thread(pthread_t *waiter, int cancelable) /* Destroy the condition variable */ - printf("%s: Destroying cond\n", __FUNCTION__); + printf("restart_thread: Destroying cond\n"); status = pthread_cond_destroy(&cond); if (status != 0) { - printf("%s: ERROR pthread_cond_destroy failed, status=%d\n", __FUNCTION__, status); + printf("restart_thread: ERROR pthread_cond_destroy failed, status=%d\n", status); } /* Destroy the mutex */ - printf("%s: Destroying mutex\n", __FUNCTION__); + printf("restart_thread: Destroying mutex\n"); status = pthread_cond_destroy(&cond); if (status != 0) { - printf("%s: ERROR pthread_mutex_destroy failed, status=%d\n", __FUNCTION__, status); + printf("restart_thread: ERROR pthread_mutex_destroy failed, status=%d\n", status); } /* Then restart the thread */ - printf("%s: Re-starting thread\n", __FUNCTION__); + printf("restart_thread: Re-starting thread\n"); start_thread(waiter, cancelable); } @@ -190,44 +190,44 @@ void cancel_test(void) /* Test 1: Normal Cancel *********************************************/ /* Start the waiter thread */ - printf("%s: Test 1: Normal Cancelation\n", __FUNCTION__); - printf("%s: Starting thread\n", __FUNCTION__); + printf("cancel_test: Test 1: Normal Cancelation\n"); + printf("cancel_test: Starting thread\n"); start_thread(&waiter, 1); /* Then cancel it. It should be in the pthread_cond_wait now */ - printf("%s: Canceling thread\n", __FUNCTION__); + printf("cancel_test: Canceling thread\n"); status = pthread_cancel(waiter); if (status != 0) { - printf("%s: ERROR pthread_cancel failed, status=%d\n", __FUNCTION__, status); + printf("cancel_test: ERROR pthread_cancel failed, status=%d\n", status); } /* Then join to the thread to pick up the result */ - printf("%s: Joining\n", __FUNCTION__); + printf("cancel_test: Joining\n"); status = pthread_join(waiter, &result); if (status != 0) { - printf("%s: ERROR pthread_join failed, status=%d\n", __FUNCTION__, status); + printf("cancel_test: ERROR pthread_join failed, status=%d\n", status); } else { - printf("%s: waiter exited with result=%p\n", __FUNCTION__, result); + printf("cancel_test: waiter exited with result=%p\n", result); if (result != PTHREAD_CANCELED) { - printf("%s: ERROR expected result=%p\n", __FUNCTION__, PTHREAD_CANCELED); + printf("cancel_test: ERROR expected result=%p\n", PTHREAD_CANCELED); } else { - printf("%s: PASS thread terminated with PTHREAD_CANCELED\n", __FUNCTION__); + printf("cancel_test: PASS thread terminated with PTHREAD_CANCELED\n"); } } /* Test 2: Cancel Detached Thread ************************************/ - printf("%s: Test 2: Cancelation of detached thread\n", __FUNCTION__); - printf("%s: Re-starting thread\n", __FUNCTION__); + printf("cancel_test: Test 2: Cancelation of detached thread\n"); + printf("cancel_test: Re-starting thread\n"); restart_thread(&waiter, 1); /* Detach the thread */ @@ -235,39 +235,39 @@ void cancel_test(void) status = pthread_detach(waiter); if (status != 0) { - printf("%s: ERROR pthread_detach, status=%d\n", __FUNCTION__, status); + printf("cancel_test: ERROR pthread_detach, status=%d\n", status); } /* Then cancel it. It should be in the pthread_cond_wait now */ - printf("%s: Canceling thread\n", __FUNCTION__); + printf("cancel_test: Canceling thread\n"); status = pthread_cancel(waiter); if (status != 0) { - printf("%s: ERROR pthread_cancel failed, status=%d\n", __FUNCTION__, status); + printf("cancel_test: ERROR pthread_cancel failed, status=%d\n", status); } /* Join should now fail */ - printf("%s: Joining\n", __FUNCTION__); + printf("cancel_test: Joining\n"); status = pthread_join(waiter, &result); if (status == 0) { - printf("%s: ERROR pthread_join succeeded\n", __FUNCTION__); + printf("cancel_test: ERROR pthread_join succeeded\n"); } else if (status != ESRCH) { - printf("%s: ERROR pthread_join failed but with wrong status=%d\n", __FUNCTION__, status); + printf("cancel_test: ERROR pthread_join failed but with wrong status=%d\n", status); } else { - printf("%s: PASS pthread_join failed with status=ESRCH\n", __FUNCTION__); + printf("cancel_test: PASS pthread_join failed with status=ESRCH\n"); } /* Test 3: Non-cancelable threads ************************************/ - printf("%s: Test 3: Non-cancelable threads\n", __FUNCTION__); - printf("%s: Re-starting thread (non-cancelable)\n", __FUNCTION__); + printf("cancel_test: Test 3: Non-cancelable threads\n"); + printf("cancel_test: Re-starting thread (non-cancelable)\n"); restart_thread(&waiter, 0); /* Then cancel it. It should be in the pthread_cond_wait now. The @@ -277,11 +277,11 @@ void cancel_test(void) * The cancelation should succeed, because the cancelation is pending. */ - printf("%s: Canceling thread\n", __FUNCTION__); + printf("cancel_test: Canceling thread\n"); status = pthread_cancel(waiter); if (status != 0) { - printf("%s: ERROR pthread_cancel failed, status=%d\n", __FUNCTION__, status); + printf("cancel_test: ERROR pthread_cancel failed, status=%d\n", status); } /* Signal the thread. It should wake up an restore the cancelable state. @@ -291,18 +291,18 @@ void cancel_test(void) status = pthread_mutex_lock(&mutex); if (status != 0) { - printf("%s: ERROR pthread_mutex_lock failed, status=%d\n", __FUNCTION__, status); + printf("cancel_test: ERROR pthread_mutex_lock failed, status=%d\n", status); } status = pthread_cond_signal(&cond); if (status != 0) { - printf("%s: ERROR pthread_cond_signal failed, status=%d\n", __FUNCTION__, status); + printf("cancel_test: ERROR pthread_cond_signal failed, status=%d\n", status); } status = pthread_mutex_unlock(&mutex); if (status != 0) { - printf("%s: ERROR pthread_mutex_unlock failed, status=%d\n", __FUNCTION__, status); + printf("cancel_test: ERROR pthread_mutex_unlock failed, status=%d\n", status); } } diff --git a/examples/ostest/cond.c b/examples/ostest/cond.c index be995fa080..13e7b46697 100644 --- a/examples/ostest/cond.c +++ b/examples/ostest/cond.c @@ -59,7 +59,7 @@ static void *thread_waiter(void *parameter) { int status; - printf("%s: Started\n", __FUNCTION__); + printf("waiter_thread: Started\n"); for(;;) { @@ -71,7 +71,7 @@ static void *thread_waiter(void *parameter) if (status != 0) { - printf("%s: ERROR pthread_mutex_lock failed, status=%d\n", __FUNCTION__, status); + printf("waiter_thread: ERROR pthread_mutex_lock failed, status=%d\n", status); waiter_nerrors++; } @@ -94,7 +94,7 @@ static void *thread_waiter(void *parameter) if (status != 0) { - printf("%s: ERROR pthread_cond_wait failed, status=%d\n", __FUNCTION__, status); + printf("waiter_thread: ERROR pthread_cond_wait failed, status=%d\n", status); waiter_nerrors++; } waiter_waits++; @@ -104,7 +104,7 @@ static void *thread_waiter(void *parameter) if (!data_available) { - printf("%s: ERROR data not available after wait\n", __FUNCTION__); + printf("waiter_thread: ERROR data not available after wait\n"); waiter_nerrors++; } @@ -117,7 +117,7 @@ static void *thread_waiter(void *parameter) status = pthread_mutex_unlock(&mutex); if (status != 0) { - printf("%s: ERROR waiter: pthread_mutex_unlock failed, status=%d\n", __FUNCTION__, status); + printf("waiter_thread: ERROR waiter: pthread_mutex_unlock failed, status=%d\n", status); waiter_nerrors++; } @@ -130,7 +130,7 @@ static void *thread_signaler(void *parameter) int status; int i; - printf("%s: Started\n", __FUNCTION__); + printf("thread_signaler: Started\n"); for (i = 0; i < 32; i++) { /* Take the mutex. The waiter is higher priority and should @@ -141,7 +141,7 @@ static void *thread_signaler(void *parameter) status = pthread_mutex_lock(&mutex); if (status != 0) { - printf("%s: ERROR pthread_mutex_lock failed, status=%d\n", __FUNCTION__, status); + printf("thread_signaler: ERROR pthread_mutex_lock failed, status=%d\n", status); signaler_nerrors++; } @@ -149,13 +149,13 @@ static void *thread_signaler(void *parameter) if (waiter_state != COND_WAIT) { - printf("%s: ERROR waiter state = %d != COND_WAITING\n", __FUNCTION__, waiter_state); + printf("thread_signaler: ERROR waiter state = %d != COND_WAITING\n", waiter_state); signaler_state++; } if (data_available) { - printf("%s: ERROR data already available, waiter_state=%d\n", __FUNCTION__, waiter_state); + printf("thread_signaler: ERROR data already available, waiter_state=%d\n", waiter_state); signaler_already++; } @@ -165,7 +165,7 @@ static void *thread_signaler(void *parameter) status = pthread_cond_signal(&cond); if (status != 0) { - printf("%s: ERROR pthread_cond_signal failed, status=%d\n", __FUNCTION__, status); + printf("thread_signaler: ERROR pthread_cond_signal failed, status=%d\n", status); signaler_nerrors++; } @@ -174,14 +174,14 @@ static void *thread_signaler(void *parameter) status = pthread_mutex_unlock(&mutex); if (status != 0) { - printf("%s: ERROR pthread_mutex_unlock failed, status=%d\n", __FUNCTION__, status); + printf("thread_signaler: ERROR pthread_mutex_unlock failed, status=%d\n", status); signaler_nerrors++; } signaler_nloops++; } - printf("%s: Terminating\n", __FUNCTION__); + printf("thread_signaler: Terminating\n"); pthread_exit(NULL); } @@ -198,29 +198,29 @@ void cond_test(void) /* Initialize the mutex */ - printf("%s: Initializing mutex\n", __FUNCTION__); + printf("cond_test: Initializing mutex\n"); status = pthread_mutex_init(&mutex, NULL); if (status != 0) { - printf("%s: ERROR pthread_mutex_init failed, status=%d\n", __FUNCTION__, status); + printf("cond_test: ERROR pthread_mutex_init failed, status=%d\n", status); } /* Initialize the condition variable */ - printf("%s: Initializing cond\n", __FUNCTION__); + printf("cond_test: Initializing cond\n"); status = pthread_cond_init(&cond, NULL); if (status != 0) { - printf("%s: ERROR pthread_condinit failed, status=%d\n", __FUNCTION__, status); + printf("cond_test: ERROR pthread_condinit failed, status=%d\n", status); } /* Start the waiter thread at higher priority */ - printf("%s: Starting waiter\n", __FUNCTION__); + printf("cond_test: Starting waiter\n"); status = pthread_attr_init(&attr); if (status != 0) { - printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status); + printf("cond_test: pthread_attr_init failed, status=%d\n", status); } prio_min = sched_get_priority_min(SCHED_FIFO); @@ -231,54 +231,54 @@ void cond_test(void) status = pthread_attr_setschedparam(&attr,&sparam); if (status != OK) { - printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status); + printf("cond_test: pthread_attr_setschedparam failed, status=%d\n", status); } else { - printf("%s: Set thread 1 priority to %d\n", __FUNCTION__, sparam.sched_priority); + printf("cond_test: Set thread 1 priority to %d\n", sparam.sched_priority); } status = pthread_create(&waiter, &attr, thread_waiter, NULL); if (status != 0) { - printf("%s: pthread_create failed, status=%d\n", __FUNCTION__, status); + printf("cond_test: pthread_create failed, status=%d\n", status); } - printf("%s: Starting signaler\n", __FUNCTION__); + printf("cond_test: Starting signaler\n"); status = pthread_attr_init(&attr); if (status != 0) { - printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status); + printf("cond_test: pthread_attr_init failed, status=%d\n", status); } sparam.sched_priority = (prio_min + prio_mid) / 2; status = pthread_attr_setschedparam(&attr,&sparam); if (status != OK) { - printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status); + printf("cond_test: pthread_attr_setschedparam failed, status=%d\n", status); } else { - printf("%s: Set thread 2 priority to %d\n", __FUNCTION__, sparam.sched_priority); + printf("cond_test: Set thread 2 priority to %d\n", sparam.sched_priority); } status = pthread_create(&signaler, &attr, thread_signaler, NULL); if (status != 0) { - printf("%s: pthread_create failed, status=%d\n", __FUNCTION__, status); + printf("cond_test: pthread_create failed, status=%d\n", status); } /* Wait for the threads to stop */ pthread_join(signaler, NULL); - printf("%s: signaler terminated, now cancel the waiter\n", __FUNCTION__); + printf("cond_test: signaler terminated, now cancel the waiter\n"); pthread_detach(waiter); pthread_cancel(waiter); - printf("%s: \tWaiter\tSignaler\n", __FUNCTION__); - printf("%s: Loops\t%d\t%d\n", __FUNCTION__, waiter_nloops, signaler_nloops); - printf("%s: Errors\t%d\t%d\n", __FUNCTION__, waiter_nerrors, signaler_nerrors); - printf("%s: \n%d times, waiter did not have to wait for data\n", __FUNCTION__, waiter_nloops - waiter_waits); - printf("%s: %d times, data was already available when the signaler run\n", __FUNCTION__, signaler_already); - printf("%s: %d times, the waiter was in an unexpected state when the signaler ran\n", __FUNCTION__, signaler_state); + printf("cond_test: \tWaiter\tSignaler\n"); + printf("cond_test: Loops\t%d\t%d\n", waiter_nloops, signaler_nloops); + printf("cond_test: Errors\t%d\t%d\n", waiter_nerrors, signaler_nerrors); + printf("cond_test: \n%d times, waiter did not have to wait for data\n", waiter_nloops - waiter_waits); + printf("cond_test: %d times, data was already available when the signaler run\n", signaler_already); + printf("cond_test: %d times, the waiter was in an unexpected state when the signaler ran\n", signaler_state); } diff --git a/examples/ostest/dev_null.c b/examples/ostest/dev_null.c index 11d6056c84..f9ca5623a6 100644 --- a/examples/ostest/dev_null.c +++ b/examples/ostest/dev_null.c @@ -64,27 +64,27 @@ int dev_null(void) fd = open("/dev/null", O_RDWR); if (fd < 0) { - fprintf(stderr, "%s: Failed to open /dev/null\n", __FUNCTION__); + fprintf(stderr, "dev_null: Failed to open /dev/null\n"); return -1; } nbytes = read(fd, buffer, 1024); if (nbytes < 0) { - fprintf(stderr, "%s: Failed to read from /dev/null\n", __FUNCTION__); + fprintf(stderr, "dev_null: Failed to read from /dev/null\n"); close(fd); return -1; } - printf("%s: Read %d bytes from /dev/null\n", __FUNCTION__, nbytes); + printf("dev_null: Read %d bytes from /dev/null\n", nbytes); nbytes = write(fd, buffer, 1024); if (nbytes < 0) { - fprintf(stderr, "%s: Failed to write to /dev/null\n", __FUNCTION__); + fprintf(stderr, "dev_null: Failed to write to /dev/null\n"); close(fd); return -1; } - printf("%s: Wrote %d bytes to /dev/null\n", __FUNCTION__, nbytes); + printf("dev_null: Wrote %d bytes to /dev/null\n", nbytes); close(fd); return 0; diff --git a/examples/ostest/main.c b/examples/ostest/main.c index f6c0c65caf..3122ef3430 100644 --- a/examples/ostest/main.c +++ b/examples/ostest/main.c @@ -76,27 +76,27 @@ static int user_main(int argc, char *argv[]) { int i; - printf("%s: Started with argc=%d\n", __FUNCTION__, argc); + printf("user_main: Started with argc=%d\n", argc); /* Verify passed arguments */ if (argc != NARGS + 1) { - fprintf(stderr, "%s: Error expected argc=%d got argc=%d\n", - __FUNCTION__, NARGS+1, argc); + fprintf(stderr, "user_main: Error expected argc=%d got argc=%d\n", + NARGS+1, argc); } for (i = 0; i <= NARGS; i++) { - printf("%s: argv[%d]=\"%s\"\n", __FUNCTION__, i, argv[i]); + printf("user_main: argv[%d]=\"%s\"\n", i, argv[i]); } for (i = 1; i <= NARGS; i++) { if (strcmp(argv[i], args[i-1]) != 0) { - fprintf(stderr, "%s: ERROR argv[%d]: Expected \"%s\" found \"%s\"\n", - __FUNCTION__, i, argv[i], args[i-1]); + fprintf(stderr, "user_main: ERROR argv[%d]: Expected \"%s\" found \"%s\"\n", + i, argv[i], args[i-1]); } } @@ -158,9 +158,9 @@ int user_start(int parm1, int parm2, int parm3, int parm4) /* Verify that we can communicate */ write(1, write_data1, sizeof(write_data1)); - printf("%s: Standard I/O Check: printf\n", __FUNCTION__); + printf("user_start: Standard I/O Check: printf\n"); write(2, write_data2, sizeof(write_data2)); - fprintf(stderr, "%s: Standard I/O Check: fprintf to stderr\n", __FUNCTION__); + fprintf(stderr, "user_start: Standard I/O Check: fprintf to stderr\n"); /* Verify that we can spawn a new task */ @@ -168,11 +168,11 @@ int user_start(int parm1, int parm2, int parm3, int parm4) ARG1, ARG2, ARG3, ARG4); if (result == ERROR) { - fprintf(stderr, "%s: Failed to start user_main\n", __FUNCTION__); + fprintf(stderr, "user_start: Failed to start user_main\n"); } else { - printf("%s: Started user_main at PID=%d\n", __FUNCTION__, result); + printf("user_start: Started user_main at PID=%d\n", result); } return 0; } diff --git a/examples/ostest/mqueue.c b/examples/ostest/mqueue.c index f9e6b6e034..acdbea99eb 100644 --- a/examples/ostest/mqueue.c +++ b/examples/ostest/mqueue.c @@ -85,7 +85,7 @@ static void *sender_thread(void *arg) int nerrors = 0; int i; - printf("%s: Starting\n", __FUNCTION__); + printf("sender_thread: Starting\n"); /* Fill in attributes for message queue */ @@ -107,7 +107,7 @@ static void *sender_thread(void *arg) mqfd = mq_open("testmq", O_WRONLY|O_CREAT, 0666, &attr); if (mqfd < 0) { - printf("%s: ERROR mq_open failed\n", __FUNCTION__); + printf("sender_thread: ERROR mq_open failed\n"); pthread_exit((void*)1); } @@ -122,12 +122,12 @@ static void *sender_thread(void *arg) status = mq_send(mqfd, msg_buffer, TEST_MSGLEN, 42); if (status < 0) { - printf("%s: ERROR mq_send failure=%d on msg %d\n", __FUNCTION__, status, i); + printf("sender_thread: ERROR mq_send failure=%d on msg %d\n", status, i); nerrors++; } else { - printf("%s: mq_send succeeded on msg %d\n", __FUNCTION__, i); + printf("sender_thread: mq_send succeeded on msg %d\n", i); } } @@ -135,10 +135,10 @@ static void *sender_thread(void *arg) if (mq_close(mqfd) < 0) { - printf("%s: ERROR mq_close failed\n", __FUNCTION__); + printf("sender_thread: ERROR mq_close failed\n"); } - printf("%s: returning nerrors=%d\n", __FUNCTION__, nerrors); + printf("sender_thread: returning nerrors=%d\n", nerrors); return (void*)nerrors; } @@ -151,7 +151,7 @@ static void *receiver_thread(void *arg) int nerrors = 0; int i; - printf("%s: Starting\n", __FUNCTION__); + printf("receiver_thread: Starting\n"); /* Fill in attributes for message queue */ @@ -173,7 +173,7 @@ static void *receiver_thread(void *arg) mqfd = mq_open("testmq", O_RDONLY|O_CREAT, 0666, &attr); if (mqfd < 0) { - printf("%s: ERROR mq_open failed\n", __FUNCTION__); + printf("receiver_thread: ERROR mq_open failed\n"); pthread_exit((void*)1); } @@ -184,33 +184,32 @@ static void *receiver_thread(void *arg) nbytes = mq_receive(mqfd, msg_buffer, TEST_MSGLEN, 0); if (nbytes < 0) { - printf("%s: ERROR mq_receive failure on msg %d\n", __FUNCTION__, i); + printf("receiver_thread: ERROR mq_receive failure on msg %d\n", i); nerrors++; } else if (nbytes != TEST_MSGLEN) { - printf("%s: mq_receive return bad size %d on msg %d\n", __FUNCTION__, nbytes, i); + printf("receiver_thread: mq_receive return bad size %d on msg %d\n", nbytes, i); nerrors++; } else if (memcmp(TEST_MESSAGE, msg_buffer, nbytes) != 0) { int j; - printf("%s: mq_receive returned corrupt message on msg %d\n", __FUNCTION__, i); - printf("%s: i Expected Received\n", __FUNCTION__); + printf("receiver_thread: mq_receive returned corrupt message on msg %d\n", i); + printf("receiver_thread: i Expected Received\n"); for (j = 0; j < TEST_MSGLEN-1; j++) { - printf("%s: %2d %02x (%c) %02x\n", - __FUNCTION__, + printf("receiver_thread: %2d %02x (%c) %02x\n", j, TEST_MESSAGE[j], TEST_MESSAGE[j], msg_buffer[j] & 0x0ff); } - printf("%s: %2d 00 %02x\n", - __FUNCTION__, j, msg_buffer[j] & 0xff); + printf("receiver_thread: %2d 00 %02x\n", + j, msg_buffer[j] & 0xff); } else { - printf("%s: mq_receive succeeded on msg %d\n", __FUNCTION__, i); + printf("receiver_thread: mq_receive succeeded on msg %d\n", i); } } @@ -218,7 +217,7 @@ static void *receiver_thread(void *arg) if (mq_close(mqfd) < 0) { - printf("%s: ERROR mq_close failed\n", __FUNCTION__); + printf("receiver_thread: ERROR mq_close failed\n"); nerrors++; } @@ -228,11 +227,11 @@ static void *receiver_thread(void *arg) if (mq_unlink("testmq") < 0) { - printf("%s: ERROR mq_close failed\n", __FUNCTION__); + printf("receiver_thread: ERROR mq_close failed\n"); nerrors++; } - printf("%s: returning nerrors=%d\n", __FUNCTION__, nerrors); + printf("receiver_thread: returning nerrors=%d\n", nerrors); return (void*)nerrors; } @@ -250,17 +249,17 @@ void mqueue_test(void) /* Start the sending thread at higher priority */ - printf("%s: Starting receiver\n", __FUNCTION__); + printf("mqueue_test: Starting receiver\n"); status = pthread_attr_init(&attr); if (status != 0) { - printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status); + printf("mqueue_test: pthread_attr_init failed, status=%d\n", status); } status = pthread_attr_setstacksize(&attr, 16384); if (status != 0) { - printf("%s: pthread_attr_setstacksize failed, status=%d\n", __FUNCTION__, status); + printf("mqueue_test: pthread_attr_setstacksize failed, status=%d\n", status); } prio_min = sched_get_priority_min(SCHED_FIFO); @@ -271,62 +270,62 @@ void mqueue_test(void) status = pthread_attr_setschedparam(&attr,&sparam); if (status != OK) { - printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status); + printf("mqueue_test: pthread_attr_setschedparam failed, status=%d\n", status); } else { - printf("%s: Set receiver priority to %d\n", __FUNCTION__, sparam.sched_priority); + printf("mqueue_test: Set receiver priority to %d\n", sparam.sched_priority); } status = pthread_create(&receiver, &attr, receiver_thread, NULL); if (status != 0) { - printf("%s: pthread_create failed, status=%d\n", __FUNCTION__, status); + printf("mqueue_test: pthread_create failed, status=%d\n", status); } /* Start the sending thread at lower priority */ - printf("%s: Starting sender\n", __FUNCTION__); + printf("mqueue_test: Starting sender\n"); status = pthread_attr_init(&attr); if (status != 0) { - printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status); + printf("mqueue_test: pthread_attr_init failed, status=%d\n", status); } status = pthread_attr_setstacksize(&attr, 16384); if (status != 0) { - printf("%s: pthread_attr_setstacksize failed, status=%d\n", __FUNCTION__, status); + printf("mqueue_test: pthread_attr_setstacksize failed, status=%d\n", status); } sparam.sched_priority = (prio_min + prio_mid) / 2; status = pthread_attr_setschedparam(&attr,&sparam); if (status != OK) { - printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status); + printf("mqueue_test: pthread_attr_setschedparam failed, status=%d\n", status); } else { - printf("%s: Set sender thread priority to %d\n", __FUNCTION__, sparam.sched_priority); + printf("mqueue_test: Set sender thread priority to %d\n", sparam.sched_priority); } status = pthread_create(&sender, &attr, sender_thread, NULL); if (status != 0) { - printf("%s: pthread_create failed, status=%d\n", __FUNCTION__, status); + printf("mqueue_test: pthread_create failed, status=%d\n", status); } pthread_join(sender, &result); if (result != (void*)0) { - printf("%s: ERROR sender thread exited with %d errors\n", __FUNCTION__, (int)result); + printf("mqueue_test: ERROR sender thread exited with %d errors\n", (int)result); } pthread_cancel(receiver); pthread_join(receiver, &result); if (result != (void*)0) { - printf("%s: ERROR receiver thread exited with %d errors\n", __FUNCTION__, (int)result); + printf("mqueue_test: ERROR receiver thread exited with %d errors\n", (int)result); } } diff --git a/examples/ostest/mutex.c b/examples/ostest/mutex.c index d6cad9e39f..cb8996053c 100644 --- a/examples/ostest/mutex.c +++ b/examples/ostest/mutex.c @@ -60,14 +60,14 @@ static void *thread_func(void *parameter) if (status != 0) { printf("ERROR thread %d: pthread_mutex_lock failed, status=%d\n", - id, status); + id, status); } if (my_mutex == 1) { printf("ERROR thread=%d: " - "my_mutex should be zero, instead my_mutex=%d\n", - id, my_mutex); + "my_mutex should be zero, instead my_mutex=%d\n", + id, my_mutex); nerrors[ndx]++; } @@ -82,7 +82,7 @@ static void *thread_func(void *parameter) if (status != 0) { printf("ERROR thread %d: pthread_mutex_unlock failed, status=%d\n", - id, status); + id, status); } } pthread_exit(NULL); @@ -114,7 +114,7 @@ void mutex_test(void) pthread_join(thread1, NULL); pthread_join(thread2, NULL); - printf("%s:\t\tThread1\tThread2\n", __FUNCTION__); - printf("%s:\tLoops\t%ld\t%ld\n", __FUNCTION__, nloops[0], nloops[1]); - printf("%s:\tErrors\t%ld\t%ld\n", __FUNCTION__, nerrors[0], nerrors[1]); + printf("\t\tThread1\tThread2\n"); + printf("\tLoops\t%ld\t%ld\n", nloops[0], nloops[1]); + printf("\tErrors\t%ld\t%ld\n", nerrors[0], nerrors[1]); } diff --git a/examples/ostest/ostest.h b/examples/ostest/ostest.h index 3871ecc67b..8d567cb37a 100644 --- a/examples/ostest/ostest.h +++ b/examples/ostest/ostest.h @@ -88,4 +88,8 @@ extern void cancel_test(void); extern void timedwait_test(void); +/* sighand.c ************************************************/ + +extern void sighand_test(void); + #endif /* __OSTEST_H */ diff --git a/examples/ostest/sem.c b/examples/ostest/sem.c index 0b532982dc..73be6910e3 100644 --- a/examples/ostest/sem.c +++ b/examples/ostest/sem.c @@ -52,39 +52,39 @@ static void *waiter_func(void *parameter) int status; int value; - printf("%s: Thread %d Started\n", __FUNCTION__, id); + printf("waiter_func: Thread %d Started\n", id); /* Take the semaphore */ status = sem_getvalue(&sem, &value); if (status < 0) { - printf("%s: ERROR thread %d could not get semaphore value\n", __FUNCTION__, id); + printf("waiter_func: ERROR thread %d could not get semaphore value\n", id); } else { - printf("%s: Thread %d initial semaphore value = %d\n", __FUNCTION__, id, value); + printf("waiter_func: Thread %d initial semaphore value = %d\n", id, value); } - printf("%s: Thread %d aiting on semaphore\n", __FUNCTION__, id); + printf("waiter_func: Thread %d aiting on semaphore\n", id); status = sem_wait(&sem); if (status != 0) { - printf("%s: ERROR thread %d sem_wait failed\n", __FUNCTION__, id); + printf("waiter_func: ERROR thread %d sem_wait failed\n", id); } - printf("%s: Thread %d awakened\n", __FUNCTION__, id); + printf("waiter_func: Thread %d awakened\n", id); status = sem_getvalue(&sem, &value); if (status < 0) { - printf("%s: ERROR thread %d could not get semaphore value\n", __FUNCTION__, id); + printf("waiter_func: ERROR thread %d could not get semaphore value\n", id); } else { - printf("%s: Thread %d new semaphore value = %d\n", __FUNCTION__, id, value); + printf("waiter_func: Thread %d new semaphore value = %d\n", id, value); } - printf("%s: Thread %d done\n", __FUNCTION__, id); + printf("waiter_func: Thread %d done\n", id); return NULL; } @@ -94,7 +94,7 @@ static void *poster_func(void *parameter) int status; int value; - printf("%s: Thread %d started\n", __FUNCTION__, id); + printf("poster_func: Thread %d started\n", id); /* Take the semaphore */ @@ -103,20 +103,20 @@ static void *poster_func(void *parameter) status = sem_getvalue(&sem, &value); if (status < 0) { - printf("%s: ERROR thread %d could not get semaphore value\n", __FUNCTION__, id); + printf("poster_func: ERROR thread %d could not get semaphore value\n", id); } else { - printf("%s: Thread %d semaphore value = %d\n", __FUNCTION__, id, value); + printf("poster_func: Thread %d semaphore value = %d\n", id, value); } if (value < 0) { - printf("%s: Thread %d posting semaphore\n", __FUNCTION__, id); + printf("poster_func: Thread %d posting semaphore\n", id); status = sem_post(&sem); if (status != 0) { - printf("%s: ERROR thread %d sem_wait failed\n", __FUNCTION__, id); + printf("poster_func: ERROR thread %d sem_wait failed\n", id); } pthread_yield(); @@ -124,17 +124,17 @@ static void *poster_func(void *parameter) status = sem_getvalue(&sem, &value); if (status < 0) { - printf("%s: ERROR thread %d could not get semaphore value\n", __FUNCTION__, id); + printf("poster_func: ERROR thread %d could not get semaphore value\n", id); } else { - printf("%s: Thread %d new semaphore value = %d\n", __FUNCTION__, id, value); + printf("poster_func: Thread %d new semaphore value = %d\n", id, value); } } } while (value < 0); - printf("%s: Thread %d done\n", __FUNCTION__, id); + printf("poster_func: Thread %d done\n", id); return NULL; } @@ -151,16 +151,16 @@ void sem_test(void) pthread_attr_t attr; int status; - printf("%s: Initializing semaphore to 0\n", __FUNCTION__); + printf("sem_test: Initializing semaphore to 0\n"); sem_init(&sem, 0, 0); /* Start two waiter thread instances */ - printf("%s: Starting waiter thread 1\n", __FUNCTION__); + printf("sem_test: Starting waiter thread 1\n"); status = pthread_attr_init(&attr); if (status != OK) { - printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status); + printf("sem_test: pthread_attr_init failed, status=%d\n", status); } prio_min = sched_get_priority_min(SCHED_FIFO); @@ -171,65 +171,65 @@ void sem_test(void) status = pthread_attr_setschedparam(&attr,&sparam); if (status != OK) { - printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status); + printf("sem_test: pthread_attr_setschedparam failed, status=%d\n", status); } else { - printf("%s: Set thread 1 priority to %d\n", __FUNCTION__, sparam.sched_priority); + printf("sem_test: Set thread 1 priority to %d\n", sparam.sched_priority); } status = pthread_create(&waiter_thread1, &attr, waiter_func, (void*)1); if (status != 0) { - printf("%s: Error in thread 1 creation, status=%d\n", __FUNCTION__, status); + printf("sem_test: Error in thread 1 creation, status=%d\n", status); } - printf("%s: Starting waiter thread 2\n", __FUNCTION__); + printf("sem_test: Starting waiter thread 2\n"); status = pthread_attr_init(&attr); if (status != 0) { - printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status); + printf("sem_test: pthread_attr_init failed, status=%d\n", status); } sparam.sched_priority = prio_mid; status = pthread_attr_setschedparam(&attr,&sparam); if (status != OK) { - printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status); + printf("sem_test: pthread_attr_setschedparam failed, status=%d\n", status); } else { - printf("%s: Set thread 2 priority to %d\n", __FUNCTION__, sparam.sched_priority); + printf("sem_test: Set thread 2 priority to %d\n", sparam.sched_priority); } status = pthread_create(&waiter_thread2, &attr, waiter_func, (void*)2); if (status != 0) { - printf("%s: Error in thread 2 creation, status=%d\n", __FUNCTION__, status); + printf("sem_test: Error in thread 2 creation, status=%d\n", status); } - printf("%s: Starting poster thread 3\n", __FUNCTION__); + printf("sem_test: Starting poster thread 3\n"); status = pthread_attr_init(&attr); if (status != 0) { - printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status); + printf("sem_test: pthread_attr_init failed, status=%d\n", status); } sparam.sched_priority = (prio_min + prio_mid) / 2; status = pthread_attr_setschedparam(&attr,&sparam); if (status != OK) { - printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status); + printf("sem_test: pthread_attr_setschedparam failed, status=%d\n", status); } else { - printf("%s: Set thread 3 priority to %d\n", __FUNCTION__, sparam.sched_priority); + printf("sem_test: Set thread 3 priority to %d\n", sparam.sched_priority); } status = pthread_create(&poster_thread, &attr, poster_func, (void*)3); if (status != 0) { - printf("%s: Error in thread 3 creation, status=%d\n", __FUNCTION__, status); + printf("sem_test: Error in thread 3 creation, status=%d\n", status); } pthread_join(waiter_thread1, NULL); diff --git a/examples/ostest/sighand.c b/examples/ostest/sighand.c index 9ffd166f46..ada7d88364 100644 --- a/examples/ostest/sighand.c +++ b/examples/ostest/sighand.c @@ -60,7 +60,7 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext) sigset_t allsigs; int status; - printf("%s: Received signal %d\n", __FUNCTION__, signo); + printf("wakeup_action: Received signal %d\n" , signo); sigreceived = TRUE; @@ -68,32 +68,32 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext) if (signo != WAKEUP_SIGNAL) { - printf("%s: ERROR expected signo=%d\n", __FUNCTION__, WAKEUP_SIGNAL); + printf("wakeup_action: ERROR expected signo=%d\n" , WAKEUP_SIGNAL); } /* Check siginfo */ if (info->si_value.sival_int != SIGVALUE_INT) { - printf("%s: ERROR sival_int=%d expected %d\n", - __FUNCTION__, info->si_value.sival_int, SIGVALUE_INT); + printf("wakeup_action: ERROR sival_int=%d expected %d\n", + info->si_value.sival_int, SIGVALUE_INT); } else { - printf("%s: sival_int=%d\n", __FUNCTION__, info->si_value.sival_int); + printf("wakeup_action: sival_int=%d\n" , info->si_value.sival_int); } if (info->si_signo != WAKEUP_SIGNAL) { - printf("%s: ERROR expected si_signo=%d, got=%d\n", - __FUNCTION__, WAKEUP_SIGNAL, info->si_signo); + printf("wakeup_action: ERROR expected si_signo=%d, got=%d\n", + WAKEUP_SIGNAL, info->si_signo); } - printf("%s: si_code=%d\n", __FUNCTION__, info->si_code); + printf("wakeup_action: si_code=%d\n" , info->si_code); /* Check ucontext_t */ - printf("%s: ucontext=%p\n", __FUNCTION__, ucontext); + printf("wakeup_action: ucontext=%p\n" , ucontext); /* Check sigprocmask */ @@ -101,14 +101,14 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext) status = sigprocmask(SIG_SETMASK, NULL, &oldset); if (status != OK) { - printf("%s: ERROR sigprocmask failed, status=%d\n", - __FUNCTION__, status); + printf("wakeup_action: ERROR sigprocmask failed, status=%d\n", + status); } if (oldset != allsigs) { - printf("%s: ERROR sigprocmask=%x expected=%x\n", - __FUNCTION__, oldset, allsigs); + printf("wakeup_action: ERROR sigprocmask=%x expected=%x\n", + oldset, allsigs); } } @@ -120,19 +120,19 @@ static int waiter_main(int argc, char *argv[]) struct sigaction oact; int status; - printf("%s: Waiter started\n", __FUNCTION__); + printf("wakeup_action: Waiter started\n" ); - printf("%s: Unmasking signal %d\n", __FUNCTION__, WAKEUP_SIGNAL); + printf("waiter_main: Unmasking signal %d\n" , WAKEUP_SIGNAL); (void)sigemptyset(&sigset); (void)sigaddset(&sigset, WAKEUP_SIGNAL); status = sigprocmask(SIG_UNBLOCK, &sigset, NULL); if (status != OK) { - printf("%s: ERROR sigprocmask failed, status=%d\n", - __FUNCTION__, status); + printf("waiter_main: ERROR sigprocmask failed, status=%d\n", + status); } - printf("%s: Registering signal handler\n", __FUNCTION__); + printf("waiter_main: Registering signal handler\n" ); act.sa_sigaction = wakeup_action; act.sa_flags = SA_SIGINFO; @@ -142,15 +142,15 @@ static int waiter_main(int argc, char *argv[]) status = sigaction(WAKEUP_SIGNAL, &act, &oact); if (status != OK) { - printf("%s: ERROR sigaction failed, status=%d\n", __FUNCTION__, status); + printf("waiter_main: ERROR sigaction failed, status=%d\n" , status); } - printf("%s: oact.sigaction=%p oact.sa_flags=%x oact.sa_mask=%x\n", - __FUNCTION__, oact.sa_sigaction, oact.sa_flags, oact.sa_mask); + printf("waiter_main: oact.sigaction=%p oact.sa_flags=%x oact.sa_mask=%x\n", + oact.sa_sigaction, oact.sa_flags, oact.sa_mask); /* Take the semaphore */ - printf("%s: Waiting on semaphore\n", __FUNCTION__); + printf("waiter_main: Waiting on semaphore\n" ); fflush(stdout); status = sem_wait(&sem); if (status != 0) @@ -158,19 +158,19 @@ static int waiter_main(int argc, char *argv[]) int error = *get_errno_ptr(); if (error == EINTR) { - printf("%s: sem_wait() successfully interrupted by signal\n", __FUNCTION__); + printf("waiter_main: sem_wait() successfully interrupted by signal\n" ); } else { - printf("%s: ERROR sem_wait failed, errno=%d\n", __FUNCTION__, error); + printf("waiter_main: ERROR sem_wait failed, errno=%d\n" , error); } } else { - printf("%s: ERROR awakened with no error!\n", __FUNCTION__); + printf("waiter_main: ERROR awakened with no error!\n" ); } - printf("%s: done\n", __FUNCTION__); + printf("waiter_main: done\n" ); fflush(stdout); threadexited = TRUE; return 0; @@ -184,25 +184,25 @@ void sighand_test(void) int policy; int status; - printf("%s: Initializing semaphore to 0\n", __FUNCTION__); + printf("waiter_main: Initializing semaphore to 0\n" ); sem_init(&sem, 0, 0); /* Start waiter thread */ - printf("%s: Starting waiter task\n", __FUNCTION__); + printf("sighand_test: Starting waiter task\n" ); status = sched_getparam (0, ¶m); if (status != OK) { - printf("%s: ERROR sched_getparam() failed\n", __FUNCTION__); + printf("sighand_test: ERROR sched_getparam() failed\n" ); param.sched_priority = PTHREAD_DEFAULT_PRIORITY; } policy = sched_getscheduler(0); if (policy == ERROR) { - printf("%s: ERROR sched_getscheduler() failed\n", __FUNCTION__); + printf("sighand_test: ERROR sched_getscheduler() failed\n" ); policy = SCHED_FIFO; } @@ -210,11 +210,11 @@ void sighand_test(void) PTHREAD_STACK_DEFAULT, waiter_main, 0, 0, 0, 0); if (waiterpid == ERROR) { - printf("%s: ERROR failed to start waiter_main\n", __FUNCTION__); + printf("sighand_test: ERROR failed to start waiter_main\n" ); } else { - printf("%s: Started waiter_main pid=%d\n", __FUNCTION__, waiterpid); + printf("sighand_test: Started waiter_main pid=%d\n" , waiterpid); } /* Wait a bit */ @@ -228,7 +228,7 @@ void sighand_test(void) status = sigqueue(waiterpid, WAKEUP_SIGNAL, sigvalue); if (status != OK) { - printf("%s: ERROR sigqueue failed\n", __FUNCTION__); + printf("sighand_test: ERROR sigqueue failed\n" ); task_delete(waiterpid); } @@ -241,14 +241,14 @@ void sighand_test(void) if (!threadexited) { - printf("%s: ERROR waiter task did not exit\n", __FUNCTION__); + printf("sighand_test: ERROR waiter task did not exit\n" ); } if (!sigreceived) { - printf("%s: ERROR signal handler did not run\n", __FUNCTION__); + printf("sighand_test: ERROR signal handler did not run\n" ); } - printf("%s: done\n", __FUNCTION__); + printf("sighand_test: done\n" ); fflush(stdout); } diff --git a/examples/ostest/timedwait.c b/examples/ostest/timedwait.c index 9f3e61eae2..b01b352fff 100644 --- a/examples/ostest/timedwait.c +++ b/examples/ostest/timedwait.c @@ -49,19 +49,19 @@ static void *thread_waiter(void *parameter) /* Take the mutex */ - printf("%s: Taking mutex\n", __FUNCTION__); + printf("thread_waiter: Taking mutex\n"); status = pthread_mutex_lock(&mutex); if (status != 0) { - printf("%s: ERROR pthread_mutex_lock failed, status=%d\n", __FUNCTION__, status); + printf("thread_waiter: ERROR pthread_mutex_lock failed, status=%d\n", status); } - printf("%s: Starting 5 second wait for condition\n", __FUNCTION__); + printf("thread_waiter: Starting 5 second wait for condition\n"); status = clock_gettime(CLOCK_REALTIME, &time); if (status != 0) { - printf("%s: ERROR clock_gettime failed\n", __FUNCTION__); + printf("thread_waiter: ERROR clock_gettime failed\n"); } time.tv_sec += 5; @@ -70,19 +70,19 @@ static void *thread_waiter(void *parameter) status = pthread_cond_timedwait(&cond, &mutex, &time); if (status != 0) { - printf("%s: ERROR pthread_cond_timedwait failed, status=%d\n", __FUNCTION__, status); + printf("thread_waiter: ERROR pthread_cond_timedwait failed, status=%d\n", status); } /* Release the mutex */ - printf("%s: Releasing mutex\n", __FUNCTION__); + printf("thread_waiter: Releasing mutex\n"); status = pthread_mutex_unlock(&mutex); if (status != 0) { - printf("%s: ERROR pthread_mutex_unlock failed, status=%d\n", __FUNCTION__, status); + printf("thread_waiter: ERROR pthread_mutex_unlock failed, status=%d\n", status); } - printf("%s: Exit with status 0x12345678\n", __FUNCTION__); + printf("thread_waiter: Exit with status 0x12345678\n"); pthread_exit((void*)0x12345678); return NULL; } @@ -98,36 +98,36 @@ void timedwait_test(void) /* Initialize the mutex */ - printf("%s: Initializing mutex\n", __FUNCTION__); + printf("thread_waiter: Initializing mutex\n"); status = pthread_mutex_init(&mutex, NULL); if (status != 0) { - printf("%s: ERROR pthread_mutex_init failed, status=%d\n", __FUNCTION__, status); + printf("timedwait_test: ERROR pthread_mutex_init failed, status=%d\n", status); } /* Initialize the condition variable */ - printf("%s: Initializing cond\n", __FUNCTION__); + printf("timedwait_test: Initializing cond\n"); status = pthread_cond_init(&cond, NULL); if (status != 0) { - printf("%s: ERROR pthread_condinit failed, status=%d\n", __FUNCTION__, status); + printf("timedwait_test: ERROR pthread_condinit failed, status=%d\n", status); } /* Start the waiter thread at higher priority */ - printf("%s: Starting waiter\n", __FUNCTION__); + printf("timedwait_test: Starting waiter\n"); status = pthread_attr_init(&attr); if (status != 0) { - printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status); + printf("timedwait_test: pthread_attr_init failed, status=%d\n", status); } prio_max = sched_get_priority_max(SCHED_FIFO); status = sched_getparam (getpid(), &sparam); if (status != 0) { - printf("%s: sched_getparam failed\n", __FUNCTION__); + printf("timedwait_test: sched_getparam failed\n"); sparam.sched_priority = PTHREAD_DEFAULT_PRIORITY; } @@ -135,27 +135,27 @@ void timedwait_test(void) status = pthread_attr_setschedparam(&attr,&sparam); if (status != OK) { - printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status); + printf("timedwait_test: pthread_attr_setschedparam failed, status=%d\n", status); } else { - printf("%s: Set thread 2 priority to %d\n", __FUNCTION__, sparam.sched_priority); + printf("timedwait_test: Set thread 2 priority to %d\n", sparam.sched_priority); } status = pthread_create(&waiter, &attr, thread_waiter, NULL); if (status != 0) { - printf("%s: pthread_create failed, status=%d\n", __FUNCTION__, status); + printf("timedwait_test: pthread_create failed, status=%d\n", status); } - printf("%s: Joining\n", __FUNCTION__); + printf("timedwait_test: Joining\n"); status = pthread_join(waiter, &result); if (status != 0) { - printf("%s: ERROR pthread_join failed, status=%d\n", __FUNCTION__, status); + printf("timedwait_test: ERROR pthread_join failed, status=%d\n", status); } else { - printf("%s: waiter exited with result=%p\n", __FUNCTION__, result); + printf("timedwait_test: waiter exited with result=%p\n", result); } } diff --git a/include/ctype.h b/include/ctype.h index c9acca9e70..9b62034ff7 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -49,7 +49,7 @@ #include /************************************************************ - * Public Type Definitions + * Definitions ************************************************************/ /************************************************************ @@ -63,18 +63,9 @@ * ************************************************************/ -static inline int isspace(int c) -{ - if (c == ' ' || c == '\t' || c == '\n' || \ - c == '\r' || c == '\f' || c == '\v') - { - return TRUE; - } - else - { - return FALSE; - } -} +#define isspace(c) \ + (c == ' ' || c == '\t' || c == '\n' || \ + c == '\r' || c == '\f' || c== '\v') /************************************************************ * Function: isdigit @@ -84,10 +75,8 @@ static inline int isspace(int c) * ************************************************************/ -static inline int isdigit(int c) -{ - return (c >= '0' && c <= '9'); -} +#define isdigit(c) \ + (c >= '0' && c <= '9') /************************************************************ * Function: isascii @@ -98,14 +87,11 @@ static inline int isdigit(int c) * ************************************************************/ -static inline int isascii(int c) -{ - return (c >= 0 && c <= 0177); -} - +#define isascii(c) \ + (c >= 0 && c <= 0177); /************************************************************ - * Function: isascii + * Function: isxdigit * * Description: * isxdigit() checks for a hexadecimal digits, i.e. one of @@ -113,60 +99,36 @@ static inline int isascii(int c) * ************************************************************/ -static inline int isxdigit(int c) -{ - if ((c >= '0' && c <= '9') || - (c >= 'a' && c <= 'f') || - (c >= 'A' && c <= 'F')) - { - return 1; - } - else - { - - return 0; - } -} +#define isxdigit(c) \ + ((c >= '0' && c <= '9') || \ + (c >= 'a' && c <= 'f') || \ + (c >= 'A' && c <= 'F')) /************************************************************ - * Function: isascii + * Function: toupper * * Description: * toupper() converts the letter c to upper case, if possible. * ************************************************************/ -static inline int toupper(int c) -{ - if (c >= 'a' && c <= 'z') - { - return c - 'a' + 'A'; - } - else - { - return c; - } -} +#define toupper(c) \ + ((c >= 'a' && c <= 'z') ? ((c) - 'a' + 'A') : (c)) /************************************************************ - * Function: isascii + * Function: tolower * * Description: * tolower() converts the letter c to lower case, if possible. * ************************************************************/ -static inline int tolower(int c) -{ - if (c >= 'A' && c <= 'Z') - { - return c - 'A' + 'a'; - } - else - { - return c; - } -} +#define tolower(c) \ + ((c >= 'A' && c <= 'Z') ? ((c) - 'A' + 'a') : (c)) + +/************************************************************ + * Public Type Definitions + ************************************************************/ /************************************************************ * Public Functions diff --git a/include/debug.h b/include/debug.h index db47bf6b12..2055fb9db6 100644 --- a/include/debug.h +++ b/include/debug.h @@ -48,17 +48,28 @@ /* Debug macros to runtime filter the opsys debug messages */ +#ifdef __GNUC__ +# define EXTRA_FMT "%s: " +# define EXTRA_ARG ,__FUNCTION__ +#else +# define EXTRA_FMT +# define EXTRA_ARG +#endif + #ifdef CONFIG_DEBUG -# define dbg(format, arg...) lib_rawprintf(format, ##arg) +# define dbg(format, arg...) \ + lib_rawprintf(EXTRA_FMT format EXTRA_ARG, ##arg) # ifdef CONFIG_ARCH_LOWPUTC -# define lldbg(format, arg...) lib_lowprintf(format, ##arg) +# define lldbg(format, arg...) \ + lib_lowprintf(EXTRA_FMT format EXTRA_ARG, ##arg) # else # define lldbg(x...) # endif # ifdef CONFIG_DEBUG_VERBOSE -# define vdbg(format, arg...) lib_rawprintf(format, ##arg) +# define vdbg(format, arg...) \ + lib_rawprintf(EXTRA_FMT format EXTRA_ARG, ##arg) # else # define vdbg(x...) # endif diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index a5731b7a0e..1299b53f0f 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -405,7 +405,7 @@ EXTERN void sched_process_timer(void); * ***********************************************************/ -EXTERN void irq_dispatch(int irq, struct xcptcontext *xcp); +EXTERN void irq_dispatch(int irq, void *context); /************************************************************ * Debug interfaces exported by the architecture-specific diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h index 5ada38075e..1916d8b9c5 100644 --- a/include/nuttx/compiler.h +++ b/include/nuttx/compiler.h @@ -49,7 +49,7 @@ extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))); # define weak_function __attribute__ ((weak)) # define weak_const_function __attribute__ ((weak, __const__)) -# define noreturn_function +# define noreturn_function __attribute__ ((noreturn)) #else # define weak_alias(name, aliasname) # define weak_function diff --git a/include/nuttx/irq.h b/include/nuttx/irq.h index e1b1c5a65c..0e29e2476f 100644 --- a/include/nuttx/irq.h +++ b/include/nuttx/irq.h @@ -60,11 +60,9 @@ /* This struct defines the way the registers are stored */ #ifndef __ASSEMBLY__ -struct xcptcontext; /* forward reference */ - -typedef int (*xcpt_t)(int irq, struct xcptcontext *xcp); +typedef int (*xcpt_t)(int irq, void *context); typedef int (*swint_t)(uint32 code, uint32 parm2, uint32 parm3, - struct xcptcontext *xcp); + void *context); #endif /* Now include architecture-specific types */ diff --git a/include/pthread.h b/include/pthread.h index c15cf3e0f6..c03e2a5fad 100644 --- a/include/pthread.h +++ b/include/pthread.h @@ -40,10 +40,11 @@ * Included Files ************************************************************/ -#include /* Default settings */ -#include /* Needed for general types */ -#include /* Needed for sem_t */ -#include /* Needed for struct timespec */ +#include /* Default settings */ +#include /* Needed for general types */ +#include /* Needed for sem_t */ +#include /* Needed for struct timespec */ +#include /* For noreturn_function */ /************************************************************ * Compilation Switches @@ -117,11 +118,7 @@ struct pthread_addr_s }; typedef struct pthread_addr_s pthread_attr_t; -struct pthread_s -{ - int pid; -}; -typedef struct pthread_s pthread_t; +typedef pid_t pthread_t; typedef int pthread_condattr_t; @@ -215,7 +212,7 @@ EXTERN int pthread_detach(pthread_t thread); * execution of another thread. *----------------------------------------------------------*/ -EXTERN void pthread_exit(pthread_addr_t pvValue) __attribute__ ((noreturn)); +EXTERN void pthread_exit(pthread_addr_t pvValue) noreturn_function; EXTERN int pthread_cancel(pthread_t thread); EXTERN int pthread_setcancelstate(int state, int *oldstate); EXTERN void pthread_testcancel(void); @@ -238,7 +235,7 @@ EXTERN void pthread_yield(void); * A thread may obtain a copy of its own thread handle. *----------------------------------------------------------*/ -EXTERN pthread_t pthread_self(void); +#define pthread_self() ((pthread_t)getpid()) /*----------------------------------------------------------* * Thread scheduling parameters diff --git a/include/signal.h b/include/signal.h index 67236fd6c5..621a6d5f35 100644 --- a/include/signal.h +++ b/include/signal.h @@ -40,6 +40,7 @@ * Included Files ************************************************************/ +#include #include /* Needed for struct timespec */ #include /* Needed for, e.g., sigset_t */ @@ -164,8 +165,12 @@ EXTERN int sigwaitinfo(const sigset_t *set, EXTERN int sigtimedwait(const sigset_t *set, struct siginfo *value, const struct timespec *timeout); +#ifdef CONFIG_CAN_PASS_STRUCTS EXTERN int sigqueue(int tid, int signo, const union sigval value); +#else +EXTERN int sigqueue(int tid, int signo, void *sival_ptr); +#endif #undef EXTERN #ifdef __cplusplus diff --git a/include/stdio.h b/include/stdio.h index b210dc708e..0cc8639b46 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -200,6 +200,7 @@ typedef void DIR; /* Used to reference stdin, stdout, and stderr */ +#ifdef CONFIG_HAVE_INLINE static inline FILE *__stdfile(int fd) { if ((unsigned int)fd < CONFIG_NFILE_DESCRIPTORS) @@ -212,6 +213,9 @@ static inline FILE *__stdfile(int fd) } return NULL; } +#else +extern FILE *__stdfile(int fd); +#endif /************************************************************ * Public Function Prototypes diff --git a/include/stdlib.h b/include/stdlib.h index c5cf3edda3..ba4f2b502a 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -97,7 +97,7 @@ EXTERN int atexit(void (*func)(void)); /* String to binary conversions */ #define atoi(nptr) strtol((nptr), (char**)NULL, 10) EXTERN long strtol(const char *, char **, int); -EXTERN double strtod(const char *, char **); +EXTERN double_t strtod(const char *, char **); /* Memory Management */ EXTERN void *malloc(size_t); diff --git a/include/sys/types.h b/include/sys/types.h index 4cebb48a94..82f7046d2c 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -40,6 +40,7 @@ * Included Files ************************************************************/ +#include #include /************************************************************ @@ -110,6 +111,12 @@ * Type Declarations ************************************************************/ +#ifndef CONFIG_HAVE_DOUBLE +typedef float double_t; +#else +typedef double double_t; +#endif + /* Misc. scalar types */ typedef uint32 mode_t; diff --git a/include/unistd.h b/include/unistd.h index d68b0e28b2..e6c787ecc9 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -41,6 +41,7 @@ ************************************************************/ #include +#include /************************************************************ * Definitions @@ -67,7 +68,7 @@ extern "C" { /* Task Control Interfaces (based on ANSII APIs) */ EXTERN pid_t getpid( void ); -EXTERN void _exit(int status) __attribute__ ((noreturn)); +EXTERN void _exit(int status) noreturn_function; EXTERN unsigned int sleep(unsigned int seconds); EXTERN void usleep(unsigned long usec); diff --git a/lib/lib_libvsprintf.c b/lib/lib_libvsprintf.c index da03f7f318..2e60ffa22f 100644 --- a/lib/lib_libvsprintf.c +++ b/lib/lib_libvsprintf.c @@ -807,7 +807,7 @@ int lib_vsprintf(struct lib_stream_s *obj, const char *src, va_list ap) char tmpfmt[40]; const char *psrc; char *pdst; - double dbl; + double_t dbl; /* Reconstruct the floating point format. */ @@ -818,7 +818,7 @@ int lib_vsprintf(struct lib_stream_s *obj, const char *src, va_list ap) /* Extract the floating point number. */ - dbl = va_arg(ap, double); + dbl = va_arg(ap, double_t); /* Then let the lib_sprintf do the work. */ diff --git a/lib/lib_rand.c b/lib/lib_rand.c index 5ce708bc82..5dde2dd8ce 100644 --- a/lib/lib_rand.c +++ b/lib/lib_rand.c @@ -81,11 +81,11 @@ ************************************************************/ static unsigned int nrand(unsigned int nLimit); -static double frand1(void); +static double_t frand1(void); #if (RND_ORDER > 1) -static double frand2(void); +static double_t frand2(void); #if (RND_ORDER > 2) -static double frand3(void); +static double_t frand3(void); #endif #endif @@ -140,7 +140,7 @@ int rand(void) static unsigned int nrand(unsigned int nLimit) { unsigned long nResult; - double fRatio; + double_t fRatio; /* Loop to be sure a legal random number is generated */ do { @@ -155,7 +155,7 @@ static unsigned int nrand(unsigned int nLimit) #endif /* Then, produce the return-able value */ - nResult = (unsigned long)(((double)nLimit) * fRatio); + nResult = (unsigned long)(((double_t)nLimit) * fRatio); } while (nResult >= (unsigned long)nLimit); @@ -163,7 +163,7 @@ static unsigned int nrand(unsigned int nLimit) } /* end nrand */ -static double frand1(void) +static double_t frand1(void) { unsigned long nRandInt; @@ -172,12 +172,12 @@ static double frand1(void) g_nRandInt1 = nRandInt; /* Construct an floating point value in the range from 0.0 up to 1.0 */ - return ((double)nRandInt) / ((double)RND_CONSTP); + return ((double_t)nRandInt) / ((double_t)RND_CONSTP); } /* end frand */ #if (RND_ORDER > 1) -static double frand2(void) +static double_t frand2(void) { unsigned long nRandInt; @@ -188,12 +188,12 @@ static double frand2(void) g_nRandInt1 = nRandInt; /* Construct an floating point value in the range from 0.0 up to 1.0 */ - return ((double)nRandInt) / ((double)RND_CONSTP); + return ((double_t)nRandInt) / ((double_t)RND_CONSTP); } /* end frand */ #if (RND_ORDER > 2) -static double frand(void) +static double_t frand(void) { unsigned long nRandInt; @@ -205,7 +205,7 @@ static double frand(void) g_nRandInt1 = nRandInt; /* Construct an floating point value in the range from 0.0 up to 1.0 */ - return ((double)nRandInt) / ((double)RND_CONSTP); + return ((double_t)nRandInt) / ((double_t)RND_CONSTP); } /* end frand */ #endif diff --git a/lib/lib_rint.c b/lib/lib_rint.c index f747eea863..73600f6bfe 100644 --- a/lib/lib_rint.c +++ b/lib/lib_rint.c @@ -72,9 +72,9 @@ * Private Variables ************************************************************/ -double rint(double x) +double_t rint(double x) { - double retValue; + double_t retValue; /* If the current rounding mode rounds toward negative * infinity, rint() is identical to floor(). If the current @@ -93,7 +93,7 @@ double rint(double x) * |rint(x)-x|=1/2, then rint(x) is even. */ long dwInteger = (long)x; - double fRemainder = x - (double)dwInteger; + double_t fRemainder = x - (double_t)dwInteger; if (x < 0.0) { @@ -116,7 +116,7 @@ double rint(double x) } /* end if */ } /* end else */ - retValue = (double)dwInteger; + retValue = (double_t)dwInteger; #endif return retValue; diff --git a/lib/lib_sscanf.c b/lib/lib_sscanf.c index 4f100c8cab..efd4ebcfaa 100644 --- a/lib/lib_sscanf.c +++ b/lib/lib_sscanf.c @@ -286,7 +286,7 @@ int vsscanf(char *buf, const char *s, va_list ap) { /* strtod always returns a double */ - double dvalue = strtod(tmp, NULL); + double_t dvalue = strtod(tmp, NULL); void *pv = va_arg(ap, void*); vdbg("vsscanf: Return %f to 0x%p\n", dvalue, pv); @@ -295,11 +295,13 @@ int vsscanf(char *buf, const char *s, va_list ap) * float or a double. */ +#ifdef CONFIG_HAVE_DOUBLE if (lflag) { - *((double*)pv) = dvalue; + *((double_t*)pv) = dvalue; } else +#endif { *((float*)pv) = (float)dvalue; } diff --git a/mm/mm_memalign.c b/mm/mm_memalign.c index b91625d0a2..18f3b295a0 100644 --- a/mm/mm_memalign.c +++ b/mm/mm_memalign.c @@ -97,8 +97,6 @@ void *memalign(size_t alignment, size_t size) size = MM_ALIGN_UP(size); /* Make mutliples of our granule size */ allocsize = size + 2*alignment; /* Add double full alignment size */ - /* If the alignment is small - /* Then malloc that size */ rawchunk = (uint32)malloc(allocsize); diff --git a/mm/mm_sem.c b/mm/mm_sem.c index be3a2c1b0e..3a790de1e0 100644 --- a/mm/mm_sem.c +++ b/mm/mm_sem.c @@ -113,7 +113,7 @@ void mm_takesemaphore(void) { /* Take the semaphore (perhaps waiting) */ - msemdbg("%s: PID=%d taking\n", __FUNCTION__, my_pid); + msemdbg("PID=%d taking\n", my_pid); while (sem_wait(&g_mm_semaphore) != 0) { /* The only case that an error should occur here is if @@ -129,8 +129,8 @@ void mm_takesemaphore(void) g_counts_held = 1; } - msemdbg("%s: Holder=%d count=%d\n", - __FUNCTION__, g_holder, g_counts_held); + msemdbg("Holder=%d count=%d\n", + g_holder, g_counts_held); } /************************************************************ @@ -152,14 +152,14 @@ void mm_givesemaphore(void) /* Yes, just release one count and return */ g_counts_held--; - msemdbg("%s: Holder=%d count=%d\n", - __FUNCTION__, g_holder, g_counts_held); + msemdbg("Holder=%d count=%d\n", + g_holder, g_counts_held); } else { /* Nope, this is the last reference I have */ - msemdbg("%s: PID=%d giving\n", __FUNCTION__, my_pid); + msemdbg("PID=%d giving\n", my_pid); g_holder = -1; g_counts_held = 0; ASSERT(sem_post(&g_mm_semaphore) == 0); diff --git a/sched/Makefile b/sched/Makefile index ebc27785d5..9872c7f02b 100644 --- a/sched/Makefile +++ b/sched/Makefile @@ -76,8 +76,7 @@ PTHREAD_SRCS = pthread_attrinit.c pthread_attrdestroy.c \ pthread_attrsetstacksize.c pthread_attrgetstacksize.c \ pthread_attrsetschedparam.c pthread_attrgetschedparam.c \ pthread_create.c pthread_exit.c pthread_join.c pthread_detach.c \ - pthread_yield.c pthread_self.c \ - pthread_getschedparam.c pthread_setschedparam.c \ + pthread_yield.c pthread_getschedparam.c pthread_setschedparam.c \ pthread_mutexattrinit.c pthread_mutexattrdestroy.c \ pthread_mutexattrgetpshared.c pthread_mutexattrsetpshared.c \ pthread_mutexinit.c pthread_mutexdestroy.c \ diff --git a/sched/clock_getres.c b/sched/clock_getres.c index 5cf07f2499..b3d6247db6 100644 --- a/sched/clock_getres.c +++ b/sched/clock_getres.c @@ -88,13 +88,13 @@ int clock_getres(clockid_t clock_id, struct timespec *res) uint32 time_res; int ret = OK; - dbg("%s: clock_id=%d\n", __FUNCTION__, clock_id); + dbg("clock_id=%d\n", clock_id); /* Only CLOCK_REALTIME is supported */ if (clock_id != CLOCK_REALTIME) { - dbg("%s: Returning ERROR\n", __FUNCTION__); + dbg("Returning ERROR\n"); *get_errno_ptr() = EINVAL; ret = ERROR; } @@ -109,8 +109,7 @@ int clock_getres(clockid_t clock_id, struct timespec *res) res->tv_sec = 0; res->tv_nsec = time_res; - dbg("%s: Returning res=(%d,%d) time_res=%d\n", - __FUNCTION__, + dbg("Returning res=(%d,%d) time_res=%d\n", (int)res->tv_sec, (int)res->tv_nsec, (int)time_res); } diff --git a/sched/clock_gettime.c b/sched/clock_gettime.c index ac9270975c..941d49e297 100644 --- a/sched/clock_gettime.c +++ b/sched/clock_gettime.c @@ -90,13 +90,13 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) uint32 nsecs; int ret = OK; - dbg("%s: clock_id=%d\n", __FUNCTION__, clock_id); + dbg("clock_id=%d\n", clock_id); /* Only CLOCK_REALTIME is supported */ if (clock_id != CLOCK_REALTIME) { - dbg("%s: Returning ERROR\n", __FUNCTION__); + dbg("Returning ERROR\n"); *get_errno_ptr() = EINVAL; ret = ERROR; @@ -109,7 +109,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) msecs = MSEC_PER_TICK * (g_system_timer - g_tickbias); - dbg("%s: msecs = %d g_tickbias=%d\n", __FUNCTION__, + dbg("msecs = %d g_tickbias=%d\n", (int)msecs, (int)g_tickbias); /* Get the elapsed time in seconds and nanoseconds. */ @@ -117,7 +117,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) secs = msecs / MSEC_PER_SEC; nsecs = (msecs - (secs * MSEC_PER_SEC)) * NSEC_PER_MSEC; - dbg("%s: secs = %d + %d nsecs = %d + %d\n", __FUNCTION__, + dbg("secs = %d + %d nsecs = %d + %d\n", (int)msecs, (int)g_basetime.tv_sec, (int)nsecs, (int)g_basetime.tv_nsec); @@ -140,7 +140,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) tp->tv_sec = (time_t)secs; tp->tv_nsec = (long)nsecs; - dbg("%s: Returning tp=(%d,%d)\n", __FUNCTION__, + dbg("Returning tp=(%d,%d)\n", (int)tp->tv_sec, (int)tp->tv_nsec); } diff --git a/sched/clock_settime.c b/sched/clock_settime.c index c57fb28088..5f565ea36b 100644 --- a/sched/clock_settime.c +++ b/sched/clock_settime.c @@ -87,13 +87,13 @@ int clock_settime(clockid_t clock_id, const struct timespec *tp) { int ret = OK; - dbg("%s: clock_id=%d\n", __FUNCTION__, clock_id); + dbg("clock_id=%d\n", clock_id); /* Only CLOCK_REALTIME is supported */ if (clock_id != CLOCK_REALTIME || !tp) { - dbg("%s: Returning ERROR\n", __FUNCTION__); + dbg("Returning ERROR\n"); *get_errno_ptr() = EINVAL; ret = ERROR; } @@ -109,8 +109,7 @@ int clock_settime(clockid_t clock_id, const struct timespec *tp) g_tickbias = g_system_timer; - dbg("%s: basetime=(%d,%d) tickbias=%d\n", - __FUNCTION__, + dbg("basetime=(%d,%d) tickbias=%d\n", (int)g_basetime.tv_sec, (int)g_basetime.tv_nsec, (int)g_tickbias); } diff --git a/sched/gmtime_r.c b/sched/gmtime_r.c index 8661d73b7b..bf9923bb34 100644 --- a/sched/gmtime_r.c +++ b/sched/gmtime_r.c @@ -177,7 +177,7 @@ struct tm *gmtime_r(const time_t *clock, struct tm *result) /* Get the seconds since the EPOCH */ time = *clock; - dbg("%s: clock=%d\n", __FUNCTION__, (int)time); + dbg("clock=%d\n", (int)time); /* Convert to days, hours, minutes, and seconds since the EPOCH */ @@ -192,14 +192,14 @@ struct tm *gmtime_r(const time_t *clock, struct tm *result) sec = time; - dbg("%s: hour=%d min=%d sec=%d\n", __FUNCTION__, + dbg("hour=%d min=%d sec=%d\n", (int)hour, (int)min, (int)sec); /* Convert the days since the EPOCH to calendar day */ clock_utc2calendar(jdn, &year, &month, &day); - dbg("%s: jdn=%d year=%d month=%d day=%d\n", __FUNCTION__, + dbg("jdn=%d year=%d month=%d day=%d\n", (int)jdn, (int)year, (int)month, (int)day); /* Then return the struct tm contents */ diff --git a/sched/irq_dispatch.c b/sched/irq_dispatch.c index f783b2f54d..d6466cbc0d 100644 --- a/sched/irq_dispatch.c +++ b/sched/irq_dispatch.c @@ -76,7 +76,7 @@ * ***********************************************************/ -void irq_dispatch(int irq, struct xcptcontext *xcp) +void irq_dispatch(int irq, void *context) { xcpt_t vector; @@ -93,6 +93,6 @@ void irq_dispatch(int irq, struct xcptcontext *xcp) /* Then dispatch to the interrupt handler */ - vector(irq, xcp); + vector(irq, context); } diff --git a/sched/irq_internal.h b/sched/irq_internal.h index a11120f55c..211779bc37 100644 --- a/sched/irq_internal.h +++ b/sched/irq_internal.h @@ -71,7 +71,7 @@ extern "C" { #endif EXTERN void weak_function irq_initialize(void); -EXTERN int irq_unexpected_isr(int irq, struct xcptcontext *xcp); +EXTERN int irq_unexpected_isr(int irq, void *context); #undef EXTERN #ifdef __cplusplus diff --git a/sched/irq_unexpectedisr.c b/sched/irq_unexpectedisr.c index c235c53a88..6ca3e1da83 100644 --- a/sched/irq_unexpectedisr.c +++ b/sched/irq_unexpectedisr.c @@ -75,7 +75,7 @@ * ************************************************************/ -int irq_unexpected_isr(int irq, struct xcptcontext *xcp) +int irq_unexpected_isr(int irq, void *context) { (void)irqsave(); PANIC(OSERR_UNEXPECTEDISR); diff --git a/sched/mktime.c b/sched/mktime.c index 9c84964633..a0ed379f1a 100644 --- a/sched/mktime.c +++ b/sched/mktime.c @@ -126,14 +126,14 @@ time_t mktime(struct tm *tp) */ jdn = clock_calendar2utc(tp->tm_year+1900, tp->tm_mon+1, tp->tm_mday); - dbg("%s: jdn=%d tm_year=%d tm_mon=%d tm_mday=%d\n", - __FUNCTION__, (int)jdn, tp->tm_year, tp->tm_mon, tp->tm_mday); + dbg("jdn=%d tm_year=%d tm_mon=%d tm_mday=%d\n", + (int)jdn, tp->tm_year, tp->tm_mon, tp->tm_mday); /* Return the seconds into the julian day. */ ret = ((jdn*24 + tp->tm_hour)*60 + tp->tm_min)*60 + tp->tm_sec; dbg("%s:\tret=%d tm_hour=%d tm_min=%d tm_sec=%d\n", - __FUNCTION__, (int)ret, tp->tm_hour, tp->tm_min, tp->tm_sec); + (int)ret, tp->tm_hour, tp->tm_min, tp->tm_sec); return ret; } diff --git a/sched/mq_internal.h b/sched/mq_internal.h index 5768bbd706..226835d21e 100644 --- a/sched/mq_internal.h +++ b/sched/mq_internal.h @@ -138,10 +138,6 @@ struct mq_des int oflags; /* Flags set when message queue was opened */ }; -/* This is the handle used to reference a message queue */ - -typedef struct mq_des *mqd_t; - /************************************************************ * Global Variables ************************************************************/ diff --git a/sched/mq_send.c b/sched/mq_send.c index b5dda82786..431d8613c9 100644 --- a/sched/mq_send.c +++ b/sched/mq_send.c @@ -145,7 +145,7 @@ mqmsg_t *mq_msgalloc(void) else { - dbg("%s: Out of messages\n", __FUNCTION__); + dbg("Out of messages\n"); PANIC((uint32)OSERR_OUTOFMESSAGES); } } diff --git a/sched/os_start.c b/sched/os_start.c index 1b249a5b91..b96a650cbe 100644 --- a/sched/os_start.c +++ b/sched/os_start.c @@ -192,7 +192,7 @@ void os_start(void) int init_taskid; int i; - lldbg("%s: Entry\n", __FUNCTION__); + lldbg("Entry\n"); /* Initialize all task lists */ @@ -349,7 +349,7 @@ void os_start(void) * started by spawning the user init thread of execution. */ - dbg("%s: Starting init thread\n", __FUNCTION__); + dbg("Starting init thread\n"); init_taskid = task_create("init", SCHED_PRIORITY_DEFAULT, CONFIG_PROC_STACK_SIZE, (main_t)user_start, 0, 0, 0, 0); @@ -357,7 +357,7 @@ void os_start(void) /* When control is return to this point, the system is idle. */ - dbg("%s: Beginning Idle Loop\n", __FUNCTION__); + dbg("Beginning Idle Loop\n"); for (;;) { /* Check if there is anything in the delayed deallocation list. */ diff --git a/sched/pthread_attrdestroy.c b/sched/pthread_attrdestroy.c index 9bb86268c6..c71fa6271f 100644 --- a/sched/pthread_attrdestroy.c +++ b/sched/pthread_attrdestroy.c @@ -89,7 +89,7 @@ int pthread_attr_destroy(pthread_attr_t *attr) { int ret; - dbg("%s: attr=0x%p\n", __FUNCTION__, attr); + dbg("attr=0x%p\n", attr); if (!attr) { @@ -101,7 +101,7 @@ int pthread_attr_destroy(pthread_attr_t *attr) ret = OK; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_attrgetinheritsched.c b/sched/pthread_attrgetinheritsched.c index d0d3143e75..e1c69346cb 100644 --- a/sched/pthread_attrgetinheritsched.c +++ b/sched/pthread_attrgetinheritsched.c @@ -92,8 +92,7 @@ int pthread_attr_getinheritsched(const pthread_attr_t *attr, { int ret; - dbg("%s: attr=0x%p inheritsched=0x%p\n", - __FUNCTION__, attr, inheritsched); + dbg("attr=0x%p inheritsched=0x%p\n", attr, inheritsched); if (!attr || !inheritsched) { @@ -105,7 +104,7 @@ int pthread_attr_getinheritsched(const pthread_attr_t *attr, ret = OK; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_attrgetschedparam.c b/sched/pthread_attrgetschedparam.c index 2285895e7f..defed57e61 100644 --- a/sched/pthread_attrgetschedparam.c +++ b/sched/pthread_attrgetschedparam.c @@ -89,7 +89,7 @@ int pthread_attr_getschedparam(pthread_attr_t *attr, { int ret; - dbg("%s: attr=0x%p param=0x%p\n", __FUNCTION__, attr, param); + dbg("attr=0x%p param=0x%p\n", attr, param); if (!attr || !param) { @@ -101,7 +101,7 @@ int pthread_attr_getschedparam(pthread_attr_t *attr, ret = OK; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_attrgetschedpolicy.c b/sched/pthread_attrgetschedpolicy.c index 801226c982..67948cd953 100644 --- a/sched/pthread_attrgetschedpolicy.c +++ b/sched/pthread_attrgetschedpolicy.c @@ -89,7 +89,7 @@ int pthread_attr_getschedpolicy(pthread_attr_t *attr, int *policy) { int ret; - dbg("%s: attr=0x%p policy=0x%p\n", __FUNCTION__, attr, policy); + dbg("attr=0x%p policy=0x%p\n", attr, policy); if (!attr || !policy) { @@ -101,6 +101,6 @@ int pthread_attr_getschedpolicy(pthread_attr_t *attr, int *policy) ret = OK; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_attrgetstacksize.c b/sched/pthread_attrgetstacksize.c index d36ae172e8..9b160ead63 100644 --- a/sched/pthread_attrgetstacksize.c +++ b/sched/pthread_attrgetstacksize.c @@ -88,7 +88,7 @@ int pthread_attr_getstacksize(pthread_attr_t *attr, long *stacksize) { int ret; - dbg("%s: attr=0x%p stacksize=0x%p\n", __FUNCTION__, attr, stacksize); + dbg("attr=0x%p stacksize=0x%p\n", attr, stacksize); if (!stacksize) { @@ -100,7 +100,7 @@ int pthread_attr_getstacksize(pthread_attr_t *attr, long *stacksize) ret = OK; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_attrinit.c b/sched/pthread_attrinit.c index 51d2ea5250..7f6639b9c4 100644 --- a/sched/pthread_attrinit.c +++ b/sched/pthread_attrinit.c @@ -90,7 +90,7 @@ int pthread_attr_init(pthread_attr_t *attr) { int ret = OK; - dbg("%s: attr=0x%p\n", __FUNCTION__, attr); + dbg("attr=0x%p\n", attr); if (!attr) { ret = ENOMEM; @@ -105,7 +105,7 @@ int pthread_attr_init(pthread_attr_t *attr) memcpy(attr, &g_default_pthread_attr, sizeof(pthread_attr_t)); } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_attrsetinheritsched.c b/sched/pthread_attrsetinheritsched.c index e83d13d73d..75468aad33 100644 --- a/sched/pthread_attrsetinheritsched.c +++ b/sched/pthread_attrsetinheritsched.c @@ -92,7 +92,7 @@ int pthread_attr_setinheritsched(pthread_attr_t *attr, { int ret; - dbg("%s: inheritsched=%d\n", __FUNCTION__, inheritsched); + dbg("inheritsched=%d\n", inheritsched); if (!attr || (inheritsched != PTHREAD_INHERIT_SCHED && @@ -106,7 +106,7 @@ int pthread_attr_setinheritsched(pthread_attr_t *attr, ret = OK; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_attrsetschedparam.c b/sched/pthread_attrsetschedparam.c index 4a0d983483..77dfa1ccc0 100644 --- a/sched/pthread_attrsetschedparam.c +++ b/sched/pthread_attrsetschedparam.c @@ -89,7 +89,7 @@ int pthread_attr_setschedparam(pthread_attr_t *attr, { int ret; - dbg("%s: attr=0x%p param=0x%p\n", __FUNCTION__, attr, param); + dbg("attr=0x%p param=0x%p\n", attr, param); if (!attr || !param) { @@ -100,7 +100,7 @@ int pthread_attr_setschedparam(pthread_attr_t *attr, attr->priority = (short)param->sched_priority; ret = OK; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_attrsetschedpolicy.c b/sched/pthread_attrsetschedpolicy.c index d750cf6fd4..2ba20db517 100644 --- a/sched/pthread_attrsetschedpolicy.c +++ b/sched/pthread_attrsetschedpolicy.c @@ -89,7 +89,7 @@ int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy) { int ret; - dbg("%s: attr=0x%p policy=%d\n", __FUNCTION__, attr, policy); + dbg("attr=0x%p policy=%d\n", attr, policy); #if CONFIG_RR_INTERVAL > 0 if (!attr || (policy != SCHED_FIFO && policy != SCHED_RR)) @@ -105,6 +105,6 @@ int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy) ret = OK; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_attrsetstacksize.c b/sched/pthread_attrsetstacksize.c index b33b75e635..c62093f234 100644 --- a/sched/pthread_attrsetstacksize.c +++ b/sched/pthread_attrsetstacksize.c @@ -88,8 +88,7 @@ int pthread_attr_setstacksize(pthread_attr_t *attr, long stacksize) { int ret; - dbg("%s: attr=0x%p stacksize=%ld\n", - __FUNCTION__, attr, stacksize); + dbg("attr=0x%p stacksize=%ld\n", attr, stacksize); if (!attr || stacksize < PTHREAD_STACK_MIN) { @@ -101,7 +100,7 @@ int pthread_attr_setstacksize(pthread_attr_t *attr, long stacksize) ret = OK; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_cancel.c b/sched/pthread_cancel.c index d34c29ae3d..8b8c36c991 100644 --- a/sched/pthread_cancel.c +++ b/sched/pthread_cancel.c @@ -77,7 +77,7 @@ int pthread_cancel(pthread_t thread) /* First, make sure that the handle references a valid thread */ - if (!thread.pid) + if (!thread) { /* pid == 0 is the IDLE task. Callers cannot cancel the * IDLE task. @@ -86,7 +86,7 @@ int pthread_cancel(pthread_t thread) return ESRCH; } - tcb = sched_gettcb(thread.pid); + tcb = sched_gettcb((pid_t)thread); if (!tcb) { /* The pid does not correspond to any known thread */ @@ -132,11 +132,11 @@ int pthread_cancel(pthread_t thread) /* Complete pending join operations */ - (void)pthread_completejoin(thread.pid, PTHREAD_CANCELED); + (void)pthread_completejoin((pid_t)thread, PTHREAD_CANCELED); /* Then let pthread_delete do the real work */ - task_delete(thread.pid); + task_delete((pid_t)thread); return OK; } diff --git a/sched/pthread_completejoin.c b/sched/pthread_completejoin.c index a5e7651e01..8e57ada8ba 100644 --- a/sched/pthread_completejoin.c +++ b/sched/pthread_completejoin.c @@ -79,7 +79,7 @@ static void pthread_destroyjoininfo(join_t *pjoin) int ntasks_waiting; int status; - dbg("%s: pjoin=0x%p\n", __FUNCTION__, pjoin); + dbg("pjoin=0x%p\n", pjoin); /* Are any tasks waiting for our exit value? */ @@ -150,7 +150,7 @@ int pthread_completejoin(pid_t pid, void *exit_value) join_t *pjoin; boolean detached = FALSE; - dbg("%s: process_id=%d exit_value=%p\n", __FUNCTION__, pid, exit_value); + dbg("process_id=%d exit_value=%p\n", pid, exit_value); /* First, find thread's structure in the private data set. */ @@ -170,7 +170,7 @@ int pthread_completejoin(pid_t pid, void *exit_value) detached = pjoin->detached; if (detached) { - dbg("%s: Detaching\n", __FUNCTION__); + dbg("Detaching\n"); /* If so, then remove the thread's structure from the private * data set. After this point, no other thread can perform a join diff --git a/sched/pthread_condattrdestroy.c b/sched/pthread_condattrdestroy.c index a12c3f57c0..8cc524ae5e 100644 --- a/sched/pthread_condattrdestroy.c +++ b/sched/pthread_condattrdestroy.c @@ -67,14 +67,14 @@ int pthread_condattr_destroy(pthread_condattr_t *attr) { int ret = OK; - dbg("%s: attr=0x%p\n", __FUNCTION__, attr); + dbg("attr=0x%p\n", attr); if (!attr) { ret = EINVAL; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_condattrinit.c b/sched/pthread_condattrinit.c index 739b703ff0..0d341dbc8f 100644 --- a/sched/pthread_condattrinit.c +++ b/sched/pthread_condattrinit.c @@ -67,7 +67,7 @@ int pthread_condattr_init(pthread_condattr_t *attr) { int ret = OK; - dbg("%s: attr=0x%p\n", __FUNCTION__, attr); + dbg("attr=0x%p\n", attr); if (!attr) { @@ -78,7 +78,7 @@ int pthread_condattr_init(pthread_condattr_t *attr) *attr = 0; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_condbroadcast.c b/sched/pthread_condbroadcast.c index 322a4d288b..1fd1292485 100644 --- a/sched/pthread_condbroadcast.c +++ b/sched/pthread_condbroadcast.c @@ -89,7 +89,7 @@ int pthread_cond_broadcast(pthread_cond_t *cond) int ret = OK; int sval; - dbg("%s: cond=0x%p\n", __FUNCTION__, cond); + dbg("cond=0x%p\n", cond); if (!cond) { @@ -135,7 +135,7 @@ int pthread_cond_broadcast(pthread_cond_t *cond) sched_unlock(); } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_conddestroy.c b/sched/pthread_conddestroy.c index 5272008570..5c95577a96 100644 --- a/sched/pthread_conddestroy.c +++ b/sched/pthread_conddestroy.c @@ -67,7 +67,7 @@ int pthread_cond_destroy(pthread_cond_t *cond) { int ret = OK; - dbg("%s: cond=0x%p\n", __FUNCTION__, cond); + dbg("cond=0x%p\n", cond); if (!cond) { @@ -81,7 +81,7 @@ int pthread_cond_destroy(pthread_cond_t *cond) ret = EINVAL; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_condinit.c b/sched/pthread_condinit.c index 9dac4692fe..90ee127827 100644 --- a/sched/pthread_condinit.c +++ b/sched/pthread_condinit.c @@ -67,7 +67,7 @@ int pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *attr) { int ret = OK; - dbg("%s: cond=0x%p attr=0x%p\n", __FUNCTION__, cond, attr); + dbg("cond=0x%p attr=0x%p\n", cond, attr); if (!cond) { @@ -83,7 +83,7 @@ int pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *attr) ret = EINVAL; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_condsignal.c b/sched/pthread_condsignal.c index f9ee3781d2..90698ce2aa 100644 --- a/sched/pthread_condsignal.c +++ b/sched/pthread_condsignal.c @@ -88,7 +88,7 @@ int pthread_cond_signal(pthread_cond_t *cond) int ret = OK; int sval; - dbg("%s: cond=0x%p\n", __FUNCTION__, cond); + dbg("cond=0x%p\n", cond); if (!cond) { @@ -110,16 +110,16 @@ int pthread_cond_signal(pthread_cond_t *cond) else { - dbg("%s: sval=%d\n", __FUNCTION__, sval); + dbg("sval=%d\n", sval); if (sval < 0) { - dbg("%s: Signalling...\n", __FUNCTION__); + dbg("Signalling...\n"); ret = pthread_givesemaphore((sem_t*)&cond->sem); } } } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_condtimedwait.c b/sched/pthread_condtimedwait.c index f651226998..59d92921e8 100644 --- a/sched/pthread_condtimedwait.c +++ b/sched/pthread_condtimedwait.c @@ -116,8 +116,7 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, int int_state; int status; - dbg("%s: cond=0x%p mutex=0x%p abstime=0x%p\n", - __FUNCTION__, cond, mutex, abstime); + dbg("cond=0x%p mutex=0x%p abstime=0x%p\n", cond, mutex, abstime); /* Make sure that non-NULL references were provided. */ @@ -153,7 +152,7 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, } else { - dbg("%s: Give up mutex...\n", __FUNCTION__); + dbg("Give up mutex...\n"); /* We must disable pre-emption and interrupts here so that * the time stays valid until the wait begins. This adds @@ -263,7 +262,7 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, if (*get_errno_ptr() == EINTR) { - dbg("%s: Timedout!\n", __FUNCTION__); + dbg("Timedout!\n"); ret = ETIMEDOUT; } else @@ -275,7 +274,7 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, /* Reacquire the mutex (retaining the ret). */ - dbg("%s: Re-locking...\n", __FUNCTION__); + dbg("Re-locking...\n"); status = pthread_takesemaphore((sem_t*)&mutex->sem); if (!status) { @@ -300,7 +299,7 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, } } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_condwait.c b/sched/pthread_condwait.c index 555d3d06ff..cbfacf2a32 100644 --- a/sched/pthread_condwait.c +++ b/sched/pthread_condwait.c @@ -90,7 +90,7 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { int ret; - dbg("%s: cond=0x%p mutex=0x%p\n", __FUNCTION__, cond, mutex); + dbg("cond=0x%p mutex=0x%p\n", cond, mutex); /* Make sure that non-NULL references were provided. */ @@ -110,7 +110,7 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { /* Give up the mutex */ - dbg("%s: Give up mutex / take cond\n", __FUNCTION__); + dbg("Give up mutex / take cond\n"); sched_lock(); mutex->pid = 0; @@ -123,7 +123,7 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) /* Reacquire the mutex */ - dbg("%s: Reacquire mutex...\n", __FUNCTION__); + dbg("Reacquire mutex...\n"); ret |= pthread_takesemaphore((sem_t*)&mutex->sem); if (!ret) { @@ -131,7 +131,7 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) } } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_create.c b/sched/pthread_create.c index c8ec604d1a..5d9104c754 100644 --- a/sched/pthread_create.c +++ b/sched/pthread_create.c @@ -297,7 +297,7 @@ int pthread_create(pthread_t *thread, pthread_attr_t *attr, */ pid = (int)ptcb->pid; - pjoin->thread.pid = pid; + pjoin->thread = (pthread_t)pid; /* Initialize the semaphores in the join structure to zero. */ @@ -322,7 +322,7 @@ int pthread_create(pthread_t *thread, pthread_attr_t *attr, /* Return the thread information to the caller */ - if (thread) thread->pid = pid; + if (thread) *thread = (pthread_t)pid; if (!pjoin->started) status = ERROR; sched_unlock(); diff --git a/sched/pthread_detach.c b/sched/pthread_detach.c index 967ed237f9..4306b28e44 100644 --- a/sched/pthread_detach.c +++ b/sched/pthread_detach.c @@ -90,15 +90,15 @@ int pthread_detach(pthread_t thread) join_t *pjoin; int ret; - dbg("%s: Thread=%d\n", __FUNCTION__, thread.pid); + dbg("Thread=%d\n", thread); /* Find the entry associated with this pthread. */ (void)pthread_takesemaphore(&g_join_semaphore); - pjoin = pthread_findjoininfo(thread.pid); + pjoin = pthread_findjoininfo((pid_t)thread); if (!pjoin) { - dbg("%s: Could not find thread entry\n", __FUNCTION__); + dbg("Could not find thread entry\n"); ret = EINVAL; } else @@ -109,7 +109,7 @@ int pthread_detach(pthread_t thread) { /* YES.. just remove the thread entry. */ - (void)pthread_removejoininfo(thread.pid); + (void)pthread_removejoininfo((pid_t)thread); sched_free(pjoin); pjoin = NULL; } @@ -129,6 +129,6 @@ int pthread_detach(pthread_t thread) } (void)pthread_givesemaphore(&g_join_semaphore); - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_exit.c b/sched/pthread_exit.c index 5330ee3f07..e6ed040d49 100644 --- a/sched/pthread_exit.c +++ b/sched/pthread_exit.c @@ -91,7 +91,7 @@ void pthread_exit(void *exit_value) int error_code = (int)exit_value; int status; - dbg("%s: exit_value=%p\n", __FUNCTION__, exit_value); + dbg("exit_value=%p\n", exit_value); /* Complete pending join operations */ diff --git a/sched/pthread_findjoininfo.c b/sched/pthread_findjoininfo.c index 48871cf80c..1d33c50e00 100644 --- a/sched/pthread_findjoininfo.c +++ b/sched/pthread_findjoininfo.c @@ -81,14 +81,14 @@ * ************************************************************/ -join_t *pthread_findjoininfo(int pid) +join_t *pthread_findjoininfo(pid_t pid) { join_t *pjoin; /* Find the entry with the matching pid */ for (pjoin = g_pthread_head; - (pjoin && pjoin->thread.pid != pid); + (pjoin && (pid_t)pjoin->thread != pid); pjoin = pjoin->next); /* and return it */ diff --git a/sched/pthread_getschedparam.c b/sched/pthread_getschedparam.c index 0a30fba8f6..0e410ef9ed 100644 --- a/sched/pthread_getschedparam.c +++ b/sched/pthread_getschedparam.c @@ -91,8 +91,7 @@ int pthread_getschedparam(pthread_t thread, int *policy, { int ret; - dbg("%s: thread ID=%d policy=0x%p param=0x%p\n", - __FUNCTION__, thread.pid, policy, param); + dbg("Thread ID=%d policy=0x%p param=0x%p\n", thread, policy, param); if (!policy || !param) { @@ -102,7 +101,7 @@ int pthread_getschedparam(pthread_t thread, int *policy, { /* Get the schedparams of the thread. */ - ret = sched_getparam(thread.pid, param); + ret = sched_getparam((pid_t)thread, param); if (ret != OK) { ret = EINVAL; @@ -110,14 +109,14 @@ int pthread_getschedparam(pthread_t thread, int *policy, /* Return the policy. */ - *policy = sched_getscheduler(thread.pid); + *policy = sched_getscheduler((pid_t)thread); if (*policy == ERROR) { ret = *get_errno_ptr(); } } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_internal.h b/sched/pthread_internal.h index d0b1cdeb9e..f23bafe5cb 100644 --- a/sched/pthread_internal.h +++ b/sched/pthread_internal.h @@ -115,9 +115,9 @@ extern "C" { EXTERN void weak_function pthread_initialize(void); EXTERN int pthread_completejoin(pid_t pid, void *exit_value); -EXTERN join_t *pthread_findjoininfo(int pid); +EXTERN join_t *pthread_findjoininfo(pid_t pid); EXTERN int pthread_givesemaphore(sem_t *sem); -EXTERN join_t *pthread_removejoininfo(int pid); +EXTERN join_t *pthread_removejoininfo(pid_t pid); EXTERN int pthread_takesemaphore(sem_t *sem); #undef EXTERN diff --git a/sched/pthread_join.c b/sched/pthread_join.c index 4e956777c9..28c8bf1c9d 100644 --- a/sched/pthread_join.c +++ b/sched/pthread_join.c @@ -98,13 +98,13 @@ int pthread_join(pthread_t thread, pthread_addr_t *pexit_value) join_t *pjoin; int ret; - dbg("%s: thread=%d\n", __FUNCTION__, thread.pid); + dbg("thread=%d\n", thread); /* First make sure that this is not an attempt to join to * ourself. */ - if (thread.pid == getpid()) + if ((pid_t)thread == getpid()) { return EDEADLK; } @@ -124,14 +124,14 @@ int pthread_join(pthread_t thread, pthread_addr_t *pexit_value) * was detached and has exitted. */ - pjoin = pthread_findjoininfo(thread.pid); + pjoin = pthread_findjoininfo((pid_t)thread); if (!pjoin) { /* Determine what kind of error to return */ - _TCB *tcb = sched_gettcb(thread.pid); + _TCB *tcb = sched_gettcb((pthread_t)thread); - dbg("%s: Could not find thread data\n", __FUNCTION__); + dbg("Could not find thread data\n"); /* Case (1) or (3) -- we can't tell which. Assume (3) */ @@ -153,26 +153,26 @@ int pthread_join(pthread_t thread, pthread_addr_t *pexit_value) } else if (pjoin->terminated) { - dbg("%s: Thread has terminated\n", __FUNCTION__); + dbg("Thread has terminated\n"); /* Get the thread exit value from the terminated thread. */ if (pexit_value) { - dbg("%s: exit_value=0x%p\n", __FUNCTION__, pjoin->exit_value); + dbg("exit_value=0x%p\n", pjoin->exit_value); *pexit_value = pjoin->exit_value; } /* Then remove and deallocate the thread entry. */ - (void)pthread_removejoininfo(thread.pid); + (void)pthread_removejoininfo((pid_t)thread); (void)pthread_givesemaphore(&g_join_semaphore); sched_free(pjoin); ret = OK; } else { - dbg("%s: Thread is still running\n", __FUNCTION__); + dbg("Thread is still running\n"); /* Relinquish the data set semaphore, making certain that * no task has the opportunity to run between the time @@ -192,7 +192,7 @@ int pthread_join(pthread_t thread, pthread_addr_t *pexit_value) if (pexit_value) { *pexit_value = pjoin->exit_value; - dbg("%s: exit_value=0x%p\n", __FUNCTION__, pjoin->exit_value); + dbg("exit_value=0x%p\n", pjoin->exit_value); } /* Post the thread's join semaphore so that exitting thread @@ -208,6 +208,6 @@ int pthread_join(pthread_t thread, pthread_addr_t *pexit_value) ret = OK; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_mutexattrdestroy.c b/sched/pthread_mutexattrdestroy.c index 8e3abdb47b..a61b60c876 100644 --- a/sched/pthread_mutexattrdestroy.c +++ b/sched/pthread_mutexattrdestroy.c @@ -88,7 +88,7 @@ int pthread_mutexattr_destroy(pthread_mutexattr_t *attr) { int ret = OK; - dbg("%s: attr=0x%p\n", __FUNCTION__, attr); + dbg("attr=0x%p\n", attr); if (!attr) { @@ -99,6 +99,6 @@ int pthread_mutexattr_destroy(pthread_mutexattr_t *attr) attr->pshared = 0; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_mutexattrgetpshared.c b/sched/pthread_mutexattrgetpshared.c index 1d54b90127..82198dfddb 100644 --- a/sched/pthread_mutexattrgetpshared.c +++ b/sched/pthread_mutexattrgetpshared.c @@ -88,7 +88,7 @@ int pthread_mutexattr_getpshared(pthread_mutexattr_t *attr, int *pshared) { int ret = OK; - dbg("%s: attr=0x%p pshared=0x%p\n", __FUNCTION__, attr, pshared); + dbg("attr=0x%p pshared=0x%p\n", attr, pshared); if (!attr || !pshared) { @@ -99,6 +99,6 @@ int pthread_mutexattr_getpshared(pthread_mutexattr_t *attr, int *pshared) *pshared = attr->pshared; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_mutexattrinit.c b/sched/pthread_mutexattrinit.c index 920ccf0ee4..6bddd19f44 100644 --- a/sched/pthread_mutexattrinit.c +++ b/sched/pthread_mutexattrinit.c @@ -87,7 +87,7 @@ int pthread_mutexattr_init(pthread_mutexattr_t *attr) { int ret = OK; - dbg("%s: attr=0x%p\n", __FUNCTION__, attr); + dbg("attr=0x%p\n", attr); if (!attr) { @@ -98,6 +98,6 @@ int pthread_mutexattr_init(pthread_mutexattr_t *attr) attr->pshared = 0; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_mutexattrsetpshared.c b/sched/pthread_mutexattrsetpshared.c index a9ddd0c3c9..f25ed4639b 100644 --- a/sched/pthread_mutexattrsetpshared.c +++ b/sched/pthread_mutexattrsetpshared.c @@ -88,7 +88,7 @@ int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared) { int ret = OK; - dbg("%s: attr=0x%p pshared=%d\n", __FUNCTION__, attr, pshared); + dbg("attr=0x%p pshared=%d\n", attr, pshared); if (!attr || (pshared != 0 && pshared != 1)) { @@ -99,6 +99,6 @@ int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared) attr->pshared = pshared; } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_mutexdestroy.c b/sched/pthread_mutexdestroy.c index bf82d4f436..14b5727c05 100644 --- a/sched/pthread_mutexdestroy.c +++ b/sched/pthread_mutexdestroy.c @@ -90,7 +90,7 @@ int pthread_mutex_destroy(pthread_mutex_t *mutex) int ret = OK; int status; - dbg("%s: mutex=0x%p\n", __FUNCTION__, mutex); + dbg("mutex=0x%p\n", mutex); if (!mutex) { @@ -123,6 +123,6 @@ int pthread_mutex_destroy(pthread_mutex_t *mutex) sched_unlock(); } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_mutexinit.c b/sched/pthread_mutexinit.c index faa06f227d..a91a0339d4 100644 --- a/sched/pthread_mutexinit.c +++ b/sched/pthread_mutexinit.c @@ -89,7 +89,7 @@ int pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *attr) int pshared = 0; int status; - dbg("%s: mutex=0x%p attr=0x%p\n", __FUNCTION__, mutex, attr); + dbg("mutex=0x%p attr=0x%p\n", mutex, attr); if (!mutex) { @@ -117,6 +117,6 @@ int pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *attr) } } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_mutexlock.c b/sched/pthread_mutexlock.c index 43e7c83562..64a6632190 100644 --- a/sched/pthread_mutexlock.c +++ b/sched/pthread_mutexlock.c @@ -90,7 +90,7 @@ int pthread_mutex_lock(pthread_mutex_t *mutex) int mypid = (int)getpid(); int ret = OK; - dbg("%s: mutex=0x%p\n", __FUNCTION__, mutex); + dbg("mutex=0x%p\n", mutex); if (!mutex) { @@ -108,7 +108,7 @@ int pthread_mutex_lock(pthread_mutex_t *mutex) if (mutex->pid == mypid) { - dbg("%s: Returning EDEADLK\n", __FUNCTION__); + dbg("Returning EDEADLK\n"); ret = EDEADLK; } else @@ -129,7 +129,7 @@ int pthread_mutex_lock(pthread_mutex_t *mutex) sched_unlock(); } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_mutextrylock.c b/sched/pthread_mutextrylock.c index 010c85f805..6474579a10 100644 --- a/sched/pthread_mutextrylock.c +++ b/sched/pthread_mutextrylock.c @@ -90,7 +90,7 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex) { int ret = OK; - dbg("%s: mutex=0x%p\n", __FUNCTION__, mutex); + dbg("mutex=0x%p\n", mutex); if (!mutex) { @@ -129,7 +129,7 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex) sched_unlock(); } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_mutexunlock.c b/sched/pthread_mutexunlock.c index 133dc1a942..2bc63eb264 100644 --- a/sched/pthread_mutexunlock.c +++ b/sched/pthread_mutexunlock.c @@ -89,7 +89,7 @@ int pthread_mutex_unlock(pthread_mutex_t *mutex) { int ret = OK; - dbg("%s: mutex=0x%p\n", __FUNCTION__, mutex); + dbg("mutex=0x%p\n", mutex); if (!mutex) { @@ -107,7 +107,7 @@ int pthread_mutex_unlock(pthread_mutex_t *mutex) if (mutex->pid != (int)getpid()) { - dbg("%s: Holder=%d Returning EPERM\n", __FUNCTION__, mutex->pid); + dbg("Holder=%d returning EPERM\n", mutex->pid); ret = EPERM; } else @@ -120,7 +120,7 @@ int pthread_mutex_unlock(pthread_mutex_t *mutex) sched_unlock(); } - dbg("%s: Returning %d\n", __FUNCTION__, ret); + dbg("Returning %d\n", ret); return ret; } diff --git a/sched/pthread_removejoininfo.c b/sched/pthread_removejoininfo.c index ecdc6d99e1..33fb243918 100644 --- a/sched/pthread_removejoininfo.c +++ b/sched/pthread_removejoininfo.c @@ -81,7 +81,7 @@ * ************************************************************/ -join_t *pthread_removejoininfo(int pid) +join_t *pthread_removejoininfo(pid_t pid) { join_t *prev; join_t *join; @@ -89,7 +89,7 @@ join_t *pthread_removejoininfo(int pid) /* Find the entry with the matching pid */ for (prev = NULL, join = g_pthread_head; - (join && join->thread.pid != pid); + (join && (pid_t)join->thread != pid); prev = join, join = join->next); /* Remove it from the data set. */ diff --git a/sched/pthread_self.c b/sched/pthread_self.c deleted file mode 100644 index 55ceddbddd..0000000000 --- a/sched/pthread_self.c +++ /dev/null @@ -1,91 +0,0 @@ -/************************************************************ - * pthread_self.c - * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ************************************************************/ - -/************************************************************ - * Included Files - ************************************************************/ - -#include -#include -#include -#include "pthread_internal.h" - -/************************************************************ - * Definitions - ************************************************************/ - -/************************************************************ - * Private Type Declarations - ************************************************************/ - -/************************************************************ - * Global Variables - ************************************************************/ - -/************************************************************ - * Private Variables - ************************************************************/ - -/************************************************************ - * Private Functions - ************************************************************/ - -/************************************************************ - * Public Functions - ************************************************************/ - -/************************************************************ - * Function: pthread_self - * - * Description: - * A thread may obtain a copy of its own thread handle. - * - * Parameters: - * None - * - * Return Value: - * A copy of this threads handle - * - * Assumptions: - * - ************************************************************/ - -pthread_t pthread_self(void) -{ - pthread_t thread; - thread.pid = (int)getpid(); - return thread; -} - diff --git a/sched/pthread_setschedparam.c b/sched/pthread_setschedparam.c index 5d0f913c25..bb0435aa03 100644 --- a/sched/pthread_setschedparam.c +++ b/sched/pthread_setschedparam.c @@ -89,15 +89,9 @@ int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param) { - int ret; - - dbg("%s: thread ID=%d policy=%d param=0x%p\n", - __FUNCTION__, thread.pid, policy, param); + dbg("thread ID=%d policy=%d param=0x%p\n", thread, policy, param); /* Let sched_setscheduler do all of the work */ - ret = sched_setscheduler(thread.pid, policy, param); - - dbg("%s: Returning %d\n", __FUNCTION__, ret); - return ret; + return sched_setscheduler((pid_t)thread, policy, param); } diff --git a/sched/sched_getscheduler.c b/sched/sched_getscheduler.c index 9406d9774c..ae97391854 100644 --- a/sched/sched_getscheduler.c +++ b/sched/sched_getscheduler.c @@ -103,7 +103,7 @@ int sched_getscheduler(pid_t pid) /* Verify that the pid corresponds to a real task */ - if (pid = 0) + if (!pid) { tcb = (_TCB*)g_readytorun.head; } diff --git a/sched/sem_internal.h b/sched/sem_internal.h index dd15ae6df7..460b358fc6 100644 --- a/sched/sem_internal.h +++ b/sched/sem_internal.h @@ -87,7 +87,7 @@ extern "C" { #endif EXTERN void weak_function sem_initialize(void); -EXTERN void weak_function sem_waitirq(_TCB *wtcb); +EXTERN void sem_waitirq(_TCB *wtcb); EXTERN nsem_t *sem_findnamed(const char *name); #undef EXTERN diff --git a/sched/task_create.c b/sched/task_create.c index dd7da112e4..c1cf117725 100644 --- a/sched/task_create.c +++ b/sched/task_create.c @@ -226,8 +226,6 @@ STATUS _task_init(_TCB *tcb, char *name, int priority, { STATUS ret; - vdbg("%s: Entry\n", __FUNCTION__); - /* Assign a unique task ID to the task. */ ret = task_assignpid(tcb); @@ -382,8 +380,6 @@ STATUS task_activate(_TCB *tcb) uint32 flags; #endif - vdbg("%s: Entry\n", __FUNCTION__); - #ifdef CONFIG_SCHED_INSTRUMENTATION flags = irqsave(); @@ -449,8 +445,6 @@ int task_create(char *name, int priority, STATUS status; pid_t pid; - vdbg("%s: Entry\n", __FUNCTION__); - /* Allocate a TCB for the new task. */ tcb = (_TCB*)kzmalloc(sizeof(_TCB)); diff --git a/sched/wd_internal.h b/sched/wd_internal.h index 9198387cca..212c686192 100644 --- a/sched/wd_internal.h +++ b/sched/wd_internal.h @@ -70,7 +70,6 @@ struct wdog_s }; typedef struct wdog_s wdog_t; -typedef struct wdog_s *WDOG_ID; /************************************************************ * Public Variables