Commit abcd5da72e66becf055aff3a225f7c8645c18fff
1 parent
97a847bc
use bswap.h
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@351 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
8 additions
and
82 deletions
dyngen.c
| @@ -25,7 +25,7 @@ | @@ -25,7 +25,7 @@ | ||
| 25 | #include <unistd.h> | 25 | #include <unistd.h> |
| 26 | #include <fcntl.h> | 26 | #include <fcntl.h> |
| 27 | 27 | ||
| 28 | -#include "config.h" | 28 | +#include "config-host.h" |
| 29 | 29 | ||
| 30 | /* elf format definitions. We use these macros to test the CPU to | 30 | /* elf format definitions. We use these macros to test the CPU to |
| 31 | allow cross compilation (this tool must be ran on the build | 31 | 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; | ||
| 108 | #define SHT_RELOC SHT_REL | 108 | #define SHT_RELOC SHT_REL |
| 109 | #endif | 109 | #endif |
| 110 | 110 | ||
| 111 | -#define NO_THUNK_TYPE_SIZE | ||
| 112 | -#include "thunk.h" | 111 | +#include "bswap.h" |
| 113 | 112 | ||
| 114 | enum { | 113 | enum { |
| 115 | OUT_GEN_OP, | 114 | 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, | ||
| 648 | { | 647 | { |
| 649 | ElfW(Sym) *sym; | 648 | ElfW(Sym) *sym; |
| 650 | const char *sym_name, *p; | 649 | const char *sym_name, *p; |
| 651 | - target_ulong val; | 650 | + unsigned long val; |
| 652 | int n; | 651 | int n; |
| 653 | 652 | ||
| 654 | for(i = 0, sym = symtab; i < nb_syms; i++, sym++) { | 653 | 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, | ||
| 663 | if (!ptr) | 662 | if (!ptr) |
| 664 | error("__op_labelN in invalid section"); | 663 | error("__op_labelN in invalid section"); |
| 665 | offset = sym->st_value; | 664 | offset = sym->st_value; |
| 666 | - val = *(target_ulong *)(ptr + offset); | 665 | + val = *(unsigned long *)(ptr + offset); |
| 667 | #ifdef ELF_USES_RELOCA | 666 | #ifdef ELF_USES_RELOCA |
| 668 | { | 667 | { |
| 669 | int reloc_shndx, nb_relocs1, j; | 668 | 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, | ||
| 687 | 686 | ||
| 688 | if (val >= start_offset && val < start_offset + copy_size) { | 687 | if (val >= start_offset && val < start_offset + copy_size) { |
| 689 | n = strtol(p, NULL, 10); | 688 | n = strtol(p, NULL, 10); |
| 690 | - fprintf(outfile, " label_offsets[%d] = %d + (gen_code_ptr - gen_code_buf);\n", n, val - start_offset); | 689 | + fprintf(outfile, " label_offsets[%d] = %ld + (gen_code_ptr - gen_code_buf);\n", n, val - start_offset); |
| 691 | } | 690 | } |
| 692 | } | 691 | } |
| 693 | } | 692 | } |
thunk.h
| @@ -23,43 +23,7 @@ | @@ -23,43 +23,7 @@ | ||
| 23 | #include <inttypes.h> | 23 | #include <inttypes.h> |
| 24 | #include "config.h" | 24 | #include "config.h" |
| 25 | 25 | ||
| 26 | -#ifdef HAVE_BYTESWAP_H | ||
| 27 | -#include <byteswap.h> | ||
| 28 | -#else | ||
| 29 | - | ||
| 30 | -#define bswap_16(x) \ | ||
| 31 | -({ \ | ||
| 32 | - uint16_t __x = (x); \ | ||
| 33 | - ((uint16_t)( \ | ||
| 34 | - (((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \ | ||
| 35 | - (((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \ | ||
| 36 | -}) | ||
| 37 | - | ||
| 38 | -#define bswap_32(x) \ | ||
| 39 | -({ \ | ||
| 40 | - uint32_t __x = (x); \ | ||
| 41 | - ((uint32_t)( \ | ||
| 42 | - (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \ | ||
| 43 | - (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \ | ||
| 44 | - (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \ | ||
| 45 | - (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \ | ||
| 46 | -}) | ||
| 47 | - | ||
| 48 | -#define bswap_64(x) \ | ||
| 49 | -({ \ | ||
| 50 | - uint64_t __x = (x); \ | ||
| 51 | - ((uint64_t)( \ | ||
| 52 | - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \ | ||
| 53 | - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \ | ||
| 54 | - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \ | ||
| 55 | - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \ | ||
| 56 | - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \ | ||
| 57 | - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \ | ||
| 58 | - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \ | ||
| 59 | - (uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \ | ||
| 60 | -}) | ||
| 61 | - | ||
| 62 | -#endif | 26 | +#include "bswap.h" |
| 63 | 27 | ||
| 64 | #if defined(WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) | 28 | #if defined(WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) |
| 65 | #define BSWAP_NEEDED | 29 | #define BSWAP_NEEDED |
| @@ -68,44 +32,7 @@ | @@ -68,44 +32,7 @@ | ||
| 68 | /* XXX: autoconf */ | 32 | /* XXX: autoconf */ |
| 69 | #define TARGET_LONG_BITS 32 | 33 | #define TARGET_LONG_BITS 32 |
| 70 | 34 | ||
| 71 | -#if defined(__alpha__) || defined (__ia64__) | ||
| 72 | -#define HOST_LONG_BITS 64 | ||
| 73 | -#else | ||
| 74 | -#define HOST_LONG_BITS 32 | ||
| 75 | -#endif | ||
| 76 | - | ||
| 77 | #define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) | 35 | #define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) |
| 78 | -#define HOST_LONG_SIZE (HOST_LONG_BITS / 8) | ||
| 79 | - | ||
| 80 | -static inline uint16_t bswap16(uint16_t x) | ||
| 81 | -{ | ||
| 82 | - return bswap_16(x); | ||
| 83 | -} | ||
| 84 | - | ||
| 85 | -static inline uint32_t bswap32(uint32_t x) | ||
| 86 | -{ | ||
| 87 | - return bswap_32(x); | ||
| 88 | -} | ||
| 89 | - | ||
| 90 | -static inline uint64_t bswap64(uint64_t x) | ||
| 91 | -{ | ||
| 92 | - return bswap_64(x); | ||
| 93 | -} | ||
| 94 | - | ||
| 95 | -static inline void bswap16s(uint16_t *s) | ||
| 96 | -{ | ||
| 97 | - *s = bswap16(*s); | ||
| 98 | -} | ||
| 99 | - | ||
| 100 | -static inline void bswap32s(uint32_t *s) | ||
| 101 | -{ | ||
| 102 | - *s = bswap32(*s); | ||
| 103 | -} | ||
| 104 | - | ||
| 105 | -static inline void bswap64s(uint64_t *s) | ||
| 106 | -{ | ||
| 107 | - *s = bswap64(*s); | ||
| 108 | -} | ||
| 109 | 36 | ||
| 110 | #ifdef BSWAP_NEEDED | 37 | #ifdef BSWAP_NEEDED |
| 111 | 38 |
vlmkcow.c
| @@ -38,12 +38,12 @@ | @@ -38,12 +38,12 @@ | ||
| 38 | #include <sys/poll.h> | 38 | #include <sys/poll.h> |
| 39 | #include <errno.h> | 39 | #include <errno.h> |
| 40 | #include <sys/wait.h> | 40 | #include <sys/wait.h> |
| 41 | +#include <sys/stat.h> | ||
| 41 | #include <netinet/in.h> | 42 | #include <netinet/in.h> |
| 42 | 43 | ||
| 43 | #include "vl.h" | 44 | #include "vl.h" |
| 44 | 45 | ||
| 45 | -#define NO_THUNK_TYPE_SIZE | ||
| 46 | -#include "thunk.h" | 46 | +#include "bswap.h" |
| 47 | 47 | ||
| 48 | int cow_create(int cow_fd, const char *image_filename, | 48 | int cow_create(int cow_fd, const char *image_filename, |
| 49 | int64_t image_sectors) | 49 | int64_t image_sectors) |