summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-09-17 16:12:04 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-09-17 16:12:04 +0000
commitd40da79b04ee4756675c3356cfc156fb7d9bd547 (patch)
treef55cad54aadd9cac001bccbbb37922cc27597107 /cpukit/libcsupport
parent2008-09-17 Miao Yan <yanmiaobest@gmail.com> (diff)
downloadrtems-d40da79b04ee4756675c3356cfc156fb7d9bd547.tar.bz2
2008-09-17 Miao Yan <yanmiaobest@gmail.com>
* Makefile.am, preinstall.am, libcsupport/Makefile.am, libcsupport/include/rtems/libcsupport.h, libcsupport/include/rtems/libio.h, libcsupport/src/base_fs.c, libcsupport/src/libio_init.c, libcsupport/src/newlibc_exit.c, libcsupport/src/newlibc_init.c, libcsupport/src/sync.c, libfs/Makefile.am, libfs/src/imfs/deviceio.c, sapi/include/confdefs.h: Merge GSOC project code to add simple device only filesystem (devfs), optionally completely drop out filesystem, and to clean up disabling newlib reentrancy support. This dropped 17K from the minimum.exe for sparc/sis and arm/rtl22xx_t now has a 15K code space. * libcsupport/src/__usrenv.c, libcsupport/src/newlibc_reent.c, libfs/src/devfs/devclose.c, libfs/src/devfs/devfs.h, libfs/src/devfs/devfs_eval.c, libfs/src/devfs/devfs_init.c, libfs/src/devfs/devfs_mknod.c, libfs/src/devfs/devfs_node_type.c, libfs/src/devfs/devfs_show.c, libfs/src/devfs/devioctl.c, libfs/src/devfs/devopen.c, libfs/src/devfs/devread.c, libfs/src/devfs/devstat.c, libfs/src/devfs/devwrite.c, libfs/src/imfs/deviceerrno.c: New files. * libcsupport/src/newlibc.c: Removed.
Diffstat (limited to '')
-rw-r--r--cpukit/libcsupport/Makefile.am4
-rw-r--r--cpukit/libcsupport/include/rtems/libcsupport.h24
-rw-r--r--cpukit/libcsupport/include/rtems/libio.h12
-rw-r--r--cpukit/libcsupport/src/__usrenv.c27
-rw-r--r--cpukit/libcsupport/src/base_fs.c9
-rw-r--r--cpukit/libcsupport/src/libio_init.c3
-rw-r--r--cpukit/libcsupport/src/newlibc_exit.c8
-rw-r--r--cpukit/libcsupport/src/newlibc_init.c20
-rw-r--r--cpukit/libcsupport/src/newlibc_reent.c (renamed from cpukit/libcsupport/src/newlibc.c)35
-rw-r--r--cpukit/libcsupport/src/sync.c8
10 files changed, 81 insertions, 69 deletions
diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am
index f5cb6fdae3..12395b1af7 100644
--- a/cpukit/libcsupport/Makefile.am
+++ b/cpukit/libcsupport/Makefile.am
@@ -47,7 +47,7 @@ ASSOCIATION_C_FILES = src/assoclocalbyname.c \
BASE_FS_C_FILES = src/base_fs.c src/mount.c src/unmount.c src/libio.c \
src/libio_init.c \
src/libio_sockets.c src/eval.c src/fs_null_handlers.c src/privateenv.c \
- src/open_dev_console.c
+ src/open_dev_console.c src/__usrenv.c
TERMIOS_C_FILES = src/cfgetispeed.c src/cfgetospeed.c src/cfsetispeed.c \
src/cfsetospeed.c src/tcgetattr.c src/tcsetattr.c src/tcdrain.c \
@@ -94,7 +94,7 @@ TERMINAL_IDENTIFICATION_C_FILES = src/ctermid.c src/isatty.c src/ttyname.c
LIBC_GLUE_C_FILES = src/__getpid.c src/__gettod.c src/__times.c \
src/truncate.c src/access.c src/stat.c src/lstat.c src/pathconf.c \
- src/newlibc.c src/newlibc_init.c src/newlibc_exit.c src/no_posix.c \
+ src/newlibc_reent.c src/newlibc_init.c src/newlibc_exit.c src/no_posix.c \
src/no_libc.c src/utsname.c
BSD_LIBC_C_FILES = src/strlcpy.c src/strlcat.c
diff --git a/cpukit/libcsupport/include/rtems/libcsupport.h b/cpukit/libcsupport/include/rtems/libcsupport.h
index 2c6efd1536..7197df5708 100644
--- a/cpukit/libcsupport/include/rtems/libcsupport.h
+++ b/cpukit/libcsupport/include/rtems/libcsupport.h
@@ -45,33 +45,33 @@ extern void open_dev_console(void);
/*
* Prototypes required to install newlib reentrancy user extension
*/
-bool libc_create_hook(
+bool newlib_create_hook(
rtems_tcb *current_task,
rtems_tcb *creating_task
);
#if defined(RTEMS_UNIX) && !defined(hpux)
- rtems_extension libc_begin_hook(rtems_tcb *current_task);
- #define __RTEMS_NEWLIB_BEGIN libc_begin_hook
+ rtems_extension newlib_begin_hook(rtems_tcb *current_task);
+ #define __RTEMS_NEWLIB_BEGIN newlib_begin_hook
#else
#define __RTEMS_NEWLIB_BEGIN 0
#endif
-rtems_extension libc_delete_hook(
+rtems_extension newlib_delete_hook(
rtems_tcb *current_task,
rtems_tcb *deleted_task
);
#define RTEMS_NEWLIB_EXTENSION \
{ \
- libc_create_hook, /* rtems_task_create */ \
- 0, /* rtems_task_start */ \
- 0, /* rtems_task_restart */ \
- libc_delete_hook, /* rtems_task_delete */ \
- 0, /* task_switch */ \
- __RTEMS_NEWLIB_BEGIN, /* task_begin */ \
- 0, /* task_exitted */ \
- 0 /* fatal */ \
+ newlib_create_hook, /* rtems_task_create */ \
+ 0, /* rtems_task_start */ \
+ 0, /* rtems_task_restart */ \
+ newlib_delete_hook, /* rtems_task_delete */ \
+ 0, /* task_switch */ \
+ __RTEMS_NEWLIB_BEGIN, /* task_begin */ \
+ 0, /* task_exitted */ \
+ 0 /* fatal */ \
}
#ifdef __cplusplus
diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h
index 1767d1d789..9147218629 100644
--- a/cpukit/libcsupport/include/rtems/libio.h
+++ b/cpukit/libcsupport/include/rtems/libio.h
@@ -634,6 +634,18 @@ typedef struct {
extern const rtems_filesystem_mount_table_t *rtems_filesystem_mount_table;
extern const int rtems_filesystem_mount_table_size;
+
+typedef void (*rtems_libio_init_functions_t)(void);
+extern rtems_libio_init_functions_t rtems_libio_init_helper;
+
+void open_dev_console(void);
+
+typedef void (*rtems_libio_supp_functions_t)(void);
+extern rtems_libio_supp_functions_t rtems_libio_supp_helper;
+
+typedef void (*rtems_fs_init_functions_t)(void);
+extern rtems_fs_init_functions_t rtems_fs_init_helper;
+
#ifdef __cplusplus
}
#endif
diff --git a/cpukit/libcsupport/src/__usrenv.c b/cpukit/libcsupport/src/__usrenv.c
new file mode 100644
index 0000000000..0b3469fa1a
--- /dev/null
+++ b/cpukit/libcsupport/src/__usrenv.c
@@ -0,0 +1,27 @@
+/*
+ * COPYRIGHT (c) 1989-2008.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/libio.h>
+#include <rtems/libio_.h>
+
+/*
+ * Global information for POSIX Process Environment Support
+ */
+
+rtems_user_env_t rtems_global_user_env;
+rtems_user_env_t * rtems_current_user_env = &rtems_global_user_env;
+
+
diff --git a/cpukit/libcsupport/src/base_fs.c b/cpukit/libcsupport/src/base_fs.c
index 4ce53b0e4b..91466a5b07 100644
--- a/cpukit/libcsupport/src/base_fs.c
+++ b/cpukit/libcsupport/src/base_fs.c
@@ -1,7 +1,7 @@
/*
* Base file system initialization
*
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -20,13 +20,6 @@
#include <rtems/libio_.h>
/*
- * Global information for the base file system.
- */
-
-rtems_user_env_t rtems_global_user_env;
-rtems_user_env_t * rtems_current_user_env = &rtems_global_user_env;
-
-/*
* Default mode for created files.
*/
diff --git a/cpukit/libcsupport/src/libio_init.c b/cpukit/libcsupport/src/libio_init.c
index 4968058637..9bb96e40c2 100644
--- a/cpukit/libcsupport/src/libio_init.c
+++ b/cpukit/libcsupport/src/libio_init.c
@@ -86,5 +86,6 @@ void rtems_libio_init( void )
* Initialize the base file system infrastructure.
*/
- rtems_filesystem_initialize();
+ if (rtems_fs_init_helper)
+ (* rtems_fs_init_helper)();
}
diff --git a/cpukit/libcsupport/src/newlibc_exit.c b/cpukit/libcsupport/src/newlibc_exit.c
index 68212b692e..f7f8a6e481 100644
--- a/cpukit/libcsupport/src/newlibc_exit.c
+++ b/cpukit/libcsupport/src/newlibc_exit.c
@@ -40,7 +40,7 @@ int _fwalk(struct _reent *ptr, int (*function) (FILE *) );
/* do we think we are reentrant? */
extern int libc_reentrant;
-extern struct _reent libc_global_reent __ATTRIBUTE_IMPURE_PTR__;
+extern struct _reent * const _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
/*
* CYGNUS newlib routine that does atexit() processing and flushes
@@ -66,15 +66,15 @@ void libc_wrapup(void)
_wrapup_reent(0);
*/
- if (_REENT != &libc_global_reent) {
- _wrapup_reent(&libc_global_reent);
+ if (_REENT != _global_impure_ptr) {
+ _wrapup_reent(_global_impure_ptr);
#if 0
/* Don't reclaim this one, just in case we do printfs
* on the way out to ROM.
*/
_reclaim_reent(&libc_global_reent);
#endif
- _REENT = &libc_global_reent;
+ _REENT = _global_impure_ptr;
}
/*
diff --git a/cpukit/libcsupport/src/newlibc_init.c b/cpukit/libcsupport/src/newlibc_init.c
index a37ab29663..dbf9544fd5 100644
--- a/cpukit/libcsupport/src/newlibc_init.c
+++ b/cpukit/libcsupport/src/newlibc_init.c
@@ -17,22 +17,7 @@
#include "config.h"
#endif
-#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
-#include <rtems.h>
-
#if defined(RTEMS_NEWLIB)
-#include <rtems/libcsupport.h>
-
-/* Since we compile with strict ANSI we need to undef it to get
- * prototypes for extensions
- */
-#undef __STRICT_ANSI__
-
-#include <stdlib.h> /* for free() */
-#include <string.h> /* for memset() */
-
-#include <sys/reent.h> /* for extern of _REENT (aka _impure_ptr) */
-#include <errno.h>
/*
* Init libc for CYGNUS newlib
@@ -48,14 +33,9 @@
*/
-struct _reent libc_global_reent
- __ATTRIBUTE_IMPURE_PTR__ = _REENT_INIT(libc_global_reent);
void
libc_init(void)
{
- _REENT = &libc_global_reent;
-
- _Thread_Set_libc_reent (&_REENT);
}
#endif
diff --git a/cpukit/libcsupport/src/newlibc.c b/cpukit/libcsupport/src/newlibc_reent.c
index 79c1dc7dd4..ba8078a135 100644
--- a/cpukit/libcsupport/src/newlibc.c
+++ b/cpukit/libcsupport/src/newlibc_reent.c
@@ -1,10 +1,4 @@
/*
- * Implementation of hooks for the CYGNUS newlib libc
- * These hooks set things up so that:
- * + '_REENT' is switched at task switch time.
- *
- * COPYRIGHT (c) 1994 by Division Incorporated
- *
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
@@ -50,8 +44,7 @@
int _fwalk(struct _reent *ptr, int (*function) (FILE *) );
-extern struct _reent libc_global_reent __ATTRIBUTE_IMPURE_PTR__;
-
+extern struct _reent * const _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
/*
* reent struct allocation moved here from libc_start_hook() to avoid
* mutual exclusion problems when memory is allocated from the start hook.
@@ -59,13 +52,20 @@ extern struct _reent libc_global_reent __ATTRIBUTE_IMPURE_PTR__;
* Memory is also now allocated from the workspace rather than the heap.
* -- ptorre 9/30/03
*/
-bool libc_create_hook(
+bool newlib_create_hook(
rtems_tcb *current_task,
rtems_tcb *creating_task
)
{
struct _reent *ptr;
+ if (_Thread_libc_reent == 0)
+ {
+ _REENT = _global_impure_ptr;
+
+ _Thread_Set_libc_reent (&_REENT);
+ }
+
/* NOTE: The RTEMS malloc is reentrant without a reent ptr since
* it is based on the Classic API Region Manager.
*/
@@ -81,13 +81,12 @@ bool libc_create_hook(
#endif
if (ptr) {
-
- _REENT_INIT_PTR((ptr)); /* GCC extension: structure constants */
- creating_task->libc_reent = ptr;
- return true;
+ _REENT_INIT_PTR((ptr)); /* GCC extension: structure constants */
+ creating_task->libc_reent = ptr;
+ return TRUE;
}
- else
- return false;
+
+ return FALSE;
}
/*
@@ -95,7 +94,7 @@ bool libc_create_hook(
*/
#ifdef NEED_SETVBUF
-rtems_extension libc_begin_hook(rtems_tcb *current_task)
+rtems_extension newlib_begin_hook(rtems_tcb *current_task)
{
setvbuf( stdout, NULL, _IOLBF, BUFSIZ );
}
@@ -128,7 +127,7 @@ int newlib_free_buffers(
return 0;
}
-rtems_extension libc_delete_hook(
+rtems_extension newlib_delete_hook(
rtems_tcb *current_task,
rtems_tcb *deleted_task
)
@@ -145,7 +144,7 @@ rtems_extension libc_delete_hook(
ptr = deleted_task->libc_reent;
}
- if (ptr && ptr != &libc_global_reent) {
+ if (ptr && ptr != _global_impure_ptr) {
/*
_wrapup_reent(ptr);
_reclaim_reent(ptr);
diff --git a/cpukit/libcsupport/src/sync.c b/cpukit/libcsupport/src/sync.c
index 14c20cebb3..8db3f62161 100644
--- a/cpukit/libcsupport/src/sync.c
+++ b/cpukit/libcsupport/src/sync.c
@@ -7,7 +7,7 @@
* fsync()
* fdatasync()
*
- * COPYRIGHT (c) 1989-2003.
+ * COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -71,10 +71,10 @@ static void sync_per_thread(Thread_Control *t)
}
/*
- * libc_global_reent is not prototyped in any .h files.
+ * _global_impure_ptr is not prototyped in any .h files.
* We have to extern it here.
*/
-extern struct _reent libc_global_reent;
+extern struct _reent * const _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
void sync(void)
{
@@ -82,7 +82,7 @@ void sync(void)
/*
* Walk the one used initially by RTEMS.
*/
- _fwalk(&libc_global_reent, sync_wrapper);
+ _fwalk(_global_impure_ptr, sync_wrapper);
/*
* XXX Do we walk the one used globally by newlib?