--- previous/src/cpu/maccess.h 2018/04/24 19:25:47 1.1 +++ previous/src/cpu/maccess.h 2018/04/24 19:33:32 1.1.1.2 @@ -14,96 +14,21 @@ #ifndef UAE_MACCESS_H #define UAE_MACCESS_H - -/* Can the actual CPU access unaligned memory? */ -#ifndef CPU_CAN_ACCESS_UNALIGNED -# if defined(__i386__) || defined(powerpc) || defined(__mc68020__) -# define CPU_CAN_ACCESS_UNALIGNED 1 -# else -# define CPU_CAN_ACCESS_UNALIGNED 0 -# endif -#endif - - -/* If the CPU can access unaligned memory, use these accelerated functions: */ -#if CPU_CAN_ACCESS_UNALIGNED - #include +#if (SDL_BYTE_ORDER == SDL_BIG_ENDIAN) +#define do_get_mem_word(a) (*((uae_u16*)a)) +#define do_put_mem_word(a, v) (*((uae_u16*)a)) = v +#define do_get_mem_long(a) (*((uae_u32*)a)) +#define do_put_mem_long(a, v) (*((uae_u32*)a)) = v +#else +#define do_get_mem_word(a) __builtin_bswap16(*((uae_u16 *)(a))) +#define do_put_mem_word(a, v) *((uae_u16 *)(a)) = __builtin_bswap16(v) +#define do_get_mem_long(a) __builtin_bswap32(*((uae_u32 *)(a))) +#define do_put_mem_long(a, v) *((uae_u32 *)(a)) = __builtin_bswap32(v) +#endif -static inline uae_u32 do_get_mem_long(void *a) -{ - return SDL_SwapBE32(*(uae_u32 *)a); -} - -static inline uae_u16 do_get_mem_word(void *a) -{ - return SDL_SwapBE16(*(uae_u16 *)a); -} - - -static inline void do_put_mem_long(void *a, uae_u32 v) -{ - *(uae_u32 *)a = SDL_SwapBE32(v); -} - -static inline void do_put_mem_word(void *a, uae_u16 v) -{ - *(uae_u16 *)a = SDL_SwapBE16(v); -} - - -#else /* Cpu can not access unaligned memory: */ - - -static inline uae_u32 do_get_mem_long(void *a) -{ - uae_u8 *b = (uae_u8 *)a; - - return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]; -} - -static inline uae_u16 do_get_mem_word(void *a) -{ - uae_u8 *b = (uae_u8 *)a; - - return (b[0] << 8) | b[1]; -} - - -static inline void do_put_mem_long(void *a, uae_u32 v) -{ - uae_u8 *b = (uae_u8 *)a; - - b[0] = v >> 24; - b[1] = v >> 16; - b[2] = v >> 8; - b[3] = v; -} - -static inline void do_put_mem_word(void *a, uae_u16 v) -{ - uae_u8 *b = (uae_u8 *)a; - - b[0] = v >> 8; - b[1] = v; -} - - -#endif /* CPU_CAN_ACCESS_UNALIGNED */ - - -/* These are same for all architectures: */ - -static inline uae_u8 do_get_mem_byte(uae_u8 *a) -{ - return *a; -} - -static inline void do_put_mem_byte(uae_u8 *a, uae_u8 v) -{ - *a = v; -} - +#define do_get_mem_byte(a) (*((uae_u8*)a)) +#define do_put_mem_byte(a, v) (*((uae_u8*)a)) = v #endif /* UAE_MACCESS_H */