summaryrefslogtreecommitdiff
path: root/nuttx/examples/ostest
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-02-27 21:17:21 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-02-27 21:17:21 +0000
commit148cde5e982950ad5836fa96baa466de842e1c14 (patch)
treebf737b367b91c5da81345eb21016b07400d7a72f /nuttx/examples/ostest
parentf6b81a790c28d7d36d9de33810df5270c1ebbfd7 (diff)
downloadpx4-nuttx-148cde5e982950ad5836fa96baa466de842e1c14.tar.gz
px4-nuttx-148cde5e982950ad5836fa96baa466de842e1c14.tar.bz2
px4-nuttx-148cde5e982950ad5836fa96baa466de842e1c14.zip
Finally, a clean SDCC compile
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@20 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/ostest')
-rw-r--r--nuttx/examples/ostest/Makefile2
-rw-r--r--nuttx/examples/ostest/cancel.c4
-rw-r--r--nuttx/examples/ostest/cond.c7
-rw-r--r--nuttx/examples/ostest/main.c14
-rw-r--r--nuttx/examples/ostest/mqueue.c14
-rw-r--r--nuttx/examples/ostest/mutex.c25
-rw-r--r--nuttx/examples/ostest/sem.c15
-rw-r--r--nuttx/examples/ostest/sighand.c6
-rw-r--r--nuttx/examples/ostest/timedwait.c2
9 files changed, 68 insertions, 21 deletions
diff --git a/nuttx/examples/ostest/Makefile b/nuttx/examples/ostest/Makefile
index df30ca841..44c7f3f06 100644
--- a/nuttx/examples/ostest/Makefile
+++ b/nuttx/examples/ostest/Makefile
@@ -70,7 +70,7 @@ $(BIN): $(OBJS)
depend: .depend
clean:
- rm -f $(BIN) *.o *~
+ rm -f $(BIN) *.o *.asm *.lst *.sym *.adb *~
distclean: clean
rm -f Make.dep .depend
diff --git a/nuttx/examples/ostest/cancel.c b/nuttx/examples/ostest/cancel.c
index 1fda4166c..c6803c048 100644
--- a/nuttx/examples/ostest/cancel.c
+++ b/nuttx/examples/ostest/cancel.c
@@ -96,7 +96,7 @@ static void *thread_waiter(void *parameter)
}
printf("thread_waiter: Exit with status 0x12345678\n");
- pthread_exit((void*)0x12345678);
+ pthread_exit((pthread_addr_t)0x12345678);
return NULL;
}
@@ -140,7 +140,7 @@ static void start_thread(pthread_t *waiter, int cancelable)
/* Start the waiter thread */
printf("start_thread: Starting thread\n");
- status = pthread_create(waiter, NULL, thread_waiter, (void*)cancelable);
+ status = pthread_create(waiter, &attr, thread_waiter, (pthread_addr_t)cancelable);
if (status != 0)
{
printf("start_thread: ERROR pthread_create failed, status=%d\n", status);
diff --git a/nuttx/examples/ostest/cond.c b/nuttx/examples/ostest/cond.c
index 13e7b4669..6214ea9d0 100644
--- a/nuttx/examples/ostest/cond.c
+++ b/nuttx/examples/ostest/cond.c
@@ -190,6 +190,9 @@ void cond_test(void)
pthread_t waiter;
pthread_t signaler;
pthread_attr_t attr;
+#ifdef SDCC
+ pthread_addr_t result;
+#endif
struct sched_param sparam;
int prio_min;
int prio_max;
@@ -270,7 +273,11 @@ void cond_test(void)
/* Wait for the threads to stop */
+#ifdef SDCC
+ pthread_join(signaler, &result);
+#else
pthread_join(signaler, NULL);
+#endif
printf("cond_test: signaler terminated, now cancel the waiter\n");
pthread_detach(waiter);
pthread_cancel(waiter);
diff --git a/nuttx/examples/ostest/main.c b/nuttx/examples/ostest/main.c
index 3122ef343..ff1072176 100644
--- a/nuttx/examples/ostest/main.c
+++ b/nuttx/examples/ostest/main.c
@@ -55,18 +55,18 @@
#define STACKSIZE 8192
#define NARGS 4
-#define ARG1 "Arg1"
-#define ARG2 "Arg2"
-#define ARG3 "Arg3"
-#define ARG4 "Arg4"
-
/************************************************************
* Private Data
************************************************************/
+static FAR char arg1[] = "Arg1";
+static FAR char arg2[] = "Arg2";
+static FAR char arg3[] = "Arg3";
+static FAR char arg4[] = "Arg4";
+
static char write_data1[] = "Standard I/O Check: write fd=1\n";
static char write_data2[] = "Standard I/O Check: write fd=2\n";
-static char *args[NARGS] = { ARG1, ARG2, ARG3, ARG4 };
+static char *args[NARGS] = { arg1, arg2, arg3, arg4 };
/************************************************************
* Private Functions
@@ -165,7 +165,7 @@ int user_start(int parm1, int parm2, int parm3, int parm4)
/* Verify that we can spawn a new task */
result = task_create("ostest", PRIORITY, STACKSIZE, user_main,
- ARG1, ARG2, ARG3, ARG4);
+ arg1, arg2, arg3, arg4);
if (result == ERROR)
{
fprintf(stderr, "user_start: Failed to start user_main\n");
diff --git a/nuttx/examples/ostest/mqueue.c b/nuttx/examples/ostest/mqueue.c
index acdbea99e..9e9360726 100644
--- a/nuttx/examples/ostest/mqueue.c
+++ b/nuttx/examples/ostest/mqueue.c
@@ -50,7 +50,11 @@
**************************************************************************/
#define TEST_MESSAGE "This is a test and only a test"
+#ifdef SDCC
+#define TEST_MSGLEN (31)
+#else
#define TEST_MSGLEN (strlen(TEST_MESSAGE)+1)
+#endif
/**************************************************************************
* Private Types
@@ -108,7 +112,7 @@ static void *sender_thread(void *arg)
if (mqfd < 0)
{
printf("sender_thread: ERROR mq_open failed\n");
- pthread_exit((void*)1);
+ pthread_exit((pthread_addr_t)1);
}
/* Fill in a test message buffer to send */
@@ -139,7 +143,7 @@ static void *sender_thread(void *arg)
}
printf("sender_thread: returning nerrors=%d\n", nerrors);
- return (void*)nerrors;
+ return (pthread_addr_t)nerrors;
}
static void *receiver_thread(void *arg)
@@ -174,7 +178,7 @@ static void *receiver_thread(void *arg)
if (mqfd < 0)
{
printf("receiver_thread: ERROR mq_open failed\n");
- pthread_exit((void*)1);
+ pthread_exit((pthread_addr_t)1);
}
/* Perform the receive 10 times */
@@ -221,7 +225,7 @@ static void *receiver_thread(void *arg)
nerrors++;
}
- pthread_exit((void*)nerrors);
+ pthread_exit((pthread_addr_t)nerrors);
/* Destroy the queue */
@@ -232,7 +236,7 @@ static void *receiver_thread(void *arg)
}
printf("receiver_thread: returning nerrors=%d\n", nerrors);
- return (void*)nerrors;
+ return (pthread_addr_t)nerrors;
}
void mqueue_test(void)
diff --git a/nuttx/examples/ostest/mutex.c b/nuttx/examples/ostest/mutex.c
index cb8996053..5edf60dba 100644
--- a/nuttx/examples/ostest/mutex.c
+++ b/nuttx/examples/ostest/mutex.c
@@ -91,6 +91,11 @@ static void *thread_func(void *parameter)
void mutex_test(void)
{
pthread_t thread1, thread2;
+#ifdef SDCC
+ pthread_addr_t result1, result2;
+ pthread_attr_t attr;
+#endif
+ int status;
/* Initialize the mutex */
@@ -100,19 +105,35 @@ void mutex_test(void)
/* Start two thread instances */
printf("Starting thread 1\n");
- if ((pthread_create(&thread1, NULL, thread_func, (void*)1)) != 0)
+#ifdef SDCC
+ (void)pthread_attr_init(&attr);
+ status = pthread_create(&thread1, &attr, thread_func, (pthread_addr_t)1);
+#else
+ status = pthread_create(&thread1, NULL, thread_func, (pthread_addr_t)1);
+#endif
+ if (status != 0)
{
printf("Error in thread#1 creation\n");
}
printf("Starting thread 2\n");
- if ((pthread_create(&thread2, NULL, thread_func, (void*)2)) != 0)
+#ifdef SDCC
+ status = pthread_create(&thread2, &attr, thread_func, (pthread_addr_t)2);
+#else
+ status = pthread_create(&thread2, NULL, thread_func, (pthread_addr_t)2);
+#endif
+ if (status != 0)
{
printf("Error in thread#2 creation\n");
}
+#ifdef SDCC
+ pthread_join(thread1, &result1);
+ pthread_join(thread2, &result2);
+#else
pthread_join(thread1, NULL);
pthread_join(thread2, NULL);
+#endif
printf("\t\tThread1\tThread2\n");
printf("\tLoops\t%ld\t%ld\n", nloops[0], nloops[1]);
diff --git a/nuttx/examples/ostest/sem.c b/nuttx/examples/ostest/sem.c
index 73be6910e..f6e6ddbb5 100644
--- a/nuttx/examples/ostest/sem.c
+++ b/nuttx/examples/ostest/sem.c
@@ -144,6 +144,9 @@ void sem_test(void)
pthread_t waiter_thread1;
pthread_t waiter_thread2;
pthread_t poster_thread;
+#ifdef SDCC
+ pthread_addr_t result;
+#endif
struct sched_param sparam;
int prio_min;
int prio_max;
@@ -178,7 +181,7 @@ void sem_test(void)
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, (pthread_addr_t)1);
if (status != 0)
{
printf("sem_test: Error in thread 1 creation, status=%d\n", status);
@@ -202,7 +205,7 @@ void sem_test(void)
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, (pthread_addr_t)2);
if (status != 0)
{
printf("sem_test: Error in thread 2 creation, status=%d\n", status);
@@ -226,13 +229,19 @@ void sem_test(void)
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, (pthread_addr_t)3);
if (status != 0)
{
printf("sem_test: Error in thread 3 creation, status=%d\n", status);
}
+#ifdef SDCC
+ pthread_join(waiter_thread1, &result);
+ pthread_join(waiter_thread2, &result);
+ pthread_join(poster_thread, &result);
+#else
pthread_join(waiter_thread1, NULL);
pthread_join(waiter_thread2, NULL);
pthread_join(poster_thread, NULL);
+#endif
}
diff --git a/nuttx/examples/ostest/sighand.c b/nuttx/examples/ostest/sighand.c
index ada7d8836..f6970deb0 100644
--- a/nuttx/examples/ostest/sighand.c
+++ b/nuttx/examples/ostest/sighand.c
@@ -145,8 +145,10 @@ static int waiter_main(int argc, char *argv[])
printf("waiter_main: ERROR sigaction failed, status=%d\n" , status);
}
+#ifndef SDCC
printf("waiter_main: oact.sigaction=%p oact.sa_flags=%x oact.sa_mask=%x\n",
oact.sa_sigaction, oact.sa_flags, oact.sa_mask);
+#endif
/* Take the semaphore */
@@ -225,7 +227,11 @@ void sighand_test(void)
/* Then signal the waiter thread. */
sigvalue.sival_int = SIGVALUE_INT;
+#ifdef CONFIG_CAN_PASS_STRUCTS
status = sigqueue(waiterpid, WAKEUP_SIGNAL, sigvalue);
+#else
+ status = sigqueue(waiterpid, WAKEUP_SIGNAL, sigvalue.sival_ptr);
+#endif
if (status != OK)
{
printf("sighand_test: ERROR sigqueue failed\n" );
diff --git a/nuttx/examples/ostest/timedwait.c b/nuttx/examples/ostest/timedwait.c
index af2fd2551..81e7c4a61 100644
--- a/nuttx/examples/ostest/timedwait.c
+++ b/nuttx/examples/ostest/timedwait.c
@@ -95,7 +95,7 @@ static void *thread_waiter(void *parameter)
}
printf("thread_waiter: Exit with status 0x12345678\n");
- pthread_exit((void*)0x12345678);
+ pthread_exit((pthread_addr_t)0x12345678);
return NULL;
}