[PATCH] SPU Add support for nanosleep, sleep and usleep
Joel Sherrill
joel.sherrill@oarcorp.com
Wed Jun 13 05:18:00 GMT 2007
Jeff Johnston wrote:
> Patrick Mansfield wrote:
>> Add support for SPU nanosleep, sleep and usleep.
>>
>> The SPU can only use 3 of the 19 files in libc/posix, so just copy the
>> ones we want (another patch is needed to add/use creat.c).
>>
>> Depends on previous patch (newlib libc/machine/spu/Makefile.am change).
>>
>> 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.
> You don't need to refer to SPU since it is referring to the libc/posix
> prototype.
Thanks for watching out for us Jeff. :)
--joel
More information about the Newlib
mailing list