usleep() implementation for UnixLib

John Tytgat John.Tytgat at aaug.net
Wed Feb 13 15:24:14 PST 2002


In message <m3ofogzw2b.fsf at nick.ws.noc.dsvr.net>
          Nick Burrett <nick at dsvr.net> wrote:

> John Tytgat <John.Tytgat at aaug.net> writes:
> 
> > In message <m3g09t269f.fsf at nick.ws.noc.dsvr.net>
> >           Nick Burrett <nick at dsvr.net> wrote:
> > 
> > > John Tytgat <John.Tytgat at aaug.net> writes:
> > > 
> > > > Find enclosed a usleep() implementation for UnixLib.
> > > 
> > > Thanks.  I've committed this.  But I reckon that usleep
> > > should return unsigned int, so I've changed it.
> > >  
> > > > +
> > > > +void
> > > > +usleep (unsigned int usec)
> > > > +{
> > > > +  (void) sleep ((usec + 999) / 1000);
> > > > +}
> > 
> > You're sure ? The header files on my Linux tell otherwise and on page
> > p. 705 of "Advanced Programming in the UNIX Environment" tell me that
> > the return type is void.  Or is this a BSD vs POSIX difference ?
> 
> My Linux box (glibc 2.2.4) suggests it returns unsigned int.
> So does the Single UNIX Specification version 2.

Apologies for reopening an old thread but I'm working again in this area
now and notices that the return type of usleep() is 'int'
(not 'unsigned int') in Single UNIX Specification version 2,
cfr. <URL:http://www.opengroup.org/onlinepubs/007908799/xsh/usleep.html>
and also in glibc 2.2.5.  Shall we change it ? ;-)

> Looking at the man pages on the freebsd site, usleep returns void
> on FreeBSD version 1 and 2,  4.3BSD, 4.4BSDLite2.  So it looks like
> it was the a much older definition.

Indeed.  See ChangeLog files in glibc distribution as well.

John.
-- 
John Tytgat, in his comfy chair at home                                 BASS
John.Tytgat at aaug.net                             ARM powered, RISC OS driven



More information about the gcc mailing list