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.
This commit is contained in:
Joel Sherrill
2002-05-17 18:03:34 +00:00
parent cb3a7edfa3
commit 7c844e30ab
4 changed files with 90 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
/*
* $Id$
*
* Author: Till Straumann <strauman@slac.stanford.edu>, 3/2002
*
* $Id$
*/
/* provide locking for the global environment 'environ' */
@@ -30,8 +30,13 @@
* - 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

View File

@@ -1,3 +1,9 @@
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.
2002-05-15 Chris Johns <ccj@acm.org>
* libc/newlibc.c: Per PR141, move the C library re-enterrant

View File

@@ -1,7 +1,7 @@
/*
* $Id$
*
* Author: Till Straumann <strauman@slac.stanford.edu>, 3/2002
*
* $Id$
*/
/* provide locking for the global environment 'environ' */
@@ -30,8 +30,13 @@
* - 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

View File

@@ -1,7 +1,7 @@
/*
* $Id$
*
* Author: Till Straumann <strauman@slac.stanford.edu>, 3/2002
*
* $Id$
*/
/* provide locking for the global environment 'environ' */
@@ -30,8 +30,13 @@
* - 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