From 5e9a59462cdd7d3af4cc45777dd9add9f86e7699 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 18 Sep 1996 20:53:35 +0000 Subject: modified to support non-GNU compilers and to use calloc rather than malloc for per-thread reentrancy structure allocation. --- cpukit/libcsupport/src/newlibc.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'cpukit/libcsupport/src/newlibc.c') diff --git a/cpukit/libcsupport/src/newlibc.c b/cpukit/libcsupport/src/newlibc.c index c4903b343f..2909c0e541 100644 --- a/cpukit/libcsupport/src/newlibc.c +++ b/cpukit/libcsupport/src/newlibc.c @@ -64,7 +64,7 @@ int libc_reentrant; /* do we think we are reentrant? */ -struct _reent libc_global_reent = _REENT_INIT(libc_global_reent);; +struct _reent libc_global_reent = _REENT_INIT(libc_global_reent); /* * CYGNUS newlib routine that does atexit() processing and flushes @@ -114,10 +114,27 @@ libc_start_hook(rtems_tcb *current_task, * it is based on region manager */ - ptr = (struct _reent *) malloc(sizeof(struct _reent)); + ptr = (struct _reent *) calloc(1, sizeof(struct _reent)); + if (!ptr) + rtems_fatal_error_occurred(RTEMS_NO_MEMORY); + +#ifdef __GNUC__ /* GCC extension: structure constants */ *ptr = (struct _reent) _REENT_INIT((*ptr)); +#else + /* + * Warning: THIS IS VERY DEPENDENT ON NEWLIB!!! WRITTEN FOR 1.7.0 + */ + ptr->_errno=0; + ptr->_stdin=&ptr->__sf[0]; + ptr->_stdout=&ptr->__sf[1]; + ptr->_stderr=&ptr->__sf[2]; + ptr->_scanpoint=0; + ptr->_asctime[0]=0; + ptr->_next=1; + ptr->__sdidinit=0; +#endif MY_task_set_note(starting_task, LIBC_NOTEPAD, (rtems_unsigned32) ptr); } @@ -329,7 +346,7 @@ int get_errno() * */ -#if !defined(RTEMS_UNIX) && !defined(__GO32__) +#if !defined(RTEMS_UNIX) && !defined(__GO32__) && !defined(_AM29K) void _exit(int status) { rtems_shutdown_executive(status); -- cgit v1.2.3