mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
Progress toward clean SDCC compilation
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@18 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -47,7 +47,7 @@ COBJS = $(CSRCS:.c=.o)
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
BIN = lib$(CONFIG_EXAMPLE).a
|
||||
BIN = lib$(CONFIG_EXAMPLE)$(LIBEXT)
|
||||
|
||||
all: $(BIN)
|
||||
|
||||
@@ -58,7 +58,10 @@ $(COBJS): %.o: %.c
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
$(BIN): $(OBJS)
|
||||
$(AR) rcs $@ $(OBJS)
|
||||
( for obj in $(OBJS) ; do \
|
||||
$(AR) $@ $${obj} || \
|
||||
{ echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \
|
||||
done ; )
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
|
||||
+25
-13
@@ -37,6 +37,7 @@
|
||||
#include <time.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "ostest.h"
|
||||
|
||||
static pthread_mutex_t mutex;
|
||||
@@ -70,7 +71,18 @@ static void *thread_waiter(void *parameter)
|
||||
status = pthread_cond_timedwait(&cond, &mutex, &time);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("thread_waiter: ERROR pthread_cond_timedwait failed, status=%d\n", status);
|
||||
if (status == ETIMEDOUT)
|
||||
{
|
||||
printf("thread_waiter: pthread_cond_timedwait timed out\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("thread_waiter: ERROR pthread_cond_timedwait failed, status=%d\n", status);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("thread_waiter: ERROR pthread_cond_timedwait returned without timeout, status=%d\n", status);
|
||||
}
|
||||
|
||||
/* Release the mutex */
|
||||
@@ -102,32 +114,32 @@ void timedwait_test(void)
|
||||
status = pthread_mutex_init(&mutex, NULL);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("timedwait_test: ERROR pthread_mutex_init failed, status=%d\n", status);
|
||||
printf("timedwait_test: ERROR pthread_mutex_init failed, status=%d\n", status);
|
||||
}
|
||||
|
||||
/* Initialize the condition variable */
|
||||
|
||||
printf("timedwait_test: Initializing cond\n");
|
||||
printf("timedwait_test: Initializing cond\n");
|
||||
status = pthread_cond_init(&cond, NULL);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("timedwait_test: ERROR pthread_condinit failed, status=%d\n", status);
|
||||
printf("timedwait_test: ERROR pthread_condinit failed, status=%d\n", status);
|
||||
}
|
||||
|
||||
/* Start the waiter thread at higher priority */
|
||||
|
||||
printf("timedwait_test: Starting waiter\n");
|
||||
printf("timedwait_test: Starting waiter\n");
|
||||
status = pthread_attr_init(&attr);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("timedwait_test: pthread_attr_init failed, status=%d\n", 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("timedwait_test: sched_getparam failed\n");
|
||||
printf("timedwait_test: sched_getparam failed\n");
|
||||
sparam.sched_priority = PTHREAD_DEFAULT_PRIORITY;
|
||||
}
|
||||
|
||||
@@ -135,27 +147,27 @@ void timedwait_test(void)
|
||||
status = pthread_attr_setschedparam(&attr,&sparam);
|
||||
if (status != OK)
|
||||
{
|
||||
printf("timedwait_test: pthread_attr_setschedparam failed, status=%d\n", status);
|
||||
printf("timedwait_test: pthread_attr_setschedparam failed, status=%d\n", status);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("timedwait_test: Set thread 2 priority to %d\n", 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("timedwait_test: pthread_create failed, status=%d\n", status);
|
||||
printf("timedwait_test: pthread_create failed, status=%d\n", status);
|
||||
}
|
||||
|
||||
printf("timedwait_test: Joining\n");
|
||||
printf("timedwait_test: Joining\n");
|
||||
status = pthread_join(waiter, &result);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("timedwait_test: ERROR pthread_join failed, status=%d\n", status);
|
||||
printf("timedwait_test: ERROR pthread_join failed, status=%d\n", status);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("timedwait_test: waiter exited with result=%p\n", result);
|
||||
printf("timedwait_test: waiter exited with result=%p\n", result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user