summaryrefslogtreecommitdiff
path: root/nuttx/examples
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-02-20 22:39:56 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-02-20 22:39:56 +0000
commit630b4bdd3d2ca967f0e1d4f438f7f1761461dd31 (patch)
treef640e5eab1ce66cdeadd0ab3684ea326f56db8a5 /nuttx/examples
parentbd7dce092d36128a0f84e5544ccc857a45f6ba2f (diff)
downloadpx4-nuttx-630b4bdd3d2ca967f0e1d4f438f7f1761461dd31.tar.gz
px4-nuttx-630b4bdd3d2ca967f0e1d4f438f7f1761461dd31.tar.bz2
px4-nuttx-630b4bdd3d2ca967f0e1d4f438f7f1761461dd31.zip
Eliminating GCC dependencies
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@14 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples')
-rw-r--r--nuttx/examples/ostest/cancel.c100
-rw-r--r--nuttx/examples/ostest/cond.c66
-rw-r--r--nuttx/examples/ostest/dev_null.c10
-rw-r--r--nuttx/examples/ostest/main.c20
-rw-r--r--nuttx/examples/ostest/mqueue.c67
-rw-r--r--nuttx/examples/ostest/mutex.c14
-rw-r--r--nuttx/examples/ostest/ostest.h4
-rw-r--r--nuttx/examples/ostest/sem.c66
-rw-r--r--nuttx/examples/ostest/sighand.c72
-rw-r--r--nuttx/examples/ostest/timedwait.c42
10 files changed, 232 insertions, 229 deletions
diff --git a/nuttx/examples/ostest/cancel.c b/nuttx/examples/ostest/cancel.c
index d52c596fc..1fda4166c 100644
--- a/nuttx/examples/ostest/cancel.c
+++ b/nuttx/examples/ostest/cancel.c
@@ -48,24 +48,24 @@ static void *thread_waiter(void *parameter)
/* Take the mutex */
- printf("%s: Taking mutex\n", __FUNCTION__);
+ printf("thread_waiter: Taking mutex\n");
status = pthread_mutex_lock(&mutex);
if (status != 0)
{
- printf("%s: ERROR pthread_mutex_lock failed, status=%d\n", __FUNCTION__, status);
+ printf("thread_waiter: ERROR pthread_mutex_lock failed, status=%d\n", status);
}
- printf("%s: Starting wait for condition\n", __FUNCTION__);
+ printf("thread_waiter: Starting wait for condition\n");
/* Are we a non-cancelable thread? Yes, set the non-cancelable state */
if (!parameter)
{
- printf("%s: Setting non-cancelable\n", __FUNCTION__);
+ printf("thread_waiter: Setting non-cancelable\n");
status = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
if (status != 0)
{
- printf("%s: ERROR pthread_setcancelstate failed, status=%d\n", __FUNCTION__, status);
+ printf("thread_waiter: ERROR pthread_setcancelstate failed, status=%d\n", status);
}
}
@@ -74,28 +74,28 @@ static void *thread_waiter(void *parameter)
status = pthread_cond_wait(&cond, &mutex);
if (status != 0)
{
- printf("%s: ERROR pthread_cond_wait failed, status=%d\n", __FUNCTION__, status);
+ printf("thread_waiter: ERROR pthread_cond_wait failed, status=%d\n", status);
}
/* Release the mutex */
- printf("%s: Releasing mutex\n", __FUNCTION__);
+ printf("thread_waiter: Releasing mutex\n");
status = pthread_mutex_unlock(&mutex);
if (status != 0)
{
- printf("%s: ERROR pthread_mutex_unlock failed, status=%d\n", __FUNCTION__, status);
+ printf("thread_waiter: ERROR pthread_mutex_unlock failed, status=%d\n", status);
}
/* Set the cancelable state */
- printf("%s: Setting cancelable\n", __FUNCTION__);
+ printf("thread_waiter: Setting cancelable\n");
status = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
if (status != 0)
{
- printf("%s: ERROR pthread_setcancelstate failed, status=%d\n", __FUNCTION__, status);
+ printf("thread_waiter: ERROR pthread_setcancelstate failed, status=%d\n", status);
}
- printf("%s: Exit with status 0x12345678\n", __FUNCTION__);
+ printf("thread_waiter: Exit with status 0x12345678\n");
pthread_exit((void*)0x12345678);
return NULL;
}
@@ -107,20 +107,20 @@ static void start_thread(pthread_t *waiter, int cancelable)
/* Initialize the mutex */
- printf("%s: Initializing mutex\n", __FUNCTION__);
+ printf("start_thread: Initializing mutex\n");
status = pthread_mutex_init(&mutex, NULL);
if (status != 0)
{
- printf("%s: ERROR pthread_mutex_init failed, status=%d\n", __FUNCTION__, status);
+ printf("start_thread: ERROR pthread_mutex_init failed, status=%d\n", status);
}
/* Initialize the condition variable */
- printf("%s: Initializing cond\n", __FUNCTION__);
+ printf("start_thread: Initializing cond\n");
status = pthread_cond_init(&cond, NULL);
if (status != 0)
{
- printf("%s: ERROR pthread_cond_init failed, status=%d\n", __FUNCTION__, status);
+ printf("start_thread: ERROR pthread_cond_init failed, status=%d\n", status);
}
/* Set up attributes */
@@ -128,27 +128,27 @@ static void start_thread(pthread_t *waiter, int cancelable)
status = pthread_attr_init(&attr);
if (status != 0)
{
- printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status);
+ printf("start_thread: pthread_attr_init failed, status=%d\n", status);
}
status = pthread_attr_setstacksize(&attr, 16384);
if (status != 0)
{
- printf("%s: pthread_attr_setstacksize failed, status=%d\n", __FUNCTION__, status);
+ printf("start_thread: pthread_attr_setstacksize failed, status=%d\n", status);
}
/* Start the waiter thread */
- printf("%s: Starting thread\n", __FUNCTION__);
+ printf("start_thread: Starting thread\n");
status = pthread_create(waiter, NULL, thread_waiter, (void*)cancelable);
if (status != 0)
{
- printf("%s: ERROR pthread_create failed, status=%d\n", __FUNCTION__, status);
+ printf("start_thread: ERROR pthread_create failed, status=%d\n", status);
}
/* Make sure that the waiter thread gets a chance to run */
- printf("%s: Yielding\n", __FUNCTION__);
+ printf("start_thread: Yielding\n");
pthread_yield();
}
@@ -159,25 +159,25 @@ static void restart_thread(pthread_t *waiter, int cancelable)
/* Destroy the condition variable */
- printf("%s: Destroying cond\n", __FUNCTION__);
+ printf("restart_thread: Destroying cond\n");
status = pthread_cond_destroy(&cond);
if (status != 0)
{
- printf("%s: ERROR pthread_cond_destroy failed, status=%d\n", __FUNCTION__, status);
+ printf("restart_thread: ERROR pthread_cond_destroy failed, status=%d\n", status);
}
/* Destroy the mutex */
- printf("%s: Destroying mutex\n", __FUNCTION__);
+ printf("restart_thread: Destroying mutex\n");
status = pthread_cond_destroy(&cond);
if (status != 0)
{
- printf("%s: ERROR pthread_mutex_destroy failed, status=%d\n", __FUNCTION__, status);
+ printf("restart_thread: ERROR pthread_mutex_destroy failed, status=%d\n", status);
}
/* Then restart the thread */
- printf("%s: Re-starting thread\n", __FUNCTION__);
+ printf("restart_thread: Re-starting thread\n");
start_thread(waiter, cancelable);
}
@@ -190,44 +190,44 @@ void cancel_test(void)
/* Test 1: Normal Cancel *********************************************/
/* Start the waiter thread */
- printf("%s: Test 1: Normal Cancelation\n", __FUNCTION__);
- printf("%s: Starting thread\n", __FUNCTION__);
+ printf("cancel_test: Test 1: Normal Cancelation\n");
+ printf("cancel_test: Starting thread\n");
start_thread(&waiter, 1);
/* Then cancel it. It should be in the pthread_cond_wait now */
- printf("%s: Canceling thread\n", __FUNCTION__);
+ printf("cancel_test: Canceling thread\n");
status = pthread_cancel(waiter);
if (status != 0)
{
- printf("%s: ERROR pthread_cancel failed, status=%d\n", __FUNCTION__, status);
+ printf("cancel_test: ERROR pthread_cancel failed, status=%d\n", status);
}
/* Then join to the thread to pick up the result */
- printf("%s: Joining\n", __FUNCTION__);
+ printf("cancel_test: Joining\n");
status = pthread_join(waiter, &result);
if (status != 0)
{
- printf("%s: ERROR pthread_join failed, status=%d\n", __FUNCTION__, status);
+ printf("cancel_test: ERROR pthread_join failed, status=%d\n", status);
}
else
{
- printf("%s: waiter exited with result=%p\n", __FUNCTION__, result);
+ printf("cancel_test: waiter exited with result=%p\n", result);
if (result != PTHREAD_CANCELED)
{
- printf("%s: ERROR expected result=%p\n", __FUNCTION__, PTHREAD_CANCELED);
+ printf("cancel_test: ERROR expected result=%p\n", PTHREAD_CANCELED);
}
else
{
- printf("%s: PASS thread terminated with PTHREAD_CANCELED\n", __FUNCTION__);
+ printf("cancel_test: PASS thread terminated with PTHREAD_CANCELED\n");
}
}
/* Test 2: Cancel Detached Thread ************************************/
- printf("%s: Test 2: Cancelation of detached thread\n", __FUNCTION__);
- printf("%s: Re-starting thread\n", __FUNCTION__);
+ printf("cancel_test: Test 2: Cancelation of detached thread\n");
+ printf("cancel_test: Re-starting thread\n");
restart_thread(&waiter, 1);
/* Detach the thread */
@@ -235,39 +235,39 @@ void cancel_test(void)
status = pthread_detach(waiter);
if (status != 0)
{
- printf("%s: ERROR pthread_detach, status=%d\n", __FUNCTION__, status);
+ printf("cancel_test: ERROR pthread_detach, status=%d\n", status);
}
/* Then cancel it. It should be in the pthread_cond_wait now */
- printf("%s: Canceling thread\n", __FUNCTION__);
+ printf("cancel_test: Canceling thread\n");
status = pthread_cancel(waiter);
if (status != 0)
{
- printf("%s: ERROR pthread_cancel failed, status=%d\n", __FUNCTION__, status);
+ printf("cancel_test: ERROR pthread_cancel failed, status=%d\n", status);
}
/* Join should now fail */
- printf("%s: Joining\n", __FUNCTION__);
+ printf("cancel_test: Joining\n");
status = pthread_join(waiter, &result);
if (status == 0)
{
- printf("%s: ERROR pthread_join succeeded\n", __FUNCTION__);
+ printf("cancel_test: ERROR pthread_join succeeded\n");
}
else if (status != ESRCH)
{
- printf("%s: ERROR pthread_join failed but with wrong status=%d\n", __FUNCTION__, status);
+ printf("cancel_test: ERROR pthread_join failed but with wrong status=%d\n", status);
}
else
{
- printf("%s: PASS pthread_join failed with status=ESRCH\n", __FUNCTION__);
+ printf("cancel_test: PASS pthread_join failed with status=ESRCH\n");
}
/* Test 3: Non-cancelable threads ************************************/
- printf("%s: Test 3: Non-cancelable threads\n", __FUNCTION__);
- printf("%s: Re-starting thread (non-cancelable)\n", __FUNCTION__);
+ printf("cancel_test: Test 3: Non-cancelable threads\n");
+ printf("cancel_test: Re-starting thread (non-cancelable)\n");
restart_thread(&waiter, 0);
/* Then cancel it. It should be in the pthread_cond_wait now. The
@@ -277,11 +277,11 @@ void cancel_test(void)
* The cancelation should succeed, because the cancelation is pending.
*/
- printf("%s: Canceling thread\n", __FUNCTION__);
+ printf("cancel_test: Canceling thread\n");
status = pthread_cancel(waiter);
if (status != 0)
{
- printf("%s: ERROR pthread_cancel failed, status=%d\n", __FUNCTION__, status);
+ printf("cancel_test: ERROR pthread_cancel failed, status=%d\n", status);
}
/* Signal the thread. It should wake up an restore the cancelable state.
@@ -291,18 +291,18 @@ void cancel_test(void)
status = pthread_mutex_lock(&mutex);
if (status != 0)
{
- printf("%s: ERROR pthread_mutex_lock failed, status=%d\n", __FUNCTION__, status);
+ printf("cancel_test: ERROR pthread_mutex_lock failed, status=%d\n", status);
}
status = pthread_cond_signal(&cond);
if (status != 0)
{
- printf("%s: ERROR pthread_cond_signal failed, status=%d\n", __FUNCTION__, status);
+ printf("cancel_test: ERROR pthread_cond_signal failed, status=%d\n", status);
}
status = pthread_mutex_unlock(&mutex);
if (status != 0)
{
- printf("%s: ERROR pthread_mutex_unlock failed, status=%d\n", __FUNCTION__, status);
+ printf("cancel_test: ERROR pthread_mutex_unlock failed, status=%d\n", status);
}
}
diff --git a/nuttx/examples/ostest/cond.c b/nuttx/examples/ostest/cond.c
index be995fa08..13e7b4669 100644
--- a/nuttx/examples/ostest/cond.c
+++ b/nuttx/examples/ostest/cond.c
@@ -59,7 +59,7 @@ static void *thread_waiter(void *parameter)
{
int status;
- printf("%s: Started\n", __FUNCTION__);
+ printf("waiter_thread: Started\n");
for(;;)
{
@@ -71,7 +71,7 @@ static void *thread_waiter(void *parameter)
if (status != 0)
{
- printf("%s: ERROR pthread_mutex_lock failed, status=%d\n", __FUNCTION__, status);
+ printf("waiter_thread: ERROR pthread_mutex_lock failed, status=%d\n", status);
waiter_nerrors++;
}
@@ -94,7 +94,7 @@ static void *thread_waiter(void *parameter)
if (status != 0)
{
- printf("%s: ERROR pthread_cond_wait failed, status=%d\n", __FUNCTION__, status);
+ printf("waiter_thread: ERROR pthread_cond_wait failed, status=%d\n", status);
waiter_nerrors++;
}
waiter_waits++;
@@ -104,7 +104,7 @@ static void *thread_waiter(void *parameter)
if (!data_available)
{
- printf("%s: ERROR data not available after wait\n", __FUNCTION__);
+ printf("waiter_thread: ERROR data not available after wait\n");
waiter_nerrors++;
}
@@ -117,7 +117,7 @@ static void *thread_waiter(void *parameter)
status = pthread_mutex_unlock(&mutex);
if (status != 0)
{
- printf("%s: ERROR waiter: pthread_mutex_unlock failed, status=%d\n", __FUNCTION__, status);
+ printf("waiter_thread: ERROR waiter: pthread_mutex_unlock failed, status=%d\n", status);
waiter_nerrors++;
}
@@ -130,7 +130,7 @@ static void *thread_signaler(void *parameter)
int status;
int i;
- printf("%s: Started\n", __FUNCTION__);
+ printf("thread_signaler: Started\n");
for (i = 0; i < 32; i++)
{
/* Take the mutex. The waiter is higher priority and should
@@ -141,7 +141,7 @@ static void *thread_signaler(void *parameter)
status = pthread_mutex_lock(&mutex);
if (status != 0)
{
- printf("%s: ERROR pthread_mutex_lock failed, status=%d\n", __FUNCTION__, status);
+ printf("thread_signaler: ERROR pthread_mutex_lock failed, status=%d\n", status);
signaler_nerrors++;
}
@@ -149,13 +149,13 @@ static void *thread_signaler(void *parameter)
if (waiter_state != COND_WAIT)
{
- printf("%s: ERROR waiter state = %d != COND_WAITING\n", __FUNCTION__, waiter_state);
+ printf("thread_signaler: ERROR waiter state = %d != COND_WAITING\n", waiter_state);
signaler_state++;
}
if (data_available)
{
- printf("%s: ERROR data already available, waiter_state=%d\n", __FUNCTION__, waiter_state);
+ printf("thread_signaler: ERROR data already available, waiter_state=%d\n", waiter_state);
signaler_already++;
}
@@ -165,7 +165,7 @@ static void *thread_signaler(void *parameter)
status = pthread_cond_signal(&cond);
if (status != 0)
{
- printf("%s: ERROR pthread_cond_signal failed, status=%d\n", __FUNCTION__, status);
+ printf("thread_signaler: ERROR pthread_cond_signal failed, status=%d\n", status);
signaler_nerrors++;
}
@@ -174,14 +174,14 @@ static void *thread_signaler(void *parameter)
status = pthread_mutex_unlock(&mutex);
if (status != 0)
{
- printf("%s: ERROR pthread_mutex_unlock failed, status=%d\n", __FUNCTION__, status);
+ printf("thread_signaler: ERROR pthread_mutex_unlock failed, status=%d\n", status);
signaler_nerrors++;
}
signaler_nloops++;
}
- printf("%s: Terminating\n", __FUNCTION__);
+ printf("thread_signaler: Terminating\n");
pthread_exit(NULL);
}
@@ -198,29 +198,29 @@ void cond_test(void)
/* Initialize the mutex */
- printf("%s: Initializing mutex\n", __FUNCTION__);
+ printf("cond_test: Initializing mutex\n");
status = pthread_mutex_init(&mutex, NULL);
if (status != 0)
{
- printf("%s: ERROR pthread_mutex_init failed, status=%d\n", __FUNCTION__, status);
+ printf("cond_test: ERROR pthread_mutex_init failed, status=%d\n", status);
}
/* Initialize the condition variable */
- printf("%s: Initializing cond\n", __FUNCTION__);
+ printf("cond_test: Initializing cond\n");
status = pthread_cond_init(&cond, NULL);
if (status != 0)
{
- printf("%s: ERROR pthread_condinit failed, status=%d\n", __FUNCTION__, status);
+ printf("cond_test: ERROR pthread_condinit failed, status=%d\n", status);
}
/* Start the waiter thread at higher priority */
- printf("%s: Starting waiter\n", __FUNCTION__);
+ printf("cond_test: Starting waiter\n");
status = pthread_attr_init(&attr);
if (status != 0)
{
- printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status);
+ printf("cond_test: pthread_attr_init failed, status=%d\n", status);
}
prio_min = sched_get_priority_min(SCHED_FIFO);
@@ -231,54 +231,54 @@ void cond_test(void)
status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK)
{
- printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status);
+ printf("cond_test: pthread_attr_setschedparam failed, status=%d\n", status);
}
else
{
- printf("%s: Set thread 1 priority to %d\n", __FUNCTION__, sparam.sched_priority);
+ printf("cond_test: Set thread 1 priority to %d\n", sparam.sched_priority);
}
status = pthread_create(&waiter, &attr, thread_waiter, NULL);
if (status != 0)
{
- printf("%s: pthread_create failed, status=%d\n", __FUNCTION__, status);
+ printf("cond_test: pthread_create failed, status=%d\n", status);
}
- printf("%s: Starting signaler\n", __FUNCTION__);
+ printf("cond_test: Starting signaler\n");
status = pthread_attr_init(&attr);
if (status != 0)
{
- printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status);
+ printf("cond_test: pthread_attr_init failed, status=%d\n", status);
}
sparam.sched_priority = (prio_min + prio_mid) / 2;
status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK)
{
- printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status);
+ printf("cond_test: pthread_attr_setschedparam failed, status=%d\n", status);
}
else
{
- printf("%s: Set thread 2 priority to %d\n", __FUNCTION__, sparam.sched_priority);
+ printf("cond_test: Set thread 2 priority to %d\n", sparam.sched_priority);
}
status = pthread_create(&signaler, &attr, thread_signaler, NULL);
if (status != 0)
{
- printf("%s: pthread_create failed, status=%d\n", __FUNCTION__, status);
+ printf("cond_test: pthread_create failed, status=%d\n", status);
}
/* Wait for the threads to stop */
pthread_join(signaler, NULL);
- printf("%s: signaler terminated, now cancel the waiter\n", __FUNCTION__);
+ printf("cond_test: signaler terminated, now cancel the waiter\n");
pthread_detach(waiter);
pthread_cancel(waiter);
- printf("%s: \tWaiter\tSignaler\n", __FUNCTION__);
- printf("%s: Loops\t%d\t%d\n", __FUNCTION__, waiter_nloops, signaler_nloops);
- printf("%s: Errors\t%d\t%d\n", __FUNCTION__, waiter_nerrors, signaler_nerrors);
- printf("%s: \n%d times, waiter did not have to wait for data\n", __FUNCTION__, waiter_nloops - waiter_waits);
- printf("%s: %d times, data was already available when the signaler run\n", __FUNCTION__, signaler_already);
- printf("%s: %d times, the waiter was in an unexpected state when the signaler ran\n", __FUNCTION__, signaler_state);
+ printf("cond_test: \tWaiter\tSignaler\n");
+ printf("cond_test: Loops\t%d\t%d\n", waiter_nloops, signaler_nloops);
+ printf("cond_test: Errors\t%d\t%d\n", waiter_nerrors, signaler_nerrors);
+ printf("cond_test: \n%d times, waiter did not have to wait for data\n", waiter_nloops - waiter_waits);
+ printf("cond_test: %d times, data was already available when the signaler run\n", signaler_already);
+ printf("cond_test: %d times, the waiter was in an unexpected state when the signaler ran\n", signaler_state);
}
diff --git a/nuttx/examples/ostest/dev_null.c b/nuttx/examples/ostest/dev_null.c
index 11d6056c8..f9ca5623a 100644
--- a/nuttx/examples/ostest/dev_null.c
+++ b/nuttx/examples/ostest/dev_null.c
@@ -64,27 +64,27 @@ int dev_null(void)
fd = open("/dev/null", O_RDWR);
if (fd < 0)
{
- fprintf(stderr, "%s: Failed to open /dev/null\n", __FUNCTION__);
+ fprintf(stderr, "dev_null: Failed to open /dev/null\n");
return -1;
}
nbytes = read(fd, buffer, 1024);
if (nbytes < 0)
{
- fprintf(stderr, "%s: Failed to read from /dev/null\n", __FUNCTION__);
+ fprintf(stderr, "dev_null: Failed to read from /dev/null\n");
close(fd);
return -1;
}
- printf("%s: Read %d bytes from /dev/null\n", __FUNCTION__, nbytes);
+ printf("dev_null: Read %d bytes from /dev/null\n", nbytes);
nbytes = write(fd, buffer, 1024);
if (nbytes < 0)
{
- fprintf(stderr, "%s: Failed to write to /dev/null\n", __FUNCTION__);
+ fprintf(stderr, "dev_null: Failed to write to /dev/null\n");
close(fd);
return -1;
}
- printf("%s: Wrote %d bytes to /dev/null\n", __FUNCTION__, nbytes);
+ printf("dev_null: Wrote %d bytes to /dev/null\n", nbytes);
close(fd);
return 0;
diff --git a/nuttx/examples/ostest/main.c b/nuttx/examples/ostest/main.c
index f6c0c65ca..3122ef343 100644
--- a/nuttx/examples/ostest/main.c
+++ b/nuttx/examples/ostest/main.c
@@ -76,27 +76,27 @@ static int user_main(int argc, char *argv[])
{
int i;
- printf("%s: Started with argc=%d\n", __FUNCTION__, argc);
+ printf("user_main: Started with argc=%d\n", argc);
/* Verify passed arguments */
if (argc != NARGS + 1)
{
- fprintf(stderr, "%s: Error expected argc=%d got argc=%d\n",
- __FUNCTION__, NARGS+1, argc);
+ fprintf(stderr, "user_main: Error expected argc=%d got argc=%d\n",
+ NARGS+1, argc);
}
for (i = 0; i <= NARGS; i++)
{
- printf("%s: argv[%d]=\"%s\"\n", __FUNCTION__, i, argv[i]);
+ printf("user_main: argv[%d]=\"%s\"\n", i, argv[i]);
}
for (i = 1; i <= NARGS; i++)
{
if (strcmp(argv[i], args[i-1]) != 0)
{
- fprintf(stderr, "%s: ERROR argv[%d]: Expected \"%s\" found \"%s\"\n",
- __FUNCTION__, i, argv[i], args[i-1]);
+ fprintf(stderr, "user_main: ERROR argv[%d]: Expected \"%s\" found \"%s\"\n",
+ i, argv[i], args[i-1]);
}
}
@@ -158,9 +158,9 @@ int user_start(int parm1, int parm2, int parm3, int parm4)
/* Verify that we can communicate */
write(1, write_data1, sizeof(write_data1));
- printf("%s: Standard I/O Check: printf\n", __FUNCTION__);
+ printf("user_start: Standard I/O Check: printf\n");
write(2, write_data2, sizeof(write_data2));
- fprintf(stderr, "%s: Standard I/O Check: fprintf to stderr\n", __FUNCTION__);
+ fprintf(stderr, "user_start: Standard I/O Check: fprintf to stderr\n");
/* Verify that we can spawn a new task */
@@ -168,11 +168,11 @@ int user_start(int parm1, int parm2, int parm3, int parm4)
ARG1, ARG2, ARG3, ARG4);
if (result == ERROR)
{
- fprintf(stderr, "%s: Failed to start user_main\n", __FUNCTION__);
+ fprintf(stderr, "user_start: Failed to start user_main\n");
}
else
{
- printf("%s: Started user_main at PID=%d\n", __FUNCTION__, result);
+ printf("user_start: Started user_main at PID=%d\n", result);
}
return 0;
}
diff --git a/nuttx/examples/ostest/mqueue.c b/nuttx/examples/ostest/mqueue.c
index f9e6b6e03..acdbea99e 100644
--- a/nuttx/examples/ostest/mqueue.c
+++ b/nuttx/examples/ostest/mqueue.c
@@ -85,7 +85,7 @@ static void *sender_thread(void *arg)
int nerrors = 0;
int i;
- printf("%s: Starting\n", __FUNCTION__);
+ printf("sender_thread: Starting\n");
/* Fill in attributes for message queue */
@@ -107,7 +107,7 @@ static void *sender_thread(void *arg)
mqfd = mq_open("testmq", O_WRONLY|O_CREAT, 0666, &attr);
if (mqfd < 0)
{
- printf("%s: ERROR mq_open failed\n", __FUNCTION__);
+ printf("sender_thread: ERROR mq_open failed\n");
pthread_exit((void*)1);
}
@@ -122,12 +122,12 @@ static void *sender_thread(void *arg)
status = mq_send(mqfd, msg_buffer, TEST_MSGLEN, 42);
if (status < 0)
{
- printf("%s: ERROR mq_send failure=%d on msg %d\n", __FUNCTION__, status, i);
+ printf("sender_thread: ERROR mq_send failure=%d on msg %d\n", status, i);
nerrors++;
}
else
{
- printf("%s: mq_send succeeded on msg %d\n", __FUNCTION__, i);
+ printf("sender_thread: mq_send succeeded on msg %d\n", i);
}
}
@@ -135,10 +135,10 @@ static void *sender_thread(void *arg)
if (mq_close(mqfd) < 0)
{
- printf("%s: ERROR mq_close failed\n", __FUNCTION__);
+ printf("sender_thread: ERROR mq_close failed\n");
}
- printf("%s: returning nerrors=%d\n", __FUNCTION__, nerrors);
+ printf("sender_thread: returning nerrors=%d\n", nerrors);
return (void*)nerrors;
}
@@ -151,7 +151,7 @@ static void *receiver_thread(void *arg)
int nerrors = 0;
int i;
- printf("%s: Starting\n", __FUNCTION__);
+ printf("receiver_thread: Starting\n");
/* Fill in attributes for message queue */
@@ -173,7 +173,7 @@ static void *receiver_thread(void *arg)
mqfd = mq_open("testmq", O_RDONLY|O_CREAT, 0666, &attr);
if (mqfd < 0)
{
- printf("%s: ERROR mq_open failed\n", __FUNCTION__);
+ printf("receiver_thread: ERROR mq_open failed\n");
pthread_exit((void*)1);
}
@@ -184,33 +184,32 @@ static void *receiver_thread(void *arg)
nbytes = mq_receive(mqfd, msg_buffer, TEST_MSGLEN, 0);
if (nbytes < 0)
{
- printf("%s: ERROR mq_receive failure on msg %d\n", __FUNCTION__, i);
+ printf("receiver_thread: ERROR mq_receive failure on msg %d\n", i);
nerrors++;
}
else if (nbytes != TEST_MSGLEN)
{
- printf("%s: mq_receive return bad size %d on msg %d\n", __FUNCTION__, nbytes, i);
+ printf("receiver_thread: mq_receive return bad size %d on msg %d\n", nbytes, i);
nerrors++;
}
else if (memcmp(TEST_MESSAGE, msg_buffer, nbytes) != 0)
{
int j;
- printf("%s: mq_receive returned corrupt message on msg %d\n", __FUNCTION__, i);
- printf("%s: i Expected Received\n", __FUNCTION__);
+ printf("receiver_thread: mq_receive returned corrupt message on msg %d\n", i);
+ printf("receiver_thread: i Expected Received\n");
for (j = 0; j < TEST_MSGLEN-1; j++)
{
- printf("%s: %2d %02x (%c) %02x\n",
- __FUNCTION__,
+ printf("receiver_thread: %2d %02x (%c) %02x\n",
j, TEST_MESSAGE[j], TEST_MESSAGE[j], msg_buffer[j] & 0x0ff);
}
- printf("%s: %2d 00 %02x\n",
- __FUNCTION__, j, msg_buffer[j] & 0xff);
+ printf("receiver_thread: %2d 00 %02x\n",
+ j, msg_buffer[j] & 0xff);
}
else
{
- printf("%s: mq_receive succeeded on msg %d\n", __FUNCTION__, i);
+ printf("receiver_thread: mq_receive succeeded on msg %d\n", i);
}
}
@@ -218,7 +217,7 @@ static void *receiver_thread(void *arg)
if (mq_close(mqfd) < 0)
{
- printf("%s: ERROR mq_close failed\n", __FUNCTION__);
+ printf("receiver_thread: ERROR mq_close failed\n");
nerrors++;
}
@@ -228,11 +227,11 @@ static void *receiver_thread(void *arg)
if (mq_unlink("testmq") < 0)
{
- printf("%s: ERROR mq_close failed\n", __FUNCTION__);
+ printf("receiver_thread: ERROR mq_close failed\n");
nerrors++;
}
- printf("%s: returning nerrors=%d\n", __FUNCTION__, nerrors);
+ printf("receiver_thread: returning nerrors=%d\n", nerrors);
return (void*)nerrors;
}
@@ -250,17 +249,17 @@ void mqueue_test(void)
/* Start the sending thread at higher priority */
- printf("%s: Starting receiver\n", __FUNCTION__);
+ printf("mqueue_test: Starting receiver\n");
status = pthread_attr_init(&attr);
if (status != 0)
{
- printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status);
+ printf("mqueue_test: pthread_attr_init failed, status=%d\n", status);
}
status = pthread_attr_setstacksize(&attr, 16384);
if (status != 0)
{
- printf("%s: pthread_attr_setstacksize failed, status=%d\n", __FUNCTION__, status);
+ printf("mqueue_test: pthread_attr_setstacksize failed, status=%d\n", status);
}
prio_min = sched_get_priority_min(SCHED_FIFO);
@@ -271,62 +270,62 @@ void mqueue_test(void)
status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK)
{
- printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status);
+ printf("mqueue_test: pthread_attr_setschedparam failed, status=%d\n", status);
}
else
{
- printf("%s: Set receiver priority to %d\n", __FUNCTION__, sparam.sched_priority);
+ printf("mqueue_test: Set receiver priority to %d\n", sparam.sched_priority);
}
status = pthread_create(&receiver, &attr, receiver_thread, NULL);
if (status != 0)
{
- printf("%s: pthread_create failed, status=%d\n", __FUNCTION__, status);
+ printf("mqueue_test: pthread_create failed, status=%d\n", status);
}
/* Start the sending thread at lower priority */
- printf("%s: Starting sender\n", __FUNCTION__);
+ printf("mqueue_test: Starting sender\n");
status = pthread_attr_init(&attr);
if (status != 0)
{
- printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status);
+ printf("mqueue_test: pthread_attr_init failed, status=%d\n", status);
}
status = pthread_attr_setstacksize(&attr, 16384);
if (status != 0)
{
- printf("%s: pthread_attr_setstacksize failed, status=%d\n", __FUNCTION__, status);
+ printf("mqueue_test: pthread_attr_setstacksize failed, status=%d\n", status);
}
sparam.sched_priority = (prio_min + prio_mid) / 2;
status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK)
{
- printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status);
+ printf("mqueue_test: pthread_attr_setschedparam failed, status=%d\n", status);
}
else
{
- printf("%s: Set sender thread priority to %d\n", __FUNCTION__, sparam.sched_priority);
+ printf("mqueue_test: Set sender thread priority to %d\n", sparam.sched_priority);
}
status = pthread_create(&sender, &attr, sender_thread, NULL);
if (status != 0)
{
- printf("%s: pthread_create failed, status=%d\n", __FUNCTION__, status);
+ printf("mqueue_test: pthread_create failed, status=%d\n", status);
}
pthread_join(sender, &result);
if (result != (void*)0)
{
- printf("%s: ERROR sender thread exited with %d errors\n", __FUNCTION__, (int)result);
+ printf("mqueue_test: ERROR sender thread exited with %d errors\n", (int)result);
}
pthread_cancel(receiver);
pthread_join(receiver, &result);
if (result != (void*)0)
{
- printf("%s: ERROR receiver thread exited with %d errors\n", __FUNCTION__, (int)result);
+ printf("mqueue_test: ERROR receiver thread exited with %d errors\n", (int)result);
}
}
diff --git a/nuttx/examples/ostest/mutex.c b/nuttx/examples/ostest/mutex.c
index d6cad9e39..cb8996053 100644
--- a/nuttx/examples/ostest/mutex.c
+++ b/nuttx/examples/ostest/mutex.c
@@ -60,14 +60,14 @@ static void *thread_func(void *parameter)
if (status != 0)
{
printf("ERROR thread %d: pthread_mutex_lock failed, status=%d\n",
- id, status);
+ id, status);
}
if (my_mutex == 1)
{
printf("ERROR thread=%d: "
- "my_mutex should be zero, instead my_mutex=%d\n",
- id, my_mutex);
+ "my_mutex should be zero, instead my_mutex=%d\n",
+ id, my_mutex);
nerrors[ndx]++;
}
@@ -82,7 +82,7 @@ static void *thread_func(void *parameter)
if (status != 0)
{
printf("ERROR thread %d: pthread_mutex_unlock failed, status=%d\n",
- id, status);
+ id, status);
}
}
pthread_exit(NULL);
@@ -114,7 +114,7 @@ void mutex_test(void)
pthread_join(thread1, NULL);
pthread_join(thread2, NULL);
- printf("%s:\t\tThread1\tThread2\n", __FUNCTION__);
- printf("%s:\tLoops\t%ld\t%ld\n", __FUNCTION__, nloops[0], nloops[1]);
- printf("%s:\tErrors\t%ld\t%ld\n", __FUNCTION__, nerrors[0], nerrors[1]);
+ printf("\t\tThread1\tThread2\n");
+ printf("\tLoops\t%ld\t%ld\n", nloops[0], nloops[1]);
+ printf("\tErrors\t%ld\t%ld\n", nerrors[0], nerrors[1]);
}
diff --git a/nuttx/examples/ostest/ostest.h b/nuttx/examples/ostest/ostest.h
index 3871ecc67..8d567cb37 100644
--- a/nuttx/examples/ostest/ostest.h
+++ b/nuttx/examples/ostest/ostest.h
@@ -88,4 +88,8 @@ extern void cancel_test(void);
extern void timedwait_test(void);
+/* sighand.c ************************************************/
+
+extern void sighand_test(void);
+
#endif /* __OSTEST_H */
diff --git a/nuttx/examples/ostest/sem.c b/nuttx/examples/ostest/sem.c
index 0b532982d..73be6910e 100644
--- a/nuttx/examples/ostest/sem.c
+++ b/nuttx/examples/ostest/sem.c
@@ -52,39 +52,39 @@ static void *waiter_func(void *parameter)
int status;
int value;
- printf("%s: Thread %d Started\n", __FUNCTION__, id);
+ printf("waiter_func: Thread %d Started\n", id);
/* Take the semaphore */
status = sem_getvalue(&sem, &value);
if (status < 0)
{
- printf("%s: ERROR thread %d could not get semaphore value\n", __FUNCTION__, id);
+ printf("waiter_func: ERROR thread %d could not get semaphore value\n", id);
}
else
{
- printf("%s: Thread %d initial semaphore value = %d\n", __FUNCTION__, id, value);
+ printf("waiter_func: Thread %d initial semaphore value = %d\n", id, value);
}
- printf("%s: Thread %d aiting on semaphore\n", __FUNCTION__, id);
+ printf("waiter_func: Thread %d aiting on semaphore\n", id);
status = sem_wait(&sem);
if (status != 0)
{
- printf("%s: ERROR thread %d sem_wait failed\n", __FUNCTION__, id);
+ printf("waiter_func: ERROR thread %d sem_wait failed\n", id);
}
- printf("%s: Thread %d awakened\n", __FUNCTION__, id);
+ printf("waiter_func: Thread %d awakened\n", id);
status = sem_getvalue(&sem, &value);
if (status < 0)
{
- printf("%s: ERROR thread %d could not get semaphore value\n", __FUNCTION__, id);
+ printf("waiter_func: ERROR thread %d could not get semaphore value\n", id);
}
else
{
- printf("%s: Thread %d new semaphore value = %d\n", __FUNCTION__, id, value);
+ printf("waiter_func: Thread %d new semaphore value = %d\n", id, value);
}
- printf("%s: Thread %d done\n", __FUNCTION__, id);
+ printf("waiter_func: Thread %d done\n", id);
return NULL;
}
@@ -94,7 +94,7 @@ static void *poster_func(void *parameter)
int status;
int value;
- printf("%s: Thread %d started\n", __FUNCTION__, id);
+ printf("poster_func: Thread %d started\n", id);
/* Take the semaphore */
@@ -103,20 +103,20 @@ static void *poster_func(void *parameter)
status = sem_getvalue(&sem, &value);
if (status < 0)
{
- printf("%s: ERROR thread %d could not get semaphore value\n", __FUNCTION__, id);
+ printf("poster_func: ERROR thread %d could not get semaphore value\n", id);
}
else
{
- printf("%s: Thread %d semaphore value = %d\n", __FUNCTION__, id, value);
+ printf("poster_func: Thread %d semaphore value = %d\n", id, value);
}
if (value < 0)
{
- printf("%s: Thread %d posting semaphore\n", __FUNCTION__, id);
+ printf("poster_func: Thread %d posting semaphore\n", id);
status = sem_post(&sem);
if (status != 0)
{
- printf("%s: ERROR thread %d sem_wait failed\n", __FUNCTION__, id);
+ printf("poster_func: ERROR thread %d sem_wait failed\n", id);
}
pthread_yield();
@@ -124,17 +124,17 @@ static void *poster_func(void *parameter)
status = sem_getvalue(&sem, &value);
if (status < 0)
{
- printf("%s: ERROR thread %d could not get semaphore value\n", __FUNCTION__, id);
+ printf("poster_func: ERROR thread %d could not get semaphore value\n", id);
}
else
{
- printf("%s: Thread %d new semaphore value = %d\n", __FUNCTION__, id, value);
+ printf("poster_func: Thread %d new semaphore value = %d\n", id, value);
}
}
}
while (value < 0);
- printf("%s: Thread %d done\n", __FUNCTION__, id);
+ printf("poster_func: Thread %d done\n", id);
return NULL;
}
@@ -151,16 +151,16 @@ void sem_test(void)
pthread_attr_t attr;
int status;
- printf("%s: Initializing semaphore to 0\n", __FUNCTION__);
+ printf("sem_test: Initializing semaphore to 0\n");
sem_init(&sem, 0, 0);
/* Start two waiter thread instances */
- printf("%s: Starting waiter thread 1\n", __FUNCTION__);
+ printf("sem_test: Starting waiter thread 1\n");
status = pthread_attr_init(&attr);
if (status != OK)
{
- printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status);
+ printf("sem_test: pthread_attr_init failed, status=%d\n", status);
}
prio_min = sched_get_priority_min(SCHED_FIFO);
@@ -171,65 +171,65 @@ void sem_test(void)
status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK)
{
- printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status);
+ printf("sem_test: pthread_attr_setschedparam failed, status=%d\n", status);
}
else
{
- printf("%s: Set thread 1 priority to %d\n", __FUNCTION__, sparam.sched_priority);
+ printf("sem_test: Set thread 1 priority to %d\n", sparam.sched_priority);
}
status = pthread_create(&waiter_thread1, &attr, waiter_func, (void*)1);
if (status != 0)
{
- printf("%s: Error in thread 1 creation, status=%d\n", __FUNCTION__, status);
+ printf("sem_test: Error in thread 1 creation, status=%d\n", status);
}
- printf("%s: Starting waiter thread 2\n", __FUNCTION__);
+ printf("sem_test: Starting waiter thread 2\n");
status = pthread_attr_init(&attr);
if (status != 0)
{
- printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status);
+ printf("sem_test: pthread_attr_init failed, status=%d\n", status);
}
sparam.sched_priority = prio_mid;
status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK)
{
- printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status);
+ printf("sem_test: pthread_attr_setschedparam failed, status=%d\n", status);
}
else
{
- printf("%s: Set thread 2 priority to %d\n", __FUNCTION__, sparam.sched_priority);
+ printf("sem_test: Set thread 2 priority to %d\n", sparam.sched_priority);
}
status = pthread_create(&waiter_thread2, &attr, waiter_func, (void*)2);
if (status != 0)
{
- printf("%s: Error in thread 2 creation, status=%d\n", __FUNCTION__, status);
+ printf("sem_test: Error in thread 2 creation, status=%d\n", status);
}
- printf("%s: Starting poster thread 3\n", __FUNCTION__);
+ printf("sem_test: Starting poster thread 3\n");
status = pthread_attr_init(&attr);
if (status != 0)
{
- printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status);
+ printf("sem_test: pthread_attr_init failed, status=%d\n", status);
}
sparam.sched_priority = (prio_min + prio_mid) / 2;
status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK)
{
- printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status);
+ printf("sem_test: pthread_attr_setschedparam failed, status=%d\n", status);
}
else
{
- printf("%s: Set thread 3 priority to %d\n", __FUNCTION__, sparam.sched_priority);
+ printf("sem_test: Set thread 3 priority to %d\n", sparam.sched_priority);
}
status = pthread_create(&poster_thread, &attr, poster_func, (void*)3);
if (status != 0)
{
- printf("%s: Error in thread 3 creation, status=%d\n", __FUNCTION__, status);
+ printf("sem_test: Error in thread 3 creation, status=%d\n", status);
}
pthread_join(waiter_thread1, NULL);
diff --git a/nuttx/examples/ostest/sighand.c b/nuttx/examples/ostest/sighand.c
index 9ffd166f4..ada7d8836 100644
--- a/nuttx/examples/ostest/sighand.c
+++ b/nuttx/examples/ostest/sighand.c
@@ -60,7 +60,7 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext)
sigset_t allsigs;
int status;
- printf("%s: Received signal %d\n", __FUNCTION__, signo);
+ printf("wakeup_action: Received signal %d\n" , signo);
sigreceived = TRUE;
@@ -68,32 +68,32 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext)
if (signo != WAKEUP_SIGNAL)
{
- printf("%s: ERROR expected signo=%d\n", __FUNCTION__, WAKEUP_SIGNAL);
+ printf("wakeup_action: ERROR expected signo=%d\n" , WAKEUP_SIGNAL);
}
/* Check siginfo */
if (info->si_value.sival_int != SIGVALUE_INT)
{
- printf("%s: ERROR sival_int=%d expected %d\n",
- __FUNCTION__, info->si_value.sival_int, SIGVALUE_INT);
+ printf("wakeup_action: ERROR sival_int=%d expected %d\n",
+ info->si_value.sival_int, SIGVALUE_INT);
}
else
{
- printf("%s: sival_int=%d\n", __FUNCTION__, info->si_value.sival_int);
+ printf("wakeup_action: sival_int=%d\n" , info->si_value.sival_int);
}
if (info->si_signo != WAKEUP_SIGNAL)
{
- printf("%s: ERROR expected si_signo=%d, got=%d\n",
- __FUNCTION__, WAKEUP_SIGNAL, info->si_signo);
+ printf("wakeup_action: ERROR expected si_signo=%d, got=%d\n",
+ WAKEUP_SIGNAL, info->si_signo);
}
- printf("%s: si_code=%d\n", __FUNCTION__, info->si_code);
+ printf("wakeup_action: si_code=%d\n" , info->si_code);
/* Check ucontext_t */
- printf("%s: ucontext=%p\n", __FUNCTION__, ucontext);
+ printf("wakeup_action: ucontext=%p\n" , ucontext);
/* Check sigprocmask */
@@ -101,14 +101,14 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext)
status = sigprocmask(SIG_SETMASK, NULL, &oldset);
if (status != OK)
{
- printf("%s: ERROR sigprocmask failed, status=%d\n",
- __FUNCTION__, status);
+ printf("wakeup_action: ERROR sigprocmask failed, status=%d\n",
+ status);
}
if (oldset != allsigs)
{
- printf("%s: ERROR sigprocmask=%x expected=%x\n",
- __FUNCTION__, oldset, allsigs);
+ printf("wakeup_action: ERROR sigprocmask=%x expected=%x\n",
+ oldset, allsigs);
}
}
@@ -120,19 +120,19 @@ static int waiter_main(int argc, char *argv[])
struct sigaction oact;
int status;
- printf("%s: Waiter started\n", __FUNCTION__);
+ printf("wakeup_action: Waiter started\n" );
- printf("%s: Unmasking signal %d\n", __FUNCTION__, WAKEUP_SIGNAL);
+ printf("waiter_main: Unmasking signal %d\n" , WAKEUP_SIGNAL);
(void)sigemptyset(&sigset);
(void)sigaddset(&sigset, WAKEUP_SIGNAL);
status = sigprocmask(SIG_UNBLOCK, &sigset, NULL);
if (status != OK)
{
- printf("%s: ERROR sigprocmask failed, status=%d\n",
- __FUNCTION__, status);
+ printf("waiter_main: ERROR sigprocmask failed, status=%d\n",
+ status);
}
- printf("%s: Registering signal handler\n", __FUNCTION__);
+ printf("waiter_main: Registering signal handler\n" );
act.sa_sigaction = wakeup_action;
act.sa_flags = SA_SIGINFO;
@@ -142,15 +142,15 @@ static int waiter_main(int argc, char *argv[])
status = sigaction(WAKEUP_SIGNAL, &act, &oact);
if (status != OK)
{
- printf("%s: ERROR sigaction failed, status=%d\n", __FUNCTION__, status);
+ printf("waiter_main: ERROR sigaction failed, status=%d\n" , status);
}
- printf("%s: oact.sigaction=%p oact.sa_flags=%x oact.sa_mask=%x\n",
- __FUNCTION__, oact.sa_sigaction, oact.sa_flags, oact.sa_mask);
+ printf("waiter_main: oact.sigaction=%p oact.sa_flags=%x oact.sa_mask=%x\n",
+ oact.sa_sigaction, oact.sa_flags, oact.sa_mask);
/* Take the semaphore */
- printf("%s: Waiting on semaphore\n", __FUNCTION__);
+ printf("waiter_main: Waiting on semaphore\n" );
fflush(stdout);
status = sem_wait(&sem);
if (status != 0)
@@ -158,19 +158,19 @@ static int waiter_main(int argc, char *argv[])
int error = *get_errno_ptr();
if (error == EINTR)
{
- printf("%s: sem_wait() successfully interrupted by signal\n", __FUNCTION__);
+ printf("waiter_main: sem_wait() successfully interrupted by signal\n" );
}
else
{
- printf("%s: ERROR sem_wait failed, errno=%d\n", __FUNCTION__, error);
+ printf("waiter_main: ERROR sem_wait failed, errno=%d\n" , error);
}
}
else
{
- printf("%s: ERROR awakened with no error!\n", __FUNCTION__);
+ printf("waiter_main: ERROR awakened with no error!\n" );
}
- printf("%s: done\n", __FUNCTION__);
+ printf("waiter_main: done\n" );
fflush(stdout);
threadexited = TRUE;
return 0;
@@ -184,25 +184,25 @@ void sighand_test(void)
int policy;
int status;
- printf("%s: Initializing semaphore to 0\n", __FUNCTION__);
+ printf("waiter_main: Initializing semaphore to 0\n" );
sem_init(&sem, 0, 0);
/* Start waiter thread */
- printf("%s: Starting waiter task\n", __FUNCTION__);
+ printf("sighand_test: Starting waiter task\n" );
status = sched_getparam (0, &param);
if (status != OK)
{
- printf("%s: ERROR sched_getparam() failed\n", __FUNCTION__);
+ printf("sighand_test: ERROR sched_getparam() failed\n" );
param.sched_priority = PTHREAD_DEFAULT_PRIORITY;
}
policy = sched_getscheduler(0);
if (policy == ERROR)
{
- printf("%s: ERROR sched_getscheduler() failed\n", __FUNCTION__);
+ printf("sighand_test: ERROR sched_getscheduler() failed\n" );
policy = SCHED_FIFO;
}
@@ -210,11 +210,11 @@ void sighand_test(void)
PTHREAD_STACK_DEFAULT, waiter_main, 0, 0, 0, 0);
if (waiterpid == ERROR)
{
- printf("%s: ERROR failed to start waiter_main\n", __FUNCTION__);
+ printf("sighand_test: ERROR failed to start waiter_main\n" );
}
else
{
- printf("%s: Started waiter_main pid=%d\n", __FUNCTION__, waiterpid);
+ printf("sighand_test: Started waiter_main pid=%d\n" , waiterpid);
}
/* Wait a bit */
@@ -228,7 +228,7 @@ void sighand_test(void)
status = sigqueue(waiterpid, WAKEUP_SIGNAL, sigvalue);
if (status != OK)
{
- printf("%s: ERROR sigqueue failed\n", __FUNCTION__);
+ printf("sighand_test: ERROR sigqueue failed\n" );
task_delete(waiterpid);
}
@@ -241,14 +241,14 @@ void sighand_test(void)
if (!threadexited)
{
- printf("%s: ERROR waiter task did not exit\n", __FUNCTION__);
+ printf("sighand_test: ERROR waiter task did not exit\n" );
}
if (!sigreceived)
{
- printf("%s: ERROR signal handler did not run\n", __FUNCTION__);
+ printf("sighand_test: ERROR signal handler did not run\n" );
}
- printf("%s: done\n", __FUNCTION__);
+ printf("sighand_test: done\n" );
fflush(stdout);
}
diff --git a/nuttx/examples/ostest/timedwait.c b/nuttx/examples/ostest/timedwait.c
index 9f3e61eae..b01b352ff 100644
--- a/nuttx/examples/ostest/timedwait.c
+++ b/nuttx/examples/ostest/timedwait.c
@@ -49,19 +49,19 @@ static void *thread_waiter(void *parameter)
/* Take the mutex */
- printf("%s: Taking mutex\n", __FUNCTION__);
+ printf("thread_waiter: Taking mutex\n");
status = pthread_mutex_lock(&mutex);
if (status != 0)
{
- printf("%s: ERROR pthread_mutex_lock failed, status=%d\n", __FUNCTION__, status);
+ printf("thread_waiter: ERROR pthread_mutex_lock failed, status=%d\n", status);
}
- printf("%s: Starting 5 second wait for condition\n", __FUNCTION__);
+ printf("thread_waiter: Starting 5 second wait for condition\n");
status = clock_gettime(CLOCK_REALTIME, &time);
if (status != 0)
{
- printf("%s: ERROR clock_gettime failed\n", __FUNCTION__);
+ printf("thread_waiter: ERROR clock_gettime failed\n");
}
time.tv_sec += 5;
@@ -70,19 +70,19 @@ static void *thread_waiter(void *parameter)
status = pthread_cond_timedwait(&cond, &mutex, &time);
if (status != 0)
{
- printf("%s: ERROR pthread_cond_timedwait failed, status=%d\n", __FUNCTION__, status);
+ printf("thread_waiter: ERROR pthread_cond_timedwait failed, status=%d\n", status);
}
/* Release the mutex */
- printf("%s: Releasing mutex\n", __FUNCTION__);
+ printf("thread_waiter: Releasing mutex\n");
status = pthread_mutex_unlock(&mutex);
if (status != 0)
{
- printf("%s: ERROR pthread_mutex_unlock failed, status=%d\n", __FUNCTION__, status);
+ printf("thread_waiter: ERROR pthread_mutex_unlock failed, status=%d\n", status);
}
- printf("%s: Exit with status 0x12345678\n", __FUNCTION__);
+ printf("thread_waiter: Exit with status 0x12345678\n");
pthread_exit((void*)0x12345678);
return NULL;
}
@@ -98,36 +98,36 @@ void timedwait_test(void)
/* Initialize the mutex */
- printf("%s: Initializing mutex\n", __FUNCTION__);
+ printf("thread_waiter: Initializing mutex\n");
status = pthread_mutex_init(&mutex, NULL);
if (status != 0)
{
- printf("%s: ERROR pthread_mutex_init failed, status=%d\n", __FUNCTION__, status);
+ printf("timedwait_test: ERROR pthread_mutex_init failed, status=%d\n", status);
}
/* Initialize the condition variable */
- printf("%s: Initializing cond\n", __FUNCTION__);
+ printf("timedwait_test: Initializing cond\n");
status = pthread_cond_init(&cond, NULL);
if (status != 0)
{
- printf("%s: ERROR pthread_condinit failed, status=%d\n", __FUNCTION__, status);
+ printf("timedwait_test: ERROR pthread_condinit failed, status=%d\n", status);
}
/* Start the waiter thread at higher priority */
- printf("%s: Starting waiter\n", __FUNCTION__);
+ printf("timedwait_test: Starting waiter\n");
status = pthread_attr_init(&attr);
if (status != 0)
{
- printf("%s: pthread_attr_init failed, status=%d\n", __FUNCTION__, status);
+ printf("timedwait_test: pthread_attr_init failed, status=%d\n", status);
}
prio_max = sched_get_priority_max(SCHED_FIFO);
status = sched_getparam (getpid(), &sparam);
if (status != 0)
{
- printf("%s: sched_getparam failed\n", __FUNCTION__);
+ printf("timedwait_test: sched_getparam failed\n");
sparam.sched_priority = PTHREAD_DEFAULT_PRIORITY;
}
@@ -135,27 +135,27 @@ void timedwait_test(void)
status = pthread_attr_setschedparam(&attr,&sparam);
if (status != OK)
{
- printf("%s: pthread_attr_setschedparam failed, status=%d\n", __FUNCTION__, status);
+ printf("timedwait_test: pthread_attr_setschedparam failed, status=%d\n", status);
}
else
{
- printf("%s: Set thread 2 priority to %d\n", __FUNCTION__, sparam.sched_priority);
+ printf("timedwait_test: Set thread 2 priority to %d\n", sparam.sched_priority);
}
status = pthread_create(&waiter, &attr, thread_waiter, NULL);
if (status != 0)
{
- printf("%s: pthread_create failed, status=%d\n", __FUNCTION__, status);
+ printf("timedwait_test: pthread_create failed, status=%d\n", status);
}
- printf("%s: Joining\n", __FUNCTION__);
+ printf("timedwait_test: Joining\n");
status = pthread_join(waiter, &result);
if (status != 0)
{
- printf("%s: ERROR pthread_join failed, status=%d\n", __FUNCTION__, status);
+ printf("timedwait_test: ERROR pthread_join failed, status=%d\n", status);
}
else
{
- printf("%s: waiter exited with result=%p\n", __FUNCTION__, result);
+ printf("timedwait_test: waiter exited with result=%p\n", result);
}
}