From c0d4abe6b0b79ff2c908869e379f71fd80437d49 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 15 May 2002 16:29:05 +0000 Subject: 2002-05-15 Chris Johns * libc/newlibc.c: Per PR141, move the C library re-enterrant support directly into the thread dispatch code. RTEMS needs libc and so requiring libc to use a user extension with its overhead is not the best solution. This patch lowers the overhead to 2 pointer moves. --- c/src/exec/libcsupport/src/newlibc.c | 41 ++++++------------------------------ 1 file changed, 6 insertions(+), 35 deletions(-) (limited to 'c/src/exec/libcsupport/src/newlibc.c') diff --git a/c/src/exec/libcsupport/src/newlibc.c b/c/src/exec/libcsupport/src/newlibc.c index 41c9359200..8c3836a1e7 100644 --- a/c/src/exec/libcsupport/src/newlibc.c +++ b/c/src/exec/libcsupport/src/newlibc.c @@ -44,18 +44,6 @@ #include #endif -static int extension_index; - -/* - * Private routines - */ - -#define set_newlib_extension( _the_thread, _value ) \ - (_the_thread)->extensions[ extension_index ] = (_value); - -#define get_newlib_extension( _the_thread ) \ - (_the_thread)->extensions[ extension_index ] - int libc_reentrant; /* do we think we are reentrant? */ struct _reent libc_global_reent; @@ -114,7 +102,7 @@ rtems_boolean libc_create_hook( rtems_tcb *creating_task ) { - set_newlib_extension( creating_task, NULL ); + creating_task->libc_reent = NULL; return TRUE; } @@ -156,7 +144,7 @@ rtems_extension libc_start_hook( ptr->_new._reent._rand_next = 1; #endif - set_newlib_extension( starting_task, ptr ); + starting_task->libc_reent = ptr; } /* @@ -170,22 +158,6 @@ rtems_extension libc_begin_hook(rtems_tcb *current_task) } #endif -rtems_extension libc_switch_hook( - rtems_tcb *current_task, - rtems_tcb *heir_task -) -{ - /* - * Don't touch the outgoing task if it has been deleted. - */ - - if ( !_States_Is_transient( current_task->current_state ) ) { - set_newlib_extension( current_task, _REENT ); - } - - _REENT = (struct _reent *) get_newlib_extension( heir_task ); -} - /* * Function: libc_delete_hook * Created: 94/12/10 @@ -225,7 +197,7 @@ rtems_extension libc_delete_hook( if (current_task == deleted_task) { ptr = _REENT; } else { - ptr = (struct _reent *) get_newlib_extension( deleted_task ); + ptr = (struct _reent *) deleted_task->libc_reent; } /* if (ptr) */ @@ -235,7 +207,7 @@ rtems_extension libc_delete_hook( free(ptr); } - set_newlib_extension( deleted_task, NULL ); + deleted_task->libc_reent = NULL; /* * Require the switch back to another task to install its own @@ -294,16 +266,16 @@ libc_init(int reentrant) #ifdef NEED_SETVBUF libc_extension.thread_begin = libc_begin_hook; #endif - libc_extension.thread_switch = libc_switch_hook; libc_extension.thread_delete = libc_delete_hook; + _Thread_Set_libc_reent ((void**) &_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; - extension_index = rtems_get_index( extension_id ); } } @@ -359,5 +331,4 @@ void exit(int status) } #endif - #endif -- cgit v1.2.3