diff --git a/Documentation/NuttxUserGuide.html b/Documentation/NuttxUserGuide.html
index 213f75d751..8396651c66 100644
--- a/Documentation/NuttxUserGuide.html
+++ b/Documentation/NuttxUserGuide.html
@@ -1806,7 +1806,7 @@ initialization time).
Function Prototype:
#include <wdog.h>
- STATUS wd_delete (WDOG_ID wdId);
+ STATUS wd_delete (WDOG_ID wdog);
@@ -1816,7 +1816,7 @@ has been started.
Input Parameters:
-- wdId. The watchdog ID to delete. This is actually a
+
- wdog. The watchdog ID to delete. This is actually a
pointer to a watchdog structure.
@@ -1834,7 +1834,7 @@ it.
POSIX Compatibility: This is a NON-POSIX interface.
VxWorks provides the following comparable interface:
- STATUS wdDelete (WDOG_ID wdId);
+ STATUS wdDelete (WDOG_ID wdog);
@@ -1850,8 +1850,8 @@ before de-allocating it (i.e., never returns ERROR).
Function Prototype:
#include <wdog.h>
- STATUS wd_start( WDOG_ID wdId, int delay, wdentry_t wdentry,
- int parm1, int parm2, int parm3, int parm4 );
+ STATUS wd_start( WDOG_ID wdog, int delay, wdentry_t wdentry,
+ intt argc, ....);
@@ -1867,15 +1867,16 @@ was called.
Watchdog timers execute only once.
To replace either the timeout delay or the function to be executed,
-call wd_start again with the same wdId; only the most recent
+call wd_start again with the same wdog; only the most recent
wd_start() on a given watchdog ID has any effect.
Input Parameters:
-- wdId. Watchdog ID
+
- wdog. Watchdog ID
- delay. Delay count in clock ticks
- wdentry. Function to call on timeout
-
- parm1..4. Parameters to pass to wdentry
+
- argc. The number of uint32 parameters to pass to wdentry.
+
- .... uint32 size parameters to pass to wdentry
@@ -1892,14 +1893,15 @@ restrictions.
POSIX Compatibility: This is a NON-POSIX interface.
VxWorks provides the following comparable interface:
- STATUS wdStart (WDOG_ID wdId, int delay, FUNCPTR wdentry, int parameter);
+ STATUS wdStart (WDOG_ID wdog, int delay, FUNCPTR wdentry, int parameter);
Differences from the VxWorks interface include:
-- The present implementation supports four parameters passed
-to wdentry; VxWorks supports only a single parameter.
+
- The present implementation supports multiple parameters passed
+to wdentry; VxWorks supports only a single parameter. The maximum
+number of parameters is determined by
2.6.4 wd_cancel
@@ -1908,7 +1910,7 @@ to wdentry; VxWorks supports only a single parameter.
Function Prototype:
#include <wdog.h>
- STATUS wd_cancel (WDOG_ID wdId);
+ STATUS wd_cancel (WDOG_ID wdog);
@@ -1918,7 +1920,7 @@ level.
Input Parameters:
-- wdId. ID of the watchdog to cancel.
+
- wdog. ID of the watchdog to cancel.
@@ -1933,7 +1935,7 @@ level.
POSIX Compatibility: This is a NON-POSIX interface.
VxWorks provides the following comparable interface:
- STATUS wdCancel (WDOG_ID wdId);
+ STATUS wdCancel (WDOG_ID wdog);
@@ -4073,6 +4075,39 @@ notify a task when a message is available on a queue.
int sigev_notify;
};
+
+3.4.9 Watchdog Data Types
+
+
+ When a watchdog expires, the callback function with this
+ type is called:
+
+
+ typedef void (*wdentry_t)(int argc, ...);
+
+
+ Where argc is the number of uint32 type arguments that follow.
+
+ The arguments are passed as uint32 values.
+ For systems where the sizeof(pointer) < sizeof(uint32), the
+ following union defines the alignment of the pointer within the
+ uint32. For example, the SDCC MCS51 general pointer is
+ 24-bits, but uint32 is 32-bits (of course).
+
+
+ union wdparm_u
+ {
+ void *pvarg;
+ uint32 *dwarg;
+ };
+ typedef union wdparm_u wdparm_t;
+
+
+ For most 32-bit systems, pointers and uint32 are the same size
+ For systems where sizeof(pointer) > sizeof(uint32), we will
+ have to do some redesign.
+
+
diff --git a/Makefile b/Makefile
index 48fab7bda6..af2121ab24 100644
--- a/Makefile
+++ b/Makefile
@@ -44,9 +44,9 @@ SUBDIRS = sched lib $(ARCH_SRC) mm fs drivers examples/$(CONFIG_EXAMPLE)
OBJS = $(ARCH_SRC)/up_head.o
LIBGCC = ${shell $(CC) -print-libgcc-file-name}
-LIBS = sched/libsched.a $(ARCH_SRC)/libarch.a mm/libmm.a \
- fs/libfs.a drivers/libdrivers.a lib/liblib.a \
- examples/$(CONFIG_EXAMPLE)/lib$(CONFIG_EXAMPLE).a
+LIBS = sched/libsched$(LIBEXT) $(ARCH_SRC)/libarch$(LIBEXT) mm/libmm$(LIBEXT) \
+ fs/libfs$(LIBEXT) drivers/libdrivers$(LIBEXT) lib/liblib$(LIBEXT) \
+ examples/$(CONFIG_EXAMPLE)/lib$(CONFIG_EXAMPLE)$(LIBEXT)
LDLIBS = -lsched -larch -lmm -lfs -ldrivers -llib -l$(CONFIG_EXAMPLE) $(LIBGCC) $(EXTRA_LIBS)
BIN = nuttx
@@ -78,29 +78,29 @@ check_context:
exit 1 ; \
fi
-sched/libsched.a: context
- $(MAKE) -C sched TOPDIR=$(TOPDIR) libsched.a
+sched/libsched$(LIBEXT): context
+ $(MAKE) -C sched TOPDIR=$(TOPDIR) libsched$(LIBEXT)
-lib/liblib.a: context
- $(MAKE) -C lib TOPDIR=$(TOPDIR) liblib.a
+lib/liblib$(LIBEXT): context
+ $(MAKE) -C lib TOPDIR=$(TOPDIR) liblib$(LIBEXT)
-$(ARCH_SRC)/libarch.a: context
- $(MAKE) -C $(ARCH_SRC) TOPDIR=$(TOPDIR) libarch.a
+$(ARCH_SRC)/libarch$(LIBEXT): context
+ $(MAKE) -C $(ARCH_SRC) TOPDIR=$(TOPDIR) libarch$(LIBEXT)
$(ARCH_SRC)/up_head.o: context
$(MAKE) -C $(ARCH_SRC) TOPDIR=$(TOPDIR) up_head.o
-mm/libmm.a: context
- $(MAKE) -C mm TOPDIR=$(TOPDIR) libmm.a
+mm/libmm$(LIBEXT): context
+ $(MAKE) -C mm TOPDIR=$(TOPDIR) libmm$(LIBEXT)
-fs/libfs.a: context
- $(MAKE) -C fs TOPDIR=$(TOPDIR) libfs.a
+fs/libfs$(LIBEXT): context
+ $(MAKE) -C fs TOPDIR=$(TOPDIR) libfs$(LIBEXT)
-drivers/libdrivers.a: context
- $(MAKE) -C drivers TOPDIR=$(TOPDIR) libdrivers.a
+drivers/libdrivers$(LIBEXT): context
+ $(MAKE) -C drivers TOPDIR=$(TOPDIR) libdrivers$(LIBEXT)
-examples/$(CONFIG_EXAMPLE)/lib$(CONFIG_EXAMPLE).a: context
- $(MAKE) -C examples/$(CONFIG_EXAMPLE) TOPDIR=$(TOPDIR) lib$(CONFIG_EXAMPLE).a
+examples/$(CONFIG_EXAMPLE)/lib$(CONFIG_EXAMPLE)$(LIBEXT): context
+ $(MAKE) -C examples/$(CONFIG_EXAMPLE) TOPDIR=$(TOPDIR) lib$(CONFIG_EXAMPLE)$(LIBEXT)
$(BIN): context depend $(OBJS) $(LIBS)
ifeq ($(CONFIG_ARCH),sim)
diff --git a/arch/README.txt b/arch/README.txt
index ff0fd4f004..0c7e195361 100644
--- a/arch/README.txt
+++ b/arch/README.txt
@@ -142,7 +142,18 @@ include/types.h
This provides architecture/toolchain-specific definitions for
standard types. This file should typedef:
- sbyte, ubyte, uint8, boolean, sint16, uint16, sint32, uint32, sint64, uint64
+ sbyte, ubyte, uint8, boolean, sint16, uint16, sint32, uint32
+
+ and
+
+ sint64, uint64
+
+ if the architecture supports 64-bit integers.
+
+ irqstate_t
+
+ Must be defined to the be the size required to hold the interrupt
+ enable/disable state.
This file will be included by include/sys/types.h and be made
available to all files.
@@ -154,9 +165,9 @@ include/irq.h
- struct xcptcontext. This structures represents the saved context
of a thread.
- - uint32 irqsave(void) -- Used to disable all interrupts.
+ - irqstate_t irqsave(void) -- Used to disable all interrupts.
- - void irqrestore(uint32 flags) -- Used to restore interrupt
+ - void irqrestore(irqstate_t flags) -- Used to restore interrupt
enables to the same state as before irqsave was called.
This file must also define NR_IRQS, the total number of IRQs supported
diff --git a/arch/c5471/Make.defs b/arch/c5471/Make.defs
index 7e68d8e566..8f00136708 100644
--- a/arch/c5471/Make.defs
+++ b/arch/c5471/Make.defs
@@ -52,7 +52,7 @@ ARCHSCRIPT = -T$(TOPDIR)/arch/$(CONFIG_ARCH)/ld.script
CROSSDEV = arm-elf-
CC = $(CROSSDEV)gcc
LD = $(CROSSDEV)ld
-AR = $(CROSSDEV)ar
+AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
@@ -62,6 +62,7 @@ CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
LDFLAGS = $(ARCHSCRIPT)
EXTRA_LIBS =
+LIBEXT = .a
ifeq ("${CONFIG_DEBUG}","y")
LDFLAGS += -g
diff --git a/arch/c5471/defconfig b/arch/c5471/defconfig
index 3871d7e149..2dd38f0144 100644
--- a/arch/c5471/defconfig
+++ b/arch/c5471/defconfig
@@ -132,6 +132,8 @@ CONFIG_ARCH_KFREE=n
#
# General Compile environment setup
#
+# CONFIG_SMALL_MEMORY - enable if your processor supports
+# 16-bit addressing; disable if it supports 32-bit.
# CONFIG_HAVE_INLINE - enable if your compiler supports
# inline functions
# CONFIG_HAVE_DOUBLE - enable if your compiler supports type
@@ -139,21 +141,26 @@ CONFIG_ARCH_KFREE=n
# CONFIG_HAVE_LONG_LONG - enable if your architecture supports
# long long types and if you plan to use them
# CONFIG_CAN_PASS_STRUCTS - enable if your compiler supports
-# passing structures and unions as values
+# passing and assiging structures and unions as values
+# CONFIG_CAN_CAST_POINTERS - enable if you can cast between
+# integers and pointer.
# CONFIG_HAVE_WEAKFUNCTIONS - enable if you compiler supports
# weak functions (see include/nuttx/comp
#
+CONFIG_SMALL_MEMORY=n
CONFIG_HAVE_INLINE=y
CONFIG_HAVE_DOUBLE=y
CONFIG_HAVE_LONG_LONG=n
CONFIG_CAN_PASS_STRUCTS=y
+CONFIG_CAN_CAST_POINTERS=y
CONFIG_HAVE_WEAKFUNCTIONS=y
#
# General build options
#
-# CONFIG_RRLOAD_BINY - make the rrload binary format used with
+# CONFIG_RRLOAD_BINARY - make the rrload binary format used with
# BSPs from www.ridgerun.com
+#
CONFIG_RRLOAD_BINARY=y
#
@@ -175,6 +182,8 @@ CONFIG_RRLOAD_BINARY=y
# CONFIG_MQ_MAXMSGSIZE - Message structures are allocated with
# a fixed payload size given by this settin (does not include
# other message structure overhead.
+# CONFIG_MAX_WDOGPARMS - Maximum number of parameters that
+# can be passed to a watchdog handler
# CONFIG_PREALLOC_WDOGS - The number of pre-allocated watchdog
# structures. The system manages a pool of preallocated
# watchdog structures to minimize dynamic allocations
@@ -186,6 +195,7 @@ CONFIG_STDIO_BUFFER_SIZE=1024
CONFIG_NUNGET_CHARS=2
CONFIG_PREALLOC_MQ_MSGS=32
CONFIG_MQ_MAXMSGSIZE=32
+CONFIG_MAX_WDOGPARMS=4
CONFIG_PREALLOC_WDOGS=32
#
diff --git a/arch/c5471/include/irq.h b/arch/c5471/include/irq.h
index 0745ba6aab..c6a89e9511 100644
--- a/arch/c5471/include/irq.h
+++ b/arch/c5471/include/irq.h
@@ -177,10 +177,10 @@ struct xcptcontext
/* Save the current interrupt enable state & disable IRQs */
-static inline uint32 irqsave(void)
+static inline irqstate_t irqsave(void)
{
- unsigned long flags;
- unsigned long temp;
+ unsigned int flags;
+ unsigned int temp;
__asm__ __volatile__
(
"\tmrs %0, cpsr\n"
@@ -194,7 +194,7 @@ static inline uint32 irqsave(void)
/* Restore saved IRQ & FIQ state */
-static inline void irqrestore(uint32 flags)
+static inline void irqrestore(irqstate_t flags)
{
__asm__ __volatile__
(
@@ -204,8 +204,8 @@ static inline void irqrestore(uint32 flags)
: "memory");
}
-static inline void system_call(swint_t func, uint32 parm1,
- uint32 parm2, uint32 parm3)
+static inline void system_call(swint_t func, int parm1,
+ int parm2, int parm3)
{
__asm__ __volatile__
(
diff --git a/arch/c5471/include/types.h b/arch/c5471/include/types.h
index 7b39302f0b..5ec6e81e1d 100644
--- a/arch/c5471/include/types.h
+++ b/arch/c5471/include/types.h
@@ -52,6 +52,10 @@
* Type Declarations
************************************************************/
+#ifndef __ASSEMBLY__
+
+/* These are the sizes of the standard GNU types */
+
typedef char sbyte;
typedef unsigned char ubyte;
typedef unsigned char uint8;
@@ -63,6 +67,14 @@ typedef unsigned int uint32;
typedef long long sint64;
typedef unsigned long long uint64;
+/* This is the size of the interrupt state save returned by
+ * irqsave()
+ */
+
+typedef unsigned int irqstate_t;
+
+#endif /* __ASSEMBLY__ */
+
/************************************************************
* Global Function Prototypes
************************************************************/
diff --git a/arch/c5471/src/Makefile b/arch/c5471/src/Makefile
index a4f953c6f9..57d741aaa5 100644
--- a/arch/c5471/src/Makefile
+++ b/arch/c5471/src/Makefile
@@ -56,7 +56,7 @@ COBJS = $(CSRCS:.c=.o)
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
-all: up_head.o libarch.a
+all: up_head.o libarch$(LIBEXT)
$(AOBJS) up_head.o: %.o: %.S
$(CC) -c $(CFLAGS) -D__ASSEMBLY__ $< -o $@
@@ -64,8 +64,11 @@ $(AOBJS) up_head.o: %.o: %.S
$(COBJS): %.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
-libarch.a: $(OBJS)
- $(AR) rcs $@ $(OBJS)
+libarch$(LIBEXT): $(OBJS)
+ ( for obj in $(OBJS) ; do \
+ $(AR) $@ $${obj} || \
+ { echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \
+ done ; )
.depend: Makefile $(SRCS)
$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
@@ -74,7 +77,7 @@ libarch.a: $(OBJS)
depend: .depend
clean:
- rm -f libarch.a *.o *~
+ rm -f libarch$(LIBEXT) *.o *~
distclean: clean
rm -f Make.dep .depend
diff --git a/arch/c5471/src/up_assert.c b/arch/c5471/src/up_assert.c
index eaddc7c8e1..8b70349f47 100644
--- a/arch/c5471/src/up_assert.c
+++ b/arch/c5471/src/up_assert.c
@@ -63,7 +63,7 @@
* Name: up_assert
************************************************************/
-void up_assert(const ubyte *filename, uint32 lineno)
+void up_assert(const ubyte *filename, int lineno)
{
dbg("Assertion failed at file:%s line: %d\n",
filename, lineno);
@@ -74,7 +74,7 @@ void up_assert(const ubyte *filename, uint32 lineno)
* Name: up_assert_code
************************************************************/
-void up_assert_code(const ubyte *filename, uint32 lineno, uint16 errorcode)
+void up_assert_code(const ubyte *filename, int lineno, int errorcode)
{
dbg("Assertion failed at file:%s line: %d error code: %d\n",
filename, lineno, errorcode);
diff --git a/arch/c5471/src/up_createstack.c b/arch/c5471/src/up_createstack.c
index 90919e265f..0e1f0690af 100644
--- a/arch/c5471/src/up_createstack.c
+++ b/arch/c5471/src/up_createstack.c
@@ -78,7 +78,7 @@
* must be allocated.
************************************************************/
-STATUS up_create_stack(_TCB *tcb, uint32 stack_size)
+STATUS up_create_stack(_TCB *tcb, size_t stack_size)
{
if (tcb->stack_alloc_ptr &&
tcb->adj_stack_size != stack_size)
@@ -94,8 +94,8 @@ STATUS up_create_stack(_TCB *tcb, uint32 stack_size)
if (tcb->stack_alloc_ptr)
{
- uint32 top_of_stack;
- uint32 size_of_stack;
+ size_t top_of_stack;
+ size_t size_of_stack;
/* The Arm7Tdmi uses a push-down stack: the stack grows
* toward loweraddresses in memory. The stack pointer
diff --git a/arch/c5471/src/up_schedulesigaction.c b/arch/c5471/src/up_schedulesigaction.c
index 4ea39bec2d..3f4e32ec9f 100644
--- a/arch/c5471/src/up_schedulesigaction.c
+++ b/arch/c5471/src/up_schedulesigaction.c
@@ -101,7 +101,7 @@ void up_schedule_sigaction(_TCB *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver)
{
- uint32 flags;
+ irqstate_t flags;
/* Make sure that interrupts are disabled */
diff --git a/arch/c5471/src/up_serial.c b/arch/c5471/src/up_serial.c
index df4927660a..b11bfc0706 100644
--- a/arch/c5471/src/up_serial.c
+++ b/arch/c5471/src/up_serial.c
@@ -721,7 +721,7 @@ static void up_uartsetup(up_dev_t *dev)
static void shutdown(up_dev_t * dev)
{
- uint32 flags;
+ irqstate_t flags;
uint16 msr;
/* Free the IRQ */
@@ -878,7 +878,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */
{
- uint32 flags = irqsave();
+ irqstate_t flags = irqsave();
up_enablebreaks(dev);
irqrestore(flags);
}
@@ -886,7 +886,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
case TIOCCBRK: /* BSD compatibility: Turn break off, unconditionally */
{
- uint32 flags;
+ irqstate_t flags;
flags = irqsave();
up_disablebreaks(dev);
irqrestore(flags);
@@ -973,7 +973,7 @@ static int up_open(struct file *filep)
if (++dev->open_count == 1)
{
- int flags = irqsave();
+ irqstate_t flags = irqsave();
/* If this is the console, then the UART has already
* been initialized.
diff --git a/arch/c5471/src/up_usestack.c b/arch/c5471/src/up_usestack.c
index 4cab9209fc..3153145695 100644
--- a/arch/c5471/src/up_usestack.c
+++ b/arch/c5471/src/up_usestack.c
@@ -78,10 +78,10 @@
*
************************************************************/
-STATUS up_use_stack(_TCB *tcb, uint32 *stack, uint32 stack_size)
+STATUS up_use_stack(_TCB *tcb, void *stack, size_t stack_size)
{
- uint32 top_of_stack;
- uint32 size_of_stack;
+ size_t top_of_stack;
+ size_t size_of_stack;
if (tcb->stack_alloc_ptr)
{
diff --git a/arch/sim/Make.defs b/arch/sim/Make.defs
index 12e288a573..19c2b5db6b 100644
--- a/arch/sim/Make.defs
+++ b/arch/sim/Make.defs
@@ -51,7 +51,7 @@ ARCHSCRIPT =
CROSSDEV =
CC = $(CROSSDEV)gcc
LD = $(CROSSDEV)ld
-AR = $(CROSSDEV)ar
+AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
@@ -61,6 +61,7 @@ CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
LDFLAGS = $(ARCHSCRIPT)
EXTRA_LIBS = -lc
+LIBEXT = .a
ifeq ("${CONFIG_DEBUG}","y")
LDFLAGS += -g
diff --git a/arch/sim/defconfig b/arch/sim/defconfig
index 80de3cbdc6..5b6f2ae6f0 100644
--- a/arch/sim/defconfig
+++ b/arch/sim/defconfig
@@ -99,6 +99,8 @@ CONFIG_ARCH_KFREE=n
#
# General Compile environment setup
#
+# CONFIG_SMALL_MEMORY - enable if your processor supports
+# 16-bit addressing; disable if it supports 32-bit.
# CONFIG_HAVE_INLINE - enable if your compiler supports
# inline functions
# CONFIG_HAVE_DOUBLE - enable if your compiler supports type
@@ -106,21 +108,26 @@ CONFIG_ARCH_KFREE=n
# CONFIG_HAVE_LONG_LONG - enable if your architecture supports
# long long types and if you plan to use them
# CONFIG_CAN_PASS_STRUCTS - enable if your compiler supports
-# passing structures and unions as values
+# passing and assiging structures and unions as values
+# CONFIG_CAN_CAST_POINTERS - enable if you can cast between
+# integers and pointer.
# CONFIG_HAVE_WEAKFUNCTIONS - enable if you compiler supports
# weak functions (see include/nuttx/comp
#
+CONFIG_SMALL_MEMORY=n
CONFIG_HAVE_INLINE=y
CONFIG_HAVE_DOUBLE=y
CONFIG_HAVE_LONG_LONG=n
CONFIG_CAN_PASS_STRUCTS=y
+CONFIG_CAN_CAST_POINTERS=y
CONFIG_HAVE_WEAKFUNCTIONS=y
#
# General build options
#
-# CONFIG_RRLOAD_BINY - make the rrload binary format used with
+# CONFIG_RRLOAD_BINARY - make the rrload binary format used with
# BSPs from www.ridgerun.com
+#
CONFIG_RRLOAD_BINARY=n
#
@@ -142,6 +149,8 @@ CONFIG_RRLOAD_BINARY=n
# CONFIG_MQ_MAXMSGSIZE - Message structures are allocated with
# a fixed payload size given by this settin (does not include
# other message structure overhead.
+# CONFIG_MAX_WDOGPARMS - Maximum number of parameters that
+# can be passed to a watchdog handler
# CONFIG_PREALLOC_WDOGS - The number of pre-allocated watchdog
# structures. The system manages a pool of preallocated
# watchdog structures to minimize dynamic allocations
@@ -153,6 +162,7 @@ CONFIG_STDIO_BUFFER_SIZE=1024
CONFIG_NUNGET_CHARS=2
CONFIG_PREALLOC_MQ_MSGS=32
CONFIG_MQ_MAXMSGSIZE=32
+CONFIG_MAX_WDOGPARMS=4
CONFIG_PREALLOC_WDOGS=32
#
diff --git a/arch/sim/include/irq.h b/arch/sim/include/irq.h
index 3ae46aa42d..f866da50dc 100644
--- a/arch/sim/include/irq.h
+++ b/arch/sim/include/irq.h
@@ -44,6 +44,8 @@
* Included Files
************************************************************/
+#include
+
/************************************************************
* Definitions
************************************************************/
@@ -72,12 +74,12 @@ struct xcptcontext
************************************************************/
#ifndef __ASSEMBLY__
-static inline uint32 irqsave(void)
+static inline irqstate_t irqsave(void)
{
return 0;
}
-static inline void irqrestore(uint32 flags)
+static inline void irqrestore(irqstate_t flags)
{
}
#endif
diff --git a/arch/sim/include/types.h b/arch/sim/include/types.h
index 39232af7d7..1c7636886c 100644
--- a/arch/sim/include/types.h
+++ b/arch/sim/include/types.h
@@ -52,6 +52,10 @@
* Type Declarations
************************************************************/
+#ifndef __ASSEMBLY__
+
+/* These are the sizes of the standard GNU types */
+
typedef char sbyte;
typedef unsigned char ubyte;
typedef unsigned char uint8;
@@ -63,6 +67,14 @@ typedef unsigned int uint32;
typedef long long sint64;
typedef unsigned long long uint64;
+/* This is the size of the interrupt state save returned by
+ * irqsave()
+ */
+
+typedef unsigned int irqstate_t;
+
+#endif /* __ASSEMBLY__ */
+
/************************************************************
* Global Function Prototypes
************************************************************/
diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile
index 780cff5968..53b4c6a7ea 100644
--- a/arch/sim/src/Makefile
+++ b/arch/sim/src/Makefile
@@ -49,7 +49,7 @@ COBJS = $(CSRCS:.c=.o)
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
-all: up_head.o libarch.a
+all: up_head.o libarch$(LIBEXT)
$(AOBJS): %.o: %.S
$(CC) -c $(CFLAGS) -D__ASSEMBLY__ $< -o $@
@@ -57,8 +57,11 @@ $(AOBJS): %.o: %.S
$(COBJS) up_head.o: %.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
-libarch.a: $(OBJS)
- $(AR) rcs $@ $(OBJS)
+libarch$(LIBEXT): $(OBJS)
+ ( for obj in $(OBJS) ; do \
+ $(AR) $@ $${obj} || \
+ { echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \
+ done ; )
.depend: Makefile $(SRCS)
$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
@@ -67,7 +70,7 @@ libarch.a: $(OBJS)
depend: .depend
clean:
- rm -f libarch.a *.o *~
+ rm -f libarch$(LIBEXT) *.o *~
distclean: clean
rm -f Make.dep .depend
diff --git a/arch/sim/src/up_createstack.c b/arch/sim/src/up_createstack.c
index 0e2c63e4d1..845c766618 100644
--- a/arch/sim/src/up_createstack.c
+++ b/arch/sim/src/up_createstack.c
@@ -81,14 +81,14 @@
*
************************************************************/
-STATUS up_create_stack(_TCB *tcb, uint32 stack_size)
+STATUS up_create_stack(_TCB *tcb, size_t stack_size)
{
STATUS ret = ERROR;
/* Move up to next even word boundary if necessary */
- uint32 adj_stack_size = (stack_size + 3) & ~3;
- uint32 adj_stack_words = adj_stack_size >> 2;
+ size_t adj_stack_size = (stack_size + 3) & ~3;
+ size_t adj_stack_words = adj_stack_size >> 2;
/* Allocate the memory for the stack */
@@ -97,9 +97,10 @@ STATUS up_create_stack(_TCB *tcb, uint32 stack_size)
{
/* This is the address of the last word in the allocation */
- uint32 *adj_stack_ptr = &stack_alloc_ptr[adj_stack_words - 1];
+ size_t *adj_stack_ptr = &stack_alloc_ptr[adj_stack_words - 1];
/* Save the values in the TCB */
+
tcb->adj_stack_size = adj_stack_size;
tcb->stack_alloc_ptr = stack_alloc_ptr;
tcb->adj_stack_ptr = adj_stack_ptr;
diff --git a/arch/sim/src/up_head.c b/arch/sim/src/up_head.c
index 9d1ccf1533..1fc705b5b4 100644
--- a/arch/sim/src/up_head.c
+++ b/arch/sim/src/up_head.c
@@ -64,13 +64,13 @@ int main(int argc, char **argv, char **envp)
return 0;
}
-void up_assert(const ubyte *filename, uint32 line)
+void up_assert(const ubyte *filename, int line)
{
fprintf(stderr, "Assertion failed at file:%s line: %d\n", filename, line);
longjmp(sim_abort, 1);
}
-void up_assert_code(const ubyte *filename, uint32 line, uint16 code)
+void up_assert_code(const ubyte *filename, int line, int code)
{
fprintf(stderr, "Assertion failed at file:%s line: %d error code: %d\n", filename, line, code);
longjmp(sim_abort, 1);
diff --git a/arch/sim/src/up_usestack.c b/arch/sim/src/up_usestack.c
index 26bf14b211..0c6e7650f3 100644
--- a/arch/sim/src/up_usestack.c
+++ b/arch/sim/src/up_usestack.c
@@ -81,18 +81,19 @@
*
************************************************************/
-STATUS up_use_stack(_TCB *tcb, uint32 *stack, uint32 stack_size)
+STATUS up_use_stack(_TCB *tcb, void *stack, size_t stack_size)
{
/* Move up to next even word boundary if necessary */
- uint32 adj_stack_size = stack_size & ~3;
- uint32 adj_stack_words = adj_stack_size >> 2;
+ size_t adj_stack_size = stack_size & ~3;
+ size_t adj_stack_words = adj_stack_size >> 2;
/* This is the address of the last word in the allocation */
- uint32 *adj_stack_ptr = &stack[adj_stack_words - 1];
+ size_t *adj_stack_ptr = &stack[adj_stack_words - 1];
/* Save the values in the TCB */
+
tcb->adj_stack_size = adj_stack_size;
tcb->stack_alloc_ptr = stack;
tcb->adj_stack_ptr = adj_stack_ptr;
diff --git a/drivers/Makefile b/drivers/Makefile
index dcd4dec625..695dd806a4 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -46,7 +46,7 @@ COBJS = $(CSRCS:.c=.o)
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
-BIN = libdrivers.a
+BIN = libdrivers$(LIBEXT)
all: $(BIN)
@@ -57,7 +57,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
diff --git a/examples/ostest/Makefile b/examples/ostest/Makefile
index 85612a9921..df30ca841c 100644
--- a/examples/ostest/Makefile
+++ b/examples/ostest/Makefile
@@ -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
diff --git a/examples/ostest/timedwait.c b/examples/ostest/timedwait.c
index b01b352fff..af2fd2551c 100644
--- a/examples/ostest/timedwait.c
+++ b/examples/ostest/timedwait.c
@@ -37,6 +37,7 @@
#include
#include
#include
+#include
#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);
}
}
diff --git a/fs/Makefile b/fs/Makefile
index fa69e2b4b7..36b651739e 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -47,7 +47,7 @@ COBJS = $(CSRCS:.c=.o)
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
-BIN = libfs.a
+BIN = libfs$(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
diff --git a/include/assert.h b/include/assert.h
index 831b574852..022e343cab 100644
--- a/include/assert.h
+++ b/include/assert.h
@@ -53,21 +53,42 @@
#undef ASSERTCODE
#undef DEBUGASSERT
-#define ASSERT(f) \
- { if (!(f)) up_assert((const ubyte *)__FILE__, (uint32)__LINE__); }
+#ifdef __GNUC__
-#define ASSERTCODE(f, errCode) \
- { if (!(f)) up_assert_code((const ubyte *)__FILE__, (uint32)__LINE__, errCode); }
+# define ASSERT(f) \
+ { if (!(f)) up_assert((const ubyte *)__FILE__, (int)__LINE__); }
+
+# define ASSERTCODE(f, errCode) \
+ { if (!(f)) up_assert_code((const ubyte *)__FILE__, (int)__LINE__, errCode); }
+
+# ifdef CONFIG_DEBUG
+# define DEBUGASSERT(f) \
+ { if (!(f)) up_assert((const ubyte *)__FILE__, (int)__LINE__); }
+# else
+# define DEBUGASSERT(f)
+# endif /* CONFIG_DEBUG */
+
+# define PANIC(errCode) \
+ up_assert_code((const ubyte *)__FILE__, (int)__LINE__, (errCode)|0x8000)
-#ifdef CONFIG_DEBUG
-#define DEBUGASSERT(f) \
- { if (!(f)) up_assert((const ubyte *)__FILE__, (uint32)__LINE__); }
#else
-#define DEBUGASSERT(f)
-#endif /* CONFIG_DEBUG */
+# define ASSERT(f) \
+ { if (!(f)) up_assert(); }
-#define PANIC(errCode) \
- up_assert_code((const ubyte *)__FILE__, (uint32)__LINE__, ((errCode)|(0x8000)))
+# define ASSERTCODE(f, errCode) \
+ { if (!(f)) up_assert_code(errCode); }
+
+# ifdef CONFIG_DEBUG
+# define DEBUGASSERT(f) \
+ { if (!(f)) up_assert(); }
+# else
+# define DEBUGASSERT(f)
+# endif /* CONFIG_DEBUG */
+
+# define PANIC(errCode) \
+ up_assert_code((errCode)|0x8000)
+
+#endif
/************************************************************
* Included Files
@@ -84,9 +105,14 @@ extern "C" {
#define EXTERN extern
#endif
-EXTERN void up_assert(const ubyte *fileName, uint32 lineNum);
-EXTERN void up_assert_code(const ubyte *fileName, uint32 lineNum,
- uint16 errorCode);
+#ifdef __GNUC__
+EXTERN void up_assert(const ubyte *fileName, int lineNum);
+EXTERN void up_assert_code(const ubyte *fileName, int lineNum,
+ int error_code);
+#else
+EXTERN void up_assert(void);
+EXTERN void up_assert_code(int error_code);
+#endif
#undef EXTERN
#ifdef __cplusplus
diff --git a/include/errno.h b/include/errno.h
index 50fddfc9f0..d189ccaa08 100644
--- a/include/errno.h
+++ b/include/errno.h
@@ -188,8 +188,16 @@ extern "C" {
#define EXTERN extern
#endif
+/* Return a pointer to the thread specifid errno */
+
extern int *get_errno_ptr(void);
+#ifndef CONFIG_CAN_CAST_POINTERS
+/* Return the value ERROR cast to (void*) */
+
+extern void *get_errorptr(void);
+#endif
+
#undef EXTERN
#if defined(__cplusplus)
}
diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h
index cc5ad35608..5ccba7c20e 100644
--- a/include/nuttx/arch.h
+++ b/include/nuttx/arch.h
@@ -150,7 +150,7 @@ EXTERN void up_initial_state(_TCB *tcb);
* must be allocated.
************************************************************/
-EXTERN STATUS up_create_stack(_TCB *tcb, uint32 stack_size);
+EXTERN STATUS up_create_stack(_TCB *tcb, size_t stack_size);
/************************************************************
* Name: up_use_stack
@@ -173,7 +173,7 @@ EXTERN STATUS up_create_stack(_TCB *tcb, uint32 stack_size);
*
************************************************************/
-EXTERN STATUS up_use_stack(_TCB *tcb, uint32 *stack, uint32 stack_size);
+EXTERN STATUS up_use_stack(_TCB *tcb, void *stack, size_t stack_size);
/************************************************************
* Name: up_release_stack
diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h
index 6f4e68baf5..b5eafe8d98 100644
--- a/include/nuttx/compiler.h
+++ b/include/nuttx/compiler.h
@@ -52,6 +52,7 @@
# define noreturn_function __attribute__ ((noreturn))
# define reentrant_function
#elif defined(__SDCC__)
+# pragma disable_warning 85
# define weak_alias(name, aliasname)
# define weak_function
# define weak_const_function
diff --git a/include/nuttx/irq.h b/include/nuttx/irq.h
index ce35434041..82a34c7604 100644
--- a/include/nuttx/irq.h
+++ b/include/nuttx/irq.h
@@ -61,7 +61,7 @@
#ifndef __ASSEMBLY__
typedef int (*xcpt_t)(int irq, void *context);
-typedef int (*swint_t)(uint32 code, uint32 parm2, uint32 parm3,
+typedef int (*swint_t)(int code, int parm2, int parm3,
void *context);
#endif
diff --git a/include/pthread.h b/include/pthread.h
index c03e2a5fad..12f0d53651 100644
--- a/include/pthread.h
+++ b/include/pthread.h
@@ -63,29 +63,33 @@
* Definitions
************************************************************/
-#define PTHREAD_PROCESS_PRIVATE 0
-#define PTHREAD_PROCESS_SHARED 1
+#define PTHREAD_PROCESS_PRIVATE 0
+#define PTHREAD_PROCESS_SHARED 1
-#define PTHREAD_STACK_MIN CONFIG_PTHREAD_STACK_MIN
-#define PTHREAD_STACK_DEFAULT CONFIG_PTHREAD_STACK_DEFAULT
+#define PTHREAD_STACK_MIN CONFIG_PTHREAD_STACK_MIN
+#define PTHREAD_STACK_DEFAULT CONFIG_PTHREAD_STACK_DEFAULT
-#define PTHREAD_INHERIT_SCHED 0
-#define PTHREAD_EXPLICIT_SCHED 1
+#define PTHREAD_INHERIT_SCHED 0
+#define PTHREAD_EXPLICIT_SCHED 1
-#define PTHREAD_PRIO_NONE 0
-#define PTHREAD_PRIO_INHERIT 1
-#define PTHREAD_PRIO_PROTECT 2
+#define PTHREAD_PRIO_NONE 0
+#define PTHREAD_PRIO_INHERIT 1
+#define PTHREAD_PRIO_PROTECT 2
#define PTHREAD_DEFAULT_PRIORITY 100
/* Cancellation states returned by pthread_cancelstate() */
-#define PTHREAD_CANCEL_ENABLE (0)
-#define PTHREAD_CANCEL_DISABLE (1)
+#define PTHREAD_CANCEL_ENABLE (0)
+#define PTHREAD_CANCEL_DISABLE (1)
/* Thread return value when a pthread is canceled */
-#define PTHREAD_CANCELED ((void*)-1)
+#ifdef CONFIG_CAN_CAST_POINTERS
+# define PTHREAD_CANCELED ((void*)ERROR)
+#else
+# define PTHREAD_CANCELED ((void*)pthread_create)
+#endif
/************************************************************
* Global Type Declarations
diff --git a/include/sched.h b/include/sched.h
index c5d7e1163a..4266eb9c0a 100644
--- a/include/sched.h
+++ b/include/sched.h
@@ -171,17 +171,19 @@ struct _TCB
/* Stack-Related Fields *********************************************/
- uint32 adj_stack_size; /* Stack size after adjustment */
+ size_t adj_stack_size; /* Stack size after adjustment */
/* for hardware, processor, etc. */
/* (for debug purposes only) */
- uint32 *stack_alloc_ptr; /* Pointer to allocated stack */
+ void *stack_alloc_ptr; /* Pointer to allocated stack */
/* Need to deallocate stack */
- uint32 *adj_stack_ptr; /* Adjusted StatckAllocPtr for HW */
+ void *adj_stack_ptr; /* Adjusted StatckAllocPtr for HW */
/* The initial stack pointer value */
/* POSIX thread Specific Data ***************************************/
+#if CONFIG_NPTHREAD_KEYS > 0
void *pthread_data[CONFIG_NPTHREAD_KEYS];
+#endif
/* POSIX Semaphore Control Fields ***********************************/
diff --git a/include/sys/types.h b/include/sys/types.h
index 37b206ee19..45971e4fd9 100644
--- a/include/sys/types.h
+++ b/include/sys/types.h
@@ -112,6 +112,7 @@
* Type Declarations
************************************************************/
+#ifndef __ASSEMBLY__
#ifndef CONFIG_HAVE_DOUBLE
typedef float double_t;
#else
@@ -120,15 +121,21 @@ typedef double double_t;
/* Misc. scalar types */
-typedef uint32 mode_t;
+typedef unsigned int mode_t;
+#ifdef CONFIG_SMALL_MEMORY
+typedef uint16 size_t;
+typedef sint16 ssize_t;
+typedef sint16 off_t;
+#else
typedef uint32 size_t;
typedef sint32 ssize_t;
-//typedef sint32 time_t;
typedef sint32 off_t;
-typedef sint32 uid_t;
-typedef sint32 gid_t;
-typedef uint32 dev_t;
-typedef uint32 ino_t;
+#endif
+//typedef sint32 time_t;
+typedef sint16 uid_t;
+typedef sint16 gid_t;
+typedef uint16 dev_t;
+typedef uint16 ino_t;
typedef unsigned int sig_atomic_t;
typedef int pid_t;
typedef int STATUS;
@@ -143,6 +150,7 @@ struct sched_param
{
int sched_priority;
};
+#endif
/************************************************************
* Global Function Prototypes
diff --git a/include/wdog.h b/include/wdog.h
index 9ef16256c6..a1065eaae1 100644
--- a/include/wdog.h
+++ b/include/wdog.h
@@ -55,11 +55,28 @@
* Global Type Declarations
************************************************************/
+/* The arguments are passed as uint32 values. For systems
+ * where the sizeof(pointer) < sizeof(uint32), the following
+ * union defines the alignment of the pointer within the
+ * uint32. For example, the SDCC MCS51 general pointer is
+ * 24-bits, but uint32 is 32-bits (of course).
+ *
+ * For systems where sizeof(pointer) > sizeof(uint32), we will
+ * have to do some redesign.
+ */
+
+union wdparm_u
+{
+ void *pvarg;
+ uint32 *dwarg;
+};
+typedef union wdparm_u wdparm_t;
+
/* This is the form of the function that is called when the
* watchdog function expires. Up to four parameters may be passed.
*/
-typedef void (*wdentry_t)(int arg1, ...);
+typedef void (*wdentry_t)(int argc, uint32 arg1, ...);
/* Watchdog 'handle' */
@@ -81,10 +98,10 @@ extern "C" {
#endif
EXTERN WDOG_ID wd_create(void);
-EXTERN STATUS wd_delete(WDOG_ID wdId);
-EXTERN STATUS wd_start(WDOG_ID wdId, int delay, wdentry_t wdentry,
- int parm1, int parm2, int parm3, int parm4);
-EXTERN STATUS wd_cancel(WDOG_ID wdId);
+EXTERN STATUS wd_delete(WDOG_ID wdog);
+EXTERN STATUS wd_start(WDOG_ID wdog, int delay, wdentry_t wdentry,
+ int argc, ...);
+EXTERN STATUS wd_cancel(WDOG_ID wdog);
#undef EXTERN
#ifdef __cplusplus
diff --git a/lib/Makefile b/lib/Makefile
index 2dfda7e819..361c0bb63c 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -68,7 +68,7 @@ COBJS = $(CSRCS:.c=.o)
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
-BIN = liblib.a
+BIN = liblib$(LIBEXT)
all: $(BIN)
@@ -79,7 +79,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
diff --git a/mm/Makefile b/mm/Makefile
index 79460a34a7..ce32beea5d 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -47,7 +47,7 @@ COBJS = $(CSRCS:.c=.o)
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
-BIN = libmm.a
+BIN = libmm$(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
diff --git a/mm/mm_environment.h b/mm/mm_environment.h
index 15f6924860..8d4816bd02 100644
--- a/mm/mm_environment.h
+++ b/mm/mm_environment.h
@@ -69,10 +69,6 @@
#ifdef MM_TEST
-/* Standard types */
-
-typedef unsigned int uint32;
-
/* Use the real system errno */
# define mm_errno errno
diff --git a/mm/mm_initialize.c b/mm/mm_initialize.c
index a16ac9b0e3..4bf24a70b8 100644
--- a/mm/mm_initialize.c
+++ b/mm/mm_initialize.c
@@ -50,7 +50,7 @@
/* This is the size of the heap provided to mm */
-uint32 g_heapsize;
+size_t g_heapsize;
/* This is the first and last nodes of the heap */
@@ -97,8 +97,8 @@ void mm_initialize(void *heapstart, size_t heapsize)
* both aligned with the MM_MIN_CHUNK size.
*/
- uint32 heapbase = MM_ALIGN_UP((uint32)heapstart);
- uint32 heapend = MM_ALIGN_DOWN((uint32)heapstart + (uint32)heapsize);
+ size_t heapbase = MM_ALIGN_UP((size_t)heapstart);
+ size_t heapend = MM_ALIGN_DOWN((size_t)heapstart + (size_t)heapsize);
/* Save the size of the heap */
diff --git a/mm/mm_internal.h b/mm/mm_internal.h
index fe519ab2e4..27c9f1f3b2 100644
--- a/mm/mm_internal.h
+++ b/mm/mm_internal.h
@@ -61,8 +61,13 @@
* losses.
*/
-#define MM_MIN_SHIFT 4 /* 16 bytes */
-#define MM_MAX_SHIFT 22 /* 4 Mb */
+#ifdef CONFIG_SMALL_MEMORY
+# define MM_MIN_SHIFT 4 /* 16 bytes */
+# define MM_MAX_SHIFT 15 /* 32 Kb */
+#else
+# define MM_MIN_SHIFT 4 /* 16 bytes */
+# define MM_MAX_SHIFT 22 /* 4 Mb */
+#endif
/* All other definitions derive from these two */
@@ -79,7 +84,11 @@
* an allocated chunk.
*/
-#define MM_ALLOC_BIT 0x80000000
+#ifdef CONFIG_SMALL_MEMORY
+# define MM_ALLOC_BIT 0x8000
+#else
+# define MM_ALLOC_BIT 0x80000000
+#endif
#define MM_IS_ALLOCATED(n) \
((int)((struct mm_allocnode_s*)(n)->preceding) < 0))
@@ -94,11 +103,16 @@
struct mm_allocnode_s
{
- uint32 size; /* Size of this chunk */
- uint32 preceding; /* Size of the preceding chunk */
+ size_t size; /* Size of this chunk */
+ size_t preceding; /* Size of the preceding chunk */
};
-#define SIZEOF_MM_ALLOCNODE 8
+#ifdef CONFIG_SMALL_MEMORY
+# define SIZEOF_MM_ALLOCNODE 4
+#else
+# define SIZEOF_MM_ALLOCNODE 8
+#endif
+
#define CHECK_ALLOCNODE_SIZE \
DEBUGASSERT(sizeof(struct mm_allocnode_s) == SIZEOF_MM_ALLOCNODE)
@@ -106,13 +120,17 @@ struct mm_allocnode_s
struct mm_freenode_s
{
- uint32 size; /* Size of this chunk */
- uint32 preceding; /* Size of the preceding chunk */
+ size_t size; /* Size of this chunk */
+ size_t preceding; /* Size of the preceding chunk */
struct mm_freenode_s *flink; /* Supports a doubly linked list */
struct mm_freenode_s *blink;
};
-#define SIZEOF_MM_FREENODE 16
+#ifdef CONFIG_SMALL_MEMORY
+# define SIZEOF_MM_FREENODE 10
+#else
+# define SIZEOF_MM_FREENODE 16
+#endif
#define CHECK_FREENODE_SIZE \
DEBUGASSERT(sizeof(struct mm_freenode_s) == SIZEOF_MM_FREENODE)
@@ -138,7 +156,7 @@ struct mallinfo
/* This is the size of the heap provided to mm */
-extern uint32 g_heapsize;
+extern size_t g_heapsize;
/* This is the first and last nodes of the heap */
@@ -168,9 +186,9 @@ extern struct mm_freenode_s g_nodelist[MM_NNODES];
extern struct mallinfo mallinfo(void);
#endif
-extern void mm_shrinkchunk(struct mm_allocnode_s *node, uint32 size);
+extern void mm_shrinkchunk(struct mm_allocnode_s *node, size_t size);
extern void mm_addfreechunk(struct mm_freenode_s *node);
-extern int mm_size2ndx(uint32 size);
+extern int mm_size2ndx(size_t size);
extern void mm_seminitialize(void);
extern void mm_takesemaphore(void);
extern void mm_givesemaphore(void);
diff --git a/mm/mm_mallinfo.c b/mm/mm_mallinfo.c
index 7b242b4ea1..4aba9770c9 100644
--- a/mm/mm_mallinfo.c
+++ b/mm/mm_mallinfo.c
@@ -69,10 +69,10 @@ struct mallinfo mallinfo(void)
{
static struct mallinfo stats;
struct mm_allocnode_s *node;
- uint32 mxordblk = 0;
+ size_t mxordblk = 0;
int ordblks = 0; /* Number of non-inuse chunks */
- uint32 uordblks = 0; /* Total allocated space */
- uint32 fordblks = 0; /* Total non-inuse space */
+ size_t uordblks = 0; /* Total allocated space */
+ size_t fordblks = 0; /* Total non-inuse space */
/* Visit each node in physical memory */
diff --git a/mm/mm_malloc.c b/mm/mm_malloc.c
index 222aca3b2a..80a89222b1 100644
--- a/mm/mm_malloc.c
+++ b/mm/mm_malloc.c
@@ -144,7 +144,7 @@ void *malloc(size_t size)
{
struct mm_freenode_s *remainder;
struct mm_freenode_s *next;
- uint32 remaining;
+ size_t remaining;
/* Remove the node. There must be a predecessor, but there may
* not be a successor node.
diff --git a/mm/mm_memalign.c b/mm/mm_memalign.c
index 18f3b295a0..1f5c077277 100644
--- a/mm/mm_memalign.c
+++ b/mm/mm_memalign.c
@@ -66,10 +66,10 @@
void *memalign(size_t alignment, size_t size)
{
struct mm_allocnode_s *node;
- uint32 rawchunk;
- uint32 alignedchunk;
- uint32 mask = (uint32)(alignment - 1);
- uint32 allocsize;
+ size_t rawchunk;
+ size_t alignedchunk;
+ size_t mask = (size_t)(alignment - 1);
+ size_t allocsize;
/* If this requested alignement less than or equal to the
* natural alignment of malloc, then just let malloc do the
@@ -99,7 +99,7 @@ void *memalign(size_t alignment, size_t size)
/* Then malloc that size */
- rawchunk = (uint32)malloc(allocsize);
+ rawchunk = (size_t)malloc(allocsize);
if (!rawchunk)
{
return NULL;
@@ -127,7 +127,7 @@ void *memalign(size_t alignment, size_t size)
{
struct mm_allocnode_s *newnode;
struct mm_allocnode_s *next;
- uint32 precedingsize;
+ size_t precedingsize;
/* Get the node the next node after the allocation. */
@@ -145,7 +145,7 @@ void *memalign(size_t alignment, size_t size)
* SIZEOF_MM_ALLOCNODE
*/
- precedingsize = (uint32)newnode - (uint32)node;
+ precedingsize = (size_t)newnode - (size_t)node;
/* If we were unlucky, then the alignedchunk can lie in such
* a position that precedingsize < SIZEOF_NODE_FREENODE. We
@@ -159,12 +159,12 @@ void *memalign(size_t alignment, size_t size)
{
alignedchunk += alignment;
newnode = (struct mm_allocnode_s*)(alignedchunk - SIZEOF_MM_ALLOCNODE);
- precedingsize = (uint32)newnode - (uint32)node;
+ precedingsize = (size_t)newnode - (size_t)node;
}
/* Set up the size of the new node */
- newnode->size = (uint32)next - (uint32)newnode;
+ newnode->size = (size_t)next - (size_t)newnode;
newnode->preceding = precedingsize | MM_ALLOC_BIT;
/* Reduce the size of the original chunk and mark it not allocated, */
diff --git a/mm/mm_realloc.c b/mm/mm_realloc.c
index 01836de60d..b288e880a3 100644
--- a/mm/mm_realloc.c
+++ b/mm/mm_realloc.c
@@ -78,9 +78,9 @@ void *realloc(void *oldmem, size_t size)
struct mm_allocnode_s *oldnode;
struct mm_freenode_s *prev;
struct mm_freenode_s *next;
- uint32 oldsize;
- uint32 prevsize = 0;
- uint32 nextsize = 0;
+ size_t oldsize;
+ size_t prevsize = 0;
+ size_t nextsize = 0;
/* If oldmem is NULL, then realloc is equivalent to malloc */
@@ -145,9 +145,9 @@ void *realloc(void *oldmem, size_t size)
if (nextsize + prevsize + oldsize >= size)
{
- uint32 needed = size - oldsize;
- uint32 takeprev;
- uint32 takenext;
+ size_t needed = size - oldsize;
+ size_t takeprev;
+ size_t takenext;
/* Check if we can extend into the previous chunk and if the
* previous chunk is smaller than the next chunk.
diff --git a/mm/mm_shrinkchunk.c b/mm/mm_shrinkchunk.c
index daf57c7076..8869f045c7 100644
--- a/mm/mm_shrinkchunk.c
+++ b/mm/mm_shrinkchunk.c
@@ -64,7 +64,7 @@
*
************************************************************/
-void mm_shrinkchunk(struct mm_allocnode_s *node, uint32 size)
+void mm_shrinkchunk(struct mm_allocnode_s *node, size_t size)
{
struct mm_freenode_s *next;
diff --git a/mm/mm_size2ndx.c b/mm/mm_size2ndx.c
index 271e3e2214..416652e034 100644
--- a/mm/mm_size2ndx.c
+++ b/mm/mm_size2ndx.c
@@ -50,7 +50,7 @@
/* Convert the size to a nodelist index */
-int mm_size2ndx(uint32 size)
+int mm_size2ndx(size_t size)
{
int ndx = 0;
diff --git a/mm/mm_test.c b/mm/mm_test.c
index 86861121ac..779fd607c7 100644
--- a/mm/mm_test.c
+++ b/mm/mm_test.c
@@ -37,7 +37,6 @@
#include
#include
-typedef unsigned int uint32;
#include "mm_internal.h"
/* Definitions */
diff --git a/sched/Makefile b/sched/Makefile
index bc144b797b..5efa4a6f02 100644
--- a/sched/Makefile
+++ b/sched/Makefile
@@ -40,7 +40,7 @@ MKDEP = $(TOPDIR)/tools/mkdeps.sh
ASRCS =
AOBJS = $(ASRCS:.S=.o)
-MISC_SRCS = os_start.c get_errno_ptr.c \
+MISC_SRCS = os_start.c get_errno_ptr.c get_errorptr.c \
sched_setupstreams.c sched_getfiles.c sched_getstreams.c \
sched_setupidlefiles.c sched_setuptaskfiles.c sched_setuppthreadfiles.c \
sched_releasefiles.c
@@ -101,7 +101,7 @@ COBJS = $(CSRCS:.c=.o)
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
-BIN = libsched.a
+BIN = libsched$(LIBEXT)
all: $(BIN)
@@ -112,7 +112,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
diff --git a/sched/get_errorptr.c b/sched/get_errorptr.c
new file mode 100644
index 0000000000..7cfad6cb13
--- /dev/null
+++ b/sched/get_errorptr.c
@@ -0,0 +1,83 @@
+/************************************************************
+ * get_errorptr.c
+ *
+ * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name Gregory Nutt nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************/
+
+/************************************************************
+ * Included Files
+ ************************************************************/
+
+#include
+#include
+
+/************************************************************
+ * Global Functions
+ ************************************************************/
+
+/************************************************************
+ * Function: get_errorptr
+ *
+ * Description:
+ * Return a pointer that is just ERROR cast to void *.
+ * most fully performing processors don't need anything
+ * like this. Hoever, this little of nonsense is necessary
+ * for some processors where sizeof(pointer) < sizeof(uint32)
+ * and which do not support casts of integers to pointers.
+ *
+ * Parameters:
+ * None
+ *
+ * Return Value:
+ * ERROR cast as a pointer value
+ *
+ * Assumptions:
+ *
+ ************************************************************/
+
+void *get_errnorptr(void)
+{
+#ifdef CONFIG_CAN_CAST_POINTERS
+ return (void*)ERROR;
+#else
+ union
+ {
+ void *verror;
+ sint32 ierror;
+ } u;
+
+ u.ierror = ERROR;
+ return u.verror;
+#endif
+}
+
+
diff --git a/sched/irq_attach.c b/sched/irq_attach.c
index 2c669071d8..d67a04a497 100644
--- a/sched/irq_attach.c
+++ b/sched/irq_attach.c
@@ -80,7 +80,7 @@ int irq_attach(int irq, xcpt_t isr)
if ((unsigned)irq < NR_IRQS)
{
- int state;
+ irqstate_t state;
/* If the new ISR is NULL, then the ISR is being detached.
* In this case, disable the ISR and direct any interrupts
diff --git a/sched/mq_close.c b/sched/mq_close.c
index c9817f9947..88fe0e0438 100644
--- a/sched/mq_close.c
+++ b/sched/mq_close.c
@@ -113,10 +113,10 @@
int mq_close(mqd_t mqdes)
{
- _TCB *rtcb = (_TCB*)g_readytorun.head;
- msgq_t *msgq;
- uint32 saved_state;
- int ret = ERROR;
+ _TCB *rtcb = (_TCB*)g_readytorun.head;
+ msgq_t *msgq;
+ irqstate_t saved_state;
+ int ret = ERROR;
/* Verify the inputs */
diff --git a/sched/mq_msgfree.c b/sched/mq_msgfree.c
index 9c5f12af5c..f9246d8fcf 100644
--- a/sched/mq_msgfree.c
+++ b/sched/mq_msgfree.c
@@ -86,7 +86,7 @@
void mq_msgfree(mqmsg_t * mqmsg)
{
- uint32 saved_state;
+ irqstate_t saved_state;
/* If this is a generally available pre-allocated message,
* then just put it back in the free list.
diff --git a/sched/mq_notify.c b/sched/mq_notify.c
index aaed2e45b1..3632c7636e 100644
--- a/sched/mq_notify.c
+++ b/sched/mq_notify.c
@@ -141,11 +141,11 @@ int mq_notify(mqd_t mqdes, const struct sigevent *notification)
{
/* Yes... Assign it to the current task. */
- msgq->ntvalue = notification->sigev_value;
- msgq->ntsigno = notification->sigev_signo;
- msgq->ntpid = rtcb->pid;
- msgq->ntmqdes = mqdes;
- ret = OK;
+ msgq->ntvalue.sival_ptr = notification->sigev_value.sival_ptr;
+ msgq->ntsigno = notification->sigev_signo;
+ msgq->ntpid = rtcb->pid;
+ msgq->ntmqdes = mqdes;
+ ret = OK;
}
}
@@ -159,7 +159,7 @@ int mq_notify(mqd_t mqdes, const struct sigevent *notification)
msgq->ntpid = INVALID_PROCESS_ID;
msgq->ntsigno = 0;
- msgq->ntvalue.sival_int = 0;
+ msgq->ntvalue.sival_ptr = NULL;
msgq->ntmqdes = NULL;
ret = OK;
}
diff --git a/sched/mq_open.c b/sched/mq_open.c
index 97b2af121b..d4ad2a322f 100644
--- a/sched/mq_open.c
+++ b/sched/mq_open.c
@@ -42,6 +42,7 @@
#include
#include
#include
+#include
#include
#include
#include "os_internal.h"
@@ -217,7 +218,11 @@ mqd_t mq_open(const char *mq_name, int oflags, ...)
if (mqdes == NULL)
{
+#ifdef CONFIG_CAN_CAST_POINTERS
return (mqd_t)ERROR;
+#else
+ return get_errorptr();
+#endif
}
else
{
diff --git a/sched/mq_receive.c b/sched/mq_receive.c
index 3dbe662c2f..4e7555e13b 100644
--- a/sched/mq_receive.c
+++ b/sched/mq_receive.c
@@ -114,13 +114,13 @@
int mq_receive(mqd_t mqdes, void *msg, size_t msglen, int *prio)
{
- _TCB *rtcb;
- _TCB *btcb;
- msgq_t *msgq;
- mqmsg_t *curr;
- uint32 saved_state;
- ubyte rcvmsglen;
- int ret = ERROR;
+ _TCB *rtcb;
+ _TCB *btcb;
+ msgq_t *msgq;
+ mqmsg_t *curr;
+ irqstate_t saved_state;
+ ubyte rcvmsglen;
+ int ret = ERROR;
/* Verify the input parameters */
diff --git a/sched/mq_send.c b/sched/mq_send.c
index 431d8613c9..0a9a125151 100644
--- a/sched/mq_send.c
+++ b/sched/mq_send.c
@@ -94,8 +94,8 @@
mqmsg_t *mq_msgalloc(void)
{
- mqmsg_t *mqmsg;
- uint32 saved_state;
+ mqmsg_t *mqmsg;
+ irqstate_t saved_state;
/* If we were called from an interrupt handler, then try to
* get the message from generally available list of messages.
@@ -202,14 +202,14 @@ mqmsg_t *mq_msgalloc(void)
int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio)
{
- _TCB *rtcb;
- _TCB *btcb;
- msgq_t *msgq;
- mqmsg_t *curr;
- mqmsg_t *next;
- mqmsg_t *prev;
- uint32 saved_state;
- int ret = ERROR;
+ _TCB *rtcb;
+ _TCB *btcb;
+ msgq_t *msgq;
+ mqmsg_t *curr;
+ mqmsg_t *next;
+ mqmsg_t *prev;
+ irqstate_t saved_state;
+ int ret = ERROR;
/* Verify the input parameters */
@@ -343,7 +343,11 @@ int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio)
{
/* Remove the message notification data from the message queue. */
+#ifdef CONFIG_CAN_PASS_STRUCTS
union sigval value = msgq->ntvalue;
+#else
+ void *sival_ptr = msgq->ntvalue.sival_ptr;
+#endif
int signo = msgq->ntsigno;
int pid = msgq->ntpid;
@@ -356,7 +360,11 @@ int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio)
/* Queue the signal -- What if this returns an error? */
+#ifdef CONFIG_CAN_PASS_STRUCTS
sig_mqnotempty(pid, signo, value);
+#else
+ sig_mqnotempty(pid, signo, sival_ptr);
+#endif
}
/* Check if any tasks are waiting for the MQ not empty event. */
diff --git a/sched/mq_unlink.c b/sched/mq_unlink.c
index dc1f951405..066bcacabb 100644
--- a/sched/mq_unlink.c
+++ b/sched/mq_unlink.c
@@ -89,9 +89,9 @@
int mq_unlink(const char *mq_name)
{
- msgq_t *msgq;
- uint32 saved_state;
- int ret = ERROR;
+ msgq_t *msgq;
+ irqstate_t saved_state;
+ int ret = ERROR;
/* Verify the input values */
diff --git a/sched/os_start.c b/sched/os_start.c
index 6381800821..09de22ce3f 100644
--- a/sched/os_start.c
+++ b/sched/os_start.c
@@ -386,7 +386,7 @@ void os_start(void)
{
/* Remove the first delayed deallocation. */
- uint32 saved_state = irqsave();
+ irqstate_t saved_state = irqsave();
void *address = (void*)sq_remfirst(&g_delayeddeallocations);
irqrestore(saved_state);
diff --git a/sched/pthread_condtimedwait.c b/sched/pthread_condtimedwait.c
index 59d92921e8..9ebaf69178 100644
--- a/sched/pthread_condtimedwait.c
+++ b/sched/pthread_condtimedwait.c
@@ -71,14 +71,18 @@
* Private Functions
************************************************************/
-static void pthread_condtimedout(int pid, int signo, int arg3, int arg4)
+static void pthread_condtimedout(int argc, uint32 pid, uint32 signo, ...)
{
+#ifdef CONFIG_CAN_PASS_STRUCTS
union sigval value;
/* Send the specified signal to the specified task. */
- value.sival_ptr = 0;
- (void)sigqueue(pid, signo, value);
+ value.sival_ptr = NULL;
+ (void)sigqueue((int)pid, (int)signo, value);
+#else
+ (void)sigqueue((int)pid, (int)signo, NULL);
+#endif
}
/************************************************************
@@ -112,8 +116,8 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
sint32 relusec;
sint32 ticks;
int mypid = (int)getpid();
+ irqstate_t int_state;
int ret = OK;
- int int_state;
int status;
dbg("cond=0x%p mutex=0x%p abstime=0x%p\n", cond, mutex, abstime);
@@ -240,7 +244,7 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
/* Start the watchdog */
wd_start(wdog, ticks, (wdentry_t)pthread_condtimedout,
- mypid, ECHO_COND_WAIT_SIGNO, 0, 0);
+ 2, (uint32)mypid, (uint32)ECHO_COND_WAIT_SIGNO);
/* Take the condition semaphore. Do not restore interrupts
* until we return from the wait. This is necessary to
diff --git a/sched/pthread_create.c b/sched/pthread_create.c
index 5d9104c754..a369f0b495 100644
--- a/sched/pthread_create.c
+++ b/sched/pthread_create.c
@@ -65,10 +65,10 @@
pthread_attr_t g_default_pthread_attr =
{
- .stacksize = PTHREAD_STACK_DEFAULT,
- .priority = PTHREAD_DEFAULT_PRIORITY,
- .policy = SCHED_RR,
- .inheritsched = PTHREAD_EXPLICIT_SCHED,
+ PTHREAD_STACK_DEFAULT, /* stacksize */
+ PTHREAD_DEFAULT_PRIORITY, /* priority */
+ SCHED_RR, /* policy */
+ PTHREAD_EXPLICIT_SCHED, /* inheritsched */
};
/************************************************************
diff --git a/sched/pthread_getspecific.c b/sched/pthread_getspecific.c
index 886557f387..afcfba55c2 100644
--- a/sched/pthread_getspecific.c
+++ b/sched/pthread_getspecific.c
@@ -37,6 +37,8 @@
* Included Files
************************************************************/
+#include
+
#include
#include
#include
@@ -103,6 +105,7 @@
void *pthread_getspecific(pthread_key_t key)
{
+#if CONFIG_NPTHREAD_KEYS > 0
_TCB *rtcb = (_TCB*)g_readytorun.head;
void *ret = NULL;
@@ -116,4 +119,7 @@ void *pthread_getspecific(pthread_key_t key)
}
return ret;
+#else
+ return NULL;
+#endif
}
diff --git a/sched/pthread_keycreate.c b/sched/pthread_keycreate.c
index bda51e53a2..00d1271606 100644
--- a/sched/pthread_keycreate.c
+++ b/sched/pthread_keycreate.c
@@ -37,6 +37,8 @@
* Included Files
************************************************************/
+#include
+
#include
#include
#include
@@ -112,6 +114,7 @@
int pthread_key_create(pthread_key_t *key, void (*destructor)(void*))
{
+#if CONFIG_NPTHREAD_KEYS > 0
int ret = EAGAIN;
/* Check if we have exceeded the system-defined number of keys. */
@@ -132,4 +135,7 @@ int pthread_key_create(pthread_key_t *key, void (*destructor)(void*))
}
return ret;
+#else
+ return ENOSYS;
+#endif
}
diff --git a/sched/pthread_keydelete.c b/sched/pthread_keydelete.c
index 486de00d83..9a53a5e5e7 100644
--- a/sched/pthread_keydelete.c
+++ b/sched/pthread_keydelete.c
@@ -37,6 +37,8 @@
* Included Files
************************************************************/
+#include
+
#include
#include
#include
@@ -91,3 +93,4 @@ int pthread_key_delete(pthread_key_t key)
{
return ENOSYS;
}
+
diff --git a/sched/pthread_setspecific.c b/sched/pthread_setspecific.c
index c08a181907..5e9ba7fb62 100644
--- a/sched/pthread_setspecific.c
+++ b/sched/pthread_setspecific.c
@@ -37,6 +37,8 @@
* Included Files
************************************************************/
+#include
+
#include
#include
#include
@@ -111,6 +113,7 @@
int pthread_setspecific(pthread_key_t key, void *value)
{
+#if CONFIG_NPTHREAD_KEYS > 0
_TCB *rtcb = (_TCB*)g_readytorun.head;
int ret = EINVAL;
@@ -128,4 +131,9 @@ int pthread_setspecific(pthread_key_t key, void *value)
}
return ret;
+#else
+ return ENOSYS;
+#endif
}
+
+
diff --git a/sched/sched_free.c b/sched/sched_free.c
index 9fc2a261d3..dc1d347894 100644
--- a/sched/sched_free.c
+++ b/sched/sched_free.c
@@ -90,7 +90,7 @@ void sched_free(void *address)
{
/* Yes.. Delay the deallocation until a more appropriate time. */
- uint32 saved_state = irqsave();
+ irqstate_t saved_state = irqsave();
sq_addlast((sq_entry_t*)address, &g_delayeddeallocations);
irqrestore(saved_state);
}
diff --git a/sched/sched_setparam.c b/sched/sched_setparam.c
index 482b62ddbf..a1e5af97f0 100644
--- a/sched/sched_setparam.c
+++ b/sched/sched_setparam.c
@@ -105,12 +105,12 @@
int sched_setparam(pid_t pid, const struct sched_param *param)
{
- _TCB *rtcb;
- _TCB *tcb;
- tstate_t task_state;
- uint32 saved_state;
- int sched_priority = param->sched_priority;
- int ret = 0;
+ _TCB *rtcb;
+ _TCB *tcb;
+ tstate_t task_state;
+ irqstate_t saved_state;
+ int sched_priority = param->sched_priority;
+ int ret = 0;
/* Verify that the requested priority is in the valid range */
diff --git a/sched/sched_setscheduler.c b/sched/sched_setscheduler.c
index 29c0d0c98e..7d1b11ba48 100644
--- a/sched/sched_setscheduler.c
+++ b/sched/sched_setscheduler.c
@@ -112,7 +112,7 @@ int sched_setscheduler(pid_t pid, int policy,
{
_TCB *tcb;
#if CONFIG_RR_INTERVAL > 0
- uint32 saved_state;
+ irqstate_t saved_state;
#endif
int ret;
diff --git a/sched/sem_open.c b/sched/sem_open.c
index f6139ec5e4..6a8c38a4cb 100644
--- a/sched/sem_open.c
+++ b/sched/sem_open.c
@@ -41,6 +41,7 @@
#include
#include
#include
+#include
#include
#include "sem_internal.h"
@@ -117,7 +118,11 @@ sem_t *sem_open (const char *name, int oflag, ...)
{
int namelen;
nsem_t *psem;
+#ifdef CONFIG_CAN_CAST_POINTERS
sem_t *sem = (sem_t*)ERROR;
+#else
+ sem_t *sem = get_errorptr();
+#endif
va_list arg; /* Points to each un-named argument */
mode_t mode; /* Creation mode parameter (ignored) */
unsigned int value; /* Semaphore value parameter */
diff --git a/sched/sem_post.c b/sched/sem_post.c
index c07b1d5343..348e88c808 100644
--- a/sched/sem_post.c
+++ b/sched/sem_post.c
@@ -106,9 +106,9 @@
int sem_post (sem_t *sem)
{
- _TCB *stcb;
- STATUS ret = ERROR;
- uint32 saved_state;
+ _TCB *stcb;
+ STATUS ret = ERROR;
+ irqstate_t saved_state;
/* Make sure we were supplied with a valid semaphore. */
diff --git a/sched/sem_trywait.c b/sched/sem_trywait.c
index 561ba0b444..384eff0a0c 100644
--- a/sched/sem_trywait.c
+++ b/sched/sem_trywait.c
@@ -98,9 +98,9 @@
int sem_trywait(sem_t *sem)
{
- _TCB *rtcb = (_TCB*)g_readytorun.head;
- uint32 saved_state;
- int ret = ERROR;
+ _TCB *rtcb = (_TCB*)g_readytorun.head;
+ irqstate_t saved_state;
+ int ret = ERROR;
/* Assume any errors reported are due to invalid arguments. */
diff --git a/sched/sem_wait.c b/sched/sem_wait.c
index 006c559600..78aa7d5e93 100644
--- a/sched/sem_wait.c
+++ b/sched/sem_wait.c
@@ -99,9 +99,9 @@
int sem_wait (sem_t *sem)
{
- _TCB *rtcb = (_TCB*)g_readytorun.head;
- int ret = ERROR;
- uint32 saved_state;
+ _TCB *rtcb = (_TCB*)g_readytorun.head;
+ int ret = ERROR;
+ irqstate_t saved_state;
/* Assume any errors reported are due to invalid arguments. */
diff --git a/sched/sem_waitirq.c b/sched/sem_waitirq.c
index 96ab61f445..810663732a 100644
--- a/sched/sem_waitirq.c
+++ b/sched/sem_waitirq.c
@@ -94,7 +94,7 @@
void sem_waitirq (_TCB *wtcb)
{
- uint32 saved_state;
+ irqstate_t saved_state;
/* Disable interrupts. This is necessary (unfortunately) because an
* interrupt handler may attempt to post the semaphore while we are
diff --git a/sched/sig_allocatependingsigaction.c b/sched/sig_allocatependingsigaction.c
index a6304e2059..6105964574 100644
--- a/sched/sig_allocatependingsigaction.c
+++ b/sched/sig_allocatependingsigaction.c
@@ -77,8 +77,8 @@
sigq_t *sig_allocatependingsigaction(void)
{
- sigq_t *sigq;
- uint32 saved_state;
+ sigq_t *sigq;
+ irqstate_t saved_state;
/* Check if we were called from an interrupt handler. */
diff --git a/sched/sig_deliver.c b/sched/sig_deliver.c
index dfbbc1092d..c106337979 100644
--- a/sched/sig_deliver.c
+++ b/sched/sig_deliver.c
@@ -83,12 +83,12 @@
void sig_deliver(_TCB *stcb)
{
- pid_t rpid;
- sigq_t *sigq;
- sigq_t *next;
- sigset_t savesigprocmask;
- uint32 saved_state;
- int saved_errno;
+ pid_t rpid;
+ sigq_t *sigq;
+ sigq_t *next;
+ sigset_t savesigprocmask;
+ irqstate_t saved_state;
+ int saved_errno;
sched_lock();
diff --git a/sched/sig_mqnotempty.c b/sched/sig_mqnotempty.c
index cc5a064f68..ab395db2ea 100644
--- a/sched/sig_mqnotempty.c
+++ b/sched/sig_mqnotempty.c
@@ -80,7 +80,11 @@
*
************************************************************/
+#ifdef CONFIG_CAN_PASS_STRUCTS
int sig_mqnotempty (int pid, int signo, const union sigval value)
+#else
+int sig_mqnotempty (int pid, int signo, void *sival_ptr)
+#endif
{
_TCB *stcb;
siginfo_t info;
@@ -91,14 +95,22 @@ int sig_mqnotempty (int pid, int signo, const union sigval value)
/* Get the TCB of the receiving task */
stcb = sched_gettcb(pid);
- dbg("sig_mqnotempty: TCB=0x%08x signo=%d value=%d\n",
- stcb, signo, value.sival_int);
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ dbg("TCB=%p signo=%d value=%d\n", stcb, signo, value.sival_int);
+#else
+ dbg("TCB=%p signo=%d sival_ptr=%p\n", stcb, signo, sival_ptr);
+#endif
/* Create the siginfo structure */
- info.si_signo = signo;
- info.si_code = SI_MESGQ;
- info.si_value = value;
+ info.si_signo = signo;
+ info.si_code = SI_MESGQ;
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ info.si_value = value;
+#else
+ info.si_value.sival_ptr = sival_ptr;
+#endif
/* Verify that we can perform the signalling operation */
diff --git a/sched/sig_pending.c b/sched/sig_pending.c
index 3600c6d94a..62b98f3cae 100644
--- a/sched/sig_pending.c
+++ b/sched/sig_pending.c
@@ -110,7 +110,7 @@ sigset_t sig_pendingset(_TCB *stcb)
{
sigset_t sigpendset;
sigpendq_t *sigpend;
- uint32 saved_state;
+ irqstate_t saved_state;
sigpendset = NULL_SIGNAL_SET;
diff --git a/sched/sig_procmask.c b/sched/sig_procmask.c
index b733bac0ec..dd5dd9eb81 100644
--- a/sched/sig_procmask.c
+++ b/sched/sig_procmask.c
@@ -114,10 +114,10 @@
int sigprocmask(int how, const sigset_t *set, sigset_t *oset)
{
- _TCB *rtcb = (_TCB*)g_readytorun.head;
- sigset_t oldsigprocmask;
- uint32 saved_state;
- int ret = OK;
+ _TCB *rtcb = (_TCB*)g_readytorun.head;
+ sigset_t oldsigprocmask;
+ irqstate_t saved_state;
+ int ret = OK;
sched_lock();
diff --git a/sched/sig_received.c b/sched/sig_received.c
index 8a2c3928d5..922d4b7788 100644
--- a/sched/sig_received.c
+++ b/sched/sig_received.c
@@ -38,6 +38,7 @@
************************************************************/
#include
+#include
#include
#include
#include
@@ -79,7 +80,7 @@ static int sig_queueaction(_TCB *stcb, siginfo_t *info)
{
sigactq_t *sigact;
sigq_t *sigq;
- uint32 saved_state;
+ irqstate_t saved_state;
int ret = OK;
sched_lock();
@@ -106,7 +107,7 @@ static int sig_queueaction(_TCB *stcb, siginfo_t *info)
sigq->action.sighandler = sigact->act.sa_u._sa_sigaction;
sigq->mask = sigact->act.sa_mask;
- sigq->info = *info;
+ memcpy(&sigq->info, info, sizeof(siginfo_t));
/* Put it at the end of the pending signals list */
@@ -131,7 +132,7 @@ static int sig_queueaction(_TCB *stcb, siginfo_t *info)
static sigpendq_t *sig_findpendingsignal(_TCB *stcb, int signo)
{
sigpendq_t *sigpend = NULL;
- uint32 saved_state;
+ irqstate_t saved_state;
/* Verify the caller's sanity */
@@ -163,7 +164,7 @@ static sigpendq_t *sig_findpendingsignal(_TCB *stcb, int signo)
static sigpendq_t *sig_allocatependingsignal(void)
{
sigpendq_t *sigpend;
- uint32 saved_state;
+ irqstate_t saved_state;
/* Check if we were called from an interrupt handler. */
@@ -227,7 +228,7 @@ static sigpendq_t *sig_allocatependingsignal(void)
static sigpendq_t *sig_addpendingsignal(_TCB *stcb, siginfo_t *info)
{
sigpendq_t *sigpend;
- uint32 saved_state;
+ irqstate_t saved_state;
/* Check if the signal is already pending */
@@ -236,7 +237,7 @@ static sigpendq_t *sig_addpendingsignal(_TCB *stcb, siginfo_t *info)
{
/* The signal is already pending... retain only one copy */
- sigpend->info = *info;
+ memcpy(&sigpend->info, info, sizeof(siginfo_t));
}
/* No... There is nothing pending for this signo */
@@ -250,7 +251,7 @@ static sigpendq_t *sig_addpendingsignal(_TCB *stcb, siginfo_t *info)
{
/* Put the signal information into the allocated structure */
- sigpend->info = *info;
+ memcpy(&sigpend->info, info, sizeof(siginfo_t));
/* Add the structure to the pending signal list */
@@ -284,8 +285,8 @@ static sigpendq_t *sig_addpendingsignal(_TCB *stcb, siginfo_t *info)
int sig_received(_TCB *stcb, siginfo_t *info)
{
- int ret = ERROR;
- uint32 saved_state;
+ irqstate_t saved_state;
+ int ret = ERROR;
dbg("sig_received: TCB=0x%08x signo=%d code=%d value=%d\n",
stcb, info->si_signo, info->si_code, info->si_value.sival_int);
@@ -310,7 +311,7 @@ int sig_received(_TCB *stcb, siginfo_t *info)
if (stcb->task_state == TSTATE_WAIT_SIG &&
sigismember(&stcb->sigwaitmask, info->si_signo))
{
- stcb->sigunbinfo = *info;
+ memcpy(&stcb->sigunbinfo, info, sizeof(siginfo_t));
stcb->sigwaitmask = NULL_SIGNAL_SET;
up_unblock_task(stcb);
irqrestore(saved_state);
@@ -352,7 +353,7 @@ int sig_received(_TCB *stcb, siginfo_t *info)
saved_state = irqsave();
if (stcb->task_state == TSTATE_WAIT_SIG)
{
- stcb->sigunbinfo = *info;
+ memcpy(&stcb->sigunbinfo, info, sizeof(siginfo_t));
stcb->sigwaitmask = NULL_SIGNAL_SET;
up_unblock_task(stcb);
}
diff --git a/sched/sig_releasependingsigaction.c b/sched/sig_releasependingsigaction.c
index 7187c03c7f..b25ee79e32 100644
--- a/sched/sig_releasependingsigaction.c
+++ b/sched/sig_releasependingsigaction.c
@@ -76,7 +76,7 @@
void sig_releasependingsigaction(sigq_t *sigq)
{
- uint32 saved_state;
+ irqstate_t saved_state;
/* If this is a generally available pre-allocated structyre,
* then just put it back in the free list.
diff --git a/sched/sig_releasependingsignal.c b/sched/sig_releasependingsignal.c
index 453118fb4a..43601d7db9 100644
--- a/sched/sig_releasependingsignal.c
+++ b/sched/sig_releasependingsignal.c
@@ -84,7 +84,7 @@
void sig_releasependingsignal(sigpendq_t *sigpend)
{
- uint32 saved_state;
+ irqstate_t saved_state;
/* If this is a generally available pre-allocated structyre,
* then just put it back in the free list.
diff --git a/sched/sig_removependingsignal.c b/sched/sig_removependingsignal.c
index 4163f13f0c..917d6d7e1f 100644
--- a/sched/sig_removependingsignal.c
+++ b/sched/sig_removependingsignal.c
@@ -84,8 +84,9 @@
sigpendq_t *sig_removependingsignal(_TCB *stcb, int signo)
{
- sigpendq_t *currsig, *prevsig;
- uint32 saved_state;
+ sigpendq_t *currsig;
+ sigpendq_t *prevsig;
+ irqstate_t saved_state;
saved_state = irqsave();
for (prevsig = NULL, currsig = (sigpendq_t*)stcb->sigpendingq.head;
diff --git a/sched/sig_suspend.c b/sched/sig_suspend.c
index d0167b226e..92771578fb 100644
--- a/sched/sig_suspend.c
+++ b/sched/sig_suspend.c
@@ -115,7 +115,7 @@ int sigsuspend(const sigset_t *set)
sigset_t intersection;
sigset_t saved_sigprocmask;
sigpendq_t *sigpend;
- uint32 saved_state;
+ irqstate_t saved_state;
int unblocksigno;
/* Several operations must be performed below: We must determine if any
diff --git a/sched/sig_timedwait.c b/sched/sig_timedwait.c
index 842f68c2fb..bba138fa7c 100644
--- a/sched/sig_timedwait.c
+++ b/sched/sig_timedwait.c
@@ -38,6 +38,7 @@
************************************************************/
#include
+#include
#include
#include
#include
@@ -76,11 +77,24 @@
* A timeout elapsed while waiting for signals to be queued.
************************************************************/
-static void sig_timeout(int itcb, int parm2, int parm3, int parm4)
+static void sig_timeout(int argc, uint32 itcb, ...)
{
- _TCB *wtcb = (_TCB*)itcb;
+ /* On many small machines, pointers are encoded and cannot
+ * be simply cast from uint32 to _TCB*. The following
+ * union works around this (see wdogparm_t). This odd
+ * logic could be conditioned on CONFIG_CAN_CAST_POINTERS,
+ * but it is not too bad in any case.
+ */
- if (!wtcb)
+ union
+ {
+ _TCB *wtcb;
+ uint32 itcb;
+ } u;
+
+ u.itcb = itcb;
+
+ if (!u.wtcb)
{
PANIC(OSERR_TIMEOUTNOTCB);
}
@@ -89,12 +103,12 @@ static void sig_timeout(int itcb, int parm2, int parm3, int parm4)
* still waiting for a signal
*/
- if (wtcb->task_state == TSTATE_WAIT_SIG)
+ if (u.wtcb->task_state == TSTATE_WAIT_SIG)
{
- wtcb->sigunbinfo.si_signo = ERROR;
- wtcb->sigunbinfo.si_code = SI_TIMEOUT;
- wtcb->sigunbinfo.si_value.sival_int = 0;
- up_unblock_task(wtcb);
+ u.wtcb->sigunbinfo.si_signo = ERROR;
+ u.wtcb->sigunbinfo.si_code = SI_TIMEOUT;
+ u.wtcb->sigunbinfo.si_value.sival_int = 0;
+ up_unblock_task(u.wtcb);
}
}
@@ -150,7 +164,7 @@ int sigtimedwait(const sigset_t *set, struct siginfo *info,
sigset_t intersection;
sigpendq_t *sigpend;
WDOG_ID wdog;
- uint32 saved_state;
+ irqstate_t saved_state;
sint32 waitticks;
int ret = ERROR;
@@ -184,7 +198,10 @@ int sigtimedwait(const sigset_t *set, struct siginfo *info,
/* Return the signal info to the caller if so requested */
- if (info) *info = sigpend->info;
+ if (info)
+ {
+ memcpy(info, &sigpend->info, sizeof(struct siginfo));
+ }
/* Then dispose of the pending signal structure properly */
@@ -218,10 +235,18 @@ int sigtimedwait(const sigset_t *set, struct siginfo *info,
wdog = wd_create();
if (wdog)
{
+ /* This little of nonsense is necessary for some
+ * processors where sizeof(pointer) < sizeof(uint32).
+ * see wdog.h.
+ */
+
+ wdparm_t wdparm;
+ wdparm.pvarg = (void*)rtcb;
+
/* Start the watchdog */
wd_start(wdog, waitticks, (wdentry_t)sig_timeout,
- (int)rtcb, 0, 0, 0);
+ 1, wdparm.dwarg);
/* Now wait for either the signal or the watchdog */
@@ -252,7 +277,7 @@ int sigtimedwait(const sigset_t *set, struct siginfo *info,
if (info)
{
- *info = rtcb->sigunbinfo;
+ memcpy(info, &rtcb->sigunbinfo, sizeof(struct siginfo));
}
irqrestore(saved_state);
diff --git a/sched/task_create.c b/sched/task_create.c
index c1cf117725..79f487a11e 100644
--- a/sched/task_create.c
+++ b/sched/task_create.c
@@ -377,11 +377,7 @@ STATUS task_init(_TCB *tcb, char *name, int priority,
STATUS task_activate(_TCB *tcb)
{
#ifdef CONFIG_SCHED_INSTRUMENTATION
- uint32 flags;
-#endif
-
-#ifdef CONFIG_SCHED_INSTRUMENTATION
- flags = irqsave();
+ irqstate_t flags = irqsave();
/* Check if this is really a re-start */
diff --git a/sched/task_delete.c b/sched/task_delete.c
index 5a28c3d426..ed169217d6 100644
--- a/sched/task_delete.c
+++ b/sched/task_delete.c
@@ -95,10 +95,10 @@
STATUS task_delete(pid_t pid)
{
- _TCB *rtcb;
- _TCB *dtcb;
- uint32 saved_state;
- STATUS ret = ERROR;
+ _TCB *rtcb;
+ _TCB *dtcb;
+ irqstate_t saved_state;
+ STATUS ret = ERROR;
/* Check if the task to delete is the calling task */
diff --git a/sched/task_restart.c b/sched/task_restart.c
index 6d4b7a83a5..60478c2581 100644
--- a/sched/task_restart.c
+++ b/sched/task_restart.c
@@ -99,10 +99,10 @@
STATUS task_restart(pid_t pid)
{
- _TCB *rtcb;
- _TCB *tcb;
- STATUS status;
- uint32 state;
+ _TCB *rtcb;
+ _TCB *tcb;
+ STATUS status;
+ irqstate_t state;
/* Make sure this task does not become ready-to-run while
* we are futzing with its TCB
diff --git a/sched/wd_cancel.c b/sched/wd_cancel.c
index 9a3a223fdc..c0181e43be 100644
--- a/sched/wd_cancel.c
+++ b/sched/wd_cancel.c
@@ -87,10 +87,10 @@
STATUS wd_cancel (WDOG_ID wdid)
{
- wdog_t *curr;
- wdog_t *prev;
- uint32 saved_state;
- STATUS ret = ERROR;
+ wdog_t *curr;
+ wdog_t *prev;
+ irqstate_t saved_state;
+ STATUS ret = ERROR;
/* Prohibit timer interactions with the timer queue until the
* cancellation is complete
diff --git a/sched/wd_create.c b/sched/wd_create.c
index 14a1c54104..0fad7cef97 100644
--- a/sched/wd_create.c
+++ b/sched/wd_create.c
@@ -87,8 +87,8 @@
WDOG_ID wd_create (void)
{
- wdog_t *wdog;
- sint32 saved_state;
+ wdog_t *wdog;
+ irqstate_t saved_state;
saved_state = irqsave();
wdog = (wdog_t*)sq_remfirst(&g_wdfreelist);
diff --git a/sched/wd_delete.c b/sched/wd_delete.c
index b4039cce00..96168ec2c2 100644
--- a/sched/wd_delete.c
+++ b/sched/wd_delete.c
@@ -90,7 +90,7 @@
STATUS wd_delete (WDOG_ID wdId)
{
- uint32 saved_state;
+ irqstate_t saved_state;
/* Check if the watchdog has been started. */
diff --git a/sched/wd_internal.h b/sched/wd_internal.h
index 212c686192..7794d8c12a 100644
--- a/sched/wd_internal.h
+++ b/sched/wd_internal.h
@@ -40,6 +40,7 @@
* Included Files
************************************************************/
+#include
#include
#include
#include
@@ -64,11 +65,11 @@ struct wdog_s
{
struct wdog_s *next; /* Support for singly linked lists. */
wdentry_t func; /* Function to execute when delay expires */
- sint32 lag; /* Timer associated with the delay */
- uint32 parm[4]; /* Four parameters passed to func */
+ int lag; /* Timer associated with the delay */
boolean active; /* TRUE if the watchdog is actively timing */
+ ubyte argc; /* The number of parameters to pass */
+ uint32 parm[CONFIG_MAX_WDOGPARMS];
};
-
typedef struct wdog_s wdog_t;
/************************************************************
diff --git a/sched/wd_start.c b/sched/wd_start.c
index 04ece34938..b3534593d2 100644
--- a/sched/wd_start.c
+++ b/sched/wd_start.c
@@ -38,9 +38,12 @@
************************************************************/
#include
+#include
#include
#include
#include
+#include
+#include "os_internal.h"
#include "wd_internal.h"
/************************************************************
@@ -51,6 +54,22 @@
* Private Type Declarations
************************************************************/
+typedef void (*wdentry0_t)(int argc);
+#if CONFIG_MAX_WDOGPARMS > 0
+typedef void (*wdentry1_t)(int argc, uint32 arg1);
+#endif
+#if CONFIG_MAX_WDOGPARMS > 1
+typedef void (*wdentry2_t)(int argc, uint32 arg1, uint32 arg2);
+#endif
+#if CONFIG_MAX_WDOGPARMS > 2
+typedef void (*wdentry3_t)(int argc, uint32 arg1, uint32 arg2,
+ uint32 arg3);
+#endif
+#if CONFIG_MAX_WDOGPARMS > 3
+typedef void (*wdentry4_t)(int argc, uint32 arg1, uint32 arg2,
+ uint32 arg3, uint32 arg4);
+#endif
+
/************************************************************
* Global Variables
************************************************************/
@@ -83,12 +102,12 @@
* Watchdog timers execute only once.
*
* To replace either the timeout delay or the function to
- * be executed, call wd_start again with the same wdId; only
+ * be executed, call wd_start again with the same wdog; only
* the most recent wdStart() on a given watchdog ID has
* any effect.
*
* Parameters:
- * wdId = watchdog ID
+ * wdog = watchdog ID
* delay = Delay count in clock ticks
* wdentry = function to call on timeout
* parm1..4 = parameters to pass to wdentry
@@ -102,19 +121,22 @@
*
************************************************************/
-STATUS wd_start(WDOG_ID wdId, int delay, wdentry_t wdentry,
- int parm1, int parm2, int parm3, int parm4)
+STATUS wd_start(WDOG_ID wdog, int delay, wdentry_t wdentry,
+ int argc, ...)
{
- wdog_t *curr;
- wdog_t *prev;
- wdog_t *next;
- sint32 now;
- sint32 saved_state;
+ va_list ap;
+ wdog_t *curr;
+ wdog_t *prev;
+ wdog_t *next;
+ sint32 now;
+ irqstate_t saved_state;
+ int i;
- /* Verify the wdId */
+ /* Verify the wdog */
- if (!wdId)
+ if (!wdog || argc > CONFIG_MAX_WDOGPARMS || delay < 0)
{
+ *get_errno_ptr() = EINVAL;
return ERROR;
}
@@ -125,18 +147,28 @@ STATUS wd_start(WDOG_ID wdId, int delay, wdentry_t wdentry,
*/
saved_state = irqsave();
- if (wdId->active)
+ if (wdog->active)
{
- wd_cancel(wdId);
+ wd_cancel(wdog);
}
/* Save the data in the watchdog structure */
- wdId->func = wdentry; /* Function to execute when delay expires */
- wdId->parm[0] = parm1; /* Same as the parameter to pass */
- wdId->parm[1] = parm2; /* 2nd parameter not used */
- wdId->parm[2] = parm3; /* 3rd parameter not used */
- wdId->parm[3] = parm4; /* 4th parameter not used */
+ wdog->func = wdentry; /* Function to execute when delay expires */
+ wdog->argc = argc;
+
+ va_start(ap, argc);
+ for (i = 0; i < argc; i++)
+ {
+ wdog->parm[i] = va_arg(ap, uint32);
+ }
+#ifdef CONFIG_DEBUG
+ for (; i < CONFIG_MAX_WDOGPARMS; i++)
+ {
+ wdog->parm[i] = 0;
+ }
+#endif
+ va_end(ap);
/* Calculate delay+1, forcing the delay into a range that we can handle */
@@ -153,7 +185,7 @@ STATUS wd_start(WDOG_ID wdId, int delay, wdentry_t wdentry,
if (g_wdactivelist.head == NULL)
{
- sq_addlast((sq_entry_t*)wdId,&g_wdactivelist);
+ sq_addlast((sq_entry_t*)wdog,&g_wdactivelist);
}
/* There are other active watchdogs in the timer queue */
@@ -180,7 +212,7 @@ STATUS wd_start(WDOG_ID wdId, int delay, wdentry_t wdentry,
now += curr->lag;
}
- /* Check if the new wdId must be inserted before the curr. */
+ /* Check if the new wdog must be inserted before the curr. */
if (delay < now)
{
@@ -196,18 +228,18 @@ STATUS wd_start(WDOG_ID wdId, int delay, wdentry_t wdentry,
if (curr == (wdog_t*)g_wdactivelist.head)
{
- sq_addfirst((sq_entry_t*)wdId, &g_wdactivelist);
+ sq_addfirst((sq_entry_t*)wdog, &g_wdactivelist);
}
else
{
- sq_addafter((sq_entry_t*)prev, (sq_entry_t*)wdId,
+ sq_addafter((sq_entry_t*)prev, (sq_entry_t*)wdog,
&g_wdactivelist);
}
}
/* The new watchdog delay time is greater than the curr delay time,
- * so the new wdId must be inserted after the curr. This only occurs
- * if the wdId is to be added to the end of the list.
+ * so the new wdog must be inserted after the curr. This only occurs
+ * if the wdog is to be added to the end of the list.
*/
else
@@ -215,13 +247,13 @@ STATUS wd_start(WDOG_ID wdId, int delay, wdentry_t wdentry,
delay -= now;
if (!curr->next)
{
- sq_addlast((sq_entry_t*)wdId, &g_wdactivelist);
+ sq_addlast((sq_entry_t*)wdog, &g_wdactivelist);
}
else
{
next = curr->next;
next->lag -= delay;
- sq_addafter((sq_entry_t*)curr, (sq_entry_t*)wdId,
+ sq_addafter((sq_entry_t*)curr, (sq_entry_t*)wdog,
&g_wdactivelist);
}
}
@@ -229,8 +261,8 @@ STATUS wd_start(WDOG_ID wdId, int delay, wdentry_t wdentry,
/* Put the lag into the watchdog structure and mark it as active. */
- wdId->lag = delay;
- wdId->active = TRUE;
+ wdog->lag = delay;
+ wdog->active = TRUE;
irqrestore(saved_state);
return OK;
@@ -304,8 +336,42 @@ void wd_timer(void)
/* Execute the watchdog function */
- (*wdog->func)(wdog->parm[0], wdog->parm[1],
- wdog->parm[2] ,wdog->parm[3]);
+ switch (wdog->argc)
+ {
+ default:
+#ifdef CONFIG_DEBUG
+ PANIC(OSERR_INTERNAL);
+#endif
+ case 0:
+ (*((wdentry0_t)(wdog->func)))(0);
+ break;
+
+#if CONFIG_MAX_WDOGPARMS > 0
+ case 1:
+ (*((wdentry1_t)(wdog->func)))(1, wdog->parm[0]);
+ break;
+#endif
+#if CONFIG_MAX_WDOGPARMS > 1
+ case 2:
+ (*((wdentry2_t)(wdog->func)))(2,
+ wdog->parm[0], wdog->parm[1]);
+ break;
+#endif
+#if CONFIG_MAX_WDOGPARMS > 2
+ case 3:
+ (*((wdentry3_t)(wdog->func)))(3,
+ wdog->parm[0], wdog->parm[1],
+ wdog->parm[2]);
+ break;
+#endif
+#if CONFIG_MAX_WDOGPARMS > 3
+ case 4:
+ (*((wdentry4_t)(wdog->func)))(4,
+ wdog->parm[0], wdog->parm[1],
+ wdog->parm[2] ,wdog->parm[3]);
+ break;
+#endif
+ }
}
}
}