From: kub Date: Wed, 10 Mar 2021 22:07:25 +0000 (+0100) Subject: core, libretro fixes for chd support X-Git-Tag: v2.00~589 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=886ce067c325b159939b2a8570a4b042c71eff78;p=picodrive.git core, libretro fixes for chd support --- diff --git a/Makefile b/Makefile index 08f7ee4f..6dc8f55e 100644 --- a/Makefile +++ b/Makefile @@ -249,7 +249,6 @@ CHDR = pico/cd/libchdr CHDR_OBJS += $(CHDR)/src/libchdr_chd.o $(CHDR)/src/libchdr_cdrom.o CHDR_OBJS += $(CHDR)/src/libchdr_flac.o CHDR_OBJS += $(CHDR)/src/libchdr_bitstream.o $(CHDR)/src/libchdr_huffman.o -$(CHDR_OBJS): CFLAGS += -DHAVE_FSEEKO # flac FLAC = $(CHDR)/deps/flac-1.3.3 @@ -258,6 +257,7 @@ FLAC_OBJS += $(FLAC)/src/metadata_object.o $(FLAC)/src/metadata_iterators.o FLAC_OBJS += $(FLAC)/src/bitmath.o $(FLAC)/src/bitreader.o $(FLAC)/src/md5.o FLAC_OBJS += $(FLAC)/src/memory.o $(FLAC)/src/fixed.o $(FLAC)/src/crc.o FLAC_OBJS += $(FLAC)/src/window.o $(FLAC)/src/stream_decoder.o +FLAC_OBJS += $(FLAC)/src/windows_unicode_filenames.o $(FLAC_OBJS): CFLAGS += -DPACKAGE_VERSION=\"1.3.3\" -DFLAC__HAS_OGG=0 $(FLAC_OBJS): CFLAGS += -DHAVE_FSEEKO -DHAVE_LROUND -DHAVE_STDINT_H -DHAVE_STDLIB_H # ugh... diff --git a/pico/cd/cd_parse.c b/pico/cd/cd_parse.c index 6ed6335b..974e9930 100644 --- a/pico/cd/cd_parse.c +++ b/pico/cd/cd_parse.c @@ -83,7 +83,7 @@ static int get_ext(const char *fname, char ext[4], strncpy(ext, fname + pos + 1, 4/*sizeof(ext)*/-1); ext[4/*sizeof(ext)*/-1] = '\0'; - if (base != NULL) { + if (base != NULL && base_size > 0) { if (pos + 1 < base_size) pos = base_size - 1; diff --git a/pico/cd/libchdr b/pico/cd/libchdr index 208212ae..714fc3f2 160000 --- a/pico/cd/libchdr +++ b/pico/cd/libchdr @@ -1 +1 @@ -Subproject commit 208212ae77f5c4fedca11d797e50cb1954b2c837 +Subproject commit 714fc3f268ebddf035a76cc883bd4543b5142a6f diff --git a/pico/pico_port.h b/pico/pico_port.h index ac8f0ccd..a5f8a582 100644 --- a/pico/pico_port.h +++ b/pico/pico_port.h @@ -34,8 +34,8 @@ #endif -// There's no standard way to determine endianess at compile time. -// Do not bother with mixed endian platforms, no one will ever compile on that. +// There's no standard way to determine endianess at compile time. Try using +// some well known non-standard macros for detection. #if defined __BYTE_ORDER__ #define CPU_IS_LE __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #elif defined _BYTE_ORDER @@ -48,6 +48,7 @@ #warning "can't detect byte order, assume little endian" #define CPU_IS_LE 1 #endif +// NB mixed endian integer platforms are not supported. #if CPU_IS_LE // address/offset operations @@ -56,7 +57,7 @@ #define MEM_LE2(a) (a) #define MEM_LE4(a) (a) // swapping -#define CPU_BE2(v) (((v)<<16)|((v)>>16)) +#define CPU_BE2(v) ((u32)((u64)(v)<<16)|((v)>>16)) #define CPU_BE4(v) (((u32)(v)>>24)|(((v)>>8)&0x00ff00)| \ (((v)<<8)&0xff0000)|(u32)((v)<<24)) #define CPU_LE2(v) (v) // swap of 2*u16 in u32 @@ -70,7 +71,7 @@ // swapping #define CPU_BE2(v) (v) #define CPU_BE4(v) (v) -#define CPU_LE2(v) (((v)<<16)|((v)>>16)) +#define CPU_LE2(v) ((u32)((u64)(v)<<16)|((v)>>16)) #define CPU_LE4(v) (((u32)(v)>>24)|(((v)>>8)&0x00ff00)| \ (((v)<<8)&0xff0000)|(u32)((v)<<24)) #endif diff --git a/pico/pico_types.h b/pico/pico_types.h index 6c95371d..0c842e92 100644 --- a/pico/pico_types.h +++ b/pico/pico_types.h @@ -11,6 +11,8 @@ typedef uint16_t u16; typedef int16_t s16; typedef uint32_t u32; typedef int32_t s32; +typedef uint64_t u64; +typedef int64_t s64; #endif #endif diff --git a/platform/psp/plat.c b/platform/psp/plat.c index e8a90694..fb7e310c 100644 --- a/platform/psp/plat.c +++ b/platform/psp/plat.c @@ -328,6 +328,9 @@ int _flush_cache (char *addr, const int size, const int op) } /* stubs for libflac (embedded in libchdr) */ +#include +#include + int chown(const char *pathname, uid_t owner, gid_t group) { return -1; } int chmod(const char *pathname, mode_t mode) { return -1; } int utime(const char *filename, const struct utimbuf *times) { return -1; }