Eliminating GCC dependencies

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@14 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2007-02-20 22:39:56 +00:00
parent f2a6057e3d
commit 3c0e634aee
84 changed files with 461 additions and 583 deletions

View File

@ -41,6 +41,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <debug.h> #include <debug.h>
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/fs.h>
#include "up_internal.h" #include "up_internal.h"
/************************************************************ /************************************************************

View File

@ -110,6 +110,10 @@ extern void up_serialinit(void);
extern void up_timerinit(void); extern void up_timerinit(void);
/* Defined in up_irq.c */
extern void up_maskack_irq(int irq);
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
#endif /* __UP_INTERNAL_H */ #endif /* __UP_INTERNAL_H */

View File

@ -48,24 +48,24 @@ static void *thread_waiter(void *parameter)
/* Take the mutex */ /* Take the mutex */
printf("%s: Taking mutex\n", __FUNCTION__); printf("thread_waiter: Taking mutex\n");
status = pthread_mutex_lock(&mutex); status = pthread_mutex_lock(&mutex);
if (status != 0) 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 */ /* Are we a non-cancelable thread? Yes, set the non-cancelable state */
if (!parameter) if (!parameter)
{ {
printf("%s: Setting non-cancelable\n", __FUNCTION__); printf("thread_waiter: Setting non-cancelable\n");
status = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); status = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
if (status != 0) 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); status = pthread_cond_wait(&cond, &mutex);
if (status != 0) 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 */ /* Release the mutex */
printf("%s: Releasing mutex\n", __FUNCTION__); printf("thread_waiter: Releasing mutex\n");
status = pthread_mutex_unlock(&mutex); status = pthread_mutex_unlock(&mutex);
if (status != 0) 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 */ /* Set the cancelable state */
printf("%s: Setting cancelable\n", __FUNCTION__); printf("thread_waiter: Setting cancelable\n");
status = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); status = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
if (status != 0) 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); pthread_exit((void*)0x12345678);
return NULL; return NULL;
} }
@ -107,20 +107,20 @@ static void start_thread(pthread_t *waiter, int cancelable)
/* Initialize the mutex */ /* Initialize the mutex */
printf("%s: Initializing mutex\n", __FUNCTION__); printf("start_thread: Initializing mutex\n");
status = pthread_mutex_init(&mutex, NULL); status = pthread_mutex_init(&mutex, NULL);
if (status != 0) 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 */ /* Initialize the condition variable */
printf("%s: Initializing cond\n", __FUNCTION__); printf("start_thread: Initializing cond\n");
status = pthread_cond_init(&cond, NULL); status = pthread_cond_init(&cond, NULL);
if (status != 0) 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 */ /* Set up attributes */
@ -128,27 +128,27 @@ static void start_thread(pthread_t *waiter, int cancelable)
status = pthread_attr_init(&attr); status = pthread_attr_init(&attr);
if (status != 0) 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); status = pthread_attr_setstacksize(&attr, 16384);
if (status != 0) 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 */ /* 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); status = pthread_create(waiter, NULL, thread_waiter, (void*)cancelable);
if (status != 0) 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 */ /* Make sure that the waiter thread gets a chance to run */
printf("%s: Yielding\n", __FUNCTION__); printf("start_thread: Yielding\n");
pthread_yield(); pthread_yield();
} }
@ -159,25 +159,25 @@ static void restart_thread(pthread_t *waiter, int cancelable)
/* Destroy the condition variable */ /* Destroy the condition variable */
printf("%s: Destroying cond\n", __FUNCTION__); printf("restart_thread: Destroying cond\n");
status = pthread_cond_destroy(&cond); status = pthread_cond_destroy(&cond);
if (status != 0) 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 */ /* Destroy the mutex */
printf("%s: Destroying mutex\n", __FUNCTION__); printf("restart_thread: Destroying mutex\n");
status = pthread_cond_destroy(&cond); status = pthread_cond_destroy(&cond);
if (status != 0) 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 */ /* Then restart the thread */
printf("%s: Re-starting thread\n", __FUNCTION__); printf("restart_thread: Re-starting thread\n");
start_thread(waiter, cancelable); start_thread(waiter, cancelable);
} }
@ -190,44 +190,44 @@ void cancel_test(void)
/* Test 1: Normal Cancel *********************************************/ /* Test 1: Normal Cancel *********************************************/
/* Start the waiter thread */ /* Start the waiter thread */
printf("%s: Test 1: Normal Cancelation\n", __FUNCTION__); printf("cancel_test: Test 1: Normal Cancelation\n");
printf("%s: Starting thread\n", __FUNCTION__); printf("cancel_test: Starting thread\n");
start_thread(&waiter, 1); start_thread(&waiter, 1);
/* Then cancel it. It should be in the pthread_cond_wait now */ /* 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); status = pthread_cancel(waiter);
if (status != 0) 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 */ /* 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); status = pthread_join(waiter, &result);
if (status != 0) 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 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) 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 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 ************************************/ /* Test 2: Cancel Detached Thread ************************************/
printf("%s: Test 2: Cancelation of detached thread\n", __FUNCTION__); printf("cancel_test: Test 2: Cancelation of detached thread\n");
printf("%s: Re-starting thread\n", __FUNCTION__); printf("cancel_test: Re-starting thread\n");
restart_thread(&waiter, 1); restart_thread(&waiter, 1);
/* Detach the thread */ /* Detach the thread */
@ -235,39 +235,39 @@ void cancel_test(void)
status = pthread_detach(waiter); status = pthread_detach(waiter);
if (status != 0) 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 */ /* 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); status = pthread_cancel(waiter);
if (status != 0) 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 */ /* Join should now fail */
printf("%s: Joining\n", __FUNCTION__); printf("cancel_test: Joining\n");
status = pthread_join(waiter, &result); status = pthread_join(waiter, &result);
if (status == 0) if (status == 0)
{ {
printf("%s: ERROR pthread_join succeeded\n", __FUNCTION__); printf("cancel_test: ERROR pthread_join succeeded\n");
} }
else if (status != ESRCH) 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 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 ************************************/ /* Test 3: Non-cancelable threads ************************************/
printf("%s: Test 3: Non-cancelable threads\n", __FUNCTION__); printf("cancel_test: Test 3: Non-cancelable threads\n");
printf("%s: Re-starting thread (non-cancelable)\n", __FUNCTION__); printf("cancel_test: Re-starting thread (non-cancelable)\n");
restart_thread(&waiter, 0); restart_thread(&waiter, 0);
/* Then cancel it. It should be in the pthread_cond_wait now. The /* 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. * 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); status = pthread_cancel(waiter);
if (status != 0) 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. /* 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); status = pthread_mutex_lock(&mutex);
if (status != 0) 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); status = pthread_cond_signal(&cond);
if (status != 0) 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); status = pthread_mutex_unlock(&mutex);
if (status != 0) 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);
} }
} }

View File

@ -59,7 +59,7 @@ static void *thread_waiter(void *parameter)
{ {
int status; int status;
printf("%s: Started\n", __FUNCTION__); printf("waiter_thread: Started\n");
for(;;) for(;;)
{ {
@ -71,7 +71,7 @@ static void *thread_waiter(void *parameter)
if (status != 0) 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++; waiter_nerrors++;
} }
@ -94,7 +94,7 @@ static void *thread_waiter(void *parameter)
if (status != 0) 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_nerrors++;
} }
waiter_waits++; waiter_waits++;
@ -104,7 +104,7 @@ static void *thread_waiter(void *parameter)
if (!data_available) 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++; waiter_nerrors++;
} }
@ -117,7 +117,7 @@ static void *thread_waiter(void *parameter)
status = pthread_mutex_unlock(&mutex); status = pthread_mutex_unlock(&mutex);
if (status != 0) 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++; waiter_nerrors++;
} }
@ -130,7 +130,7 @@ static void *thread_signaler(void *parameter)
int status; int status;
int i; int i;
printf("%s: Started\n", __FUNCTION__); printf("thread_signaler: Started\n");
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
{ {
/* Take the mutex. The waiter is higher priority and should /* 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); status = pthread_mutex_lock(&mutex);
if (status != 0) 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++; signaler_nerrors++;
} }
@ -149,13 +149,13 @@ static void *thread_signaler(void *parameter)
if (waiter_state != COND_WAIT) 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++; signaler_state++;
} }
if (data_available) 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++; signaler_already++;
} }
@ -165,7 +165,7 @@ static void *thread_signaler(void *parameter)
status = pthread_cond_signal(&cond); status = pthread_cond_signal(&cond);
if (status != 0) 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++; signaler_nerrors++;
} }
@ -174,14 +174,14 @@ static void *thread_signaler(void *parameter)
status = pthread_mutex_unlock(&mutex); status = pthread_mutex_unlock(&mutex);
if (status != 0) 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_nerrors++;
} }
signaler_nloops++; signaler_nloops++;
} }
printf("%s: Terminating\n", __FUNCTION__); printf("thread_signaler: Terminating\n");
pthread_exit(NULL); pthread_exit(NULL);
} }
@ -198,29 +198,29 @@ void cond_test(void)
/* Initialize the mutex */ /* Initialize the mutex */
printf("%s: Initializing mutex\n", __FUNCTION__); printf("cond_test: Initializing mutex\n");
status = pthread_mutex_init(&mutex, NULL); status = pthread_mutex_init(&mutex, NULL);
if (status != 0) 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 */ /* Initialize the condition variable */
printf("%s: Initializing cond\n", __FUNCTION__); printf("cond_test: Initializing cond\n");
status = pthread_cond_init(&cond, NULL); status = pthread_cond_init(&cond, NULL);
if (status != 0) 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 */ /* Start the waiter thread at higher priority */
printf("%s: Starting waiter\n", __FUNCTION__); printf("cond_test: Starting waiter\n");
status = pthread_attr_init(&attr); status = pthread_attr_init(&attr);
if (status != 0) 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); prio_min = sched_get_priority_min(SCHED_FIFO);
@ -231,54 +231,54 @@ void cond_test(void)
status = pthread_attr_setschedparam(&attr,&sparam); status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK) 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 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); status = pthread_create(&waiter, &attr, thread_waiter, NULL);
if (status != 0) 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); status = pthread_attr_init(&attr);
if (status != 0) 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; sparam.sched_priority = (prio_min + prio_mid) / 2;
status = pthread_attr_setschedparam(&attr,&sparam); status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK) 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 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); status = pthread_create(&signaler, &attr, thread_signaler, NULL);
if (status != 0) 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 */ /* Wait for the threads to stop */
pthread_join(signaler, NULL); 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_detach(waiter);
pthread_cancel(waiter); pthread_cancel(waiter);
printf("%s: \tWaiter\tSignaler\n", __FUNCTION__); printf("cond_test: \tWaiter\tSignaler\n");
printf("%s: Loops\t%d\t%d\n", __FUNCTION__, waiter_nloops, signaler_nloops); printf("cond_test: Loops\t%d\t%d\n", waiter_nloops, signaler_nloops);
printf("%s: Errors\t%d\t%d\n", __FUNCTION__, waiter_nerrors, signaler_nerrors); printf("cond_test: Errors\t%d\t%d\n", waiter_nerrors, signaler_nerrors);
printf("%s: \n%d times, waiter did not have to wait for data\n", __FUNCTION__, waiter_nloops - waiter_waits); printf("cond_test: \n%d times, waiter did not have to wait for data\n", waiter_nloops - waiter_waits);
printf("%s: %d times, data was already available when the signaler run\n", __FUNCTION__, signaler_already); printf("cond_test: %d times, data was already available when the signaler run\n", signaler_already);
printf("%s: %d times, the waiter was in an unexpected state when the signaler ran\n", __FUNCTION__, signaler_state); printf("cond_test: %d times, the waiter was in an unexpected state when the signaler ran\n", signaler_state);
} }

View File

@ -64,27 +64,27 @@ int dev_null(void)
fd = open("/dev/null", O_RDWR); fd = open("/dev/null", O_RDWR);
if (fd < 0) 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; return -1;
} }
nbytes = read(fd, buffer, 1024); nbytes = read(fd, buffer, 1024);
if (nbytes < 0) 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); close(fd);
return -1; 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); nbytes = write(fd, buffer, 1024);
if (nbytes < 0) 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); close(fd);
return -1; 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); close(fd);
return 0; return 0;

View File

@ -76,27 +76,27 @@ static int user_main(int argc, char *argv[])
{ {
int i; int i;
printf("%s: Started with argc=%d\n", __FUNCTION__, argc); printf("user_main: Started with argc=%d\n", argc);
/* Verify passed arguments */ /* Verify passed arguments */
if (argc != NARGS + 1) if (argc != NARGS + 1)
{ {
fprintf(stderr, "%s: Error expected argc=%d got argc=%d\n", fprintf(stderr, "user_main: Error expected argc=%d got argc=%d\n",
__FUNCTION__, NARGS+1, argc); NARGS+1, argc);
} }
for (i = 0; i <= NARGS; i++) 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++) for (i = 1; i <= NARGS; i++)
{ {
if (strcmp(argv[i], args[i-1]) != 0) if (strcmp(argv[i], args[i-1]) != 0)
{ {
fprintf(stderr, "%s: ERROR argv[%d]: Expected \"%s\" found \"%s\"\n", fprintf(stderr, "user_main: ERROR argv[%d]: Expected \"%s\" found \"%s\"\n",
__FUNCTION__, i, argv[i], args[i-1]); 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 */ /* Verify that we can communicate */
write(1, write_data1, sizeof(write_data1)); 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)); 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 */ /* 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); ARG1, ARG2, ARG3, ARG4);
if (result == ERROR) if (result == ERROR)
{ {
fprintf(stderr, "%s: Failed to start user_main\n", __FUNCTION__); fprintf(stderr, "user_start: Failed to start user_main\n");
} }
else 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; return 0;
} }

View File

@ -85,7 +85,7 @@ static void *sender_thread(void *arg)
int nerrors = 0; int nerrors = 0;
int i; int i;
printf("%s: Starting\n", __FUNCTION__); printf("sender_thread: Starting\n");
/* Fill in attributes for message queue */ /* 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); mqfd = mq_open("testmq", O_WRONLY|O_CREAT, 0666, &attr);
if (mqfd < 0) if (mqfd < 0)
{ {
printf("%s: ERROR mq_open failed\n", __FUNCTION__); printf("sender_thread: ERROR mq_open failed\n");
pthread_exit((void*)1); pthread_exit((void*)1);
} }
@ -122,12 +122,12 @@ static void *sender_thread(void *arg)
status = mq_send(mqfd, msg_buffer, TEST_MSGLEN, 42); status = mq_send(mqfd, msg_buffer, TEST_MSGLEN, 42);
if (status < 0) 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++; nerrors++;
} }
else 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) 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; return (void*)nerrors;
} }
@ -151,7 +151,7 @@ static void *receiver_thread(void *arg)
int nerrors = 0; int nerrors = 0;
int i; int i;
printf("%s: Starting\n", __FUNCTION__); printf("receiver_thread: Starting\n");
/* Fill in attributes for message queue */ /* 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); mqfd = mq_open("testmq", O_RDONLY|O_CREAT, 0666, &attr);
if (mqfd < 0) if (mqfd < 0)
{ {
printf("%s: ERROR mq_open failed\n", __FUNCTION__); printf("receiver_thread: ERROR mq_open failed\n");
pthread_exit((void*)1); pthread_exit((void*)1);
} }
@ -184,33 +184,32 @@ static void *receiver_thread(void *arg)
nbytes = mq_receive(mqfd, msg_buffer, TEST_MSGLEN, 0); nbytes = mq_receive(mqfd, msg_buffer, TEST_MSGLEN, 0);
if (nbytes < 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++; nerrors++;
} }
else if (nbytes != TEST_MSGLEN) 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++; nerrors++;
} }
else if (memcmp(TEST_MESSAGE, msg_buffer, nbytes) != 0) else if (memcmp(TEST_MESSAGE, msg_buffer, nbytes) != 0)
{ {
int j; int j;
printf("%s: mq_receive returned corrupt message on msg %d\n", __FUNCTION__, i); printf("receiver_thread: mq_receive returned corrupt message on msg %d\n", i);
printf("%s: i Expected Received\n", __FUNCTION__); printf("receiver_thread: i Expected Received\n");
for (j = 0; j < TEST_MSGLEN-1; j++) for (j = 0; j < TEST_MSGLEN-1; j++)
{ {
printf("%s: %2d %02x (%c) %02x\n", printf("receiver_thread: %2d %02x (%c) %02x\n",
__FUNCTION__,
j, TEST_MESSAGE[j], TEST_MESSAGE[j], msg_buffer[j] & 0x0ff); j, TEST_MESSAGE[j], TEST_MESSAGE[j], msg_buffer[j] & 0x0ff);
} }
printf("%s: %2d 00 %02x\n", printf("receiver_thread: %2d 00 %02x\n",
__FUNCTION__, j, msg_buffer[j] & 0xff); j, msg_buffer[j] & 0xff);
} }
else 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) if (mq_close(mqfd) < 0)
{ {
printf("%s: ERROR mq_close failed\n", __FUNCTION__); printf("receiver_thread: ERROR mq_close failed\n");
nerrors++; nerrors++;
} }
@ -228,11 +227,11 @@ static void *receiver_thread(void *arg)
if (mq_unlink("testmq") < 0) if (mq_unlink("testmq") < 0)
{ {
printf("%s: ERROR mq_close failed\n", __FUNCTION__); printf("receiver_thread: ERROR mq_close failed\n");
nerrors++; nerrors++;
} }
printf("%s: returning nerrors=%d\n", __FUNCTION__, nerrors); printf("receiver_thread: returning nerrors=%d\n", nerrors);
return (void*)nerrors; return (void*)nerrors;
} }
@ -250,17 +249,17 @@ void mqueue_test(void)
/* Start the sending thread at higher priority */ /* Start the sending thread at higher priority */
printf("%s: Starting receiver\n", __FUNCTION__); printf("mqueue_test: Starting receiver\n");
status = pthread_attr_init(&attr); status = pthread_attr_init(&attr);
if (status != 0) 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); status = pthread_attr_setstacksize(&attr, 16384);
if (status != 0) 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); prio_min = sched_get_priority_min(SCHED_FIFO);
@ -271,62 +270,62 @@ void mqueue_test(void)
status = pthread_attr_setschedparam(&attr,&sparam); status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK) 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 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); status = pthread_create(&receiver, &attr, receiver_thread, NULL);
if (status != 0) 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 */ /* Start the sending thread at lower priority */
printf("%s: Starting sender\n", __FUNCTION__); printf("mqueue_test: Starting sender\n");
status = pthread_attr_init(&attr); status = pthread_attr_init(&attr);
if (status != 0) 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); status = pthread_attr_setstacksize(&attr, 16384);
if (status != 0) 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; sparam.sched_priority = (prio_min + prio_mid) / 2;
status = pthread_attr_setschedparam(&attr,&sparam); status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK) 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 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); status = pthread_create(&sender, &attr, sender_thread, NULL);
if (status != 0) 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); pthread_join(sender, &result);
if (result != (void*)0) 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_cancel(receiver);
pthread_join(receiver, &result); pthread_join(receiver, &result);
if (result != (void*)0) 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);
} }
} }

View File

@ -114,7 +114,7 @@ void mutex_test(void)
pthread_join(thread1, NULL); pthread_join(thread1, NULL);
pthread_join(thread2, NULL); pthread_join(thread2, NULL);
printf("%s:\t\tThread1\tThread2\n", __FUNCTION__); printf("\t\tThread1\tThread2\n");
printf("%s:\tLoops\t%ld\t%ld\n", __FUNCTION__, nloops[0], nloops[1]); printf("\tLoops\t%ld\t%ld\n", nloops[0], nloops[1]);
printf("%s:\tErrors\t%ld\t%ld\n", __FUNCTION__, nerrors[0], nerrors[1]); printf("\tErrors\t%ld\t%ld\n", nerrors[0], nerrors[1]);
} }

View File

@ -88,4 +88,8 @@ extern void cancel_test(void);
extern void timedwait_test(void); extern void timedwait_test(void);
/* sighand.c ************************************************/
extern void sighand_test(void);
#endif /* __OSTEST_H */ #endif /* __OSTEST_H */

View File

@ -52,39 +52,39 @@ static void *waiter_func(void *parameter)
int status; int status;
int value; int value;
printf("%s: Thread %d Started\n", __FUNCTION__, id); printf("waiter_func: Thread %d Started\n", id);
/* Take the semaphore */ /* Take the semaphore */
status = sem_getvalue(&sem, &value); status = sem_getvalue(&sem, &value);
if (status < 0) 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 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); status = sem_wait(&sem);
if (status != 0) 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); status = sem_getvalue(&sem, &value);
if (status < 0) 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 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; return NULL;
} }
@ -94,7 +94,7 @@ static void *poster_func(void *parameter)
int status; int status;
int value; int value;
printf("%s: Thread %d started\n", __FUNCTION__, id); printf("poster_func: Thread %d started\n", id);
/* Take the semaphore */ /* Take the semaphore */
@ -103,20 +103,20 @@ static void *poster_func(void *parameter)
status = sem_getvalue(&sem, &value); status = sem_getvalue(&sem, &value);
if (status < 0) 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 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) 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); status = sem_post(&sem);
if (status != 0) 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(); pthread_yield();
@ -124,17 +124,17 @@ static void *poster_func(void *parameter)
status = sem_getvalue(&sem, &value); status = sem_getvalue(&sem, &value);
if (status < 0) 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 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); while (value < 0);
printf("%s: Thread %d done\n", __FUNCTION__, id); printf("poster_func: Thread %d done\n", id);
return NULL; return NULL;
} }
@ -151,16 +151,16 @@ void sem_test(void)
pthread_attr_t attr; pthread_attr_t attr;
int status; int status;
printf("%s: Initializing semaphore to 0\n", __FUNCTION__); printf("sem_test: Initializing semaphore to 0\n");
sem_init(&sem, 0, 0); sem_init(&sem, 0, 0);
/* Start two waiter thread instances */ /* 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); status = pthread_attr_init(&attr);
if (status != OK) 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); prio_min = sched_get_priority_min(SCHED_FIFO);
@ -171,65 +171,65 @@ void sem_test(void)
status = pthread_attr_setschedparam(&attr,&sparam); status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK) 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 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); status = pthread_create(&waiter_thread1, &attr, waiter_func, (void*)1);
if (status != 0) 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); status = pthread_attr_init(&attr);
if (status != 0) 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; sparam.sched_priority = prio_mid;
status = pthread_attr_setschedparam(&attr,&sparam); status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK) 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 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); status = pthread_create(&waiter_thread2, &attr, waiter_func, (void*)2);
if (status != 0) 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); status = pthread_attr_init(&attr);
if (status != 0) 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; sparam.sched_priority = (prio_min + prio_mid) / 2;
status = pthread_attr_setschedparam(&attr,&sparam); status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK) 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 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); status = pthread_create(&poster_thread, &attr, poster_func, (void*)3);
if (status != 0) 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); pthread_join(waiter_thread1, NULL);

View File

@ -60,7 +60,7 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext)
sigset_t allsigs; sigset_t allsigs;
int status; int status;
printf("%s: Received signal %d\n", __FUNCTION__, signo); printf("wakeup_action: Received signal %d\n" , signo);
sigreceived = TRUE; sigreceived = TRUE;
@ -68,32 +68,32 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext)
if (signo != WAKEUP_SIGNAL) 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 */ /* Check siginfo */
if (info->si_value.sival_int != SIGVALUE_INT) if (info->si_value.sival_int != SIGVALUE_INT)
{ {
printf("%s: ERROR sival_int=%d expected %d\n", printf("wakeup_action: ERROR sival_int=%d expected %d\n",
__FUNCTION__, info->si_value.sival_int, SIGVALUE_INT); info->si_value.sival_int, SIGVALUE_INT);
} }
else 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) if (info->si_signo != WAKEUP_SIGNAL)
{ {
printf("%s: ERROR expected si_signo=%d, got=%d\n", printf("wakeup_action: ERROR expected si_signo=%d, got=%d\n",
__FUNCTION__, WAKEUP_SIGNAL, info->si_signo); 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 */ /* Check ucontext_t */
printf("%s: ucontext=%p\n", __FUNCTION__, ucontext); printf("wakeup_action: ucontext=%p\n" , ucontext);
/* Check sigprocmask */ /* Check sigprocmask */
@ -101,14 +101,14 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext)
status = sigprocmask(SIG_SETMASK, NULL, &oldset); status = sigprocmask(SIG_SETMASK, NULL, &oldset);
if (status != OK) if (status != OK)
{ {
printf("%s: ERROR sigprocmask failed, status=%d\n", printf("wakeup_action: ERROR sigprocmask failed, status=%d\n",
__FUNCTION__, status); status);
} }
if (oldset != allsigs) if (oldset != allsigs)
{ {
printf("%s: ERROR sigprocmask=%x expected=%x\n", printf("wakeup_action: ERROR sigprocmask=%x expected=%x\n",
__FUNCTION__, oldset, allsigs); oldset, allsigs);
} }
} }
@ -120,19 +120,19 @@ static int waiter_main(int argc, char *argv[])
struct sigaction oact; struct sigaction oact;
int status; 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)sigemptyset(&sigset);
(void)sigaddset(&sigset, WAKEUP_SIGNAL); (void)sigaddset(&sigset, WAKEUP_SIGNAL);
status = sigprocmask(SIG_UNBLOCK, &sigset, NULL); status = sigprocmask(SIG_UNBLOCK, &sigset, NULL);
if (status != OK) if (status != OK)
{ {
printf("%s: ERROR sigprocmask failed, status=%d\n", printf("waiter_main: ERROR sigprocmask failed, status=%d\n",
__FUNCTION__, status); status);
} }
printf("%s: Registering signal handler\n", __FUNCTION__); printf("waiter_main: Registering signal handler\n" );
act.sa_sigaction = wakeup_action; act.sa_sigaction = wakeup_action;
act.sa_flags = SA_SIGINFO; act.sa_flags = SA_SIGINFO;
@ -142,15 +142,15 @@ static int waiter_main(int argc, char *argv[])
status = sigaction(WAKEUP_SIGNAL, &act, &oact); status = sigaction(WAKEUP_SIGNAL, &act, &oact);
if (status != OK) 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", printf("waiter_main: oact.sigaction=%p oact.sa_flags=%x oact.sa_mask=%x\n",
__FUNCTION__, oact.sa_sigaction, oact.sa_flags, oact.sa_mask); oact.sa_sigaction, oact.sa_flags, oact.sa_mask);
/* Take the semaphore */ /* Take the semaphore */
printf("%s: Waiting on semaphore\n", __FUNCTION__); printf("waiter_main: Waiting on semaphore\n" );
fflush(stdout); fflush(stdout);
status = sem_wait(&sem); status = sem_wait(&sem);
if (status != 0) if (status != 0)
@ -158,19 +158,19 @@ static int waiter_main(int argc, char *argv[])
int error = *get_errno_ptr(); int error = *get_errno_ptr();
if (error == EINTR) if (error == EINTR)
{ {
printf("%s: sem_wait() successfully interrupted by signal\n", __FUNCTION__); printf("waiter_main: sem_wait() successfully interrupted by signal\n" );
} }
else else
{ {
printf("%s: ERROR sem_wait failed, errno=%d\n", __FUNCTION__, error); printf("waiter_main: ERROR sem_wait failed, errno=%d\n" , error);
} }
} }
else 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); fflush(stdout);
threadexited = TRUE; threadexited = TRUE;
return 0; return 0;
@ -184,25 +184,25 @@ void sighand_test(void)
int policy; int policy;
int status; int status;
printf("%s: Initializing semaphore to 0\n", __FUNCTION__); printf("waiter_main: Initializing semaphore to 0\n" );
sem_init(&sem, 0, 0); sem_init(&sem, 0, 0);
/* Start waiter thread */ /* Start waiter thread */
printf("%s: Starting waiter task\n", __FUNCTION__); printf("sighand_test: Starting waiter task\n" );
status = sched_getparam (0, &param); status = sched_getparam (0, &param);
if (status != OK) 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; param.sched_priority = PTHREAD_DEFAULT_PRIORITY;
} }
policy = sched_getscheduler(0); policy = sched_getscheduler(0);
if (policy == ERROR) if (policy == ERROR)
{ {
printf("%s: ERROR sched_getscheduler() failed\n", __FUNCTION__); printf("sighand_test: ERROR sched_getscheduler() failed\n" );
policy = SCHED_FIFO; policy = SCHED_FIFO;
} }
@ -210,11 +210,11 @@ void sighand_test(void)
PTHREAD_STACK_DEFAULT, waiter_main, 0, 0, 0, 0); PTHREAD_STACK_DEFAULT, waiter_main, 0, 0, 0, 0);
if (waiterpid == ERROR) if (waiterpid == ERROR)
{ {
printf("%s: ERROR failed to start waiter_main\n", __FUNCTION__); printf("sighand_test: ERROR failed to start waiter_main\n" );
} }
else else
{ {
printf("%s: Started waiter_main pid=%d\n", __FUNCTION__, waiterpid); printf("sighand_test: Started waiter_main pid=%d\n" , waiterpid);
} }
/* Wait a bit */ /* Wait a bit */
@ -228,7 +228,7 @@ void sighand_test(void)
status = sigqueue(waiterpid, WAKEUP_SIGNAL, sigvalue); status = sigqueue(waiterpid, WAKEUP_SIGNAL, sigvalue);
if (status != OK) if (status != OK)
{ {
printf("%s: ERROR sigqueue failed\n", __FUNCTION__); printf("sighand_test: ERROR sigqueue failed\n" );
task_delete(waiterpid); task_delete(waiterpid);
} }
@ -241,14 +241,14 @@ void sighand_test(void)
if (!threadexited) if (!threadexited)
{ {
printf("%s: ERROR waiter task did not exit\n", __FUNCTION__); printf("sighand_test: ERROR waiter task did not exit\n" );
} }
if (!sigreceived) 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); fflush(stdout);
} }

View File

@ -49,19 +49,19 @@ static void *thread_waiter(void *parameter)
/* Take the mutex */ /* Take the mutex */
printf("%s: Taking mutex\n", __FUNCTION__); printf("thread_waiter: Taking mutex\n");
status = pthread_mutex_lock(&mutex); status = pthread_mutex_lock(&mutex);
if (status != 0) 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); status = clock_gettime(CLOCK_REALTIME, &time);
if (status != 0) if (status != 0)
{ {
printf("%s: ERROR clock_gettime failed\n", __FUNCTION__); printf("thread_waiter: ERROR clock_gettime failed\n");
} }
time.tv_sec += 5; time.tv_sec += 5;
@ -70,19 +70,19 @@ static void *thread_waiter(void *parameter)
status = pthread_cond_timedwait(&cond, &mutex, &time); status = pthread_cond_timedwait(&cond, &mutex, &time);
if (status != 0) 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 */ /* Release the mutex */
printf("%s: Releasing mutex\n", __FUNCTION__); printf("thread_waiter: Releasing mutex\n");
status = pthread_mutex_unlock(&mutex); status = pthread_mutex_unlock(&mutex);
if (status != 0) 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); pthread_exit((void*)0x12345678);
return NULL; return NULL;
} }
@ -98,36 +98,36 @@ void timedwait_test(void)
/* Initialize the mutex */ /* Initialize the mutex */
printf("%s: Initializing mutex\n", __FUNCTION__); printf("thread_waiter: Initializing mutex\n");
status = pthread_mutex_init(&mutex, NULL); status = pthread_mutex_init(&mutex, NULL);
if (status != 0) 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 */ /* Initialize the condition variable */
printf("%s: Initializing cond\n", __FUNCTION__); printf("timedwait_test: Initializing cond\n");
status = pthread_cond_init(&cond, NULL); status = pthread_cond_init(&cond, NULL);
if (status != 0) 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 */ /* Start the waiter thread at higher priority */
printf("%s: Starting waiter\n", __FUNCTION__); printf("timedwait_test: Starting waiter\n");
status = pthread_attr_init(&attr); status = pthread_attr_init(&attr);
if (status != 0) 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); prio_max = sched_get_priority_max(SCHED_FIFO);
status = sched_getparam (getpid(), &sparam); status = sched_getparam (getpid(), &sparam);
if (status != 0) if (status != 0)
{ {
printf("%s: sched_getparam failed\n", __FUNCTION__); printf("timedwait_test: sched_getparam failed\n");
sparam.sched_priority = PTHREAD_DEFAULT_PRIORITY; sparam.sched_priority = PTHREAD_DEFAULT_PRIORITY;
} }
@ -135,27 +135,27 @@ void timedwait_test(void)
status = pthread_attr_setschedparam(&attr,&sparam); status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK) 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 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); status = pthread_create(&waiter, &attr, thread_waiter, NULL);
if (status != 0) 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); status = pthread_join(waiter, &result);
if (status != 0) 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 else
{ {
printf("%s: waiter exited with result=%p\n", __FUNCTION__, result); printf("timedwait_test: waiter exited with result=%p\n", result);
} }
} }

View File

@ -49,7 +49,7 @@
#include <sys/types.h> #include <sys/types.h>
/************************************************************ /************************************************************
* Public Type Definitions * Definitions
************************************************************/ ************************************************************/
/************************************************************ /************************************************************
@ -63,18 +63,9 @@
* *
************************************************************/ ************************************************************/
static inline int isspace(int c) #define isspace(c) \
{ (c == ' ' || c == '\t' || c == '\n' || \
if (c == ' ' || c == '\t' || c == '\n' || \ c == '\r' || c == '\f' || c== '\v')
c == '\r' || c == '\f' || c == '\v')
{
return TRUE;
}
else
{
return FALSE;
}
}
/************************************************************ /************************************************************
* Function: isdigit * Function: isdigit
@ -84,10 +75,8 @@ static inline int isspace(int c)
* *
************************************************************/ ************************************************************/
static inline int isdigit(int c) #define isdigit(c) \
{ (c >= '0' && c <= '9')
return (c >= '0' && c <= '9');
}
/************************************************************ /************************************************************
* Function: isascii * Function: isascii
@ -98,14 +87,11 @@ static inline int isdigit(int c)
* *
************************************************************/ ************************************************************/
static inline int isascii(int c) #define isascii(c) \
{ (c >= 0 && c <= 0177);
return (c >= 0 && c <= 0177);
}
/************************************************************ /************************************************************
* Function: isascii * Function: isxdigit
* *
* Description: * Description:
* isxdigit() checks for a hexadecimal digits, i.e. one of * 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) #define isxdigit(c) \
{ ((c >= '0' && c <= '9') || \
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || \
(c >= 'a' && c <= 'f') ||
(c >= 'A' && c <= 'F')) (c >= 'A' && c <= 'F'))
{
return 1;
}
else
{
return 0;
}
}
/************************************************************ /************************************************************
* Function: isascii * Function: toupper
* *
* Description: * Description:
* toupper() converts the letter c to upper case, if possible. * toupper() converts the letter c to upper case, if possible.
* *
************************************************************/ ************************************************************/
static inline int toupper(int c) #define toupper(c) \
{ ((c >= 'a' && c <= 'z') ? ((c) - 'a' + 'A') : (c))
if (c >= 'a' && c <= 'z')
{
return c - 'a' + 'A';
}
else
{
return c;
}
}
/************************************************************ /************************************************************
* Function: isascii * Function: tolower
* *
* Description: * Description:
* tolower() converts the letter c to lower case, if possible. * tolower() converts the letter c to lower case, if possible.
* *
************************************************************/ ************************************************************/
static inline int tolower(int c) #define tolower(c) \
{ ((c >= 'A' && c <= 'Z') ? ((c) - 'A' + 'a') : (c))
if (c >= 'A' && c <= 'Z')
{ /************************************************************
return c - 'A' + 'a'; * Public Type Definitions
} ************************************************************/
else
{
return c;
}
}
/************************************************************ /************************************************************
* Public Functions * Public Functions

View File

@ -48,17 +48,28 @@
/* Debug macros to runtime filter the opsys debug messages */ /* 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 #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 # 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 # else
# define lldbg(x...) # define lldbg(x...)
# endif # endif
# ifdef CONFIG_DEBUG_VERBOSE # 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 # else
# define vdbg(x...) # define vdbg(x...)
# endif # endif

View File

@ -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 * Debug interfaces exported by the architecture-specific

View File

@ -49,7 +49,7 @@
extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))); extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
# define weak_function __attribute__ ((weak)) # define weak_function __attribute__ ((weak))
# define weak_const_function __attribute__ ((weak, __const__)) # define weak_const_function __attribute__ ((weak, __const__))
# define noreturn_function # define noreturn_function __attribute__ ((noreturn))
#else #else
# define weak_alias(name, aliasname) # define weak_alias(name, aliasname)
# define weak_function # define weak_function

View File

@ -60,11 +60,9 @@
/* This struct defines the way the registers are stored */ /* This struct defines the way the registers are stored */
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
struct xcptcontext; /* forward reference */ typedef int (*xcpt_t)(int irq, void *context);
typedef int (*xcpt_t)(int irq, struct xcptcontext *xcp);
typedef int (*swint_t)(uint32 code, uint32 parm2, uint32 parm3, typedef int (*swint_t)(uint32 code, uint32 parm2, uint32 parm3,
struct xcptcontext *xcp); void *context);
#endif #endif
/* Now include architecture-specific types */ /* Now include architecture-specific types */

View File

@ -44,6 +44,7 @@
#include <sys/types.h> /* Needed for general types */ #include <sys/types.h> /* Needed for general types */
#include <semaphore.h> /* Needed for sem_t */ #include <semaphore.h> /* Needed for sem_t */
#include <time.h> /* Needed for struct timespec */ #include <time.h> /* Needed for struct timespec */
#include <nuttx/compiler.h> /* For noreturn_function */
/************************************************************ /************************************************************
* Compilation Switches * Compilation Switches
@ -117,11 +118,7 @@ struct pthread_addr_s
}; };
typedef struct pthread_addr_s pthread_attr_t; typedef struct pthread_addr_s pthread_attr_t;
struct pthread_s typedef pid_t pthread_t;
{
int pid;
};
typedef struct pthread_s pthread_t;
typedef int pthread_condattr_t; typedef int pthread_condattr_t;
@ -215,7 +212,7 @@ EXTERN int pthread_detach(pthread_t thread);
* execution of another 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_cancel(pthread_t thread);
EXTERN int pthread_setcancelstate(int state, int *oldstate); EXTERN int pthread_setcancelstate(int state, int *oldstate);
EXTERN void pthread_testcancel(void); 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. * 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 * Thread scheduling parameters

View File

@ -40,6 +40,7 @@
* Included Files * Included Files
************************************************************/ ************************************************************/
#include <nuttx/config.h>
#include <time.h> /* Needed for struct timespec */ #include <time.h> /* Needed for struct timespec */
#include <sys/types.h> /* Needed for, e.g., sigset_t */ #include <sys/types.h> /* Needed for, e.g., sigset_t */
@ -164,8 +165,12 @@ EXTERN int sigwaitinfo(const sigset_t *set,
EXTERN int sigtimedwait(const sigset_t *set, EXTERN int sigtimedwait(const sigset_t *set,
struct siginfo *value, struct siginfo *value,
const struct timespec *timeout); const struct timespec *timeout);
#ifdef CONFIG_CAN_PASS_STRUCTS
EXTERN int sigqueue(int tid, int signo, EXTERN int sigqueue(int tid, int signo,
const union sigval value); const union sigval value);
#else
EXTERN int sigqueue(int tid, int signo, void *sival_ptr);
#endif
#undef EXTERN #undef EXTERN
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -200,6 +200,7 @@ typedef void DIR;
/* Used to reference stdin, stdout, and stderr */ /* Used to reference stdin, stdout, and stderr */
#ifdef CONFIG_HAVE_INLINE
static inline FILE *__stdfile(int fd) static inline FILE *__stdfile(int fd)
{ {
if ((unsigned int)fd < CONFIG_NFILE_DESCRIPTORS) if ((unsigned int)fd < CONFIG_NFILE_DESCRIPTORS)
@ -212,6 +213,9 @@ static inline FILE *__stdfile(int fd)
} }
return NULL; return NULL;
} }
#else
extern FILE *__stdfile(int fd);
#endif
/************************************************************ /************************************************************
* Public Function Prototypes * Public Function Prototypes

View File

@ -97,7 +97,7 @@ EXTERN int atexit(void (*func)(void));
/* String to binary conversions */ /* String to binary conversions */
#define atoi(nptr) strtol((nptr), (char**)NULL, 10) #define atoi(nptr) strtol((nptr), (char**)NULL, 10)
EXTERN long strtol(const char *, char **, int); EXTERN long strtol(const char *, char **, int);
EXTERN double strtod(const char *, char **); EXTERN double_t strtod(const char *, char **);
/* Memory Management */ /* Memory Management */
EXTERN void *malloc(size_t); EXTERN void *malloc(size_t);

View File

@ -40,6 +40,7 @@
* Included Files * Included Files
************************************************************/ ************************************************************/
#include <nuttx/config.h>
#include <arch/types.h> #include <arch/types.h>
/************************************************************ /************************************************************
@ -110,6 +111,12 @@
* Type Declarations * Type Declarations
************************************************************/ ************************************************************/
#ifndef CONFIG_HAVE_DOUBLE
typedef float double_t;
#else
typedef double double_t;
#endif
/* Misc. scalar types */ /* Misc. scalar types */
typedef uint32 mode_t; typedef uint32 mode_t;

View File

@ -41,6 +41,7 @@
************************************************************/ ************************************************************/
#include <sys/types.h> #include <sys/types.h>
#include <nuttx/compiler.h>
/************************************************************ /************************************************************
* Definitions * Definitions
@ -67,7 +68,7 @@ extern "C" {
/* Task Control Interfaces (based on ANSII APIs) */ /* Task Control Interfaces (based on ANSII APIs) */
EXTERN pid_t getpid( void ); 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 unsigned int sleep(unsigned int seconds);
EXTERN void usleep(unsigned long usec); EXTERN void usleep(unsigned long usec);

View File

@ -807,7 +807,7 @@ int lib_vsprintf(struct lib_stream_s *obj, const char *src, va_list ap)
char tmpfmt[40]; char tmpfmt[40];
const char *psrc; const char *psrc;
char *pdst; char *pdst;
double dbl; double_t dbl;
/* Reconstruct the floating point format. */ /* 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. */ /* Extract the floating point number. */
dbl = va_arg(ap, double); dbl = va_arg(ap, double_t);
/* Then let the lib_sprintf do the work. */ /* Then let the lib_sprintf do the work. */

View File

@ -81,11 +81,11 @@
************************************************************/ ************************************************************/
static unsigned int nrand(unsigned int nLimit); static unsigned int nrand(unsigned int nLimit);
static double frand1(void); static double_t frand1(void);
#if (RND_ORDER > 1) #if (RND_ORDER > 1)
static double frand2(void); static double_t frand2(void);
#if (RND_ORDER > 2) #if (RND_ORDER > 2)
static double frand3(void); static double_t frand3(void);
#endif #endif
#endif #endif
@ -140,7 +140,7 @@ int rand(void)
static unsigned int nrand(unsigned int nLimit) static unsigned int nrand(unsigned int nLimit)
{ {
unsigned long nResult; unsigned long nResult;
double fRatio; double_t fRatio;
/* Loop to be sure a legal random number is generated */ /* Loop to be sure a legal random number is generated */
do { do {
@ -155,7 +155,7 @@ static unsigned int nrand(unsigned int nLimit)
#endif #endif
/* Then, produce the return-able value */ /* Then, produce the return-able value */
nResult = (unsigned long)(((double)nLimit) * fRatio); nResult = (unsigned long)(((double_t)nLimit) * fRatio);
} while (nResult >= (unsigned long)nLimit); } while (nResult >= (unsigned long)nLimit);
@ -163,7 +163,7 @@ static unsigned int nrand(unsigned int nLimit)
} /* end nrand */ } /* end nrand */
static double frand1(void) static double_t frand1(void)
{ {
unsigned long nRandInt; unsigned long nRandInt;
@ -172,12 +172,12 @@ static double frand1(void)
g_nRandInt1 = nRandInt; g_nRandInt1 = nRandInt;
/* Construct an floating point value in the range from 0.0 up to 1.0 */ /* 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 */ } /* end frand */
#if (RND_ORDER > 1) #if (RND_ORDER > 1)
static double frand2(void) static double_t frand2(void)
{ {
unsigned long nRandInt; unsigned long nRandInt;
@ -188,12 +188,12 @@ static double frand2(void)
g_nRandInt1 = nRandInt; g_nRandInt1 = nRandInt;
/* Construct an floating point value in the range from 0.0 up to 1.0 */ /* 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 */ } /* end frand */
#if (RND_ORDER > 2) #if (RND_ORDER > 2)
static double frand(void) static double_t frand(void)
{ {
unsigned long nRandInt; unsigned long nRandInt;
@ -205,7 +205,7 @@ static double frand(void)
g_nRandInt1 = nRandInt; g_nRandInt1 = nRandInt;
/* Construct an floating point value in the range from 0.0 up to 1.0 */ /* 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 */ } /* end frand */
#endif #endif

View File

@ -72,9 +72,9 @@
* Private Variables * Private Variables
************************************************************/ ************************************************************/
double rint(double x) double_t rint(double x)
{ {
double retValue; double_t retValue;
/* If the current rounding mode rounds toward negative /* If the current rounding mode rounds toward negative
* infinity, rint() is identical to floor(). If the current * 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. */ * |rint(x)-x|=1/2, then rint(x) is even. */
long dwInteger = (long)x; long dwInteger = (long)x;
double fRemainder = x - (double)dwInteger; double_t fRemainder = x - (double_t)dwInteger;
if (x < 0.0) { if (x < 0.0) {
@ -116,7 +116,7 @@ double rint(double x)
} /* end if */ } /* end if */
} /* end else */ } /* end else */
retValue = (double)dwInteger; retValue = (double_t)dwInteger;
#endif #endif
return retValue; return retValue;

View File

@ -286,7 +286,7 @@ int vsscanf(char *buf, const char *s, va_list ap)
{ {
/* strtod always returns a double */ /* strtod always returns a double */
double dvalue = strtod(tmp, NULL); double_t dvalue = strtod(tmp, NULL);
void *pv = va_arg(ap, void*); void *pv = va_arg(ap, void*);
vdbg("vsscanf: Return %f to 0x%p\n", dvalue, pv); 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. * float or a double.
*/ */
#ifdef CONFIG_HAVE_DOUBLE
if (lflag) if (lflag)
{ {
*((double*)pv) = dvalue; *((double_t*)pv) = dvalue;
} }
else else
#endif
{ {
*((float*)pv) = (float)dvalue; *((float*)pv) = (float)dvalue;
} }

View File

@ -97,8 +97,6 @@ void *memalign(size_t alignment, size_t size)
size = MM_ALIGN_UP(size); /* Make mutliples of our granule size */ size = MM_ALIGN_UP(size); /* Make mutliples of our granule size */
allocsize = size + 2*alignment; /* Add double full alignment size */ allocsize = size + 2*alignment; /* Add double full alignment size */
/* If the alignment is small
/* Then malloc that size */ /* Then malloc that size */
rawchunk = (uint32)malloc(allocsize); rawchunk = (uint32)malloc(allocsize);

View File

@ -113,7 +113,7 @@ void mm_takesemaphore(void)
{ {
/* Take the semaphore (perhaps waiting) */ /* 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) while (sem_wait(&g_mm_semaphore) != 0)
{ {
/* The only case that an error should occur here is if /* The only case that an error should occur here is if
@ -129,8 +129,8 @@ void mm_takesemaphore(void)
g_counts_held = 1; g_counts_held = 1;
} }
msemdbg("%s: Holder=%d count=%d\n", msemdbg("Holder=%d count=%d\n",
__FUNCTION__, g_holder, g_counts_held); g_holder, g_counts_held);
} }
/************************************************************ /************************************************************
@ -152,14 +152,14 @@ void mm_givesemaphore(void)
/* Yes, just release one count and return */ /* Yes, just release one count and return */
g_counts_held--; g_counts_held--;
msemdbg("%s: Holder=%d count=%d\n", msemdbg("Holder=%d count=%d\n",
__FUNCTION__, g_holder, g_counts_held); g_holder, g_counts_held);
} }
else else
{ {
/* Nope, this is the last reference I have */ /* 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_holder = -1;
g_counts_held = 0; g_counts_held = 0;
ASSERT(sem_post(&g_mm_semaphore) == 0); ASSERT(sem_post(&g_mm_semaphore) == 0);

View File

@ -76,8 +76,7 @@ PTHREAD_SRCS = pthread_attrinit.c pthread_attrdestroy.c \
pthread_attrsetstacksize.c pthread_attrgetstacksize.c \ pthread_attrsetstacksize.c pthread_attrgetstacksize.c \
pthread_attrsetschedparam.c pthread_attrgetschedparam.c \ pthread_attrsetschedparam.c pthread_attrgetschedparam.c \
pthread_create.c pthread_exit.c pthread_join.c pthread_detach.c \ pthread_create.c pthread_exit.c pthread_join.c pthread_detach.c \
pthread_yield.c pthread_self.c \ pthread_yield.c pthread_getschedparam.c pthread_setschedparam.c \
pthread_getschedparam.c pthread_setschedparam.c \
pthread_mutexattrinit.c pthread_mutexattrdestroy.c \ pthread_mutexattrinit.c pthread_mutexattrdestroy.c \
pthread_mutexattrgetpshared.c pthread_mutexattrsetpshared.c \ pthread_mutexattrgetpshared.c pthread_mutexattrsetpshared.c \
pthread_mutexinit.c pthread_mutexdestroy.c \ pthread_mutexinit.c pthread_mutexdestroy.c \

View File

@ -88,13 +88,13 @@ int clock_getres(clockid_t clock_id, struct timespec *res)
uint32 time_res; uint32 time_res;
int ret = OK; int ret = OK;
dbg("%s: clock_id=%d\n", __FUNCTION__, clock_id); dbg("clock_id=%d\n", clock_id);
/* Only CLOCK_REALTIME is supported */ /* Only CLOCK_REALTIME is supported */
if (clock_id != CLOCK_REALTIME) if (clock_id != CLOCK_REALTIME)
{ {
dbg("%s: Returning ERROR\n", __FUNCTION__); dbg("Returning ERROR\n");
*get_errno_ptr() = EINVAL; *get_errno_ptr() = EINVAL;
ret = ERROR; ret = ERROR;
} }
@ -109,8 +109,7 @@ int clock_getres(clockid_t clock_id, struct timespec *res)
res->tv_sec = 0; res->tv_sec = 0;
res->tv_nsec = time_res; res->tv_nsec = time_res;
dbg("%s: Returning res=(%d,%d) time_res=%d\n", dbg("Returning res=(%d,%d) time_res=%d\n",
__FUNCTION__,
(int)res->tv_sec, (int)res->tv_nsec, (int)res->tv_sec, (int)res->tv_nsec,
(int)time_res); (int)time_res);
} }

View File

@ -90,13 +90,13 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
uint32 nsecs; uint32 nsecs;
int ret = OK; int ret = OK;
dbg("%s: clock_id=%d\n", __FUNCTION__, clock_id); dbg("clock_id=%d\n", clock_id);
/* Only CLOCK_REALTIME is supported */ /* Only CLOCK_REALTIME is supported */
if (clock_id != CLOCK_REALTIME) if (clock_id != CLOCK_REALTIME)
{ {
dbg("%s: Returning ERROR\n", __FUNCTION__); dbg("Returning ERROR\n");
*get_errno_ptr() = EINVAL; *get_errno_ptr() = EINVAL;
ret = ERROR; 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); 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); (int)msecs, (int)g_tickbias);
/* Get the elapsed time in seconds and nanoseconds. */ /* 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; secs = msecs / MSEC_PER_SEC;
nsecs = (msecs - (secs * MSEC_PER_SEC)) * NSEC_PER_MSEC; 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)msecs, (int)g_basetime.tv_sec,
(int)nsecs, (int)g_basetime.tv_nsec); (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_sec = (time_t)secs;
tp->tv_nsec = (long)nsecs; 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); (int)tp->tv_sec, (int)tp->tv_nsec);
} }

View File

@ -87,13 +87,13 @@ int clock_settime(clockid_t clock_id, const struct timespec *tp)
{ {
int ret = OK; int ret = OK;
dbg("%s: clock_id=%d\n", __FUNCTION__, clock_id); dbg("clock_id=%d\n", clock_id);
/* Only CLOCK_REALTIME is supported */ /* Only CLOCK_REALTIME is supported */
if (clock_id != CLOCK_REALTIME || !tp) if (clock_id != CLOCK_REALTIME || !tp)
{ {
dbg("%s: Returning ERROR\n", __FUNCTION__); dbg("Returning ERROR\n");
*get_errno_ptr() = EINVAL; *get_errno_ptr() = EINVAL;
ret = ERROR; ret = ERROR;
} }
@ -109,8 +109,7 @@ int clock_settime(clockid_t clock_id, const struct timespec *tp)
g_tickbias = g_system_timer; g_tickbias = g_system_timer;
dbg("%s: basetime=(%d,%d) tickbias=%d\n", dbg("basetime=(%d,%d) tickbias=%d\n",
__FUNCTION__,
(int)g_basetime.tv_sec, (int)g_basetime.tv_nsec, (int)g_basetime.tv_sec, (int)g_basetime.tv_nsec,
(int)g_tickbias); (int)g_tickbias);
} }

View File

@ -177,7 +177,7 @@ struct tm *gmtime_r(const time_t *clock, struct tm *result)
/* Get the seconds since the EPOCH */ /* Get the seconds since the EPOCH */
time = *clock; 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 */ /* 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; 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); (int)hour, (int)min, (int)sec);
/* Convert the days since the EPOCH to calendar day */ /* Convert the days since the EPOCH to calendar day */
clock_utc2calendar(jdn, &year, &month, &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); (int)jdn, (int)year, (int)month, (int)day);
/* Then return the struct tm contents */ /* Then return the struct tm contents */

View File

@ -76,7 +76,7 @@
* *
***********************************************************/ ***********************************************************/
void irq_dispatch(int irq, struct xcptcontext *xcp) void irq_dispatch(int irq, void *context)
{ {
xcpt_t vector; xcpt_t vector;
@ -93,6 +93,6 @@ void irq_dispatch(int irq, struct xcptcontext *xcp)
/* Then dispatch to the interrupt handler */ /* Then dispatch to the interrupt handler */
vector(irq, xcp); vector(irq, context);
} }

View File

@ -71,7 +71,7 @@ extern "C" {
#endif #endif
EXTERN void weak_function irq_initialize(void); 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 #undef EXTERN
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -75,7 +75,7 @@
* *
************************************************************/ ************************************************************/
int irq_unexpected_isr(int irq, struct xcptcontext *xcp) int irq_unexpected_isr(int irq, void *context)
{ {
(void)irqsave(); (void)irqsave();
PANIC(OSERR_UNEXPECTEDISR); PANIC(OSERR_UNEXPECTEDISR);

View File

@ -126,14 +126,14 @@ time_t mktime(struct tm *tp)
*/ */
jdn = clock_calendar2utc(tp->tm_year+1900, tp->tm_mon+1, tp->tm_mday); 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", dbg("jdn=%d tm_year=%d tm_mon=%d tm_mday=%d\n",
__FUNCTION__, (int)jdn, tp->tm_year, tp->tm_mon, tp->tm_mday); (int)jdn, tp->tm_year, tp->tm_mon, tp->tm_mday);
/* Return the seconds into the julian day. */ /* Return the seconds into the julian day. */
ret = ((jdn*24 + tp->tm_hour)*60 + tp->tm_min)*60 + tp->tm_sec; 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", 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; return ret;
} }

View File

@ -138,10 +138,6 @@ struct mq_des
int oflags; /* Flags set when message queue was opened */ 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 * Global Variables
************************************************************/ ************************************************************/

View File

@ -145,7 +145,7 @@ mqmsg_t *mq_msgalloc(void)
else else
{ {
dbg("%s: Out of messages\n", __FUNCTION__); dbg("Out of messages\n");
PANIC((uint32)OSERR_OUTOFMESSAGES); PANIC((uint32)OSERR_OUTOFMESSAGES);
} }
} }

View File

@ -192,7 +192,7 @@ void os_start(void)
int init_taskid; int init_taskid;
int i; int i;
lldbg("%s: Entry\n", __FUNCTION__); lldbg("Entry\n");
/* Initialize all task lists */ /* Initialize all task lists */
@ -349,7 +349,7 @@ void os_start(void)
* started by spawning the user init thread of execution. * 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, init_taskid = task_create("init", SCHED_PRIORITY_DEFAULT,
CONFIG_PROC_STACK_SIZE, CONFIG_PROC_STACK_SIZE,
(main_t)user_start, 0, 0, 0, 0); (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. */ /* When control is return to this point, the system is idle. */
dbg("%s: Beginning Idle Loop\n", __FUNCTION__); dbg("Beginning Idle Loop\n");
for (;;) for (;;)
{ {
/* Check if there is anything in the delayed deallocation list. */ /* Check if there is anything in the delayed deallocation list. */

View File

@ -89,7 +89,7 @@ int pthread_attr_destroy(pthread_attr_t *attr)
{ {
int ret; int ret;
dbg("%s: attr=0x%p\n", __FUNCTION__, attr); dbg("attr=0x%p\n", attr);
if (!attr) if (!attr)
{ {
@ -101,7 +101,7 @@ int pthread_attr_destroy(pthread_attr_t *attr)
ret = OK; ret = OK;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -92,8 +92,7 @@ int pthread_attr_getinheritsched(const pthread_attr_t *attr,
{ {
int ret; int ret;
dbg("%s: attr=0x%p inheritsched=0x%p\n", dbg("attr=0x%p inheritsched=0x%p\n", attr, inheritsched);
__FUNCTION__, attr, inheritsched);
if (!attr || !inheritsched) if (!attr || !inheritsched)
{ {
@ -105,7 +104,7 @@ int pthread_attr_getinheritsched(const pthread_attr_t *attr,
ret = OK; ret = OK;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -89,7 +89,7 @@ int pthread_attr_getschedparam(pthread_attr_t *attr,
{ {
int ret; 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) if (!attr || !param)
{ {
@ -101,7 +101,7 @@ int pthread_attr_getschedparam(pthread_attr_t *attr,
ret = OK; ret = OK;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -89,7 +89,7 @@ int pthread_attr_getschedpolicy(pthread_attr_t *attr, int *policy)
{ {
int ret; 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) if (!attr || !policy)
{ {
@ -101,6 +101,6 @@ int pthread_attr_getschedpolicy(pthread_attr_t *attr, int *policy)
ret = OK; ret = OK;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -88,7 +88,7 @@ int pthread_attr_getstacksize(pthread_attr_t *attr, long *stacksize)
{ {
int ret; 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) if (!stacksize)
{ {
@ -100,7 +100,7 @@ int pthread_attr_getstacksize(pthread_attr_t *attr, long *stacksize)
ret = OK; ret = OK;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -90,7 +90,7 @@ int pthread_attr_init(pthread_attr_t *attr)
{ {
int ret = OK; int ret = OK;
dbg("%s: attr=0x%p\n", __FUNCTION__, attr); dbg("attr=0x%p\n", attr);
if (!attr) if (!attr)
{ {
ret = ENOMEM; ret = ENOMEM;
@ -105,7 +105,7 @@ int pthread_attr_init(pthread_attr_t *attr)
memcpy(attr, &g_default_pthread_attr, sizeof(pthread_attr_t)); memcpy(attr, &g_default_pthread_attr, sizeof(pthread_attr_t));
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -92,7 +92,7 @@ int pthread_attr_setinheritsched(pthread_attr_t *attr,
{ {
int ret; int ret;
dbg("%s: inheritsched=%d\n", __FUNCTION__, inheritsched); dbg("inheritsched=%d\n", inheritsched);
if (!attr || if (!attr ||
(inheritsched != PTHREAD_INHERIT_SCHED && (inheritsched != PTHREAD_INHERIT_SCHED &&
@ -106,7 +106,7 @@ int pthread_attr_setinheritsched(pthread_attr_t *attr,
ret = OK; ret = OK;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -89,7 +89,7 @@ int pthread_attr_setschedparam(pthread_attr_t *attr,
{ {
int ret; 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) if (!attr || !param)
{ {
@ -100,7 +100,7 @@ int pthread_attr_setschedparam(pthread_attr_t *attr,
attr->priority = (short)param->sched_priority; attr->priority = (short)param->sched_priority;
ret = OK; ret = OK;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -89,7 +89,7 @@ int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
{ {
int ret; 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 CONFIG_RR_INTERVAL > 0
if (!attr || (policy != SCHED_FIFO && policy != SCHED_RR)) if (!attr || (policy != SCHED_FIFO && policy != SCHED_RR))
@ -105,6 +105,6 @@ int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
ret = OK; ret = OK;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -88,8 +88,7 @@ int pthread_attr_setstacksize(pthread_attr_t *attr, long stacksize)
{ {
int ret; int ret;
dbg("%s: attr=0x%p stacksize=%ld\n", dbg("attr=0x%p stacksize=%ld\n", attr, stacksize);
__FUNCTION__, attr, stacksize);
if (!attr || stacksize < PTHREAD_STACK_MIN) if (!attr || stacksize < PTHREAD_STACK_MIN)
{ {
@ -101,7 +100,7 @@ int pthread_attr_setstacksize(pthread_attr_t *attr, long stacksize)
ret = OK; ret = OK;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -77,7 +77,7 @@ int pthread_cancel(pthread_t thread)
/* First, make sure that the handle references a valid 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 /* pid == 0 is the IDLE task. Callers cannot cancel the
* IDLE task. * IDLE task.
@ -86,7 +86,7 @@ int pthread_cancel(pthread_t thread)
return ESRCH; return ESRCH;
} }
tcb = sched_gettcb(thread.pid); tcb = sched_gettcb((pid_t)thread);
if (!tcb) if (!tcb)
{ {
/* The pid does not correspond to any known thread */ /* The pid does not correspond to any known thread */
@ -132,11 +132,11 @@ int pthread_cancel(pthread_t thread)
/* Complete pending join operations */ /* 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 */ /* Then let pthread_delete do the real work */
task_delete(thread.pid); task_delete((pid_t)thread);
return OK; return OK;
} }

View File

@ -79,7 +79,7 @@ static void pthread_destroyjoininfo(join_t *pjoin)
int ntasks_waiting; int ntasks_waiting;
int status; int status;
dbg("%s: pjoin=0x%p\n", __FUNCTION__, pjoin); dbg("pjoin=0x%p\n", pjoin);
/* Are any tasks waiting for our exit value? */ /* Are any tasks waiting for our exit value? */
@ -150,7 +150,7 @@ int pthread_completejoin(pid_t pid, void *exit_value)
join_t *pjoin; join_t *pjoin;
boolean detached = FALSE; 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. */ /* 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; detached = pjoin->detached;
if (detached) if (detached)
{ {
dbg("%s: Detaching\n", __FUNCTION__); dbg("Detaching\n");
/* If so, then remove the thread's structure from the private /* If so, then remove the thread's structure from the private
* data set. After this point, no other thread can perform a join * data set. After this point, no other thread can perform a join

View File

@ -67,14 +67,14 @@ int pthread_condattr_destroy(pthread_condattr_t *attr)
{ {
int ret = OK; int ret = OK;
dbg("%s: attr=0x%p\n", __FUNCTION__, attr); dbg("attr=0x%p\n", attr);
if (!attr) if (!attr)
{ {
ret = EINVAL; ret = EINVAL;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -67,7 +67,7 @@ int pthread_condattr_init(pthread_condattr_t *attr)
{ {
int ret = OK; int ret = OK;
dbg("%s: attr=0x%p\n", __FUNCTION__, attr); dbg("attr=0x%p\n", attr);
if (!attr) if (!attr)
{ {
@ -78,7 +78,7 @@ int pthread_condattr_init(pthread_condattr_t *attr)
*attr = 0; *attr = 0;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -89,7 +89,7 @@ int pthread_cond_broadcast(pthread_cond_t *cond)
int ret = OK; int ret = OK;
int sval; int sval;
dbg("%s: cond=0x%p\n", __FUNCTION__, cond); dbg("cond=0x%p\n", cond);
if (!cond) if (!cond)
{ {
@ -135,7 +135,7 @@ int pthread_cond_broadcast(pthread_cond_t *cond)
sched_unlock(); sched_unlock();
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -67,7 +67,7 @@ int pthread_cond_destroy(pthread_cond_t *cond)
{ {
int ret = OK; int ret = OK;
dbg("%s: cond=0x%p\n", __FUNCTION__, cond); dbg("cond=0x%p\n", cond);
if (!cond) if (!cond)
{ {
@ -81,7 +81,7 @@ int pthread_cond_destroy(pthread_cond_t *cond)
ret = EINVAL; ret = EINVAL;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -67,7 +67,7 @@ int pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *attr)
{ {
int ret = OK; 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) if (!cond)
{ {
@ -83,7 +83,7 @@ int pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *attr)
ret = EINVAL; ret = EINVAL;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -88,7 +88,7 @@ int pthread_cond_signal(pthread_cond_t *cond)
int ret = OK; int ret = OK;
int sval; int sval;
dbg("%s: cond=0x%p\n", __FUNCTION__, cond); dbg("cond=0x%p\n", cond);
if (!cond) if (!cond)
{ {
@ -110,16 +110,16 @@ int pthread_cond_signal(pthread_cond_t *cond)
else else
{ {
dbg("%s: sval=%d\n", __FUNCTION__, sval); dbg("sval=%d\n", sval);
if (sval < 0) if (sval < 0)
{ {
dbg("%s: Signalling...\n", __FUNCTION__); dbg("Signalling...\n");
ret = pthread_givesemaphore((sem_t*)&cond->sem); ret = pthread_givesemaphore((sem_t*)&cond->sem);
} }
} }
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -116,8 +116,7 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
int int_state; int int_state;
int status; int status;
dbg("%s: cond=0x%p mutex=0x%p abstime=0x%p\n", dbg("cond=0x%p mutex=0x%p abstime=0x%p\n", cond, mutex, abstime);
__FUNCTION__, cond, mutex, abstime);
/* Make sure that non-NULL references were provided. */ /* 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 else
{ {
dbg("%s: Give up mutex...\n", __FUNCTION__); dbg("Give up mutex...\n");
/* We must disable pre-emption and interrupts here so that /* We must disable pre-emption and interrupts here so that
* the time stays valid until the wait begins. This adds * 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) if (*get_errno_ptr() == EINTR)
{ {
dbg("%s: Timedout!\n", __FUNCTION__); dbg("Timedout!\n");
ret = ETIMEDOUT; ret = ETIMEDOUT;
} }
else else
@ -275,7 +274,7 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
/* Reacquire the mutex (retaining the ret). */ /* Reacquire the mutex (retaining the ret). */
dbg("%s: Re-locking...\n", __FUNCTION__); dbg("Re-locking...\n");
status = pthread_takesemaphore((sem_t*)&mutex->sem); status = pthread_takesemaphore((sem_t*)&mutex->sem);
if (!status) 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; return ret;
} }

View File

@ -90,7 +90,7 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
{ {
int ret; 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. */ /* 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 */ /* Give up the mutex */
dbg("%s: Give up mutex / take cond\n", __FUNCTION__); dbg("Give up mutex / take cond\n");
sched_lock(); sched_lock();
mutex->pid = 0; mutex->pid = 0;
@ -123,7 +123,7 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
/* Reacquire the mutex */ /* Reacquire the mutex */
dbg("%s: Reacquire mutex...\n", __FUNCTION__); dbg("Reacquire mutex...\n");
ret |= pthread_takesemaphore((sem_t*)&mutex->sem); ret |= pthread_takesemaphore((sem_t*)&mutex->sem);
if (!ret) 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; return ret;
} }

View File

@ -297,7 +297,7 @@ int pthread_create(pthread_t *thread, pthread_attr_t *attr,
*/ */
pid = (int)ptcb->pid; pid = (int)ptcb->pid;
pjoin->thread.pid = pid; pjoin->thread = (pthread_t)pid;
/* Initialize the semaphores in the join structure to zero. */ /* 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 */ /* Return the thread information to the caller */
if (thread) thread->pid = pid; if (thread) *thread = (pthread_t)pid;
if (!pjoin->started) status = ERROR; if (!pjoin->started) status = ERROR;
sched_unlock(); sched_unlock();

View File

@ -90,15 +90,15 @@ int pthread_detach(pthread_t thread)
join_t *pjoin; join_t *pjoin;
int ret; int ret;
dbg("%s: Thread=%d\n", __FUNCTION__, thread.pid); dbg("Thread=%d\n", thread);
/* Find the entry associated with this pthread. */ /* Find the entry associated with this pthread. */
(void)pthread_takesemaphore(&g_join_semaphore); (void)pthread_takesemaphore(&g_join_semaphore);
pjoin = pthread_findjoininfo(thread.pid); pjoin = pthread_findjoininfo((pid_t)thread);
if (!pjoin) if (!pjoin)
{ {
dbg("%s: Could not find thread entry\n", __FUNCTION__); dbg("Could not find thread entry\n");
ret = EINVAL; ret = EINVAL;
} }
else else
@ -109,7 +109,7 @@ int pthread_detach(pthread_t thread)
{ {
/* YES.. just remove the thread entry. */ /* YES.. just remove the thread entry. */
(void)pthread_removejoininfo(thread.pid); (void)pthread_removejoininfo((pid_t)thread);
sched_free(pjoin); sched_free(pjoin);
pjoin = NULL; pjoin = NULL;
} }
@ -129,6 +129,6 @@ int pthread_detach(pthread_t thread)
} }
(void)pthread_givesemaphore(&g_join_semaphore); (void)pthread_givesemaphore(&g_join_semaphore);
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -91,7 +91,7 @@ void pthread_exit(void *exit_value)
int error_code = (int)exit_value; int error_code = (int)exit_value;
int status; int status;
dbg("%s: exit_value=%p\n", __FUNCTION__, exit_value); dbg("exit_value=%p\n", exit_value);
/* Complete pending join operations */ /* Complete pending join operations */

View File

@ -81,14 +81,14 @@
* *
************************************************************/ ************************************************************/
join_t *pthread_findjoininfo(int pid) join_t *pthread_findjoininfo(pid_t pid)
{ {
join_t *pjoin; join_t *pjoin;
/* Find the entry with the matching pid */ /* Find the entry with the matching pid */
for (pjoin = g_pthread_head; for (pjoin = g_pthread_head;
(pjoin && pjoin->thread.pid != pid); (pjoin && (pid_t)pjoin->thread != pid);
pjoin = pjoin->next); pjoin = pjoin->next);
/* and return it */ /* and return it */

View File

@ -91,8 +91,7 @@ int pthread_getschedparam(pthread_t thread, int *policy,
{ {
int ret; int ret;
dbg("%s: thread ID=%d policy=0x%p param=0x%p\n", dbg("Thread ID=%d policy=0x%p param=0x%p\n", thread, policy, param);
__FUNCTION__, thread.pid, policy, param);
if (!policy || !param) if (!policy || !param)
{ {
@ -102,7 +101,7 @@ int pthread_getschedparam(pthread_t thread, int *policy,
{ {
/* Get the schedparams of the thread. */ /* Get the schedparams of the thread. */
ret = sched_getparam(thread.pid, param); ret = sched_getparam((pid_t)thread, param);
if (ret != OK) if (ret != OK)
{ {
ret = EINVAL; ret = EINVAL;
@ -110,14 +109,14 @@ int pthread_getschedparam(pthread_t thread, int *policy,
/* Return the policy. */ /* Return the policy. */
*policy = sched_getscheduler(thread.pid); *policy = sched_getscheduler((pid_t)thread);
if (*policy == ERROR) if (*policy == ERROR)
{ {
ret = *get_errno_ptr(); ret = *get_errno_ptr();
} }
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -115,9 +115,9 @@ extern "C" {
EXTERN void weak_function pthread_initialize(void); EXTERN void weak_function pthread_initialize(void);
EXTERN int pthread_completejoin(pid_t pid, void *exit_value); 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 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); EXTERN int pthread_takesemaphore(sem_t *sem);
#undef EXTERN #undef EXTERN

View File

@ -98,13 +98,13 @@ int pthread_join(pthread_t thread, pthread_addr_t *pexit_value)
join_t *pjoin; join_t *pjoin;
int ret; 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 /* First make sure that this is not an attempt to join to
* ourself. * ourself.
*/ */
if (thread.pid == getpid()) if ((pid_t)thread == getpid())
{ {
return EDEADLK; return EDEADLK;
} }
@ -124,14 +124,14 @@ int pthread_join(pthread_t thread, pthread_addr_t *pexit_value)
* was detached and has exitted. * was detached and has exitted.
*/ */
pjoin = pthread_findjoininfo(thread.pid); pjoin = pthread_findjoininfo((pid_t)thread);
if (!pjoin) if (!pjoin)
{ {
/* Determine what kind of error to return */ /* 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) */ /* 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) 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. */ /* Get the thread exit value from the terminated thread. */
if (pexit_value) 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; *pexit_value = pjoin->exit_value;
} }
/* Then remove and deallocate the thread entry. */ /* Then remove and deallocate the thread entry. */
(void)pthread_removejoininfo(thread.pid); (void)pthread_removejoininfo((pid_t)thread);
(void)pthread_givesemaphore(&g_join_semaphore); (void)pthread_givesemaphore(&g_join_semaphore);
sched_free(pjoin); sched_free(pjoin);
ret = OK; ret = OK;
} }
else else
{ {
dbg("%s: Thread is still running\n", __FUNCTION__); dbg("Thread is still running\n");
/* Relinquish the data set semaphore, making certain that /* Relinquish the data set semaphore, making certain that
* no task has the opportunity to run between the time * 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) if (pexit_value)
{ {
*pexit_value = pjoin->exit_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 /* 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; ret = OK;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -88,7 +88,7 @@ int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
{ {
int ret = OK; int ret = OK;
dbg("%s: attr=0x%p\n", __FUNCTION__, attr); dbg("attr=0x%p\n", attr);
if (!attr) if (!attr)
{ {
@ -99,6 +99,6 @@ int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
attr->pshared = 0; attr->pshared = 0;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -88,7 +88,7 @@ int pthread_mutexattr_getpshared(pthread_mutexattr_t *attr, int *pshared)
{ {
int ret = OK; 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) if (!attr || !pshared)
{ {
@ -99,6 +99,6 @@ int pthread_mutexattr_getpshared(pthread_mutexattr_t *attr, int *pshared)
*pshared = attr->pshared; *pshared = attr->pshared;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -87,7 +87,7 @@ int pthread_mutexattr_init(pthread_mutexattr_t *attr)
{ {
int ret = OK; int ret = OK;
dbg("%s: attr=0x%p\n", __FUNCTION__, attr); dbg("attr=0x%p\n", attr);
if (!attr) if (!attr)
{ {
@ -98,6 +98,6 @@ int pthread_mutexattr_init(pthread_mutexattr_t *attr)
attr->pshared = 0; attr->pshared = 0;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -88,7 +88,7 @@ int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared)
{ {
int ret = OK; 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)) if (!attr || (pshared != 0 && pshared != 1))
{ {
@ -99,6 +99,6 @@ int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared)
attr->pshared = pshared; attr->pshared = pshared;
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -90,7 +90,7 @@ int pthread_mutex_destroy(pthread_mutex_t *mutex)
int ret = OK; int ret = OK;
int status; int status;
dbg("%s: mutex=0x%p\n", __FUNCTION__, mutex); dbg("mutex=0x%p\n", mutex);
if (!mutex) if (!mutex)
{ {
@ -123,6 +123,6 @@ int pthread_mutex_destroy(pthread_mutex_t *mutex)
sched_unlock(); sched_unlock();
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -89,7 +89,7 @@ int pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *attr)
int pshared = 0; int pshared = 0;
int status; 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) 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; return ret;
} }

View File

@ -90,7 +90,7 @@ int pthread_mutex_lock(pthread_mutex_t *mutex)
int mypid = (int)getpid(); int mypid = (int)getpid();
int ret = OK; int ret = OK;
dbg("%s: mutex=0x%p\n", __FUNCTION__, mutex); dbg("mutex=0x%p\n", mutex);
if (!mutex) if (!mutex)
{ {
@ -108,7 +108,7 @@ int pthread_mutex_lock(pthread_mutex_t *mutex)
if (mutex->pid == mypid) if (mutex->pid == mypid)
{ {
dbg("%s: Returning EDEADLK\n", __FUNCTION__); dbg("Returning EDEADLK\n");
ret = EDEADLK; ret = EDEADLK;
} }
else else
@ -129,7 +129,7 @@ int pthread_mutex_lock(pthread_mutex_t *mutex)
sched_unlock(); sched_unlock();
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -90,7 +90,7 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex)
{ {
int ret = OK; int ret = OK;
dbg("%s: mutex=0x%p\n", __FUNCTION__, mutex); dbg("mutex=0x%p\n", mutex);
if (!mutex) if (!mutex)
{ {
@ -129,7 +129,7 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex)
sched_unlock(); sched_unlock();
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -89,7 +89,7 @@ int pthread_mutex_unlock(pthread_mutex_t *mutex)
{ {
int ret = OK; int ret = OK;
dbg("%s: mutex=0x%p\n", __FUNCTION__, mutex); dbg("mutex=0x%p\n", mutex);
if (!mutex) if (!mutex)
{ {
@ -107,7 +107,7 @@ int pthread_mutex_unlock(pthread_mutex_t *mutex)
if (mutex->pid != (int)getpid()) 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; ret = EPERM;
} }
else else
@ -120,7 +120,7 @@ int pthread_mutex_unlock(pthread_mutex_t *mutex)
sched_unlock(); sched_unlock();
} }
dbg("%s: Returning %d\n", __FUNCTION__, ret); dbg("Returning %d\n", ret);
return ret; return ret;
} }

View File

@ -81,7 +81,7 @@
* *
************************************************************/ ************************************************************/
join_t *pthread_removejoininfo(int pid) join_t *pthread_removejoininfo(pid_t pid)
{ {
join_t *prev; join_t *prev;
join_t *join; join_t *join;
@ -89,7 +89,7 @@ join_t *pthread_removejoininfo(int pid)
/* Find the entry with the matching pid */ /* Find the entry with the matching pid */
for (prev = NULL, join = g_pthread_head; for (prev = NULL, join = g_pthread_head;
(join && join->thread.pid != pid); (join && (pid_t)join->thread != pid);
prev = join, join = join->next); prev = join, join = join->next);
/* Remove it from the data set. */ /* Remove it from the data set. */

View File

@ -1,91 +0,0 @@
/************************************************************
* pthread_self.c
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* 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 <sys/types.h>
#include <unistd.h>
#include <pthread.h>
#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;
}

View File

@ -89,15 +89,9 @@
int pthread_setschedparam(pthread_t thread, int policy, int pthread_setschedparam(pthread_t thread, int policy,
const struct sched_param *param) const struct sched_param *param)
{ {
int ret; dbg("thread ID=%d policy=%d param=0x%p\n", thread, policy, param);
dbg("%s: thread ID=%d policy=%d param=0x%p\n",
__FUNCTION__, thread.pid, policy, param);
/* Let sched_setscheduler do all of the work */ /* Let sched_setscheduler do all of the work */
ret = sched_setscheduler(thread.pid, policy, param); return sched_setscheduler((pid_t)thread, policy, param);
dbg("%s: Returning %d\n", __FUNCTION__, ret);
return ret;
} }

View File

@ -103,7 +103,7 @@ int sched_getscheduler(pid_t pid)
/* Verify that the pid corresponds to a real task */ /* Verify that the pid corresponds to a real task */
if (pid = 0) if (!pid)
{ {
tcb = (_TCB*)g_readytorun.head; tcb = (_TCB*)g_readytorun.head;
} }

View File

@ -87,7 +87,7 @@ extern "C" {
#endif #endif
EXTERN void weak_function sem_initialize(void); 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); EXTERN nsem_t *sem_findnamed(const char *name);
#undef EXTERN #undef EXTERN

View File

@ -226,8 +226,6 @@ STATUS _task_init(_TCB *tcb, char *name, int priority,
{ {
STATUS ret; STATUS ret;
vdbg("%s: Entry\n", __FUNCTION__);
/* Assign a unique task ID to the task. */ /* Assign a unique task ID to the task. */
ret = task_assignpid(tcb); ret = task_assignpid(tcb);
@ -382,8 +380,6 @@ STATUS task_activate(_TCB *tcb)
uint32 flags; uint32 flags;
#endif #endif
vdbg("%s: Entry\n", __FUNCTION__);
#ifdef CONFIG_SCHED_INSTRUMENTATION #ifdef CONFIG_SCHED_INSTRUMENTATION
flags = irqsave(); flags = irqsave();
@ -449,8 +445,6 @@ int task_create(char *name, int priority,
STATUS status; STATUS status;
pid_t pid; pid_t pid;
vdbg("%s: Entry\n", __FUNCTION__);
/* Allocate a TCB for the new task. */ /* Allocate a TCB for the new task. */
tcb = (_TCB*)kzmalloc(sizeof(_TCB)); tcb = (_TCB*)kzmalloc(sizeof(_TCB));

View File

@ -70,7 +70,6 @@ struct wdog_s
}; };
typedef struct wdog_s wdog_t; typedef struct wdog_s wdog_t;
typedef struct wdog_s *WDOG_ID;
/************************************************************ /************************************************************
* Public Variables * Public Variables