forked from Imagelibrary/rtems
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:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
* Author: Till Straumann <strauman@slac.stanford.edu>, 3/2002
|
* Author: Till Straumann <strauman@slac.stanford.edu>, 3/2002
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* provide locking for the global environment 'environ' */
|
/* 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
|
* - NEWLIB-1.8.2 has an ugly BUG: if environ is NULL, _findenv_r() bails
|
||||||
* out leaving the lock held :-(
|
* 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 rtems_id envLock=0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -80,3 +85,24 @@ __env_unlock(struct _reent *r)
|
|||||||
if (_Thread_Executing)
|
if (_Thread_Executing)
|
||||||
rtems_semaphore_release(envLock);
|
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
|
||||||
|
|||||||
@@ -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>
|
2002-05-15 Chris Johns <ccj@acm.org>
|
||||||
|
|
||||||
* libc/newlibc.c: Per PR141, move the C library re-enterrant
|
* libc/newlibc.c: Per PR141, move the C library re-enterrant
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
* Author: Till Straumann <strauman@slac.stanford.edu>, 3/2002
|
* Author: Till Straumann <strauman@slac.stanford.edu>, 3/2002
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* provide locking for the global environment 'environ' */
|
/* 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
|
* - NEWLIB-1.8.2 has an ugly BUG: if environ is NULL, _findenv_r() bails
|
||||||
* out leaving the lock held :-(
|
* 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 rtems_id envLock=0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -80,3 +85,24 @@ __env_unlock(struct _reent *r)
|
|||||||
if (_Thread_Executing)
|
if (_Thread_Executing)
|
||||||
rtems_semaphore_release(envLock);
|
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
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
* Author: Till Straumann <strauman@slac.stanford.edu>, 3/2002
|
* Author: Till Straumann <strauman@slac.stanford.edu>, 3/2002
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* provide locking for the global environment 'environ' */
|
/* 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
|
* - NEWLIB-1.8.2 has an ugly BUG: if environ is NULL, _findenv_r() bails
|
||||||
* out leaving the lock held :-(
|
* 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 rtems_id envLock=0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -80,3 +85,24 @@ __env_unlock(struct _reent *r)
|
|||||||
if (_Thread_Executing)
|
if (_Thread_Executing)
|
||||||
rtems_semaphore_release(envLock);
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user