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: Dennis Luehring
Subject: Re: [Qemu-devel] Debian 7.8.0 SPARC64 on qemu - anything i can do to speedup the emulation?
Date: Wed, 29 Jul 2015 15:55:18 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0

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]