[PATCH]: Fix libgloss read/write prototypes
J. Johnston
jjohnstn@redhat.com
Wed Jul 17 17:22:00 GMT 2002
Stephane Carrez wrote:
>
> Hi!
>
> The following patch fixes problems with read/write definition.
> A size_t is not an int and read()/write() prototypes are defined with size_t.
> The implementation must follow that too. The size_t definition is provided by gcc
> in <stddef.h> so that libgloss does not rely on any libc header.
>
> Can you integrate this patch ?
>
> Thanks,
> Stephane
>
> 2002-07-16 Stephane Carrez <Stephane.Carrez@nerim.fr>
>
> * write.c (write): Use size_t for the size of the write.
> * read.c (read): Likewise.
>
>
This is a historical mess that has existed for some time.
It would be unsafe to just change the return value as other platforms use this file as it
is currently (e.g. libgloss/mips).
In newlib, we added a _READ_WRITE_RETURN_TYPE macro in sys/config.h so systems like
Cygwin that want to have have correct POSIX behavior can specify size_t rather than
the old default int definition.
A safer way to do this would be either to adopt the newlib-style solution whereby the
type is configurable or else add read2.c and write2.c that platforms can use at their
discretion.
-- Jeff J.
------------------------------------------------------------------------------------------------------------------------------------------------------
> diff -Nrup --exclude=Makefile.in --exclude=configure --exclude=CVS newlib-main/libgloss/read.c newlib-main-integrate/libgloss/read.c
> --- newlib-main/libgloss/read.c Fri Mar 17 23:48:49 2000
> +++ newlib-main-integrate/libgloss/read.c Sat Jul 13 15:23:34 2002
> @@ -13,6 +13,7 @@
> * they apply.
> */
> #include "glue.h"
> +#include <stddef.h>
>
> extern char _DEFUN_VOID (inbyte);
>
> @@ -24,7 +25,7 @@ int
> _DEFUN (read, (fd, buf, nbytes),
> int fd _AND
> char *buf _AND
> - int nbytes)
> + size_t nbytes)
> {
> int i = 0;
>
> diff -Nrup --exclude=Makefile.in --exclude=configure --exclude=CVS newlib-main/libgloss/write.c newlib-main-integrate/libgloss/write.c
> --- newlib-main/libgloss/write.c Fri Mar 17 23:48:49 2000
> +++ newlib-main-integrate/libgloss/write.c Sat Jul 13 15:23:34 2002
> @@ -13,6 +13,7 @@
> * they apply.
> */
> #include "glue.h"
> +#include <stddef.h>
>
> extern int _EXFUN (outbyte, (char x));
>
> @@ -25,7 +26,7 @@ int
> _DEFUN (write, (fd, buf, nbytes),
> int fd _AND
> char *buf _AND
> - int nbytes)
> + size_t nbytes)
> {
> int i;
>
More information about the Newlib
mailing list