Re: Reading in dictionary from txt file: options for speed
Re: Reading in dictionary from txt file: options for speed
- Subject: Re: Reading in dictionary from txt file: options for speed
- From: Michael Ash <email@hidden>
- Date: Wed, 15 Apr 2009 00:10:02 -0400
On Tue, Apr 14, 2009 at 8:26 PM, Kyle Sluder <email@hidden> wrote:
> On Tue, Apr 14, 2009 at 7:27 PM, Michael Ash <email@hidden> wrote:
>> I should specify, it has no trouble reading a misaligned int pointer
>> *in x86-64 mode*. I did actually test it that way, although the first
>> time I ran the test I compiled it 32-bit and then felt kind of
>> stupid....
>
> You're right, I haven't been able to do it myself. Apparently you can
> set a flag to cause the CPU to generate alignment exceptions, but I
> can't seem to get it to happen:
>
> int main(int argc, const char *argv[]) {
> // Supposed to set the flag to cause
> // misalignment exception to bubble up
> asm("pushfq\n\t"
> "popq %rax\n\t"
> "orq $0x40000,%rax\n\t"
> "pushq %rax\n\t"
> "popfq");
>
> unsigned long i = 18446744073709551615UL;
> char *x = (char *)(&i) + 1;
> int *y = (int *)x;
> (*y) += 2;
> return *x;
> }
It's possible that OS X traps the misalignment exception and then
performs the fixup in software. This is not uncommon for OSes running
on CPUs which don't support misaligned accesses in hardware at all.
For example, this happened in certain circumstances on the PowerPC 603
and 604.
It would be odd for the OS to perform software fixups when it's an
optional flag, though....
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden