mirror of
https://github.com/libretro/beetle-pce-fast-libretro.git
synced 2025-02-17 05:38:28 +00:00
Use MSB_FIRST instead of LSB_FIRST
This commit is contained in:
parent
621e32d1f6
commit
f901700e64
8
Makefile
8
Makefile
@ -68,7 +68,6 @@ ifeq ($(platform), unix)
|
||||
TARGET := $(TARGET_NAME).so
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
|
||||
ENDIANNESS_DEFINES := -DLSB_FIRST
|
||||
ifneq ($(shell uname -p | grep -E '((i.|x)86|amd64)'),)
|
||||
IS_X86 = 1
|
||||
endif
|
||||
@ -83,8 +82,6 @@ else ifeq ($(platform), osx)
|
||||
ifeq ($(arch),ppc)
|
||||
ENDIANNESS_DEFINES := -DMSB_FIRST -DBYTE_ORDER=BIG_ENDIAN
|
||||
OLD_GCC := 1
|
||||
else
|
||||
ENDIANNESS_DEFINES := -DLSB_FIRST
|
||||
endif
|
||||
OSXVER = `sw_vers -productVersion | cut -d. -f 2`
|
||||
OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
|
||||
@ -95,7 +92,6 @@ else ifeq ($(platform), ios)
|
||||
TARGET := $(TARGET_NAME)_ios.dylib
|
||||
fpic := -fPIC
|
||||
SHARED := -dynamiclib
|
||||
ENDIANNESS_DEFINES := -DLSB_FIRST
|
||||
LDFLAGS += $(PTHREAD_FLAGS)
|
||||
FLAGS += $(PTHREAD_FLAGS)
|
||||
|
||||
@ -123,7 +119,6 @@ else ifeq ($(platform), qnx)
|
||||
TARGET := $(TARGET_NAME)_qnx.so
|
||||
fpic := -fPIC
|
||||
SHARED := -lcpp -lm -shared -Wl,--no-undefined -Wl,--version-script=link.T
|
||||
ENDIANNESS_DEFINES := -DLSB_FIRST
|
||||
#LDFLAGS += $(PTHREAD_FLAGS)
|
||||
#FLAGS += $(PTHREAD_FLAGS) -DHAVE_MKDIR
|
||||
FLAGS += -DHAVE_MKDIR
|
||||
@ -164,7 +159,6 @@ else ifeq ($(platform), psp1)
|
||||
CC = psp-gcc$(EXE_EXT)
|
||||
CXX = psp-g++$(EXE_EXT)
|
||||
AR = psp-ar$(EXE_EXT)
|
||||
ENDIANNESS_DEFINES := -DLSB_FIRST
|
||||
FLAGS += -DPSP -G0
|
||||
FLAGS += -DHAVE_MKDIR
|
||||
STATIC_LINKING = 1
|
||||
@ -202,7 +196,6 @@ else ifneq (,$(findstring armv,$(platform)))
|
||||
TARGET := $(TARGET_NAME).so
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
|
||||
ENDIANNESS_DEFINES := -DLSB_FIRST
|
||||
CC = gcc
|
||||
LDFLAGS += $(PTHREAD_FLAGS)
|
||||
FLAGS += $(PTHREAD_FLAGS) -DHAVE_MKDIR
|
||||
@ -233,7 +226,6 @@ else
|
||||
IS_X86 = 1
|
||||
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
|
||||
LDFLAGS += -static-libgcc -static-libstdc++ -lwinmm
|
||||
ENDIANNESS_DEFINES := -DLSB_FIRST
|
||||
FLAGS += -DHAVE__MKDIR
|
||||
endif
|
||||
|
||||
|
@ -102,41 +102,41 @@ class Stream
|
||||
template<typename T>
|
||||
INLINE T get_LE(void)
|
||||
{
|
||||
#ifdef LSB_FIRST
|
||||
return get_NE<T>();
|
||||
#else
|
||||
return get_RE<T>();
|
||||
#endif
|
||||
#ifdef MSB_FIRST
|
||||
return get_RE<T>();
|
||||
#else
|
||||
return get_NE<T>();
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
INLINE void put_LE(T c)
|
||||
{
|
||||
#ifdef LSB_FIRST
|
||||
return put_NE<T>(c);
|
||||
#else
|
||||
return put_RE<T>(c);
|
||||
#endif
|
||||
#ifdef MSB_FIRST
|
||||
return put_RE<T>(c);
|
||||
#else
|
||||
return put_NE<T>(c);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
INLINE T get_BE(void)
|
||||
{
|
||||
#ifndef LSB_FIRST
|
||||
return get_NE<T>();
|
||||
#else
|
||||
return get_RE<T>();
|
||||
#endif
|
||||
#ifdef MSB_FIRST
|
||||
return get_NE<T>();
|
||||
#else
|
||||
return get_RE<T>();
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
INLINE void put_BE(T c)
|
||||
{
|
||||
#ifndef LSB_FIRST
|
||||
return put_NE<T>(c);
|
||||
#else
|
||||
return put_RE<T>(c);
|
||||
#endif
|
||||
#ifdef MSB_FIRST
|
||||
return put_NE<T>(c);
|
||||
#else
|
||||
return put_RE<T>(c);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Reads a line into "str", overwriting its contents; returns the line-end char('\n' or '\r' or '\0'), or -1 on EOF.
|
||||
|
@ -109,18 +109,18 @@ void Endian_A16_LE_to_NE(void *src, uint32 nelements)
|
||||
|
||||
void Endian_A16_BE_to_NE(void *src, uint32 nelements)
|
||||
{
|
||||
#ifdef LSB_FIRST
|
||||
uint32 i;
|
||||
uint8 *nsrc = (uint8 *)src;
|
||||
#ifndef MSB_FIRST
|
||||
uint32 i;
|
||||
uint8 *nsrc = (uint8 *)src;
|
||||
|
||||
for(i = 0; i < nelements; i++)
|
||||
{
|
||||
uint8 tmp = nsrc[i * 2];
|
||||
for(i = 0; i < nelements; i++)
|
||||
{
|
||||
uint8 tmp = nsrc[i * 2];
|
||||
|
||||
nsrc[i * 2] = nsrc[i * 2 + 1];
|
||||
nsrc[i * 2 + 1] = tmp;
|
||||
}
|
||||
#endif
|
||||
nsrc[i * 2] = nsrc[i * 2 + 1];
|
||||
nsrc[i * 2 + 1] = tmp;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -220,26 +220,26 @@ int write32le(uint32 b, FILE *fp)
|
||||
|
||||
int read32le(uint32 *Bufo, FILE *fp)
|
||||
{
|
||||
uint32 buf;
|
||||
if(fread(&buf,1,4,fp)<4)
|
||||
return 0;
|
||||
#ifdef LSB_FIRST
|
||||
*(uint32*)Bufo=buf;
|
||||
#else
|
||||
*(uint32*)Bufo=((buf&0xFF)<<24)|((buf&0xFF00)<<8)|((buf&0xFF0000)>>8)|((buf&0xFF000000)>>24);
|
||||
#endif
|
||||
return 1;
|
||||
uint32 buf;
|
||||
if(fread(&buf,1,4,fp)<4)
|
||||
return 0;
|
||||
#ifdef MSB_FIRST
|
||||
*(uint32*)Bufo=((buf&0xFF)<<24)|((buf&0xFF00)<<8)|((buf&0xFF0000)>>8)|((buf&0xFF000000)>>24);
|
||||
#else
|
||||
*(uint32*)Bufo=buf;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int read16le(char *d, FILE *fp)
|
||||
{
|
||||
#ifdef LSB_FIRST
|
||||
return((fread(d,1,2,fp)<2)?0:2);
|
||||
#else
|
||||
int ret;
|
||||
ret=fread(d+1,1,1,fp);
|
||||
ret+=fread(d,1,1,fp);
|
||||
return ret<2?0:2;
|
||||
#endif
|
||||
#ifdef MSB_FIRST
|
||||
int ret;
|
||||
ret=fread(d+1,1,1,fp);
|
||||
ret+=fread(d,1,1,fp);
|
||||
return ret<2?0:2;
|
||||
#else
|
||||
return((fread(d,1,2,fp)<2)?0:2);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
#endif
|
||||
#else
|
||||
|
||||
#if defined (LSB_FIRST) || defined (__LITTLE_ENDIAN__) || BLARGG_CPU_X86 || \
|
||||
#if !defined(MSB_FIRST) || defined (__LITTLE_ENDIAN__) || BLARGG_CPU_X86 || \
|
||||
(defined (LITTLE_ENDIAN) && LITTLE_ENDIAN+0 != 1234)
|
||||
#define BLARGG_LITTLE_ENDIAN 1
|
||||
#endif
|
||||
|
@ -2,24 +2,20 @@
|
||||
#define __MDFN_ENDIAN_H
|
||||
|
||||
#ifdef MSB_FIRST
|
||||
#ifdef LSB_FIRST
|
||||
#error Only define one of LSB_FIRST and MSB_FIRST
|
||||
#endif
|
||||
|
||||
#ifndef le32toh
|
||||
#define le32toh(l) ((((l)>>24) & 0xff) | (((l)>>8) & 0xff00) \
|
||||
| (((l)<<8) & 0xff0000) | (((l)<<24) & 0xff000000))
|
||||
#endif
|
||||
#ifndef le16toh
|
||||
#define le16toh(l) ((((l)>>8) & 0xff) | (((l)<<8) & 0xff00))
|
||||
#endif
|
||||
#ifndef le32toh
|
||||
#define le32toh(l) ((((l)>>24) & 0xff) | (((l)>>8) & 0xff00) \
|
||||
| (((l)<<8) & 0xff0000) | (((l)<<24) & 0xff000000))
|
||||
#endif
|
||||
#ifndef le16toh
|
||||
#define le16toh(l) ((((l)>>8) & 0xff) | (((l)<<8) & 0xff00))
|
||||
#endif
|
||||
#else
|
||||
#ifndef le32toh
|
||||
#define le32toh(l) (l)
|
||||
#endif
|
||||
#ifndef le16toh
|
||||
#define le16toh(l) (l)
|
||||
#endif
|
||||
#ifndef le32toh
|
||||
#define le32toh(l) (l)
|
||||
#endif
|
||||
#ifndef le16toh
|
||||
#define le16toh(l) (l)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef htole32
|
||||
|
@ -118,10 +118,6 @@ typedef unsigned char Boolean; /* 0 or 1 */
|
||||
#undef require
|
||||
#define require( expr ) assert( expr )
|
||||
|
||||
#if !defined(MSB_FIRST) && !defined(LSB_FIRST)
|
||||
#error "Define MSB_FIRST or LSB_FIRST!"
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user