summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/newlibc.c
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/src/newlibc.c
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/src/newlibc_reent.c (renamed from cpukit/libcsupport/src/newlibc.c)35
1 files changed, 17 insertions, 18 deletions
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);