guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Avoid warnings in threads.c when building without threads


From: Eli Zaretskii
Subject: Re: Avoid warnings in threads.c when building without threads
Date: Sun, 24 Jul 2016 05:38:01 +0300

> From: Andy Wingo <address@hidden>
> Cc: address@hidden
> Date: Sat, 23 Jul 2016 22:49:03 +0200
> 
> On Sat 16 Jul 2016 19:12, Eli Zaretskii <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]