Linux and aliasing?

Andi Kleen ak@muc.de
Wed Jun 30 15:43:00 GMT 1999


mark@codesourcery.com writes:

> Despite what you say, you could just use some unions.  IMO, it
> wouldn't take that much to fix up the TCP_IPV4_MATCH macro.  I'm sorry
> the socket structure would become uglier, but, on the other hand, it
> would make more obvious what exactly it is.  Right now, some of the
> fields in the structure definition are really acting as unions, and
> you're not making that clear to the reader of the code.

This macro is just a particular example. The code is full of such stuff.

I actually started with converting some of the alias occurrences in
the 2.2 TCP code to unions, but I abandoned the project, because it
already touched far too much code and because there is no good way to 
limit the changes to specific modules. Also the unions are really ugly

Of course it would be nice to move to less such casts to allow more
optimizations in the future, but it is not realistic in a short term
fix, even for 2.3.

If GNU C had anonymous unions like VC++ or plan9 or G++ it would be a lot
easier though, because then tagless structure members could be converted
without requiring global search-replaces. Unfortunately it has not, 
and with the current "no more extensions" egcs policy it looks unlikely
(and also it would break Linux's link to gcc 2.7.2, which I fear would cause
a storm in the user and coder base)

-Andi

P.S.: David, at least it would be a good argument to merge tcp_tw_bucket
into sock, even if the cast extension would eventually get in, just to
squeeze some more optimizations out of that important paths. I imagine 
that could be important for good performance on IA64, which will probably 
be hurt much more by missed optimizations than IA32 or sparc.

-- 
This is like TV. I don't like TV.



More information about the Gcc mailing list