use bswap.h
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@351 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
		
							parent
							
								
									97a847bc03
								
							
						
					
					
						commit
						abcd5da72e
					
				
							
								
								
									
										11
									
								
								dyngen.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								dyngen.c
									
									
									
									
									
								
							@ -25,7 +25,7 @@
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
#include "config-host.h"
 | 
			
		||||
 | 
			
		||||
/* elf format definitions. We use these macros to test the CPU to
 | 
			
		||||
   allow cross compilation (this tool must be ran on the build
 | 
			
		||||
@ -108,8 +108,7 @@ typedef uint64_t host_ulong;
 | 
			
		||||
#define SHT_RELOC SHT_REL
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define NO_THUNK_TYPE_SIZE
 | 
			
		||||
#include "thunk.h"
 | 
			
		||||
#include "bswap.h"
 | 
			
		||||
 | 
			
		||||
enum {
 | 
			
		||||
    OUT_GEN_OP,
 | 
			
		||||
@ -648,7 +647,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
 | 
			
		||||
        {
 | 
			
		||||
            ElfW(Sym) *sym;
 | 
			
		||||
            const char *sym_name, *p;
 | 
			
		||||
            target_ulong val;
 | 
			
		||||
            unsigned long val;
 | 
			
		||||
            int n;
 | 
			
		||||
 | 
			
		||||
            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,
 | 
			
		||||
                    if (!ptr)
 | 
			
		||||
                        error("__op_labelN in invalid section");
 | 
			
		||||
                    offset = sym->st_value;
 | 
			
		||||
                    val = *(target_ulong *)(ptr + offset);
 | 
			
		||||
                    val = *(unsigned long *)(ptr + offset);
 | 
			
		||||
#ifdef ELF_USES_RELOCA
 | 
			
		||||
                    {
 | 
			
		||||
                        int reloc_shndx, nb_relocs1, j;
 | 
			
		||||
@ -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) {
 | 
			
		||||
                        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);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										75
									
								
								thunk.h
									
									
									
									
									
								
							
							
						
						
									
										75
									
								
								thunk.h
									
									
									
									
									
								
							@ -23,43 +23,7 @@
 | 
			
		||||
#include <inttypes.h>
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_BYTESWAP_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
 | 
			
		||||
#include "bswap.h"
 | 
			
		||||
 | 
			
		||||
#if defined(WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
 | 
			
		||||
#define BSWAP_NEEDED
 | 
			
		||||
@ -68,44 +32,7 @@
 | 
			
		||||
/* XXX: autoconf */
 | 
			
		||||
#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 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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -38,12 +38,12 @@
 | 
			
		||||
#include <sys/poll.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <sys/wait.h>
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
 | 
			
		||||
#include "vl.h"
 | 
			
		||||
 | 
			
		||||
#define NO_THUNK_TYPE_SIZE
 | 
			
		||||
#include "thunk.h"
 | 
			
		||||
#include "bswap.h"
 | 
			
		||||
 | 
			
		||||
int cow_create(int cow_fd, const char *image_filename, 
 | 
			
		||||
               int64_t image_sectors)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user