Re: VC++ 2005 beta1 fails with pthreads benchmark tests



"David Schwartz" wrote
>
> "um" wrote
>
> > if ( result == -1 )
> > {
> > perror("thread: sem_trywait 1: expected error"); // No error
> > assert(errno == EAGAIN);
> >
> > It is the last assert which fails in the first of the failing test
> > programs.
>
> Why should 'perror' be expected to cause an 'EGAIN' error? You need to
> test 'errno' before calling any library functions that might change its
> value. This code is broken.

The code is not broken. In your quote you have left out the
relevant part of the code.
It is not perror which sets errno (funny imagination, btw).
errno is set by sem_trywait(). The code is:

assert((result = sem_trywait(&s)) == -1);
if ( result == -1 )
{
perror("thread: sem_trywait 1: expected error"); // No error
assert(errno == EAGAIN);


.



Relevant Pages