summaryrefslogtreecommitdiffstats
path: root/c/src
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2002-05-15 16:29:05 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2002-05-15 16:29:05 +0000
commitc0d4abe6b0b79ff2c908869e379f71fd80437d49 (patch)
tree871c934730bcac521de373605eee4cfc4557cb15 /c/src
parent0df8293e2b26cfd56824c90803d427dcbb49f738 (diff)
downloadrtems-c0d4abe6b0b79ff2c908869e379f71fd80437d49.tar.bz2
2002-05-15 Chris Johns <ccj@acm.org>
* 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.
Diffstat (limited to 'c/src')
-rw-r--r--c/src/exec/libcsupport/src/newlibc.c41
-rw-r--r--c/src/lib/ChangeLog8
-rw-r--r--c/src/lib/libc/newlibc.c41
3 files changed, 20 insertions, 70 deletions
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 <stdio.h>
#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
diff --git a/c/src/lib/ChangeLog b/c/src/lib/ChangeLog
index 6286f735a2..0369ab6575 100644
--- a/c/src/lib/ChangeLog
+++ b/c/src/lib/ChangeLog
@@ -1,3 +1,11 @@
+2002-05-15 Chris Johns <ccj@acm.org>
+
+ * 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.
+
2001-05-15 Joel Sherrill <joel@OARcorp.com>
* libc/Makefile.am: envlock.c should only be built for embedded
diff --git a/c/src/lib/libc/newlibc.c b/c/src/lib/libc/newlibc.c
index 41c9359200..8c3836a1e7 100644
--- a/c/src/lib/libc/newlibc.c
+++ b/c/src/lib/libc/newlibc.c
@@ -44,18 +44,6 @@
#include <stdio.h>
#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