This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

cygwin-1999-12-01: Prototypes in system headers not standard-compliant


The prototype for read() and write() in Unix98 don't match those in
the Cygwin header files.

http://www.opengroup.org/onlinepubs/007908799/xsh/read.html
http://www.opengroup.org/onlinepubs/007908799/xsh/write.html

The standard return type for these functions is `ssize_t'.  
The traditional return type for these functions is `int'.
The return type in Cygwin is `int'.

On 32-bit platforms, like Cygwin, the best choice is probably to use
`ssize_t' in the prototypes (they are standard, after all, right?),
but to then have

typedef int ssize_t;

This is effectively what Linux does.

Here's the obvious untested patch (I've never used Cygwin):

--- sys/unistd.h~	Wed Dec  1 21:25:48 1999
+++ sys/unistd.h	Fri Dec  3 20:07:58 1999
@@ -75,10 +75,10 @@
 pid_t   _EXFUN(_getpid, (void ));
 int     _EXFUN(_link, (const char *__path1, const char *__path2 ));
 off_t   _EXFUN(_lseek, (int __fildes, off_t __offset, int __whence ));
-int     _EXFUN(_read, (int __fildes, void *__buf, size_t __nbyte ));
+ssize_t _EXFUN(_read, (int __fildes, void *__buf, size_t __nbyte ));
 void *  _EXFUN(_sbrk,  (size_t __incr));
 int     _EXFUN(_unlink, (const char *__path ));
-int     _EXFUN(_write, (int __fildes, const void *__buf, size_t __nbyte ));
+ssize_t _EXFUN(_write, (int __fildes, const void *__buf, size_t __nbyte ));
 
 #if defined(__CYGWIN32__) || defined(__rtems__)
 unsigned _EXFUN(usleep, (unsigned int __useconds));


--- sys/types.h~	Wed Dec  1 21:25:48 1999
+++ sys/types.h	Fri Dec  3 20:09:24 1999
@@ -110,7 +110,7 @@
 typedef	unsigned short	gid_t;
 typedef int pid_t;
 typedef	long key_t;
-typedef long ssize_t;
+typedef int ssize_t;
 
 #ifdef __MS_types__
 typedef	char *	addr_t;


--- sys/_types.h~	Wed Dec  1 21:25:42 1999
+++ sys/_types.h	Fri Dec  3 20:09:10 1999
@@ -10,6 +10,6 @@
 #define _SYS__TYPES_H
 
 typedef long _off_t;
-typedef long _ssize_t;
+typedef int _ssize_t;
 
 #endif	/* _SYS__TYPES_H */



P.S. If you do this, check all other functions for Unix98-compliance.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]