diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2002-05-17 18:03:34 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2002-05-17 18:03:34 +0000 |
commit | 7c844e30abf4729cc1cd058455f18fd4a8a7a5d5 (patch) | |
tree | 06fbe97bc5174c7954597950be2f956e7467ca08 /cpukit/libcsupport/src | |
parent | 2001-05-17 Joel Sherrill <joel@OARcorp.com> (diff) | |
download | rtems-7c844e30abf4729cc1cd058455f18fd4a8a7a5d5.tar.bz2 |
2001-05-17 Joel Sherrill <joel@OARcorp.com>
* libc/envlock.c: Implemented code to let newlib's envlock share
the libio open/close mutex. Since both should be lightly used,
this should not lead to problems and saves resources.
Diffstat (limited to 'cpukit/libcsupport/src')
-rw-r--r-- | cpukit/libcsupport/src/envlock.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/cpukit/libcsupport/src/envlock.c b/cpukit/libcsupport/src/envlock.c index c9489b3e88..444d0e6b63 100644 --- a/cpukit/libcsupport/src/envlock.c +++ b/cpukit/libcsupport/src/envlock.c @@ -1,7 +1,7 @@ /* - * $Id$ - * * Author: Till Straumann <strauman@slac.stanford.edu>, 3/2002 + * + * $Id$ */ /* provide locking for the global environment 'environ' */ @@ -29,9 +29,14 @@ * lock-lock-unlock-unlock). * - NEWLIB-1.8.2 has an ugly BUG: if environ is NULL, _findenv_r() bails * out leaving the lock held :-( + * + * Used by the following functions: + * findenv_r(), setenv_r(), and unsetenv_r() which are called by + * getenv(), getenv_r(), setenv(), and unsetenv(). * */ +#if defined(ENVLOCK_DEDIDCATED_MUTEX) static rtems_id envLock=0; static void @@ -80,3 +85,24 @@ __env_unlock(struct _reent *r) if (_Thread_Executing) rtems_semaphore_release(envLock); } +#else + +/* + * Reuse the libio mutex -- it is always initialized before we + * could possibly run. + */ + +#include <rtems/libio_.h> + +void +__env_lock(struct _reent *r) +{ + rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); +} + +void +__env_unlock(struct _reent *r) +{ + rtems_semaphore_release( rtems_libio_semaphore ); +} +#endif |