Index: c/src/exec/libcsupport/include/rtems/libio.h
===================================================================
--- c/src/exec/libcsupport/include/rtems/libio.h	(revision 634e746544cc226ef388880bb1d3ec0144ff29db)
+++ c/src/exec/libcsupport/include/rtems/libio.h	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
@@ -13,4 +13,6 @@
 #ifndef _RTEMS_LIBIO_H
 #define _RTEMS_LIBIO_H
+
+#include <sys/stat.h>
 
 typedef unsigned32 rtems_libio_offset_t;
@@ -89,10 +91,12 @@
 void rtems_libio_init(void);
 
-int __open(const char  *pathname, unsigned32 flag, unsigned32 mode);
-int __close(int  fd);
-int __read(int fd, void *buffer, unsigned32 count);
-int __write(int fd, const void *buffer, unsigned32 count);
-int __ioctl(int fd, unsigned32  command, void *buffer);
-int __lseek(int fd, rtems_libio_offset_t offset, int whence);
+int __rtems_open(const char  *pathname, unsigned32 flag, unsigned32 mode);
+int __rtems_close(int  fd);
+int __rtems_read(int fd, void *buffer, unsigned32 count);
+int __rtems_write(int fd, const void *buffer, unsigned32 count);
+int __rtems_ioctl(int fd, unsigned32  command, void *buffer);
+int __rtems_lseek(int fd, rtems_libio_offset_t offset, int whence);
+int __rtems_fstat(int _fd, struct stat* _sbuf);
+int __rtems_isatty(int _fd);
 
 #endif /* _RTEMS_LIBIO_H */
Index: c/src/exec/libcsupport/src/libio.c
===================================================================
--- c/src/exec/libcsupport/src/libio.c	(revision 634e746544cc226ef388880bb1d3ec0144ff29db)
+++ c/src/exec/libcsupport/src/libio.c	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
@@ -47,5 +47,5 @@
 #define rtems_libio_check_fd(fd) \
     do { \
-        if ((fd) >= rtems_libio_number_iops) \
+        if ((unsigned32) (fd) >= rtems_libio_number_iops) \
         { \
             errno = EBADF; \
@@ -244,5 +244,5 @@
 
 int
-__open(
+__rtems_open(
     const char   *pathname,
     unsigned32    flag,
@@ -255,8 +255,10 @@
 
     if ((rc = rtems_io_lookup_name(pathname, &np)) != RTEMS_SUCCESSFUL) {
+/*
       if ( rc == RTEMS_UNSATISFIED ) {
         puts( "open -- ENOSYS case" );
         assert( 0 );
       }
+*/
         goto done;
     }
@@ -292,5 +294,5 @@
     
 int
-__close(
+__rtems_close(
     int  fd
   )    
@@ -317,5 +319,5 @@
     
 int
-__read(
+__rtems_read(
     int       fd,
     void *    buffer,
@@ -353,5 +355,5 @@
 
 int
-__write(
+__rtems_write(
     int         fd,
     const void *buffer,
@@ -389,5 +391,5 @@
 
 int
-__ioctl(
+__rtems_ioctl(
     int         fd,
     unsigned32  command,
@@ -421,5 +423,5 @@
 
 int
-__lseek(
+__rtems_lseek(
     int                  fd,
     rtems_libio_offset_t offset,
Index: c/src/exec/libcsupport/src/malloc.c
===================================================================
--- c/src/exec/libcsupport/src/malloc.c	(revision 634e746544cc226ef388880bb1d3ec0144ff29db)
+++ c/src/exec/libcsupport/src/malloc.c	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
@@ -38,5 +38,5 @@
 
 #ifdef MALLOC_STATS
-#define MSBUMP(f,n)    malloc_stats.f += (n)
+#define MSBUMP(f,n)    rtems_malloc_stats.f += (n)
 
 struct {
@@ -49,7 +49,7 @@
     unsigned64  lifetime_allocated;
     unsigned64  lifetime_freed;
-} malloc_stats;
-
-#else			/* No malloc_stats */
+} rtems_malloc_stats;
+
+#else			/* No rtems_malloc_stats */
 #define MSBUMP(f,n)
 #endif
@@ -116,5 +116,5 @@
 #ifdef MALLOC_STATS
   /* zero all the stats */
-  (void) memset(&malloc_stats, 0, sizeof(malloc_stats));
+  (void) memset(&rtems_malloc_stats, 0, sizeof(rtems_malloc_stats));
 #endif
   
@@ -202,7 +202,7 @@
       status = rtems_region_get_segment_size(RTEMS_Malloc_Heap, return_this, &actual_size);
       MSBUMP(lifetime_allocated, actual_size);
-      current_depth = malloc_stats.lifetime_allocated - malloc_stats.lifetime_freed;
-      if (current_depth > malloc_stats.max_depth)
-          malloc_stats.max_depth = current_depth;
+      current_depth = rtems_malloc_stats.lifetime_allocated - rtems_malloc_stats.lifetime_freed;
+      if (current_depth > rtems_malloc_stats.max_depth)
+          rtems_malloc_stats.max_depth = current_depth;
   }
 #endif
@@ -315,21 +315,21 @@
 void malloc_dump(void)
 {
-    unsigned32 allocated = malloc_stats.lifetime_allocated - malloc_stats.lifetime_freed;
+    unsigned32 allocated = rtems_malloc_stats.lifetime_allocated - rtems_malloc_stats.lifetime_freed;
 
     printf("Malloc stats\n");
     printf("  avail:%uk  allocated:%uk (%d%%) max:%uk (%d%%) lifetime:%Luk freed:%Luk\n",
-           (unsigned int) malloc_stats.space_available / 1024,
+           (unsigned int) rtems_malloc_stats.space_available / 1024,
            (unsigned int) allocated / 1024,
            /* avoid float! */
-           (allocated * 100) / malloc_stats.space_available,
-           (unsigned int) malloc_stats.max_depth / 1024,
-           (malloc_stats.max_depth * 100) / malloc_stats.space_available,
-           (unsigned64) malloc_stats.lifetime_allocated / 1024,
-           (unsigned64) malloc_stats.lifetime_freed / 1024);
+           (allocated * 100) / rtems_malloc_stats.space_available,
+           (unsigned int) rtems_malloc_stats.max_depth / 1024,
+           (rtems_malloc_stats.max_depth * 100) / rtems_malloc_stats.space_available,
+           (unsigned64) rtems_malloc_stats.lifetime_allocated / 1024,
+           (unsigned64) rtems_malloc_stats.lifetime_freed / 1024);
     printf("  Call counts:   malloc:%d   free:%d   realloc:%d   calloc:%d\n",
-           malloc_stats.malloc_calls,
-           malloc_stats.free_calls,
-           malloc_stats.realloc_calls,
-           malloc_stats.calloc_calls);
+           rtems_malloc_stats.malloc_calls,
+           rtems_malloc_stats.free_calls,
+           rtems_malloc_stats.realloc_calls,
+           rtems_malloc_stats.calloc_calls);
 }
 
Index: c/src/exec/libcsupport/src/newlibc.c
===================================================================
--- c/src/exec/libcsupport/src/newlibc.c	(revision 634e746544cc226ef388880bb1d3ec0144ff29db)
+++ c/src/exec/libcsupport/src/newlibc.c	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
@@ -1,3 +1,2 @@
-#if defined(RTEMS_NEWLIB)
 
 /*
@@ -31,4 +30,6 @@
 #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
 #include <rtems.h>
+
+#if defined(RTEMS_NEWLIB)
 #include <libcsupport.h>
 #include <stdlib.h>             /* for free() */
@@ -347,4 +348,6 @@
  */
 
+#include <stdio.h>
+
 #if !defined(RTEMS_UNIX) && !defined(__GO32__) && !defined(_AM29K)
 void _exit(int status)
Index: c/src/lib/include/rtems/libio.h
===================================================================
--- c/src/lib/include/rtems/libio.h	(revision 634e746544cc226ef388880bb1d3ec0144ff29db)
+++ c/src/lib/include/rtems/libio.h	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
@@ -13,4 +13,6 @@
 #ifndef _RTEMS_LIBIO_H
 #define _RTEMS_LIBIO_H
+
+#include <sys/stat.h>
 
 typedef unsigned32 rtems_libio_offset_t;
@@ -89,10 +91,12 @@
 void rtems_libio_init(void);
 
-int __open(const char  *pathname, unsigned32 flag, unsigned32 mode);
-int __close(int  fd);
-int __read(int fd, void *buffer, unsigned32 count);
-int __write(int fd, const void *buffer, unsigned32 count);
-int __ioctl(int fd, unsigned32  command, void *buffer);
-int __lseek(int fd, rtems_libio_offset_t offset, int whence);
+int __rtems_open(const char  *pathname, unsigned32 flag, unsigned32 mode);
+int __rtems_close(int  fd);
+int __rtems_read(int fd, void *buffer, unsigned32 count);
+int __rtems_write(int fd, const void *buffer, unsigned32 count);
+int __rtems_ioctl(int fd, unsigned32  command, void *buffer);
+int __rtems_lseek(int fd, rtems_libio_offset_t offset, int whence);
+int __rtems_fstat(int _fd, struct stat* _sbuf);
+int __rtems_isatty(int _fd);
 
 #endif /* _RTEMS_LIBIO_H */
Index: c/src/lib/libc/libio.c
===================================================================
--- c/src/lib/libc/libio.c	(revision 634e746544cc226ef388880bb1d3ec0144ff29db)
+++ c/src/lib/libc/libio.c	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
@@ -47,5 +47,5 @@
 #define rtems_libio_check_fd(fd) \
     do { \
-        if ((fd) >= rtems_libio_number_iops) \
+        if ((unsigned32) (fd) >= rtems_libio_number_iops) \
         { \
             errno = EBADF; \
@@ -244,5 +244,5 @@
 
 int
-__open(
+__rtems_open(
     const char   *pathname,
     unsigned32    flag,
@@ -255,8 +255,10 @@
 
     if ((rc = rtems_io_lookup_name(pathname, &np)) != RTEMS_SUCCESSFUL) {
+/*
       if ( rc == RTEMS_UNSATISFIED ) {
         puts( "open -- ENOSYS case" );
         assert( 0 );
       }
+*/
         goto done;
     }
@@ -292,5 +294,5 @@
     
 int
-__close(
+__rtems_close(
     int  fd
   )    
@@ -317,5 +319,5 @@
     
 int
-__read(
+__rtems_read(
     int       fd,
     void *    buffer,
@@ -353,5 +355,5 @@
 
 int
-__write(
+__rtems_write(
     int         fd,
     const void *buffer,
@@ -389,5 +391,5 @@
 
 int
-__ioctl(
+__rtems_ioctl(
     int         fd,
     unsigned32  command,
@@ -421,5 +423,5 @@
 
 int
-__lseek(
+__rtems_lseek(
     int                  fd,
     rtems_libio_offset_t offset,
Index: c/src/lib/libc/libio.h
===================================================================
--- c/src/lib/libc/libio.h	(revision 634e746544cc226ef388880bb1d3ec0144ff29db)
+++ c/src/lib/libc/libio.h	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
@@ -13,4 +13,6 @@
 #ifndef _RTEMS_LIBIO_H
 #define _RTEMS_LIBIO_H
+
+#include <sys/stat.h>
 
 typedef unsigned32 rtems_libio_offset_t;
@@ -89,10 +91,12 @@
 void rtems_libio_init(void);
 
-int __open(const char  *pathname, unsigned32 flag, unsigned32 mode);
-int __close(int  fd);
-int __read(int fd, void *buffer, unsigned32 count);
-int __write(int fd, const void *buffer, unsigned32 count);
-int __ioctl(int fd, unsigned32  command, void *buffer);
-int __lseek(int fd, rtems_libio_offset_t offset, int whence);
+int __rtems_open(const char  *pathname, unsigned32 flag, unsigned32 mode);
+int __rtems_close(int  fd);
+int __rtems_read(int fd, void *buffer, unsigned32 count);
+int __rtems_write(int fd, const void *buffer, unsigned32 count);
+int __rtems_ioctl(int fd, unsigned32  command, void *buffer);
+int __rtems_lseek(int fd, rtems_libio_offset_t offset, int whence);
+int __rtems_fstat(int _fd, struct stat* _sbuf);
+int __rtems_isatty(int _fd);
 
 #endif /* _RTEMS_LIBIO_H */
Index: c/src/lib/libc/malloc.c
===================================================================
--- c/src/lib/libc/malloc.c	(revision 634e746544cc226ef388880bb1d3ec0144ff29db)
+++ c/src/lib/libc/malloc.c	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
@@ -38,5 +38,5 @@
 
 #ifdef MALLOC_STATS
-#define MSBUMP(f,n)    malloc_stats.f += (n)
+#define MSBUMP(f,n)    rtems_malloc_stats.f += (n)
 
 struct {
@@ -49,7 +49,7 @@
     unsigned64  lifetime_allocated;
     unsigned64  lifetime_freed;
-} malloc_stats;
-
-#else			/* No malloc_stats */
+} rtems_malloc_stats;
+
+#else			/* No rtems_malloc_stats */
 #define MSBUMP(f,n)
 #endif
@@ -116,5 +116,5 @@
 #ifdef MALLOC_STATS
   /* zero all the stats */
-  (void) memset(&malloc_stats, 0, sizeof(malloc_stats));
+  (void) memset(&rtems_malloc_stats, 0, sizeof(rtems_malloc_stats));
 #endif
   
@@ -202,7 +202,7 @@
       status = rtems_region_get_segment_size(RTEMS_Malloc_Heap, return_this, &actual_size);
       MSBUMP(lifetime_allocated, actual_size);
-      current_depth = malloc_stats.lifetime_allocated - malloc_stats.lifetime_freed;
-      if (current_depth > malloc_stats.max_depth)
-          malloc_stats.max_depth = current_depth;
+      current_depth = rtems_malloc_stats.lifetime_allocated - rtems_malloc_stats.lifetime_freed;
+      if (current_depth > rtems_malloc_stats.max_depth)
+          rtems_malloc_stats.max_depth = current_depth;
   }
 #endif
@@ -315,21 +315,21 @@
 void malloc_dump(void)
 {
-    unsigned32 allocated = malloc_stats.lifetime_allocated - malloc_stats.lifetime_freed;
+    unsigned32 allocated = rtems_malloc_stats.lifetime_allocated - rtems_malloc_stats.lifetime_freed;
 
     printf("Malloc stats\n");
     printf("  avail:%uk  allocated:%uk (%d%%) max:%uk (%d%%) lifetime:%Luk freed:%Luk\n",
-           (unsigned int) malloc_stats.space_available / 1024,
+           (unsigned int) rtems_malloc_stats.space_available / 1024,
            (unsigned int) allocated / 1024,
            /* avoid float! */
-           (allocated * 100) / malloc_stats.space_available,
-           (unsigned int) malloc_stats.max_depth / 1024,
-           (malloc_stats.max_depth * 100) / malloc_stats.space_available,
-           (unsigned64) malloc_stats.lifetime_allocated / 1024,
-           (unsigned64) malloc_stats.lifetime_freed / 1024);
+           (allocated * 100) / rtems_malloc_stats.space_available,
+           (unsigned int) rtems_malloc_stats.max_depth / 1024,
+           (rtems_malloc_stats.max_depth * 100) / rtems_malloc_stats.space_available,
+           (unsigned64) rtems_malloc_stats.lifetime_allocated / 1024,
+           (unsigned64) rtems_malloc_stats.lifetime_freed / 1024);
     printf("  Call counts:   malloc:%d   free:%d   realloc:%d   calloc:%d\n",
-           malloc_stats.malloc_calls,
-           malloc_stats.free_calls,
-           malloc_stats.realloc_calls,
-           malloc_stats.calloc_calls);
+           rtems_malloc_stats.malloc_calls,
+           rtems_malloc_stats.free_calls,
+           rtems_malloc_stats.realloc_calls,
+           rtems_malloc_stats.calloc_calls);
 }
 
Index: c/src/lib/libc/newlibc.c
===================================================================
--- c/src/lib/libc/newlibc.c	(revision 634e746544cc226ef388880bb1d3ec0144ff29db)
+++ c/src/lib/libc/newlibc.c	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
@@ -1,3 +1,2 @@
-#if defined(RTEMS_NEWLIB)
 
 /*
@@ -31,4 +30,6 @@
 #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
 #include <rtems.h>
+
+#if defined(RTEMS_NEWLIB)
 #include <libcsupport.h>
 #include <stdlib.h>             /* for free() */
@@ -347,4 +348,6 @@
  */
 
+#include <stdio.h>
+
 #if !defined(RTEMS_UNIX) && !defined(__GO32__) && !defined(_AM29K)
 void _exit(int status)
Index: c/src/lib/libc/newlibif.c
===================================================================
--- c/src/lib/libc/newlibif.c	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
+++ c/src/lib/libc/newlibif.c	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
@@ -0,0 +1,90 @@
+
+/*
+ *  This file contains the glue which maps newlib system calls onto their
+ *  RTEMS implementations.  This formerly was in the file
+ *  libgloss/rtems/iface.c which was installed as rtems.o.  Merging this
+ *  into the RTEMS source tree minimizes the files which must be linked
+ *  to build an rtems application.
+ *
+ *  $Id$
+ *
+ */
+
+#include <rtems.h>
+#if defined(RTEMS_NEWLIB)
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#include "internal.h"
+#include "libio.h"
+
+int
+read(int fd,
+     char *buf,
+     int nbytes)
+{
+    return __rtems_read(fd, buf, nbytes);
+}
+
+int
+write(int fd,
+      char *buf,
+      int nbytes)
+{
+    return __rtems_write(fd, buf, nbytes);
+}
+
+int
+open(char *buf,
+     int flags,
+     int mode)
+{
+    return __rtems_open(buf, flags, mode);
+}
+
+int
+close(int fd)
+{
+    return __rtems_close(fd);
+}
+
+/*
+ * isatty -- returns 1 if connected to a terminal device,
+ *           returns 0 if not.
+ */
+int
+isatty(int fd)
+{
+    return __rtems_isatty(fd);
+}
+
+/*
+ * lseek -- move read/write pointer. Since a serial port
+ *          is non-seekable, we return an error.
+ */
+off_t
+lseek(int fd,
+      off_t offset,
+      int whence)
+{
+    return __rtems_lseek(fd, offset, whence);
+}
+
+/*
+ * fstat -- get status of a file. Since we have no file
+ *          system, we just return an error.
+ */
+int
+fstat(int fd,
+      struct stat *buf)
+{
+    return __rtems_fstat(fd, buf);
+}
+
+/*
+ *  getpid and kill are provided directly by rtems
+ */
+
+#endif
Index: c/src/lib/libc/syscalls.c
===================================================================
--- c/src/lib/libc/syscalls.c	(revision 634e746544cc226ef388880bb1d3ec0144ff29db)
+++ c/src/lib/libc/syscalls.c	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
@@ -24,4 +24,7 @@
 #include <sys/stat.h>
 #include <assert.h>
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>  /* only for puts */
 
 /*
@@ -30,8 +33,8 @@
  */
 
-int __fstat(int _fd, struct stat* _sbuf)
+int __rtems_fstat(int _fd, struct stat* _sbuf)
 {
   if ( _fd > 2 ) {
-    puts( "__fstat -- only stdio supported" );
+    puts( "__rtems_fstat -- only stdio supported" );
     assert( 0 );
   }
@@ -43,5 +46,5 @@
 }
 
-int __isatty(int _fd)
+int __rtems_isatty(int _fd)
 {
   return 1;
@@ -53,5 +56,5 @@
     return -1;
   }
-  return __fstat( 0, buf );
+  return __rtems_fstat( 0, buf );
 }
 
@@ -68,3 +71,27 @@
 }
 
+char *getcwd( char *_buf, size_t _size) {
+/*  assert( FALSE ); */
+  errno = ENOSYS;
+  return 0;
+}
+int fork() {
+  puts( "fork -- not supported!!!" );
+  assert( 0 );
+  errno = ENOSYS;
+  return -1;
+}
+int execv(const char *_path, char * const _argv[] ) {
+  puts( "execv -- not supported!!!" ); 
+  assert( 0 );
+  errno = ENOSYS;
+  return -1;
+}
+int wait() {
+  puts( "wait -- not supported!!!" );
+  assert( 0 );
+  errno = ENOSYS;
+  return -1;
+}
+
 #endif
Index: cpukit/libcsupport/include/rtems/libio.h
===================================================================
--- cpukit/libcsupport/include/rtems/libio.h	(revision 634e746544cc226ef388880bb1d3ec0144ff29db)
+++ cpukit/libcsupport/include/rtems/libio.h	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
@@ -13,4 +13,6 @@
 #ifndef _RTEMS_LIBIO_H
 #define _RTEMS_LIBIO_H
+
+#include <sys/stat.h>
 
 typedef unsigned32 rtems_libio_offset_t;
@@ -89,10 +91,12 @@
 void rtems_libio_init(void);
 
-int __open(const char  *pathname, unsigned32 flag, unsigned32 mode);
-int __close(int  fd);
-int __read(int fd, void *buffer, unsigned32 count);
-int __write(int fd, const void *buffer, unsigned32 count);
-int __ioctl(int fd, unsigned32  command, void *buffer);
-int __lseek(int fd, rtems_libio_offset_t offset, int whence);
+int __rtems_open(const char  *pathname, unsigned32 flag, unsigned32 mode);
+int __rtems_close(int  fd);
+int __rtems_read(int fd, void *buffer, unsigned32 count);
+int __rtems_write(int fd, const void *buffer, unsigned32 count);
+int __rtems_ioctl(int fd, unsigned32  command, void *buffer);
+int __rtems_lseek(int fd, rtems_libio_offset_t offset, int whence);
+int __rtems_fstat(int _fd, struct stat* _sbuf);
+int __rtems_isatty(int _fd);
 
 #endif /* _RTEMS_LIBIO_H */
Index: cpukit/libcsupport/src/libio.c
===================================================================
--- cpukit/libcsupport/src/libio.c	(revision 634e746544cc226ef388880bb1d3ec0144ff29db)
+++ cpukit/libcsupport/src/libio.c	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
@@ -47,5 +47,5 @@
 #define rtems_libio_check_fd(fd) \
     do { \
-        if ((fd) >= rtems_libio_number_iops) \
+        if ((unsigned32) (fd) >= rtems_libio_number_iops) \
         { \
             errno = EBADF; \
@@ -244,5 +244,5 @@
 
 int
-__open(
+__rtems_open(
     const char   *pathname,
     unsigned32    flag,
@@ -255,8 +255,10 @@
 
     if ((rc = rtems_io_lookup_name(pathname, &np)) != RTEMS_SUCCESSFUL) {
+/*
       if ( rc == RTEMS_UNSATISFIED ) {
         puts( "open -- ENOSYS case" );
         assert( 0 );
       }
+*/
         goto done;
     }
@@ -292,5 +294,5 @@
     
 int
-__close(
+__rtems_close(
     int  fd
   )    
@@ -317,5 +319,5 @@
     
 int
-__read(
+__rtems_read(
     int       fd,
     void *    buffer,
@@ -353,5 +355,5 @@
 
 int
-__write(
+__rtems_write(
     int         fd,
     const void *buffer,
@@ -389,5 +391,5 @@
 
 int
-__ioctl(
+__rtems_ioctl(
     int         fd,
     unsigned32  command,
@@ -421,5 +423,5 @@
 
 int
-__lseek(
+__rtems_lseek(
     int                  fd,
     rtems_libio_offset_t offset,
Index: cpukit/libcsupport/src/malloc.c
===================================================================
--- cpukit/libcsupport/src/malloc.c	(revision 634e746544cc226ef388880bb1d3ec0144ff29db)
+++ cpukit/libcsupport/src/malloc.c	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
@@ -38,5 +38,5 @@
 
 #ifdef MALLOC_STATS
-#define MSBUMP(f,n)    malloc_stats.f += (n)
+#define MSBUMP(f,n)    rtems_malloc_stats.f += (n)
 
 struct {
@@ -49,7 +49,7 @@
     unsigned64  lifetime_allocated;
     unsigned64  lifetime_freed;
-} malloc_stats;
-
-#else			/* No malloc_stats */
+} rtems_malloc_stats;
+
+#else			/* No rtems_malloc_stats */
 #define MSBUMP(f,n)
 #endif
@@ -116,5 +116,5 @@
 #ifdef MALLOC_STATS
   /* zero all the stats */
-  (void) memset(&malloc_stats, 0, sizeof(malloc_stats));
+  (void) memset(&rtems_malloc_stats, 0, sizeof(rtems_malloc_stats));
 #endif
   
@@ -202,7 +202,7 @@
       status = rtems_region_get_segment_size(RTEMS_Malloc_Heap, return_this, &actual_size);
       MSBUMP(lifetime_allocated, actual_size);
-      current_depth = malloc_stats.lifetime_allocated - malloc_stats.lifetime_freed;
-      if (current_depth > malloc_stats.max_depth)
-          malloc_stats.max_depth = current_depth;
+      current_depth = rtems_malloc_stats.lifetime_allocated - rtems_malloc_stats.lifetime_freed;
+      if (current_depth > rtems_malloc_stats.max_depth)
+          rtems_malloc_stats.max_depth = current_depth;
   }
 #endif
@@ -315,21 +315,21 @@
 void malloc_dump(void)
 {
-    unsigned32 allocated = malloc_stats.lifetime_allocated - malloc_stats.lifetime_freed;
+    unsigned32 allocated = rtems_malloc_stats.lifetime_allocated - rtems_malloc_stats.lifetime_freed;
 
     printf("Malloc stats\n");
     printf("  avail:%uk  allocated:%uk (%d%%) max:%uk (%d%%) lifetime:%Luk freed:%Luk\n",
-           (unsigned int) malloc_stats.space_available / 1024,
+           (unsigned int) rtems_malloc_stats.space_available / 1024,
            (unsigned int) allocated / 1024,
            /* avoid float! */
-           (allocated * 100) / malloc_stats.space_available,
-           (unsigned int) malloc_stats.max_depth / 1024,
-           (malloc_stats.max_depth * 100) / malloc_stats.space_available,
-           (unsigned64) malloc_stats.lifetime_allocated / 1024,
-           (unsigned64) malloc_stats.lifetime_freed / 1024);
+           (allocated * 100) / rtems_malloc_stats.space_available,
+           (unsigned int) rtems_malloc_stats.max_depth / 1024,
+           (rtems_malloc_stats.max_depth * 100) / rtems_malloc_stats.space_available,
+           (unsigned64) rtems_malloc_stats.lifetime_allocated / 1024,
+           (unsigned64) rtems_malloc_stats.lifetime_freed / 1024);
     printf("  Call counts:   malloc:%d   free:%d   realloc:%d   calloc:%d\n",
-           malloc_stats.malloc_calls,
-           malloc_stats.free_calls,
-           malloc_stats.realloc_calls,
-           malloc_stats.calloc_calls);
+           rtems_malloc_stats.malloc_calls,
+           rtems_malloc_stats.free_calls,
+           rtems_malloc_stats.realloc_calls,
+           rtems_malloc_stats.calloc_calls);
 }
 
Index: cpukit/libcsupport/src/newlibc.c
===================================================================
--- cpukit/libcsupport/src/newlibc.c	(revision 634e746544cc226ef388880bb1d3ec0144ff29db)
+++ cpukit/libcsupport/src/newlibc.c	(revision dcec5a4d60405c206b1fab8630534e917fdf9857)
@@ -1,3 +1,2 @@
-#if defined(RTEMS_NEWLIB)
 
 /*
@@ -31,4 +30,6 @@
 #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
 #include <rtems.h>
+
+#if defined(RTEMS_NEWLIB)
 #include <libcsupport.h>
 #include <stdlib.h>             /* for free() */
@@ -347,4 +348,6 @@
  */
 
+#include <stdio.h>
+
 #if !defined(RTEMS_UNIX) && !defined(__GO32__) && !defined(_AM29K)
 void _exit(int status)
