kernel vm question

Dag-Erling Smørgrav des at des.no
Fri Jan 28 01:54:50 PST 2005


David Schultz <das at FreeBSD.ORG> writes:
> On Thu, Jan 27, 2005, Jacques Fourie wrote:
> > unsigned char *p = NULL;
> > unsigned char v = 0x55;
> > /* ... */
> > p = (unsigned char *)ip_output;
> > /* ... */
> > v = p[0];
> > p[0] = v;
> > /* ... */
> When the line is there, the compiler is probably smart enough to
> realize that 'x=y; y=x' is (usually) a no-op, so it optimizes away
> both statements.

Wrong.  The compiler is free to optimize away the second statement
provided that neither x nor y is declared volatile, but it cannot
optimize away the first statement.

DES
-- 
Dag-Erling Smørgrav - des at des.no


More information about the freebsd-hackers mailing list