Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 May 1996 05:25:44 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, terry@lambert.org
Cc:        current@FreeBSD.ORG, scrappy@ki.net
Subject:   Re: memset/memcopy vs bzero/bcopy
Message-ID:  <199605281925.FAA31591@godzilla.zeta.org.au>

index | next in thread | raw e-mail

>If we have a processor where we can turn on unaligned access exceptions,
>and we turn them on, how much of the kernel code starts failing?  I would

None, because alignment checking is only done in ring 3 :-).  On
Pentiums you can count misaligned data references in counter 11.

>like to see this flag on by default for P5 or better systems...  the
>better to encourage writing code that can run on RISC systems.

The library certainly isn't well aligned.  The following example dumps
core in printf:

int ef;

main()
{
    asm("pushfl; orl $0x40000,(%esp); popfl");
    asm("pushfl; popl _ef");
    printf("%x", ef);
    asm("pushfl; andl $~0x40000,(%esp); popfl");
}

It works if 0 or 1 is printed instead of `ef' but fails if 0x40000 is
printed instead of `ef'

I know of only one compiler bug in this area.  The builtin memcpy()
doesn't bother aligning things.  The builtin memcpy() is used for
structs that aren't necessarily aligned.

Bruce


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605281925.FAA31591>