This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH] SPU Add support for nanosleep, sleep and usleep
- From: Joel Sherrill <joel dot sherrill at oarcorp dot com>
- To: Jeff Johnston <jjohnstn at redhat dot com>
- Cc: Patrick Mansfield <patmans at us dot ibm dot com>, newlib at sourceware dot org
- Date: Tue, 12 Jun 2007 15:14:20 -0500
- Subject: Re: [PATCH] SPU Add support for nanosleep, sleep and usleep
- References: <20070607230308.GA16018@us.ibm.com> <466EFA89.8050401@redhat.com>
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