www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/12/03/23:14:12

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT sourceware DOT cygnus DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
MIME-Version: 1.0
Message-ID: <14408.38135.146580.963528@lasker.666.com>
Date: Fri, 3 Dec 1999 20:13:43 -0800 (PST)
From: Martin Buchholz <martin AT xemacs DOT org>
To: cygwin AT sourceware DOT cygnus DOT com
Cc: XEmacs NT <xemacs-nt AT xemacs DOT org>, Eric Christopher <echristo AT cygnus DOT com>
Subject: cygwin-1999-12-01: Prototypes in system headers not standard-compliant
X-Mailer: VM 6.72 under 21.2 (beta20) "Yoko" XEmacs Lucid
Reply-To: martin AT xemacs DOT org

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 AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019