提交 abcd5da7 编写于 作者: B bellard

use bswap.h


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@351 c046a42c-6fe2-441c-8c8c-71466251a162
上级 97a847bc
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include "config.h" #include "config-host.h"
/* elf format definitions. We use these macros to test the CPU to /* elf format definitions. We use these macros to test the CPU to
allow cross compilation (this tool must be ran on the build allow cross compilation (this tool must be ran on the build
...@@ -108,8 +108,7 @@ typedef uint64_t host_ulong; ...@@ -108,8 +108,7 @@ typedef uint64_t host_ulong;
#define SHT_RELOC SHT_REL #define SHT_RELOC SHT_REL
#endif #endif
#define NO_THUNK_TYPE_SIZE #include "bswap.h"
#include "thunk.h"
enum { enum {
OUT_GEN_OP, OUT_GEN_OP,
...@@ -648,7 +647,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size, ...@@ -648,7 +647,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
{ {
ElfW(Sym) *sym; ElfW(Sym) *sym;
const char *sym_name, *p; const char *sym_name, *p;
target_ulong val; unsigned long val;
int n; int n;
for(i = 0, sym = symtab; i < nb_syms; i++, sym++) { for(i = 0, sym = symtab; i < nb_syms; i++, sym++) {
...@@ -663,7 +662,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size, ...@@ -663,7 +662,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
if (!ptr) if (!ptr)
error("__op_labelN in invalid section"); error("__op_labelN in invalid section");
offset = sym->st_value; offset = sym->st_value;
val = *(target_ulong *)(ptr + offset); val = *(unsigned long *)(ptr + offset);
#ifdef ELF_USES_RELOCA #ifdef ELF_USES_RELOCA
{ {
int reloc_shndx, nb_relocs1, j; int reloc_shndx, nb_relocs1, j;
...@@ -687,7 +686,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size, ...@@ -687,7 +686,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
if (val >= start_offset && val < start_offset + copy_size) { if (val >= start_offset && val < start_offset + copy_size) {
n = strtol(p, NULL, 10); n = strtol(p, NULL, 10);
fprintf(outfile, " label_offsets[%d] = %d + (gen_code_ptr - gen_code_buf);\n", n, val - start_offset); fprintf(outfile, " label_offsets[%d] = %ld + (gen_code_ptr - gen_code_buf);\n", n, val - start_offset);
} }
} }
} }
......
...@@ -23,43 +23,7 @@ ...@@ -23,43 +23,7 @@
#include <inttypes.h> #include <inttypes.h>
#include "config.h" #include "config.h"
#ifdef HAVE_BYTESWAP_H #include "bswap.h"
#include <byteswap.h>
#else
#define bswap_16(x) \
({ \
uint16_t __x = (x); \
((uint16_t)( \
(((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \
(((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \
})
#define bswap_32(x) \
({ \
uint32_t __x = (x); \
((uint32_t)( \
(((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
(((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \
(((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \
(((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
})
#define bswap_64(x) \
({ \
uint64_t __x = (x); \
((uint64_t)( \
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
(uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \
})
#endif
#if defined(WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) #if defined(WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
#define BSWAP_NEEDED #define BSWAP_NEEDED
...@@ -68,44 +32,7 @@ ...@@ -68,44 +32,7 @@
/* XXX: autoconf */ /* XXX: autoconf */
#define TARGET_LONG_BITS 32 #define TARGET_LONG_BITS 32
#if defined(__alpha__) || defined (__ia64__)
#define HOST_LONG_BITS 64
#else
#define HOST_LONG_BITS 32
#endif
#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) #define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8)
#define HOST_LONG_SIZE (HOST_LONG_BITS / 8)
static inline uint16_t bswap16(uint16_t x)
{
return bswap_16(x);
}
static inline uint32_t bswap32(uint32_t x)
{
return bswap_32(x);
}
static inline uint64_t bswap64(uint64_t x)
{
return bswap_64(x);
}
static inline void bswap16s(uint16_t *s)
{
*s = bswap16(*s);
}
static inline void bswap32s(uint32_t *s)
{
*s = bswap32(*s);
}
static inline void bswap64s(uint64_t *s)
{
*s = bswap64(*s);
}
#ifdef BSWAP_NEEDED #ifdef BSWAP_NEEDED
......
...@@ -38,12 +38,12 @@ ...@@ -38,12 +38,12 @@
#include <sys/poll.h> #include <sys/poll.h>
#include <errno.h> #include <errno.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/stat.h>
#include <netinet/in.h> #include <netinet/in.h>
#include "vl.h" #include "vl.h"
#define NO_THUNK_TYPE_SIZE #include "bswap.h"
#include "thunk.h"
int cow_create(int cow_fd, const char *image_filename, int cow_create(int cow_fd, const char *image_filename,
int64_t image_sectors) int64_t image_sectors)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册