or1k: Fix critical handling in malloc locks

Only on first call to the recursive malloc lock the restore value of
    exception enable fields is stored.

    	  * libc/sys/or1k/mlock.c: Fix exception enable saving
This commit is contained in:
Jeff Johnston
2015-08-07 14:49:16 -04:00
parent 0d04c03829
commit 4098f69c43
2 changed files with 8 additions and 2 deletions

View File

@ -65,7 +65,9 @@ void __malloc_lock(struct _reent *ptr) {
}
// Store the TEE and IEE flags for later restore
_or1k_malloc_lock_restore = restore;
if (_or1k_malloc_lock_cnt == 0) {
_or1k_malloc_lock_restore = restore;
}
// Increment counter. The lock may be accessed recursively
_or1k_malloc_lock_cnt++;
@ -85,7 +87,7 @@ void __malloc_unlock(struct _reent *ptr) {
// unset lock
_or1k_malloc_lock = 0;
// Restore flags
or1k_critical_end(_or1k_malloc_lock_restore);
or1k_critical_end(restore);
}
return;