diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-08-18 15:43:45 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-08-18 15:43:45 +0000 |
commit | e49bb542270acf31e2247ab33cd5cb39b6afc9f5 (patch) | |
tree | fd4ba1a27fae8e84d3187c30e0815771b6917533 /cpukit | |
parent | 2008-08-18 Ralf Corsepius <ralf.corsepius@rtems.org> (diff) | |
download | rtems-e49bb542270acf31e2247ab33cd5cb39b6afc9f5.tar.bz2 |
2008-08-18 Joel Sherrill <joel.sherrill@oarcorp.com>
* libcsupport/Makefile.am, libcsupport/src/newlibc.c: Split libc_init()
into a separate file to avoid linkage dependencies on newlibc.c which
in turn pulls in fclose() and other C library methods.
* libcsupport/src/newlibc_init.c: New file.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/ChangeLog | 7 | ||||
-rw-r--r-- | cpukit/libcsupport/Makefile.am | 3 | ||||
-rw-r--r-- | cpukit/libcsupport/src/newlibc.c | 25 | ||||
-rw-r--r-- | cpukit/libcsupport/src/newlibc_init.c | 61 |
4 files changed, 71 insertions, 25 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 3ab988c7ec..006fc5f5e4 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,10 @@ +2008-08-18 Joel Sherrill <joel.sherrill@oarcorp.com> + + * libcsupport/Makefile.am, libcsupport/src/newlibc.c: Split libc_init() + into a separate file to avoid linkage dependencies on newlibc.c which + in turn pulls in fclose() and other C library methods. + * libcsupport/src/newlibc_init.c: New file. + 2008-08-18 Ralf Corsepius <ralf.corsepius@rtems.org> * aclocal/prog-cc.m4: Add -Wnested-externs. diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am index 0dfa4357a3..f5cb6fdae3 100644 --- a/cpukit/libcsupport/Makefile.am +++ b/cpukit/libcsupport/Makefile.am @@ -94,7 +94,8 @@ 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_exit.c src/no_posix.c src/no_libc.c src/utsname.c + src/newlibc.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/src/newlibc.c b/cpukit/libcsupport/src/newlibc.c index 013ce93413..a1ad8cf5c3 100644 --- a/cpukit/libcsupport/src/newlibc.c +++ b/cpukit/libcsupport/src/newlibc.c @@ -50,8 +50,7 @@ int _fwalk(struct _reent *ptr, int (*function) (FILE *) ); -struct _reent libc_global_reent - __ATTRIBUTE_IMPURE_PTR__ = _REENT_INIT(libc_global_reent); +extern struct _reent libc_global_reent __ATTRIBUTE_IMPURE_PTR__; /* * reent struct allocation moved here from libc_start_hook() to avoid @@ -173,26 +172,4 @@ rtems_extension libc_delete_hook( } } -/* - * 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. - * - */ - - -void -libc_init(void) -{ - _REENT = &libc_global_reent; - - _Thread_Set_libc_reent (&_REENT); -} - #endif diff --git a/cpukit/libcsupport/src/newlibc_init.c b/cpukit/libcsupport/src/newlibc_init.c new file mode 100644 index 0000000000..a37ab29663 --- /dev/null +++ b/cpukit/libcsupport/src/newlibc_init.c @@ -0,0 +1,61 @@ +/* + * 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. + * + * $Id$ + * + */ + +#if HAVE_CONFIG_H +#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 + * + * 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. + * + */ + + +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 |