diff --git a/TODO b/TODO
index 33db2ed41106baaa7cdd4f53fdf3247a72daeccb..57c3de98b6676dcdccde97c2e856594a99db800a 100644
--- a/TODO
+++ b/TODO
@@ -293,10 +293,18 @@ o pjrc-8052 / MCS51 (arch/pjrc-8051/)
   Priority:    Low
 
   Description: During build, there are several integer overflows reported:
-               gmtime_r.c aroud lines 184 and 185
-               clock_initialize.c at line 107
-               pthread_create.c at 330
-               sighand.c at 225 and 244
+               sched/gmtime_r.c aroud lines 184 and 185
+               sched/clock_initialize.c at line 107
+               sched/pthread_create.c at 330
+               examples/ostest/barrier.c around lines 53 and 74
+               examples/ostest/sighand.c at 225 and 244
   Status:      Open
   Priority:    Medium
 
+o z80 (arch/z80)
+ ^^^^^^^^^^^^^^^
+
+  Has the same problems with interger overflow during compilation as described
+  for pjrc-8051
+
+
diff --git a/arch/z80/src/z80/Make.defs b/arch/z80/src/z80/Make.defs
index 05dc8cd56fe98b6e5ae02ac05abb645baed830f7..d4e38b11ccda4b680c4cc5af7d268301d6d7cd60 100644
--- a/arch/z80/src/z80/Make.defs
+++ b/arch/z80/src/z80/Make.defs
@@ -41,7 +41,11 @@ CMN_CSRCS	= up_initialize.c up_allocateheap.c up_initialstate.c \
 		  up_blocktask.c  up_unblocktask.c up_exit.c up_releasepending.c \
 		  up_reprioritizertr.c up_copystate.c up_irq.c up_idle.c \
 		  up_assert.c up_mdelay.c up_udelay.c \
-		  up_registerdump.c up_usestack.c \
+		  up_registerdump.c up_usestack.c
+
+ifneq ($(CONFIG_DISABLE_SIGNALS),y)
+CMD_CSRCS	+= up_schedulesigaction.c up_sigdeliver.c
+endif
 
 CHIP_ASRCS	= 
 CHIP_CSRCS	= 
diff --git a/configs/z80sim/README.txt b/configs/z80sim/README.txt
index 50be916e14d28d171eb08aed09e9cdcbc6ee12d7..ff9754c04e55665d06f23376cc308c24c18a8e27 100644
--- a/configs/z80sim/README.txt
+++ b/configs/z80sim/README.txt
@@ -17,4 +17,18 @@ compatible with this build.  First start with the usual steps
   unpack
   cd sdcc
   ./configure
+
+But before making, we need to apply a patch to the SDCC 2.6.0 source
+so that the z80 assembler can handle long symbol names
+
+  Apply sdcc-2.6.0-asz80-symlen.patch
+  cd sdcc/device/lib
+
+Then make the SDCC binaries
+
+  cd sdcc
   make
+
+and install SDCC:
+
+  sudo make install
diff --git a/configs/z80sim/defconfig b/configs/z80sim/defconfig
index a993a6aeb1fcfa22086074bc9a361da0fd602ff8..6141c34b13af437efc2946351b8b2fd3f2e3e193 100644
--- a/configs/z80sim/defconfig
+++ b/configs/z80sim/defconfig
@@ -112,13 +112,13 @@ CONFIG_DEV_CONSOLE=n
 # o pthread_condtimedwait() depends on signals to wake
 #   up waiting tasks.
 #
-CONFIG_DISABLE_CLOCK=y
-CONFIG_DISABLE_POSIX_TIMERS=y
-CONFIG_DISABLE_PTHREAD=y
-CONFIG_DISABLE_SIGNALS=y
-CONFIG_DISABLE_MQUEUE=y
-CONFIG_DISABLE_MOUNTPOINT=y
-CONFIG_DISABLE_ENVIRON=y
+CONFIG_DISABLE_CLOCK=n
+CONFIG_DISABLE_POSIX_TIMERS=n
+CONFIG_DISABLE_PTHREAD=n
+CONFIG_DISABLE_SIGNALS=n
+CONFIG_DISABLE_MQUEUE=n
+CONFIG_DISABLE_MOUNTPOINT=n
+CONFIG_DISABLE_ENVIRON=n
 
 #
 # Misc libc settings
@@ -283,7 +283,7 @@ CONFIG_EXAMPLES_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
 CONFIG_BOOT_FROM_FLASH=n
 CONFIG_CUSTOM_STACK=n
 CONFIG_PROC_STACK_SIZE=1024
-CONFIG_PTHREAD_STACK_MIN=
-CONFIG_PTHREAD_STACK_DEFAULT=
+CONFIG_PTHREAD_STACK_MIN=256
+CONFIG_PTHREAD_STACK_DEFAULT=1024
 CONFIG_HEAP_SIZE=
 CONFIG_HEAP_BASE=
diff --git a/configs/z80sim/sdcc-2.6.0-asz80-symlen.patch b/configs/z80sim/sdcc-2.6.0-asz80-symlen.patch
new file mode 100644
index 0000000000000000000000000000000000000000..d91c18d9882ce8a37b8ffc383f1e8242b8930109
--- /dev/null
+++ b/configs/z80sim/sdcc-2.6.0-asz80-symlen.patch
@@ -0,0 +1,11 @@
+--- sdcc/as/z80/asm.h	2007-12-30 16:49:53.000000000 -0600
++++ sdcc.orig/as/z80/asm.h	2007-12-30 16:49:14.000000000 -0600
+@@ -65,7 +65,7 @@
+ #define	RTTERM	')'		/* Right expression delimeter */
+ 
+ #ifdef SDK
+-#define	NCPS	80		/* characters per symbol */
++#define	NCPS	32		/* characters per symbol */
+ #else /* SDK */
+ #define NCPS	8		/* Chars. per symbol */
+ #endif /* SDK */
diff --git a/examples/ostest/posixtimer.c b/examples/ostest/posixtimer.c
index 1b466c99fb17437faf6ee354945d65f198633581..87498baa26e476b7dfaa98de37e21c132ba8ab0a 100644
--- a/examples/ostest/posixtimer.c
+++ b/examples/ostest/posixtimer.c
@@ -1,7 +1,7 @@
 /***********************************************************************
  * posixtimer.c
  *
- *   Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ *   Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <spudmonkey@racsa.co.cr>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
  *    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
+ * 3. Neither the name NuttX nor the names of its contributors may be
  *    used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -33,6 +33,10 @@
  *
  ***********************************************************************/
 
+/**************************************************************************
+ * Included Files
+ **************************************************************************/
+
 #include <sys/types.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -42,6 +46,10 @@
 #include <errno.h>
 #include "ostest.h"
 
+/**************************************************************************
+ * Private Definitions
+ **************************************************************************/
+
 #ifndef NULL
 # define NULL (void*)0
 #endif
@@ -49,9 +57,23 @@
 #define MY_TIMER_SIGNAL 17
 #define SIGVALUE_INT  42
 
+#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
+#  define FFLUSH() fflush(stdout)
+#else
+#  define FFLUSH()
+#endif
+
+/**************************************************************************
+ * Private Data
+ **************************************************************************/
+
 static sem_t sem;
 static int g_nsigreceived = 0;
 
+/**************************************************************************
+ * Private Functions
+ **************************************************************************/
+
 static void timer_expiration(int signo, siginfo_t *info, void *ucontext)
 {
   sigset_t oldset;
@@ -119,6 +141,10 @@ static void timer_expiration(int signo, siginfo_t *info, void *ucontext)
 
 }
 
+/**************************************************************************
+ * Public Functions
+ **************************************************************************/
+
 void timer_test(void)
 {
   sigset_t           sigset;
@@ -200,7 +226,7 @@ void timer_test(void)
   for (i = 0; i < 5; i++)
     {
       printf("timer_test: Waiting on semaphore\n" );
-      fflush(stdout);
+      FFLUSH();
       status = sem_wait(&sem);
       if (status != 0)
         {
@@ -239,5 +265,5 @@ errorout:
   status = sigaction(MY_TIMER_SIGNAL, &act, &oact);
 
   printf("timer_test: done\n" );
-  fflush(stdout);
+  FFLUSH();
 }
diff --git a/examples/ostest/timedmqueue.c b/examples/ostest/timedmqueue.c
index 186296a06a3992c2126029ef7c932777efb368b3..2ef0dedeae90a0ca583282c39833f4e1cf24e586 100644
--- a/examples/ostest/timedmqueue.c
+++ b/examples/ostest/timedmqueue.c
@@ -66,6 +66,12 @@
 #define TEST_SEND_NMSGS     (10)
 #define TEST_RECEIVE_NMSGS  (10)
 
+#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
+#  define FFLUSH() fflush(stdout)
+#else
+#  define FFLUSH()
+#endif
+
 /**************************************************************************
  * Private Types
  **************************************************************************/
@@ -180,7 +186,7 @@ static void *sender_thread(void *arg)
     }
 
   printf("sender_thread: returning nerrors=%d\n", nerrors);
-  fflush(stdout);
+  FFLUSH();
   return (pthread_addr_t)nerrors;
 }
 
@@ -305,7 +311,7 @@ static void *receiver_thread(void *arg)
     }
 
   printf("receiver_thread: returning nerrors=%d\n", nerrors);
-  fflush(stdout);
+  FFLUSH();
   pthread_exit((pthread_addr_t)nerrors);
   return (pthread_addr_t)nerrors;
 }
diff --git a/examples/ostest/timedwait.c b/examples/ostest/timedwait.c
index 0bc47c69371a796fd7c8c68e57ef5c7b4221519a..51622bad81d45bac6834f83b57f019fba7e91106 100644
--- a/examples/ostest/timedwait.c
+++ b/examples/ostest/timedwait.c
@@ -1,7 +1,7 @@
 /***********************************************************************
- * timedwait.c
+ * examples/ostest/timedwait.c
  *
- *   Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ *   Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <spudmonkey@racsa.co.cr>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
  *    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
+ * 3. Neither the name NuttX nor the names of its contributors may be
  *    used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -33,16 +33,39 @@
  *
  ***********************************************************************/
 
+/**************************************************************************
+ * Included Files
+ **************************************************************************/
+
 #include <stdio.h>
 #include <time.h>
 #include <pthread.h>
 #include <unistd.h>
 #include <errno.h>
+
 #include "ostest.h"
 
+/**************************************************************************
+ * Private Definitions
+ **************************************************************************/
+
+#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0
+#  define FFLUSH() fflush(stdout)
+#else
+#  define FFLUSH()
+#endif
+
+/**************************************************************************
+ * Private Data
+ **************************************************************************/
+
 static pthread_mutex_t mutex;
 static pthread_cond_t  cond;
 
+/**************************************************************************
+ * Private Functions
+ **************************************************************************/
+
 static void *thread_waiter(void *parameter)
 {
   struct timespec time;
@@ -99,6 +122,10 @@ static void *thread_waiter(void *parameter)
   return NULL;
 }
 
+/**************************************************************************
+ * Public Definitions
+ **************************************************************************/
+
 void timedwait_test(void)
 {
   pthread_t waiter;
@@ -161,7 +188,7 @@ void timedwait_test(void)
     }
 
   printf("timedwait_test: Joining\n");
-  fflush(stdout);
+  FFLUSH();
   status = pthread_join(waiter, &result);
   if (status != 0)
     {
diff --git a/include/stdio.h b/include/stdio.h
index eaeb879d39ee2b46a1dc7c9bc3d074701c290252..cfb722c6d7ae803d2976e224677c2468eb3e9550 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -41,6 +41,7 @@
  ************************************************************/
 
 #include <nuttx/config.h>
+
 #include <sys/types.h>
 #include <stdarg.h>
 #include <sched.h>
diff --git a/include/sys/types.h b/include/sys/types.h
index 0460c5e5c2d139e95f1dbc6d7240201594fed37c..2fd53e41db3b0fb41b90c5251d7638343c621083 100644
--- a/include/sys/types.h
+++ b/include/sys/types.h
@@ -1,7 +1,7 @@
-/************************************************************
+/****************************************************************************
  * sys/types.h
  *
- *   Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ *   Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <spudmonkey@racsa.co.cr>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,39 +31,44 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- ************************************************************/
+ ****************************************************************************/
 
 #ifndef __SYS_TYPES_H
 #define __SYS_TYPES_H
 
-/************************************************************
+/****************************************************************************
  * Included Files
- ************************************************************/
+ ****************************************************************************/
 
 #include <nuttx/config.h>
 #include <arch/types.h>
 #include <nuttx/compiler.h>
 
-/************************************************************
+/****************************************************************************
  * Definitions
- ************************************************************/
+ ****************************************************************************/
 
 /* Values for type boolean */
 
 #define TRUE 1
 #define FALSE 0
 
-/* NULL is usually defined in stddef.h */
+/* NULL is usually defined in stddef.h (which includes this file) */
 
 #ifndef NULL
-#define NULL (void*)0L
+    /* SDCC is sensitive to NULL pointer type conversions */
+#  ifdef SDCC
+#    define NULL (0)
+#  else
+#    define NULL ((void*)0)
+#  endif
 #endif
 
 /* POSIX-like OS return values: */
 
 #if !defined(__cplusplus)
-#undef  ERROR
-#define ERROR -1
+#  undef  ERROR
+#  define ERROR -1
 #endif
 
 #undef  OK
@@ -86,9 +91,9 @@
 #define SCHED_PRIORITY_MIN       1
 #define SCHED_PRIORITY_IDLE      0
 
-/************************************************************
+/****************************************************************************
  * Type Declarations
- ************************************************************/
+ ****************************************************************************/
 
 #ifndef __ASSEMBLY__
 #ifndef CONFIG_HAVE_DOUBLE
@@ -132,8 +137,8 @@ typedef int (*main_t)(int argc, char *argv[]);
 
 #endif
 
-/************************************************************
+/****************************************************************************
  * Global Function Prototypes
- ************************************************************/
+ ****************************************************************************/
 
 #endif /* __SYS_TYPES_H */
diff --git a/sched/pthread_create.c b/sched/pthread_create.c
index 24768664bf21f118bbe74d7bbf52951e610b4b6c..bd86643f9d07b3005adcf3aecc17c59fd5681fe6 100644
--- a/sched/pthread_create.c
+++ b/sched/pthread_create.c
@@ -357,7 +357,7 @@ int pthread_create(pthread_t *thread, pthread_attr_t *attr,
    * passed by value
    */
 
-  (void)pthread_argsetup(ptcb, arg);
+  pthread_argsetup(ptcb, arg);
 
   /* Attach the join info to the TCB. */
 
diff --git a/sched/timer_create.c b/sched/timer_create.c
index 40a660f50064e53941bc031886cc3d603057ed01..645007c9fc5e027570708fb790169e973359f6aa 100644
--- a/sched/timer_create.c
+++ b/sched/timer_create.c
@@ -1,7 +1,7 @@
 /********************************************************************************
- * timer_create.c
+ * sched/timer_create.c
  *
- *   Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ *   Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <spudmonkey@racsa.co.cr>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
  *    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
+ * 3. Neither the name NuttX nor the names of its contributors may be
  *    used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -204,7 +204,7 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp, FAR timer_t *timer
 #ifdef CONFIG_CAN_PASS_STRUCTS
       ret->pt_value           = evp->sigev_value;
 #else
-      ret->pt_value.sival_ptr = evp->sigev_value.sigval_ptr;
+      ret->pt_value.sival_ptr = evp->sigev_value.sival_ptr;
 #endif
     }
   else
diff --git a/sched/timer_settime.c b/sched/timer_settime.c
index 29796a5933140f24db5b5cd671ad1b4b71ce9f00..a9a7fd7c4437556fd1170b94aacc123535a97e35 100644
--- a/sched/timer_settime.c
+++ b/sched/timer_settime.c
@@ -104,7 +104,7 @@ static void inline timer_sigqueue(FAR struct posix_timer_s *timer)
 
        info.si_signo           = timer->pt_signo;
        info.si_code            = SI_TIMER;
-#ifndef CONFIG_CAN_PASS_STRUCTS
+#ifdef CONFIG_CAN_PASS_STRUCTS
        info.si_value           = timer->pt_value;
 #else
        info.si_value.sival_ptr = timer->pt_value.sival_ptr;