[PATCH] SPU Add support for nanosleep, sleep and usleep

Jeff Johnston jjohnstn@redhat.com
Wed Jun 13 17:45:00 GMT 2007

Patrick Mansfield wrote:
> On Tue, Jun 12, 2007 at 03:14:20PM -0500, Joel Sherrill wrote:
>> Jeff Johnston wrote:
>>> Patrick Mansfield wrote:
>>>> Note the libc/include/sys/unistd.h: to change from:
>>>>    unsigned _EXFUN(usleep, (unsigned int __useconds));
>>>> To:
>>>>    int _EXFUN(usleep, (useconds_t __useconds));
>>>> So we match both the existing usleep.c and POSIX.
>>> You can't just do that arbitrarily for Cygwin and RTEMS.  That 
>>> function prototype is protected by their OS flags being set on.  If 
>>> the prototype is not a typo error, then you must leave it alone.
>> The RTEMS implementation is
>> int usleep(  useconds_t useconds );
>> and the unistd.h we are using with the RPMs has it as:
>> int _EXFUN(usleep, (useconds_t __useconds));
>> Our patch to newlib has this fragment
>> @@ -200,7 +200,7 @@
>> int    _EXFUN(getdtablesize, (void));
>> int    _EXFUN(setdtablesize, (int));
>> useconds_t _EXFUN(ualarm, (useconds_t __useconds, useconds_t __interval));
>> -unsigned _EXFUN(usleep, (unsigned int __useconds));
>> +int _EXFUN(usleep, (useconds_t __useconds));
>> #if !(defined  (_WINSOCK_H) || defined (__USE_W32_SOCKETS))
>> /* winsock[2].h defines as __stdcall, and with int as 2nd arg */
>>  int   _EXFUN(gethostname, (char *__name, size_t __len));
>> So I guess we are using  the POSIX usleep profile and it just hasn't gotten
>> merged.
>>> You should put in a #else and then prototype usleep appropriately.  
> So OK to re-submit per Jeff's comment? Then Joel/cygwin will have to
> submit the change noted above.

Actually, I have confirmed with Chris Faylor that Cygwin also will use 
the correct prototytpe so I have moved the usleep prototype up to where 
the sleep prototype is and am ready to check in the modified patch.  I 
had to reorder the Makefile.am sources to make the patch apply.

> Jeff -
> Not for this patch, but should I just remove the #ifdef CYGWIN etc. if I
> am exposing an existing POSIX prototype?

Not sure what you mean by this.

> For new POSIX prototypes do I need an #ifdef? For example, I'm adding
> lockf() and defines for it, do you want an #ifdef __SPU__ around it?

For now, unless Cygwin and RTEMS want to use them too.

-- Jeff J.

More information about the Newlib mailing list