qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Debian 7.8.0 SPARC64 on qemu - anything i can do to spe


From: Karel Gardas
Subject: Re: [Qemu-devel] Debian 7.8.0 SPARC64 on qemu - anything i can do to speedup the emulation?
Date: Wed, 29 Jul 2015 16:41:25 +0200

address@hidden:~$ ./a.out
endianess: little
try to access unaligned word
  equal to 0x1234: YES
  value: 0x1234
done

On Wed, Jul 29, 2015 at 3:55 PM, Dennis Luehring <address@hidden> wrote:
> Am 29.07.2015 um 14:34 schrieb Karel Gardas:
>>
>>   Once it boots, tell me how to find the asnwers to your
>> questions.
>
>
> compile with gcc test.cpp and run
>
> -----------
> #include <stdint.h>
> #include <stdio.h>
> #include <stddef.h>
> #include <string.h>
> #include <assert.h>
>
> int main()
> {
>   uint16_t value = 0x1234;
>
>   {
>     volatile uint8_t* ptr = (uint8_t*)&value;
>     printf("endianess: %s\n", ptr[0]==0x34 ? "little":"big");
>   }
>
>   uint8_t buffer[1+sizeof(value)]={0};
>   uint8_t* ptr = buffer;
>   if(ptrdiff_t(ptr) % 2 == 0)
>   {
>     ++ptr;
>   }
>   uint16_t* unaligned_word = (uint16_t*)ptr;
>
>   ::memcpy(unaligned_word, &value, sizeof(value));
>
>   printf("try to access unaligned word\n");
>   uint16_t read = *unaligned_word; // here can happen Bus-Errors,
> Exceptions, whatever your architecture likes
>   printf("  equal to 0x%04X: %s\n", value, read == value ? "YES":"!!NO!!");
> // sometimes you get the value - but its still wrong
>   printf("  value: 0x%04X\n", read);
>   printf("done\n");
>
>   return 0;
> }
> -----------
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]