summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/newlibc.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/libcsupport/src/newlibc.c')
-rw-r--r--cpukit/libcsupport/src/newlibc.c141
1 files changed, 27 insertions, 114 deletions
diff --git a/cpukit/libcsupport/src/newlibc.c b/cpukit/libcsupport/src/newlibc.c
index 80c5cd07ea..ff0ef21403 100644
--- a/cpukit/libcsupport/src/newlibc.c
+++ b/cpukit/libcsupport/src/newlibc.c
@@ -50,8 +50,8 @@
int _fwalk(struct _reent *ptr, int (*function) (FILE *) );
-int libc_reentrant; /* do we think we are reentrant? */
-struct _reent libc_global_reent __ATTRIBUTE_IMPURE_PTR__ = _REENT_INIT(libc_global_reent);
+struct _reent libc_global_reent
+ __ATTRIBUTE_IMPURE_PTR__ = _REENT_INIT(libc_global_reent);
/*
* reent struct allocation moved here from libc_start_hook() to avoid
@@ -71,54 +71,24 @@ rtems_boolean libc_create_hook(
* it is based on the Classic API Region Manager.
*/
-#define REENT_MALLOCED 0
-#if REENT_MALLOCED
- ptr = (struct _reent *) calloc(1, sizeof(struct _reent));
-#else
- /* It is OK to allocate from the workspace because these
- * hooks run with thread dispatching disabled.
- */
- ptr = (struct _reent *) _Workspace_Allocate(sizeof(struct _reent));
-#endif
+ #define REENT_MALLOCED 0
+ #if REENT_MALLOCED
+ ptr = (struct _reent *) calloc(1, sizeof(struct _reent));
+ #else
+ /* It is OK to allocate from the workspace because these
+ * hooks run with thread dispatching disabled.
+ */
+ ptr = (struct _reent *) _Workspace_Allocate(sizeof(struct _reent));
+ #endif
- if (ptr)
- {
-
-#ifdef __GNUC__
- /* GCC extension: structure constants */
- _REENT_INIT_PTR((ptr));
-#else
- /*
- * WARNING: THIS IS VERY DEPENDENT ON NEWLIB!!!
- * Last visual check was against newlib 1.8.2 but last known
- * use was against 1.7.0. This is basically an exansion of
- * REENT_INIT() in <sys/reent.h>.
- */
- memset(ptr, 0, sizeof(*ptr));
- ptr->_stdin = &ptr->__sf[0];
- ptr->_stdout = &ptr->__sf[1];
- ptr->_stderr = &ptr->__sf[2];
- ptr->_current_locale = "C";
- ptr->_new._reent._rand_next = 1;
-#endif
+ if (ptr) {
+ _REENT_INIT_PTR((ptr)); /* GCC extension: structure constants */
creating_task->libc_reent = ptr;
return TRUE;
}
else
- return FALSE;
-
-}
-
-/*
- * Called for all user TASKS (system tasks are MPCI Receive Server and IDLE)
- */
-
-rtems_extension libc_start_hook(
- rtems_tcb *current_task,
- rtems_tcb *starting_task
-)
-{
+ return FALSE;
}
/*
@@ -133,27 +103,9 @@ rtems_extension libc_begin_hook(rtems_tcb *current_task)
#endif
/*
- * Function: libc_delete_hook
- * Created: 94/12/10
- *
- * Description:
- * Called when a task is deleted.
- * Must restore the new lib reentrancy state for the new current
- * task.
- *
- * Parameters:
- *
- *
- * Returns:
- *
- *
- * Side Effects:
- *
- * Notes:
- *
- *
- * Deficiencies/ToDo:
- *
+ * Called when a task is deleted.
+ * Must restore the new lib reentrancy state for the new current
+ * task.
*
*/
@@ -222,64 +174,25 @@ rtems_extension libc_delete_hook(
}
/*
- * Function: libc_init
- * Created: 94/12/10
- *
- * Description:
- * Init libc for CYGNUS newlib
- * Set up _REENT to use our global libc_global_reent.
- * (newlib provides a global of its own, but we prefer our
- * own name for it)
- *
- * If reentrancy is desired (which it should be), then
- * we install the task extension hooks to maintain the
- * newlib reentrancy global variable _REENT on task
- * create, delete, switch, exit, etc.
- *
- * Parameters:
- * reentrant non-zero if reentrant library desired.
- *
- * Returns:
- *
- * Side Effects:
- * installs libc extensions if reentrant.
+ * Init libc for CYGNUS newlib
+ *
+ * Set up _REENT to use our global libc_global_reent.
+ * (newlib provides a global of its own, but we prefer our own name for it)
*
- * Notes:
- *
- *
- * Deficiencies/ToDo:
+ * If reentrancy is desired (which it should be), then
+ * we install the task extension hooks to maintain the
+ * newlib reentrancy global variable _REENT on task
+ * create, delete, switch, exit, etc.
*
*/
+
void
libc_init(int reentrant)
{
- rtems_extensions_table libc_extension;
- rtems_status_code rc;
- rtems_id extension_id;
-
-/* libc_global_reent = _REENT_INIT(libc_global_reent); */
_REENT = &libc_global_reent;
- if (reentrant) {
- memset(&libc_extension, 0, sizeof(libc_extension));
-
- libc_extension.thread_create = libc_create_hook;
- libc_extension.thread_start = libc_start_hook;
-#ifdef NEED_SETVBUF
- libc_extension.thread_begin = libc_begin_hook;
-#endif
- libc_extension.thread_delete = libc_delete_hook;
-
- _Thread_Set_libc_reent (&_REENT);
-
- rc = rtems_extension_create(rtems_build_name('L', 'I', 'B', 'C'),
- &libc_extension, &extension_id);
- if (rc != RTEMS_SUCCESSFUL)
- rtems_fatal_error_occurred( rc );
-
- libc_reentrant = reentrant;
- }
+ _Thread_Set_libc_reent (&_REENT);
}
#endif