* Trouble with sockets while compiling Tcl 8.0
@ 1998-02-12 0:49 Michael J. Donahue
0 siblings, 0 replies; 3+ messages in thread
From: Michael J. Donahue @ 1998-02-12 0:49 UTC (permalink / raw)
I'm trying to build Tcl 8.0p2 on my linux/axp/RedHat 4.1 box, and
running into some trouble with some of the socket code. To be
specific, my /usr/include/sys/socket.h file gives:
extern int accept __P ((int __fd, __SOCKADDR_ARG __addr,size_t *__addr_len));
extern int getpeername __P ((int __fd, __SOCKADDR_ARG __addr,size_t *__len));
extern int getsockname __P ((int __fd, __SOCKADDR_ARG __addr,size_t *__len));
extern int getsockopt __P ((int __fd, int __level, int __optname,
__ptr_t __optval, size_t *__optlen));
However, the man pages and the Tcl code say the last arg in each case
should be (int *) instead of (size_t *).
This is a problem, because size_t is apparently getting set in
/usr/lib/gcc-lib/alpha-linux/2.7.2.1/include/stddef.h
as (long unsigned int), which is 8 bytes wide rather than the 4 bytes
for an (int). Incidentally, my <linux/stddef.h> file gives
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned int size_t;
#endif
So, should the "len" arg in the above calls be (int *) or (size_t *)?
Is size_t suppose to be unsigned int or unsigned long? And is any of
this different in latter releases of RH?
TIA,
-mike
--
Michael J. Donahue
National Institute of Standards and Technology
Mathematical & Computational Sciences Division
Bldg 820, Rm 365
Gaithersburg, MD 20899
email: michael.donahue@nist.gov
voice: (301) 975-5424
fax: (301) 990-4127
web: http://math.nist.gov/mcsd/Staff/MDonahue/
--
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] 3+ messages in thread
* Re: Trouble with sockets while compiling Tcl 8.0
[not found] <199802120049.TAA07622@ulexite.nist.gov>
@ 1998-02-12 5:30 ` Michal Jaegermann
0 siblings, 0 replies; 3+ messages in thread
From: Michal Jaegermann @ 1998-02-12 5:30 UTC (permalink / raw)
>
> I'm trying to build Tcl 8.0p2 on my linux/axp/RedHat 4.1 box,
From everything I know about it Tcl is, unfortunately, broken
as distributed and always was. None of versions I tried was
able to get through, on Alpha, through its own self-test. Not
that I spent a lot of time on that code.
> running into some trouble with some of the socket code. To be
> specific, my /usr/include/sys/socket.h file gives:
Always believe in system headers. They have precedence over what
some outside code is trying to say.
> extern int accept __P ((int __fd, __SOCKADDR_ARG __addr,size_t *__addr_len));
^^^^
Not that I have here a copy of a POSIX standard here to check, but I
believe that this is what it requires. Other functions as well.
> However, the man pages and the Tcl code say the last arg in each case
> should be (int *) instead of (size_t *).
Both man page and Tcl should be corrected. Not that this makes,
unfortunately, a real difference on machines on which sizeof(int) ==
sizeof(size_t).
>
> This is a problem, because size_t is apparently getting set in
>
> /usr/lib/gcc-lib/alpha-linux/2.7.2.1/include/stddef.h
>
> as (long unsigned int),
Like it should be if I interpret C standard correctly. In any case
C standard does not prescribe directly some particular size to size_t
and programs assuming that it is the same as sizeof(int) are simply
broken.
> Incidentally, my <linux/stddef.h> file gives
>
> #ifndef _SIZE_T
> #define _SIZE_T
> typedef unsigned int size_t;
> #endif
This may be used internally by a kernel. Libraries do not have to
follow that (not that this is not causing problems right now when
we are switching to glibc2, a.k.a. libc6, and this separation
bites here and there :-\ ).
> And is any of
> this different in latter releases of RH?
No, AFAIK, and it will not be.
Michal
--
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] 3+ messages in thread
* Re: Trouble with sockets while compiling Tcl 8.0
@ 1998-02-12 9:36 Stefan Traby
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Traby @ 1998-02-12 9:36 UTC (permalink / raw)
Hi Michal !
> > extern int accept __P ((int __fd, __SOCKADDR_ARG __addr,size_t *__addr_len));
^^^^
> Not that I have here a copy of a POSIX standard here to check, but I
> believe that this is what it requires. Other functions as well.
;-}
The man pages are BSD like !
UNIX Network Programming (Stevens) says about BSD Sockets:
int accept(int sockfd, struct sockaddr *peer, int *addrlen);
But for all GNU software check first the info and then the man pages.
glibc-info:
- Function: int accept (int SOCKET, struct sockaddr *ADDR, socklen_t
*LENGTH-PTR)
And look deep into the info file. (An _exact_ text on your problem...)
---------
Throughout the following description at various places
variables/parameters to denote sizes are required. And here the trouble
starts. In the first implementations the type of these variables was
simply `int'. This type was on almost all machines of this time 32
bits wide and so a de-factor standard required 32 bit variables. This
is important since references to variables of this type are passed to
the kernel.
But now the POSIX people came and unified the interface with their
words "all size values are of type `size_t'". But on 64 bit machines
`size_t' is 64 bits wide and so variable references are not anymore
possible.
A solution provides the Unix98 specification which finally
introduces a type `socklen_t'. This type is used in all of the cases in
previously changed to use `size_t'. The only requirement of this type
is that it is an unsigned type of at least 32 bits. Therefore,
implementations which require references to 32 bit variables be passed
can be as happy as implementations which right from the start of 64 bit
values.
--------
--
ciao -
Stefan
Stefan Traby phone: +43-3133-6107-2
Mitterlasznitzstr. 13 fax: +43-3133-6107-9
8302 Nestelbach mailto://stefan@sime.com
Austria
--
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] 3+ messages in thread
end of thread, other threads:[~1998-02-12 9:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-02-12 0:49 Trouble with sockets while compiling Tcl 8.0 Michael J. Donahue
[not found] <199802120049.TAA07622@ulexite.nist.gov>
1998-02-12 5:30 ` Michal Jaegermann
-- strict thread matches above, loose matches on Subject: below --
1998-02-12 9:36 Stefan Traby
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox