* sockets and portability
@ 1997-04-07 15:49 Daniel Gruner
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Gruner @ 1997-04-07 15:49 UTC (permalink / raw)
Hi
Can anyone enlighten me as to why sys/socket.h on linux/alpha defines
functions like accept() and getsockname() using a "size_t *" 3rd
argument, while the rest of the world, including linux/intel use "int
*"? This causes all sorts of portability problems. Here is the
definition from linux/alpha (RH 4.0, kernel 2.0.27 + axp-diffs):
extern int accept __P ((int __fd, __SOCKADDR_ARG __addr,
size_t *__addr_len));
while on intel it is
int accept __P ((int __sockfd, __const struct sockaddr *__peer,
int *__paddrlen));
Mind you, the compiler should automatically cast one to the other (after
all the two are only pointers), but it somehow doesn't and dies with
ksock.cpp:210: passing `int *' as argument 3 of `accept(int, sockaddr *, long un
signed int *)'
Daniel.
--
Dr. Daniel Gruner dgruner@tikva.chem.utoronto.ca
Dept. of Chemistry phone: (416)-978-8689
University of Toronto fax: (416)-978-5325
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sockets and portability
[not found] <199704071549.LAA21600@tikva>
@ 1997-04-07 16:27 ` Alvin Starr
0 siblings, 0 replies; 5+ messages in thread
From: Alvin Starr @ 1997-04-07 16:27 UTC (permalink / raw)
On Mon, 7 Apr 1997, Daniel Gruner wrote:
> Hi
>
> Can anyone enlighten me as to why sys/socket.h on linux/alpha defines
> functions like accept() and getsockname() using a "size_t *" 3rd
> argument, while the rest of the world, including linux/intel use "int
> *"? This causes all sorts of portability problems. Here is the
> definition from linux/alpha (RH 4.0, kernel 2.0.27 + axp-diffs):
>
> extern int accept __P ((int __fd, __SOCKADDR_ARG __addr,
> size_t *__addr_len));
>
> while on intel it is
>
> int accept __P ((int __sockfd, __const struct sockaddr *__peer,
> int *__paddrlen));
>
size_t is an address type. or a long.
> Mind you, the compiler should automatically cast one to the other (after
> all the two are only pointers), but it somehow doesn't and dies with
you are asking system to write a long(64bit) result into a int(32bit)
location. The value that you get will be correct but it is lilkly to
overwrite the next variable.
>
> ksock.cpp:210: passing `int *' as argument 3 of `accept(int, sockaddr *, long un
> signed int *)'
>
> Daniel.
> --
>
> Dr. Daniel Gruner dgruner@tikva.chem.utoronto.ca
> Dept. of Chemistry phone: (416)-978-8689
> University of Toronto fax: (416)-978-5325
>
> --
> To unsubscribe: send e-mail to axp-list-request@redhat.com with
> 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
>
Alvin Starr || voice: (416)493-3325
Interlink Connectivity || fax: (416)493-7974
alvin@iplink.net ||
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sockets and portability
[not found] <Pine.OSF.3.91.970407121521.2467E-100000@caesar.iplink.net>
@ 1997-04-07 16:37 ` Daniel Gruner
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Gruner @ 1997-04-07 16:37 UTC (permalink / raw)
Alvin Starr wrote:
>
> On Mon, 7 Apr 1997, Daniel Gruner wrote:
> > Hi
> >
> > Can anyone enlighten me as to why sys/socket.h on linux/alpha defines
> > functions like accept() and getsockname() using a "size_t *" 3rd
> > argument, while the rest of the world, including linux/intel use "int
> > *"? This causes all sorts of portability problems. Here is the
> > definition from linux/alpha (RH 4.0, kernel 2.0.27 + axp-diffs):
> >
> > extern int accept __P ((int __fd, __SOCKADDR_ARG __addr,
> > size_t *__addr_len));
> >
> > while on intel it is
> >
> > int accept __P ((int __sockfd, __const struct sockaddr *__peer,
> > int *__paddrlen));
> >
> size_t is an address type. or a long.
>
> > Mind you, the compiler should automatically cast one to the other (after
> > all the two are only pointers), but it somehow doesn't and dies with
>
> you are asking system to write a long(64bit) result into a int(32bit)
> location. The value that you get will be correct but it is lilkly to
> overwrite the next variable.
True, and I realize this. My gripe is against the seemingly arbitrary
change on the alpha to use an argument of type "size_t *", and not one
of type "int *", like the rest of the world (or at least the machines
accessible to me), including linux/intel, irix, hp-ux...
Daniel
--
Dr. Daniel Gruner dgruner@tikva.chem.utoronto.ca
Dept. of Chemistry phone: (416)-978-8689
University of Toronto fax: (416)-978-5325
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sockets and portability
@ 1997-04-07 16:45 Michael Alan Dorman
0 siblings, 0 replies; 5+ messages in thread
From: Michael Alan Dorman @ 1997-04-07 16:45 UTC (permalink / raw)
dgruner@tikva.chem.utoronto.ca (Daniel Gruner) writes:
> Can anyone enlighten me as to why sys/socket.h on linux/alpha defines
> functions like accept() and getsockname() using a "size_t *" 3rd
> argument, while the rest of the world, including linux/intel use "int
> *"?
I believe that glibc was written to the draft XPG5 spec (or some spec,
I forget exactly which).
IMHO, the use of size_t is more consistent. But yes, it is something
of a pain in the ass.
Mike.
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sockets and portability
@ 1997-04-07 17:22 Philip Blundell
0 siblings, 0 replies; 5+ messages in thread
From: Philip Blundell @ 1997-04-07 17:22 UTC (permalink / raw)
On Mon, 7 Apr 1997, Daniel Gruner wrote:
> Can anyone enlighten me as to why sys/socket.h on linux/alpha defines
> functions like accept() and getsockname() using a "size_t *" 3rd
> argument, while the rest of the world, including linux/intel use "int
> *"? This causes all sorts of portability problems. Here is the
> definition from linux/alpha (RH 4.0, kernel 2.0.27 + axp-diffs):
POSIX specifies "size_t" for these arguments, and glibc follows POSIX as
much as possible. It shouldn't be that great a headache to work around.
phil
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1997-04-07 17:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <199704071549.LAA21600@tikva>
1997-04-07 16:27 ` sockets and portability Alvin Starr
1997-04-07 17:22 Philip Blundell
-- strict thread matches above, loose matches on Subject: below --
1997-04-07 16:45 Michael Alan Dorman
[not found] <Pine.OSF.3.91.970407121521.2467E-100000@caesar.iplink.net>
1997-04-07 16:37 ` Daniel Gruner
1997-04-07 15:49 Daniel Gruner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox