CVS - usleep argument is the wrong type
Joel Sherrill
joel.sherrill@OARcorp.com
Fri Jan 9 23:17:00 GMT 2004
The prototype currently is:
sys/unistd.h:unsigned _EXFUN(usleep, (unsigned int __useconds));
According to the opengroup website, it should be
#include <unistd.h>
int usleep(useconds_t useconds);
Where useconds_t is defined in unistd.h and meets this rule:
useconds_t
Used for time in microseconds. The type useconds_t is an unsigned
integral capable of storing values at least in the range zero to 1,000,000.
sys/types.h defines useconds_t as a signed long type for both RTEMS
and Cygwin. I propose the following patch:
2004-01-09 Joel Sherrill <joel@oarcorp.com>
* libc/include/sys/types.h: Change useconds_t to unsigned long.
* libc/sys/unistd.h: Change argument on usleep to useconds_t.
Index: sys/types.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/types.h,v
retrieving revision 1.19
diff -u -r1.19 types.h
--- sys/types.h 2 Jul 2003 20:32:07 -0000 1.19
+++ sys/types.h 9 Jan 2004 23:16:33 -0000
@@ -254,7 +254,7 @@
#endif
#if defined(__CYGWIN__) || defined(__rtems__)
-typedef long useconds_t;
+typedef unsigned long useconds_t;
#endif
#include <sys/features.h>
Index: sys/unistd.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/unistd.h,v
retrieving revision 1.47
diff -u -r1.47 unistd.h
--- sys/unistd.h 26 Nov 2003 19:15:17 -0000 1.47
+++ sys/unistd.h 9 Jan 2004 23:16:33 -0000
@@ -53,6 +53,7 @@
pid_t _EXFUN(fork, (void ));
long _EXFUN(fpathconf, (int __fd, int __name ));
int _EXFUN(fsync, (int __fd));
+int _EXFUN(fdatasync, (int __fd));
char _EXFUN(*getcwd, (char *__buf, size_t __size ));
#if defined(__CYGWIN__)
int _EXFUN(getdomainname ,(char *__name, size_t __len));
@@ -193,7 +194,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));
+unsigned _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));
--
Joel Sherrill, Ph.D. Director of Research & Development
joel@OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the Newlib
mailing list