This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/4] or1k: Fix critical handling in malloc locks


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This only stores the current exception enable flags on the first enter
of the (recursive) malloc lock.

Best,
Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iEYEARECAAYFAlXEZ0EACgkQuMYtsrn2U9yKJACfYU03ZI7cy/Ose6Y7aGyaQklG
YQgAni6UXJt1LjWJ1yu6UwC5QOOzoz0a
=kQL6
-----END PGP SIGNATURE-----
commit 72c1447477687cec83b5718850e83ca0aac72a46
Author: Stefan Wallentowitz <stefan.wallentowitz@tum.de>
Date:   Thu May 21 21:24:06 2015 +0200

    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 --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;

Attachment: 0001-or1k-restore.patch.sig
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]