libalias patch for review / testing
Dag-ErlingSmørgrav
des at des.no
Tue Mar 16 15:34:54 PST 2004
Ruslan Ermilov <ru at freebsd.org> writes:
> : `-fstrict-aliasing'
> : Allows the compiler to assume the strictest aliasing rules
> : applicable to the language being compiled. For C (and C++), this
> : activates optimizations based on the type of expressions. In
> : particular, an object of one type is assumed never to reside at
> : the same address as an object of a different type, unless the
> : types are almost the same. For example, an `unsigned int' can
> : alias an `int', but not a `void*' or a `double'. A character type
> : may alias any other type.
>
> And asking myself a question: should those (void *)'s in your patch
> be (char *)'s instead, e.g., in twowords() and DifferentialChecksum(),
> or am I misreading the above?
You're misreading, we're doing u_short * <-> void * (both pointers)
but the man page speaks about int <-> void * (scalar vs pointer)
Also, I doubt DifferentialChecksum() is a problem, since it's a
function call. I think the problem may be in the code I've replaced
with calls to twowords().
> Also, the easiest way to check if strict aliasing is guilty for not
> working libalias compiled with -O2, is to compile the original code
> with -O2 -fno-strict-aliasing.
True, I didn't think of that.
DES
--
Dag-Erling Smørgrav - des at des.no
More information about the freebsd-net
mailing list