From: Mark H Weaver <mhw@netris.org>
To: Nala Ginrut <nalaginrut@gmail.com>
Cc: guile-devel@gnu.org
Subject: Re: [PATCH] mutex-unlock! should allowed #f as timeout according to srfi-18
Date: Mon, 10 Jun 2013 14:53:59 -0400 [thread overview]
Message-ID: <87wqq1vltk.fsf@tines.lan> (raw)
In-Reply-To: <1370684669.2610.122.camel@Renee-desktop.suse> (Nala Ginrut's message of "Sat, 08 Jun 2013 17:44:29 +0800")
Hi,
Nala Ginrut <nalaginrut@gmail.com> writes:
> According to srfi-18:
>
> ---------------------cut----------------------
> Time objects and timeouts
>
> ......
>
> a time object represents an absolute point in time
> an exact or inexact real number represents a relative time in seconds
> from the moment the primitive was called
> #f means that there is no timeout
> ---------------------end----------------------
>
> Attached the patch to fix such a situation:
> ==========
> scheme@(guile-user)> (mutex-unlock! m condv #f)
> ERROR: In procedure unlock-mutex:
> ERROR: Wrong type (expecting real number): #f
> ==========
>
> And I do know that `mutex-unlock!' uses timeout as the last optional
> argument, usually users won't pass timeout when they don't need it.
> But I do think it's necessary to stick to the standard as possible as we
> can.
Agreed, good catch!
> diff --git a/libguile/threads.c b/libguile/threads.c
> index 04897e3..3e9911d 100644
> --- a/libguile/threads.c
> +++ b/libguile/threads.c
> @@ -1692,7 +1692,7 @@ SCM_DEFINE (scm_unlock_mutex_timed, "unlock-mutex", 1, 2, 0,
> scm_t_timespec cwaittime, *waittime = NULL;
>
> SCM_VALIDATE_MUTEX (1, mx);
> - if (! (SCM_UNBNDP (cond)))
> + if (! (SCM_UNBNDP (cond)) && ! scm_is_false (timeout))
> {
> SCM_VALIDATE_CONDVAR (2, cond);
This isn't quite right. If 'timeout' is false, then you fail to
validate 'cond'. Anyway, I pushed a similar patch to stable-2.0.
Thanks,
Mark
next prev parent reply other threads:[~2013-06-10 18:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-08 9:44 [PATCH] mutex-unlock! should allowed #f as timeout according to srfi-18 Nala Ginrut
2013-06-10 18:53 ` Mark H Weaver [this message]
2013-06-13 4:46 ` Nala Ginrut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wqq1vltk.fsf@tines.lan \
--to=mhw@netris.org \
--cc=guile-devel@gnu.org \
--cc=nalaginrut@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).