This is the mail archive of the
newlib-cvs@sourceware.org
mailing list for the newlib project.
[newlib-cygwin] or1k: Fix critical handling in malloc locks
- From: Jeff Johnston <jjohnstn at sourceware dot org>
- To: newlib-cvs at sourceware dot org
- Date: 7 Aug 2015 19:02:24 -0000
- Subject: [newlib-cygwin] or1k: Fix critical handling in malloc locks
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=4098f69c4302664c4dc65812779a8849ccc323b6
commit 4098f69c4302664c4dc65812779a8849ccc323b6
Author: Jeff Johnston <jjohnstn@redhat.com>
Date: Fri Aug 7 14:49:16 2015 -0400
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
Diff:
---
newlib/ChangeLog | 4 ++++
newlib/libc/sys/or1k/mlock.c | 6 ++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 6500651..e887c9a 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,7 @@
+2015-08-07 Stefan Wallentowitz <stefan.wallentowitz@tum.de>
+
+ * libc/sys/or1k/mlock.c: Fix exception enable saving
+
2015-08-03 Shoichi Sakon <s-sakon@ap.jp.nec.com>
* libc/stdio/vfwscanf.c (__SVFWSCANF_R): Convert wrong usage of va_arg
diff --git a/newlib/libc/sys/or1k/mlock.c b/newlib/libc/sys/or1k/mlock.c
index a439da6..ccb8401 100644
--- a/newlib/libc/sys/or1k/mlock.c
+++ b/newlib/libc/sys/or1k/mlock.c
@@ -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;