From: Eli Zaretskii <eliz@gnu.org>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel@gnu.org
Subject: Re: Avoid warnings in threads.c when building without threads
Date: Sun, 24 Jul 2016 05:38:01 +0300 [thread overview]
Message-ID: <8337mzvjzq.fsf@gnu.org> (raw)
In-Reply-To: <87poq4rsg0.fsf@pobox.com> (message from Andy Wingo on Sat, 23 Jul 2016 22:49:03 +0200)
> From: Andy Wingo <wingo@pobox.com>
> Cc: guile-devel@gnu.org
> Date: Sat, 23 Jul 2016 22:49:03 +0200
>
> On Sat 16 Jul 2016 19:12, Eli Zaretskii <eliz@gnu.org> writes:
>
> > The patch to shut up these warnings is below. OK to commit?
> >
> > --- libguile/null-threads.h~0 2016-01-02 13:32:40.000000000 +0200
> > +++ libguile/null-threads.h 2016-07-15 17:47:37.101375000 +0300
> > @@ -43,7 +43,7 @@
> > #define scm_i_pthread_create(t,a,f,d) (*(t)=0, (void)(f), ENOSYS)
> > #define scm_i_pthread_detach(t) do { } while (0)
> > #define scm_i_pthread_exit(v) exit (EXIT_SUCCESS)
> > -#define scm_i_pthread_cancel(t) 0
> > +#define scm_i_pthread_cancel(t) (void)0
> > #define scm_i_pthread_cleanup_push(t,v) 0
> > #define scm_i_pthread_cleanup_pop(e) 0
> > #define scm_i_sched_yield() 0
>
> I think not, sorry :/ pthread_cancel returns an int, so
> scm_i_pthread_cancel should always return an int.
Then code which ignores the value should cast to void.
> > --- libguile/threads.c~ 2016-06-20 23:35:06.000000000 +0300
> > +++ libguile/threads.c 2016-07-15 17:48:20.757625000 +0300
> > @@ -1058,7 +1058,7 @@ SCM_DEFINE (scm_call_with_new_thread, "c
> > }
> >
> > while (scm_is_false (data.thread))
> > - scm_i_scm_pthread_cond_wait (&data.cond, &data.mutex);
> > + (void)scm_i_scm_pthread_cond_wait (&data.cond, &data.mutex);
> >
> > scm_i_pthread_mutex_unlock (&data.mutex);
> >
>
> Likewise this is not needed -- the problem is in the cond_wait
> definition.
But the above is a valid code when the returned value is being
ignored, so why not use it?
> null-threads.h is a distressing header file. I think the right thing to
> do is to use typedefs and static inline functions instead of CPP macros.
> That way we keep type-safety, and also the compiler will stop
> complaining.
I'm okay with any solution that will shut up the warnings, because
they distract and mask real problems.
TIA
next prev parent reply other threads:[~2016-07-24 2:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-16 17:12 Avoid warnings in threads.c when building without threads Eli Zaretskii
2016-07-22 7:16 ` Eli Zaretskii
2016-07-23 20:49 ` Andy Wingo
2016-07-24 2:38 ` Eli Zaretskii [this message]
2016-07-24 13:32 ` Andy Wingo
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=8337mzvjzq.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=guile-devel@gnu.org \
--cc=wingo@pobox.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).