[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 16/24: Remove unchecked-unlock facility from Guile mutex
From: |
Andy Wingo |
Subject: |
[Guile-commits] 16/24: Remove unchecked-unlock facility from Guile mutexes |
Date: |
Sun, 6 Nov 2016 18:00:46 +0000 (UTC) |
wingo pushed a commit to branch master
in repository guile.
commit c0916134ac052282ebd4353f2b9894e002cb4308
Author: Andy Wingo <address@hidden>
Date: Sat Nov 5 10:13:48 2016 +0100
Remove unchecked-unlock facility from Guile mutexes
* libguile/threads.c (fat_mutex): Remove unchecked_unlock member.
(make_fat_mutex): Adapt.
(scm_make_mutex_with_flags): Remove unchecked-unlock flag.
(scm_make_recursive_mutex): Likewise.
(fat_mutex_unlock): Remove unchecked-unlock case.
* test-suite/tests/threads.test: Remove unchecked-unlock test.
---
libguile/threads.c | 23 +++++++----------------
test-suite/tests/threads.test | 6 +-----
2 files changed, 8 insertions(+), 21 deletions(-)
diff --git a/libguile/threads.c b/libguile/threads.c
index b62c163..9d9b01a 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -516,7 +516,6 @@ typedef struct {
int level; /* how much the owner owns us. <= 1 for non-recursive mutexes */
int recursive; /* allow recursive locking? */
- int unchecked_unlock; /* is it an error to unlock an unlocked mutex? */
int allow_external_unlock; /* is it an error to unlock a mutex that is not
owned by the current thread? */
@@ -1065,7 +1064,7 @@ fat_mutex_print (SCM mx, SCM port, scm_print_state
*pstate SCM_UNUSED)
}
static SCM
-make_fat_mutex (int recursive, int unchecked_unlock, int external_unlock)
+make_fat_mutex (int recursive, int external_unlock)
{
fat_mutex *m;
SCM mx;
@@ -1079,7 +1078,6 @@ make_fat_mutex (int recursive, int unchecked_unlock, int
external_unlock)
m->level = 0;
m->recursive = recursive;
- m->unchecked_unlock = unchecked_unlock;
m->allow_external_unlock = external_unlock;
m->waiting = SCM_EOL;
@@ -1093,7 +1091,6 @@ SCM scm_make_mutex (void)
return scm_make_mutex_with_flags (SCM_EOL);
}
-SCM_SYMBOL (unchecked_unlock_sym, "unchecked-unlock");
SCM_SYMBOL (allow_external_unlock_sym, "allow-external-unlock");
SCM_SYMBOL (recursive_sym, "recursive");
@@ -1102,15 +1099,13 @@ SCM_DEFINE (scm_make_mutex_with_flags, "make-mutex", 0,
0, 1,
"Create a new mutex. ")
#define FUNC_NAME s_scm_make_mutex_with_flags
{
- int unchecked_unlock = 0, external_unlock = 0, recursive = 0;
+ int external_unlock = 0, recursive = 0;
SCM ptr = flags;
while (! scm_is_null (ptr))
{
SCM flag = SCM_CAR (ptr);
- if (scm_is_eq (flag, unchecked_unlock_sym))
- unchecked_unlock = 1;
- else if (scm_is_eq (flag, allow_external_unlock_sym))
+ if (scm_is_eq (flag, allow_external_unlock_sym))
external_unlock = 1;
else if (scm_is_eq (flag, recursive_sym))
recursive = 1;
@@ -1118,7 +1113,7 @@ SCM_DEFINE (scm_make_mutex_with_flags, "make-mutex", 0,
0, 1,
SCM_MISC_ERROR ("unsupported mutex option: ~a", scm_list_1 (flag));
ptr = SCM_CDR (ptr);
}
- return make_fat_mutex (recursive, unchecked_unlock, external_unlock);
+ return make_fat_mutex (recursive, external_unlock);
}
#undef FUNC_NAME
@@ -1127,7 +1122,7 @@ SCM_DEFINE (scm_make_recursive_mutex,
"make-recursive-mutex", 0, 0, 0,
"Create a new recursive mutex. ")
#define FUNC_NAME s_scm_make_recursive_mutex
{
- return make_fat_mutex (1, 0, 0);
+ return make_fat_mutex (1, 0);
}
#undef FUNC_NAME
@@ -1285,12 +1280,8 @@ fat_mutex_unlock (SCM mutex, SCM cond,
{
if (m->level == 0)
{
- if (!m->unchecked_unlock)
- {
- scm_i_pthread_mutex_unlock (&m->lock);
- scm_misc_error (NULL, "mutex not locked", SCM_EOL);
- }
- owner = t->handle;
+ scm_i_pthread_mutex_unlock (&m->lock);
+ scm_misc_error (NULL, "mutex not locked", SCM_EOL);
}
else if (!m->allow_external_unlock)
{
diff --git a/test-suite/tests/threads.test b/test-suite/tests/threads.test
index 2156f61..4b6aa2a 100644
--- a/test-suite/tests/threads.test
+++ b/test-suite/tests/threads.test
@@ -421,11 +421,7 @@
(with-test-prefix "mutex-behavior"
- (pass-if "unchecked unlock"
- (let* ((m (make-mutex 'unchecked-unlock)))
- (unlock-mutex m)))
-
- (pass-if "allow external unlock"
+ (pass-if "allow external unlock"
(let* ((m (make-mutex 'allow-external-unlock))
(t (begin-thread (lock-mutex m))))
(join-thread t)
- [Guile-commits] 08/24: Remove lock-mutex owner facility, (continued)
- [Guile-commits] 08/24: Remove lock-mutex owner facility, Andy Wingo, 2016/11/06
- [Guile-commits] 14/24: SRFI-18 mutexes are not recursive, Andy Wingo, 2016/11/06
- [Guile-commits] 07/24: SRFI-18 threads disjoint from guile threads, Andy Wingo, 2016/11/06
- [Guile-commits] 21/24: scm_timed_lock_mutex replaces scm_lock_mutex_timed, Andy Wingo, 2016/11/06
- [Guile-commits] 15/24: Recursively locking a SRFI-18 mutex blocks, Andy Wingo, 2016/11/06
- [Guile-commits] 19/24: Separate fat mutex unlock and wait operations, Andy Wingo, 2016/11/06
- [Guile-commits] 06/24: Update SRFI-18 documentation., Andy Wingo, 2016/11/06
- [Guile-commits] 11/24: Remove thread held pthread_mutex field, Andy Wingo, 2016/11/06
- [Guile-commits] 13/24: Move more functionality to SRFI-18 mutex-unlock!, Andy Wingo, 2016/11/06
- [Guile-commits] 03/24: SRFI-18 mutexes disjoint from Guile mutexes, Andy Wingo, 2016/11/06
- [Guile-commits] 16/24: Remove unchecked-unlock facility from Guile mutexes,
Andy Wingo <=
- [Guile-commits] 24/24: Update NEWS., Andy Wingo, 2016/11/06
- [Guile-commits] 22/24: Update documentation on mutexes, Andy Wingo, 2016/11/06
- [Guile-commits] 20/24: Update mutex documentation, Andy Wingo, 2016/11/06
- [Guile-commits] 17/24: Replace scm_make_mutex_with_flags, Andy Wingo, 2016/11/06
- [Guile-commits] 23/24: Minor editing in api-scheduling.texi, Andy Wingo, 2016/11/06