[beports] Re: POSIX functions
- From: Ingo Weinhold <ingo_weinhold@xxxxxx>
- To: beports@xxxxxxxxxxxxx
- Date: Sun, 31 Aug 2008 15:21:47 +0200
On 2008-08-31 at 14:46:49 [+0200], Salvatore Benedetto <emitrax@xxxxxxxxx>
wrote:
> 2008/8/29 Andreas Färber <andreas.faerber@xxxxxx>:
> > Am 29.08.2008 um 15:33 schrieb Salvatore Benedetto:
> > But I recently encountered some problems with pthread_cond_broadcast (no
> > ticket yet since I haven't pinpointed it exactly). In a very simple C#
> > Hello
> > World app Mono checks for the pthread_cond_broadcast return codes and
> > asserts that they are zero (I assume it runs single-threaded, no Garbage
> > Collector). If I remove Mono's asserts it works as expected. The
> > problematic
> > return code is EINVAL iirc (B_BAD_VALUE), and I traced it to libroot's
> > release_sem_etc, triggered by "if (count <= 0 && (flags & B_RELEASE_ALL)
> > ==
> > 0) return B_BAD_VALUE;".
The condition variable implementation looks indeed not correct -- a
pthread_cond_broadcast() should return an error when no one is waiting. I'll
have a closer look.
> > Unfortunately it's hard to investigate this on
> > the
> > Mono side. Does the PosixTestSuite check for such subtleties?
The tests vary greatly in quality. Most tests seem to be not particularly
thorough, though.
> I just ran the posixtestsuit and as far as I can see, there is not such a
> check.
> As far as POSIX standard goes, the only possible return value *seems* to be
> - zero on success
> - EINVAL on error
>
> which means, that B_BAD_VALUE for instance might not be correct, which
> is returned
> by cond_signal.
B_BAD_VALUE == EINVAL
> Same goes for all the other values returned by
> release_sem_etc.
If the implementation were correct, the other errors wouldn't be triggered.
Besides, the policy for implementing POSIX functions is anyway to try to
return the respective error codes for the error conditions the specs specify
and in other cases the error codes that seem most appropriate. E.g. when
we're out of memory, we return B_NO_MEMORY (ENOMEM) anyway, even if the
specification doesn't mention it.
CU, Ingo
--
HaikuPorts homepage - http://ports.haiku-files.org
List archives: http://www.freelists.org/archives/beports
Administrative contact: brecht@xxxxxxxxxxx
- References:
- [beports] POSIX functions
- From: Salvatore Benedetto
- [beports] Re: POSIX functions
- From: Andreas Färber
- [beports] Re: POSIX functions
- From: Salvatore Benedetto
Other related posts:
- » [beports] POSIX functions
- » [beports] Re: POSIX functions
- » [beports] Re: POSIX functions
- » [beports] Re: POSIX functions
- » [beports] Re: POSIX functions
- » [beports] Re: POSIX functions
- » [beports] Re: POSIX functions
- » [beports] Re: POSIX functions
- » [beports] Re: POSIX functions
- » [beports] Re: POSIX functions
- » [beports] Re: POSIX functions
- » [beports] Re: POSIX functions
- » [beports] Re: POSIX functions
- [beports] POSIX functions
- From: Salvatore Benedetto
- [beports] Re: POSIX functions
- From: Andreas Färber
- [beports] Re: POSIX functions
- From: Salvatore Benedetto