summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/newlibc.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-05-09 18:27:26 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-05-09 18:27:26 +0000
commitc3db01d0f37921ba809825e9c6b7fbe86b8fae5d (patch)
tree0f7adb0ea85567c63adf99d5cf0e67b7598aa61b /cpukit/libcsupport/src/newlibc.c
parent2007-05-09 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-c3db01d0f37921ba809825e9c6b7fbe86b8fae5d.tar.bz2
2007-05-09 Joel Sherrill <joel.sherrill@OARcorp.com>
* libcsupport/include/rtems/libcsupport.h, libcsupport/src/newlibc.c, sapi/Makefile.am, sapi/include/confdefs.h, sapi/src/exinit.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/userext.h, score/src/chain.c, score/src/userext.c: Switch to newlib reentrancy extension being installed in the initial set instead of using rtems_extension_create. While implementing this, noticed that user extensions and chain code had multiple functions in a single file which is not desirable in the SuperCore and API portions of RTEMS, so split these into multiple files with one function per file. Also noticed that some of user extension code was inlined for no particular reason so moved that to C bodies. Split executive shutdown from initialization since not every application shuts down. Moved __fini call to executive shutdown to be more symmetrical with where it is called at startup. * sapi/src/exshutdown.c, score/src/chainappend.c, score/src/chainextract.c, score/src/chainget.c, score/src/chaininsert.c, score/src/userextaddapiset.c, score/src/userextaddset.c, score/src/userextremoveset.c, score/src/userextthreadbegin.c, score/src/userextthreadcreate.c, score/src/userextthreaddelete.c, score/src/userextthreadrestart.c, score/src/userextthreadstart.c, score/src/userextthreadswitch.c: New files. * score/inline/rtems/score/userext.inl: Removed.
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