recv/send/sendto
Andreas Jaeger
aj@suse.de
Mon Apr 23 02:36:00 GMT 2001
Neale.Ferguson@softwareAG-usa.com writes:
> Hi,
> I've been building Blackdown JDK against glibc-2.2.2 and am getting
> errors when compiling a module which has declarations for recv/send/sendto.
> The entry points define the functions return ssize_t but in socket.h they
> are defined to return int. According to the Single UNIX Spec V2. they
> are defined as returning ssize_t.
>
> See: http://www.unix-systems.org/onlinepubs/007908799/xns/recv.html
>
> Am I looking at the correct spec? Is it a known problem or is my compiler
> just being over picky?
You're right - I don't know why we still use int.
Here's a patch for glibc, I hope I didn't miss any declaration. At
least I encountered no errors or new warnings with make;make check on
i686.
Will this really work on 64 bit systems correctly - even if send etc
is a syscall?
Ok to commit?
Andreas
2001-04-23 Andreas Jaeger <aj@suse.de>
* sysdeps/generic/send.c (__send): Return ssize_t.
* sysdeps/mach/hurd/send.c (__send): Likewise.
* sysdeps/mach/hurd/recv.c (recv): Likewise.
* sysdeps/mach/hurd/sendto.c (sendto): Likewise.
* sysdeps/generic/sendto.c (sendto): Likewise.
* sysdeps/generic/recvmsg.c (recvmsg): Likewise.
* sysdeps/mach/hurd/recvfrom.c (recvfrom): Likewise.
* sysdeps/generic/recvfrom.c (recvfrom): Likewise.
* sysdeps/generic/sendmsg.c (sendmsg): Likewise.
* socket/sys/socket.h: send* and recv* return ssize_t.
* include/sys/socket.h: send returns ssize_t.
For linuxthreads:
2001-04-23 Andreas Jaeger <aj@suse.de>
* wrapsyscall.c: send* and recv* return ssize_t.
============================================================
Index: sysdeps/generic/send.c
--- sysdeps/generic/send.c 1997/10/13 03:52:32 1.1
+++ sysdeps/generic/send.c 2001/04/23 09:10:40
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,7 +20,7 @@
#include <sys/socket.h>
/* Send N bytes of BUF to socket FD. Returns the number sent or -1. */
-int
+ssize_t
__send (fd, buf, n, flags)
int fd;
__const __ptr_t buf;
============================================================
Index: sysdeps/generic/sendto.c
--- sysdeps/generic/sendto.c 1997/10/13 03:52:33 1.1
+++ sysdeps/generic/sendto.c 2001/04/23 09:10:40
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,7 +21,7 @@
/* Send N bytes of BUF on socket FD to peer at address ADDR (which is
ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */
-int
+ssize_t
sendto (fd, buf, n, flags, addr, addr_len)
int fd;
__const __ptr_t buf;
============================================================
Index: sysdeps/generic/recvmsg.c
--- sysdeps/generic/recvmsg.c 1997/10/13 03:52:29 1.1
+++ sysdeps/generic/recvmsg.c 2001/04/23 09:10:40
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,7 +21,7 @@
/* Receive a message as described by MESSAGE from socket FD.
Returns the number of bytes read or -1 for errors. */
-int
+ssize_t
recvmsg (fd, message, flags)
int fd;
struct msghdr *message;
============================================================
Index: sysdeps/generic/recvfrom.c
--- sysdeps/generic/recvfrom.c 1997/10/13 03:52:29 1.1
+++ sysdeps/generic/recvfrom.c 2001/04/23 09:10:40
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -22,7 +22,7 @@
/* Read N bytes into BUF through socket FD from peer
at address ADDR (which is ADDR_LEN bytes long).
Returns the number read or -1 for errors. */
-int
+ssize_t
recvfrom (fd, buf, n, flags, addr, addr_len)
int fd;
void *buf;
============================================================
Index: sysdeps/generic/sendmsg.c
--- sysdeps/generic/sendmsg.c 1997/10/13 03:52:33 1.1
+++ sysdeps/generic/sendmsg.c 2001/04/23 09:10:40
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,7 +21,7 @@
/* Send a message described MESSAGE on socket FD.
Returns the number of bytes sent, or -1 for errors. */
-int
+ssize_t
sendmsg (fd, message, flags)
int fd;
const struct msghdr *message;
============================================================
Index: sysdeps/mach/hurd/send.c
--- sysdeps/mach/hurd/send.c 1997/06/23 21:52:13 1.8
+++ sysdeps/mach/hurd/send.c 2001/04/23 09:10:40
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1994, 1996, 1997, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -23,7 +23,7 @@
#include <hurd/fd.h>
/* Send N bytes of BUF to socket FD. Returns the number sent or -1. */
-int
+ssize_t
__send (fd, buf, n, flags)
int fd;
const void *buf;
============================================================
Index: sysdeps/mach/hurd/recv.c
--- sysdeps/mach/hurd/recv.c 1997/05/26 22:23:45 1.6
+++ sysdeps/mach/hurd/recv.c 2001/04/23 09:10:40
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1994, 1997, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -27,7 +27,7 @@
Returns the number read or -1 for errors. */
/* XXX should be __recv ? */
-int
+ssize_t
recv (fd, buf, n, flags)
int fd;
void *buf;
============================================================
Index: sysdeps/mach/hurd/sendto.c
--- sysdeps/mach/hurd/sendto.c 1999/02/28 13:01:19 1.11
+++ sysdeps/mach/hurd/sendto.c 2001/04/23 09:10:40
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1994, 1995, 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -26,7 +26,7 @@
/* Send N bytes of BUF on socket FD to peer at address ADDR (which is
ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */
-int
+ssize_t
sendto (int fd,
const void *buf,
size_t n,
============================================================
Index: sysdeps/mach/hurd/recvfrom.c
--- sysdeps/mach/hurd/recvfrom.c 1999/03/15 14:22:46 1.9
+++ sysdeps/mach/hurd/recvfrom.c 2001/04/23 09:10:40
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1994, 1997, 1999, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -27,7 +27,7 @@
If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of
the sender, and store the actual size of the address in *ADDR_LEN.
Returns the number of bytes read or -1 for errors. */
-int
+ssize_t
recvfrom (fd, buf, n, flags, addrarg, addr_len)
int fd;
void *buf;
============================================================
Index: socket/sys/socket.h
--- socket/sys/socket.h 2001/01/27 21:20:48 1.33
+++ socket/sys/socket.h 2001/04/23 09:10:41
@@ -128,37 +128,37 @@
/* Send N bytes of BUF to socket FD. Returns the number sent or -1. */
-extern int send (int __fd, __const void *__buf, size_t __n, int __flags)
+extern ssize_t send (int __fd, __const void *__buf, size_t __n, int __flags)
__THROW;
/* Read N bytes into BUF from socket FD.
Returns the number read or -1 for errors. */
-extern int recv (int __fd, void *__buf, size_t __n, int __flags)
+extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags)
__THROW;
/* Send N bytes of BUF on socket FD to peer at address ADDR (which is
ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */
-extern int sendto (int __fd, __const void *__buf, size_t __n,
- int __flags, __CONST_SOCKADDR_ARG __addr,
- socklen_t __addr_len) __THROW;
+extern ssize_t sendto (int __fd, __const void *__buf, size_t __n,
+ int __flags, __CONST_SOCKADDR_ARG __addr,
+ socklen_t __addr_len) __THROW;
/* Read N bytes into BUF through socket FD.
If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of
the sender, and store the actual size of the address in *ADDR_LEN.
Returns the number of bytes read or -1 for errors. */
-extern int recvfrom (int __fd, void *__restrict __buf, size_t __n, int __flags,
- __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len)
+extern ssize_t recvfrom (int __fd, void *__restrict __buf, size_t __n, int __flags,
+ __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len)
__THROW;
/* Send a message described MESSAGE on socket FD.
Returns the number of bytes sent, or -1 for errors. */
-extern int sendmsg (int __fd, __const struct msghdr *__message, int __flags)
+extern ssize_t sendmsg (int __fd, __const struct msghdr *__message, int __flags)
__THROW;
/* Receive a message as described by MESSAGE from socket FD.
Returns the number of bytes read or -1 for errors. */
-extern int recvmsg (int __fd, struct msghdr *__message, int __flags)
+extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags)
__THROW;
============================================================
Index: include/sys/socket.h
--- include/sys/socket.h 2001/01/31 06:15:41 1.10
+++ include/sys/socket.h 2001/04/23 09:10:41
@@ -20,7 +20,7 @@
extern int __getpeername (int __fd, __SOCKADDR_ARG __addr, socklen_t *__len);
/* Send N bytes of BUF to socket FD. Returns the number sent or -1. */
-extern int __send (int __fd, __const void *__buf, size_t __n, int __flags);
+extern ssize_t __send (int __fd, __const void *__buf, size_t __n, int __flags);
/* Open a connection on socket FD to peer at ADDR (which LEN bytes long).
For connectionless socket types, just set the default address to send to
============================================================
Index: linuxthreads/wrapsyscall.c
--- linuxthreads/wrapsyscall.c 2000/07/14 06:38:38 1.5
+++ linuxthreads/wrapsyscall.c 2001/04/23 09:10:42
@@ -1,5 +1,5 @@
/* Wrapper arpund system calls to provide cancelation points.
- Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -195,31 +195,31 @@
strong_alias (connect, __connect)
/* recv(2). */
-CANCELABLE_SYSCALL (int, recv, (int fd, __ptr_t buf, size_t n, int flags),
+CANCELABLE_SYSCALL (ssize_t, recv, (int fd, __ptr_t buf, size_t n, int flags),
(fd, buf, n, flags))
/* recvfrom(2). */
-CANCELABLE_SYSCALL (int, recvfrom, (int fd, __ptr_t buf, size_t n, int flags,
- __SOCKADDR_ARG addr, socklen_t *addr_len),
+CANCELABLE_SYSCALL (ssize_t, recvfrom, (int fd, __ptr_t buf, size_t n, int flags,
+ __SOCKADDR_ARG addr, socklen_t *addr_len),
(fd, buf, n, flags, addr, addr_len))
/* recvmsg(2). */
-CANCELABLE_SYSCALL (int, recvmsg, (int fd, struct msghdr *message, int flags),
+CANCELABLE_SYSCALL (ssize_t, recvmsg, (int fd, struct msghdr *message, int flags),
(fd, message, flags))
/* send(2). */
-CANCELABLE_SYSCALL (int, send, (int fd, const __ptr_t buf, size_t n,
- int flags),
+CANCELABLE_SYSCALL (ssize_t, send, (ssize_t fd, const __ptr_t buf, size_t n,
+ int flags),
(fd, buf, n, flags))
strong_alias (send, __send)
/* sendmsg(2). */
-CANCELABLE_SYSCALL (int, sendmsg, (int fd, const struct msghdr *message,
- int flags),
+CANCELABLE_SYSCALL (ssize_t, sendmsg, (int fd, const struct msghdr *message,
+ int flags),
(fd, message, flags))
/* sendto(2). */
-CANCELABLE_SYSCALL (int, sendto, (int fd, const __ptr_t buf, size_t n,
- int flags, __CONST_SOCKADDR_ARG addr,
- socklen_t addr_len),
+CANCELABLE_SYSCALL (ssize_t, sendto, (ssize_t fd, const __ptr_t buf, size_t n,
+ int flags, __CONST_SOCKADDR_ARG addr,
+ socklen_t addr_len),
(fd, buf, n, flags, addr, addr_len))
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
More information about the Libc-alpha
mailing list