[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: [PATCH] second try at fixing up socklen issues on Solaris
From: Oswald Buddenhagen <ob6 () inf ! tu-dresden ! de>
Date: 2001-04-05 11:50:04
[Download RAW message or body]
> I can't imagine why any OS should use more than sizeof(int) bytes for
> socklen_t, but who knows?
>
me knows:
quoting the accept(2) man page on linux (so even the last person
on this list understands, what this thread is all about ...):
The third argument of accept was originally declared as an
`int *' (and is that under libc4 and libc5 and on many
other systems like BSD 4.*, SunOS 4, SGI); a POSIX 1003.1g
draft standard wanted to change it into a `size_t *', and
that is what it is for SunOS 5. Later POSIX drafts have
`socklen_t *', and so do the Single Unix Specification and
glibc2. Quoting Linus Torvalds: _Any_ sane library _must_
have "socklen_t" be the same size as int. Anything else
breaks any BSD socket layer stuff. POSIX initially _did_
make it a size_t, and I (and hopefully others, but obvi-
ously not too many) complained to them very loudly indeed.
Making it a size_t is completely broken, exactly because
size_t very seldom is the same size as "int" on 64-bit
architectures, for example. And it _has_ to be the same
size as "int" because that's what the BSD socket interface
is. Anyway, the POSIX people eventually got a clue, and
created "socklen_t". They shouldn't have touched it in
the first place, but once they did they felt it had to
have a named type for some unfathomable reason (probably
somebody didn't like losing face over having done the
original stupid thing, so they silently just renamed their
blunder).
so the only acceptable solution seems to be the one i already presented:
- export interfaces using "[unsigned] int"
- internally use "socklen_t", which is #defined to
typeof("actual-socklen_t"), if no native typedef is found by configure
don't use any ksize_t or ksocklen_t - that's only unnecessary clutter.
> My current problem is that AIX uses unsigned long instead of
> unsigned int in 32 bit mode, probably for backward compatibility.
>
is sizeof(long) == sizeof(size_t) != sizeof(int) on your system?
if so, it's one of the broken-posix systems.
> But is it guaranteed by any standard that socklen_t is a basic data
> type everywhere?
>
no. "real" socklen_t is a typedef and therefore no basic type (at least
according to the definition of "basic data type" i know). behind the
curtain it's of course an int (good) or size_t (bad).
best regards
--
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Nothing is fool-proof to a sufficiently talented fool.
>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic