mirror of
https://github.com/libretro/beetle-psx-libretro.git
synced 2024-11-23 08:49:47 +00:00
libchdr C89 compliance
This commit is contained in:
parent
b4fd7c5c44
commit
3dcc2a4593
6
deps/libchdr/include/libchdr/cdrom.h
vendored
6
deps/libchdr/include/libchdr/cdrom.h
vendored
@ -72,12 +72,12 @@ void ecc_clear(uint8_t *sector);
|
|||||||
INLINE FUNCTIONS
|
INLINE FUNCTIONS
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
static inline uint32_t msf_to_lba(uint32_t msf)
|
static INLINE uint32_t msf_to_lba(uint32_t msf)
|
||||||
{
|
{
|
||||||
return ( ((msf&0x00ff0000)>>16) * 60 * 75) + (((msf&0x0000ff00)>>8) * 75) + ((msf&0x000000ff)>>0);
|
return ( ((msf&0x00ff0000)>>16) * 60 * 75) + (((msf&0x0000ff00)>>8) * 75) + ((msf&0x000000ff)>>0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t lba_to_msf(uint32_t lba)
|
static INLINE uint32_t lba_to_msf(uint32_t lba)
|
||||||
{
|
{
|
||||||
uint8_t m, s, f;
|
uint8_t m, s, f;
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ static inline uint32_t lba_to_msf(uint32_t lba)
|
|||||||
* Angelo also says PCE tracks often start playing at the
|
* Angelo also says PCE tracks often start playing at the
|
||||||
* wrong address.. related?
|
* wrong address.. related?
|
||||||
**/
|
**/
|
||||||
static inline uint32_t lba_to_msf_alt(int lba)
|
static INLINE uint32_t lba_to_msf_alt(int lba)
|
||||||
{
|
{
|
||||||
uint32_t ret = 0;
|
uint32_t ret = 0;
|
||||||
|
|
||||||
|
2
deps/libchdr/include/libchdr/chdconfig.h
vendored
2
deps/libchdr/include/libchdr/chdconfig.h
vendored
@ -1,6 +1,8 @@
|
|||||||
#ifndef __CHDCONFIG_H__
|
#ifndef __CHDCONFIG_H__
|
||||||
#define __CHDCONFIG_H__
|
#define __CHDCONFIG_H__
|
||||||
|
|
||||||
|
#include <retro_inline.h>
|
||||||
|
|
||||||
/* Configure CHDR features here */
|
/* Configure CHDR features here */
|
||||||
#define WANT_RAW_DATA_SECTOR 1
|
#define WANT_RAW_DATA_SECTOR 1
|
||||||
#define WANT_SUBCODE 1
|
#define WANT_SUBCODE 1
|
||||||
|
10
deps/libchdr/include/libchdr/coretypes.h
vendored
10
deps/libchdr/include/libchdr/coretypes.h
vendored
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <retro_inline.h>
|
||||||
#ifdef USE_LIBRETRO_VFS
|
#ifdef USE_LIBRETRO_VFS
|
||||||
#include <streams/file_stream_transforms.h>
|
#include <streams/file_stream_transforms.h>
|
||||||
#endif
|
#endif
|
||||||
@ -45,19 +45,19 @@ typedef struct chd_core_file {
|
|||||||
int (*fseek)(struct chd_core_file*, int64_t, int);
|
int (*fseek)(struct chd_core_file*, int64_t, int);
|
||||||
} core_file;
|
} core_file;
|
||||||
|
|
||||||
static inline int core_fclose(core_file *fp) {
|
static INLINE int core_fclose(core_file *fp) {
|
||||||
return fp->fclose(fp);
|
return fp->fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t core_fread(core_file *fp, void *ptr, size_t len) {
|
static INLINE size_t core_fread(core_file *fp, void *ptr, size_t len) {
|
||||||
return fp->fread(ptr, 1, len, fp);
|
return fp->fread(ptr, 1, len, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int core_fseek(core_file* fp, int64_t offset, int whence) {
|
static INLINE int core_fseek(core_file* fp, int64_t offset, int whence) {
|
||||||
return fp->fseek(fp, offset, whence);
|
return fp->fseek(fp, offset, whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint64_t core_fsize(core_file *fp)
|
static INLINE uint64_t core_fsize(core_file *fp)
|
||||||
{
|
{
|
||||||
return fp->fsize(fp);
|
return fp->fsize(fp);
|
||||||
}
|
}
|
||||||
|
2
deps/libchdr/src/libchdr_cdrom.c
vendored
2
deps/libchdr/src/libchdr_cdrom.c
vendored
@ -304,7 +304,7 @@ static const uint16_t qoffsets[ECC_Q_NUM_BYTES][ECC_Q_COMP] =
|
|||||||
*-------------------------------------------------
|
*-------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline uint8_t ecc_source_byte(const uint8_t *sector, uint32_t offset)
|
static INLINE uint8_t ecc_source_byte(const uint8_t *sector, uint32_t offset)
|
||||||
{
|
{
|
||||||
/* in mode 2 always treat these as 0 bytes */
|
/* in mode 2 always treat these as 0 bytes */
|
||||||
return (sector[MODE_OFFSET] == 2 && offset < 4) ? 0x00 : sector[SYNC_OFFSET + SYNC_NUM_BYTES + offset];
|
return (sector[MODE_OFFSET] == 2 && offset < 4) ? 0x00 : sector[SYNC_OFFSET + SYNC_NUM_BYTES + offset];
|
||||||
|
38
deps/libchdr/src/libchdr_chd.c
vendored
38
deps/libchdr/src/libchdr_chd.c
vendored
@ -833,6 +833,7 @@ static void huff_codec_free(void *codec)
|
|||||||
|
|
||||||
static chd_error huff_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
|
static chd_error huff_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
|
||||||
{
|
{
|
||||||
|
uint32_t cur;
|
||||||
huff_codec_data* huff_codec = (huff_codec_data*) codec;
|
huff_codec_data* huff_codec = (huff_codec_data*) codec;
|
||||||
struct bitstream* bitbuf = create_bitstream(src, complen);
|
struct bitstream* bitbuf = create_bitstream(src, complen);
|
||||||
|
|
||||||
@ -845,7 +846,6 @@ static chd_error huff_codec_decompress(void *codec, const uint8_t *src, uint32_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// then decode the data
|
// then decode the data
|
||||||
uint32_t cur;
|
|
||||||
for (cur = 0; cur < destlen; cur++)
|
for (cur = 0; cur < destlen; cur++)
|
||||||
dest[cur] = huffman_decode_one(huff_codec->decoder, bitbuf);
|
dest[cur] = huffman_decode_one(huff_codec->decoder, bitbuf);
|
||||||
bitstream_flush(bitbuf);
|
bitstream_flush(bitbuf);
|
||||||
@ -1059,6 +1059,9 @@ static void zstd_codec_free(void* codec)
|
|||||||
*/
|
*/
|
||||||
static chd_error zstd_codec_decompress(void* codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
|
static chd_error zstd_codec_decompress(void* codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
|
||||||
{
|
{
|
||||||
|
ZSTD_inBuffer input = {src, complen, 0};
|
||||||
|
ZSTD_outBuffer output = {dest, destlen, 0 };
|
||||||
|
|
||||||
/* initialize */
|
/* initialize */
|
||||||
zstd_codec_data* zstd_codec = (zstd_codec_data*) codec;
|
zstd_codec_data* zstd_codec = (zstd_codec_data*) codec;
|
||||||
//reset decompressor
|
//reset decompressor
|
||||||
@ -1069,9 +1072,6 @@ static chd_error zstd_codec_decompress(void* codec, const uint8_t *src, uint32_t
|
|||||||
return CHDERR_DECOMPRESSION_ERROR;
|
return CHDERR_DECOMPRESSION_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZSTD_inBuffer input = {src, complen, 0};
|
|
||||||
ZSTD_outBuffer output = {dest, destlen, 0 };
|
|
||||||
|
|
||||||
while ((input.pos < input.size) && (output.pos < output.size))
|
while ((input.pos < input.size) && (output.pos < output.size))
|
||||||
{
|
{
|
||||||
zstd_res = ZSTD_decompressStream(zstd_codec->dstream, &output, &input);
|
zstd_res = ZSTD_decompressStream(zstd_codec->dstream, &output, &input);
|
||||||
@ -1320,7 +1320,7 @@ static const codec_interface codec_interfaces[] =
|
|||||||
the data stream in bigendian order
|
the data stream in bigendian order
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static inline uint64_t get_bigendian_uint64_t(const uint8_t *base)
|
static INLINE uint64_t get_bigendian_uint64_t(const uint8_t *base)
|
||||||
{
|
{
|
||||||
return ((uint64_t)base[0] << 56) | ((uint64_t)base[1] << 48) | ((uint64_t)base[2] << 40) | ((uint64_t)base[3] << 32) |
|
return ((uint64_t)base[0] << 56) | ((uint64_t)base[1] << 48) | ((uint64_t)base[2] << 40) | ((uint64_t)base[3] << 32) |
|
||||||
((uint64_t)base[4] << 24) | ((uint64_t)base[5] << 16) | ((uint64_t)base[6] << 8) | (uint64_t)base[7];
|
((uint64_t)base[4] << 24) | ((uint64_t)base[5] << 16) | ((uint64_t)base[6] << 8) | (uint64_t)base[7];
|
||||||
@ -1331,7 +1331,7 @@ static inline uint64_t get_bigendian_uint64_t(const uint8_t *base)
|
|||||||
the data stream in bigendian order
|
the data stream in bigendian order
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static inline void put_bigendian_uint64_t(uint8_t *base, uint64_t value)
|
static INLINE void put_bigendian_uint64_t(uint8_t *base, uint64_t value)
|
||||||
{
|
{
|
||||||
base[0] = value >> 56;
|
base[0] = value >> 56;
|
||||||
base[1] = value >> 48;
|
base[1] = value >> 48;
|
||||||
@ -1348,7 +1348,7 @@ static inline void put_bigendian_uint64_t(uint8_t *base, uint64_t value)
|
|||||||
the data stream in bigendian order
|
the data stream in bigendian order
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static inline uint64_t get_bigendian_uint48(const uint8_t *base)
|
static INLINE uint64_t get_bigendian_uint48(const uint8_t *base)
|
||||||
{
|
{
|
||||||
return ((uint64_t)base[0] << 40) | ((uint64_t)base[1] << 32) |
|
return ((uint64_t)base[0] << 40) | ((uint64_t)base[1] << 32) |
|
||||||
((uint64_t)base[2] << 24) | ((uint64_t)base[3] << 16) | ((uint64_t)base[4] << 8) | (uint64_t)base[5];
|
((uint64_t)base[2] << 24) | ((uint64_t)base[3] << 16) | ((uint64_t)base[4] << 8) | (uint64_t)base[5];
|
||||||
@ -1359,7 +1359,7 @@ static inline uint64_t get_bigendian_uint48(const uint8_t *base)
|
|||||||
the data stream in bigendian order
|
the data stream in bigendian order
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static inline void put_bigendian_uint48(uint8_t *base, uint64_t value)
|
static INLINE void put_bigendian_uint48(uint8_t *base, uint64_t value)
|
||||||
{
|
{
|
||||||
value &= 0xffffffffffff;
|
value &= 0xffffffffffff;
|
||||||
base[0] = value >> 40;
|
base[0] = value >> 40;
|
||||||
@ -1374,7 +1374,7 @@ static inline void put_bigendian_uint48(uint8_t *base, uint64_t value)
|
|||||||
the data stream in bigendian order
|
the data stream in bigendian order
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static inline uint32_t get_bigendian_uint32_t(const uint8_t *base)
|
static INLINE uint32_t get_bigendian_uint32_t(const uint8_t *base)
|
||||||
{
|
{
|
||||||
return (base[0] << 24) | (base[1] << 16) | (base[2] << 8) | base[3];
|
return (base[0] << 24) | (base[1] << 16) | (base[2] << 8) | base[3];
|
||||||
}
|
}
|
||||||
@ -1384,7 +1384,7 @@ static inline uint32_t get_bigendian_uint32_t(const uint8_t *base)
|
|||||||
the data stream in bigendian order
|
the data stream in bigendian order
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static inline void put_bigendian_uint32_t(uint8_t *base, uint32_t value)
|
static INLINE void put_bigendian_uint32_t(uint8_t *base, uint32_t value)
|
||||||
{
|
{
|
||||||
base[0] = value >> 24;
|
base[0] = value >> 24;
|
||||||
base[1] = value >> 16;
|
base[1] = value >> 16;
|
||||||
@ -1397,7 +1397,7 @@ static inline void put_bigendian_uint32_t(uint8_t *base, uint32_t value)
|
|||||||
the data stream in bigendian order
|
the data stream in bigendian order
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static inline void put_bigendian_uint24(uint8_t *base, uint32_t value)
|
static INLINE void put_bigendian_uint24(uint8_t *base, uint32_t value)
|
||||||
{
|
{
|
||||||
value &= 0xffffff;
|
value &= 0xffffff;
|
||||||
base[0] = value >> 16;
|
base[0] = value >> 16;
|
||||||
@ -1410,7 +1410,7 @@ static inline void put_bigendian_uint24(uint8_t *base, uint32_t value)
|
|||||||
the data stream in bigendian order
|
the data stream in bigendian order
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static inline uint32_t get_bigendian_uint24(const uint8_t *base)
|
static INLINE uint32_t get_bigendian_uint24(const uint8_t *base)
|
||||||
{
|
{
|
||||||
return (base[0] << 16) | (base[1] << 8) | base[2];
|
return (base[0] << 16) | (base[1] << 8) | base[2];
|
||||||
}
|
}
|
||||||
@ -1420,7 +1420,7 @@ static inline uint32_t get_bigendian_uint24(const uint8_t *base)
|
|||||||
the data stream in bigendian order
|
the data stream in bigendian order
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static inline uint16_t get_bigendian_uint16(const uint8_t *base)
|
static INLINE uint16_t get_bigendian_uint16(const uint8_t *base)
|
||||||
{
|
{
|
||||||
return (base[0] << 8) | base[1];
|
return (base[0] << 8) | base[1];
|
||||||
}
|
}
|
||||||
@ -1430,7 +1430,7 @@ static inline uint16_t get_bigendian_uint16(const uint8_t *base)
|
|||||||
the data stream in bigendian order
|
the data stream in bigendian order
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static inline void put_bigendian_uint16(uint8_t *base, uint16_t value)
|
static INLINE void put_bigendian_uint16(uint8_t *base, uint16_t value)
|
||||||
{
|
{
|
||||||
base[0] = value >> 8;
|
base[0] = value >> 8;
|
||||||
base[1] = value;
|
base[1] = value;
|
||||||
@ -1441,7 +1441,7 @@ static inline void put_bigendian_uint16(uint8_t *base, uint16_t value)
|
|||||||
entry from the datastream
|
entry from the datastream
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static inline void map_extract(const uint8_t *base, map_entry *entry)
|
static INLINE void map_extract(const uint8_t *base, map_entry *entry)
|
||||||
{
|
{
|
||||||
entry->offset = get_bigendian_uint64_t(&base[0]);
|
entry->offset = get_bigendian_uint64_t(&base[0]);
|
||||||
entry->crc = get_bigendian_uint32_t(&base[8]);
|
entry->crc = get_bigendian_uint32_t(&base[8]);
|
||||||
@ -1454,7 +1454,7 @@ static inline void map_extract(const uint8_t *base, map_entry *entry)
|
|||||||
entry to the datastream
|
entry to the datastream
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static inline void map_assemble(uint8_t *base, map_entry *entry)
|
static INLINE void map_assemble(uint8_t *base, map_entry *entry)
|
||||||
{
|
{
|
||||||
put_bigendian_uint64_t(&base[0], entry->offset);
|
put_bigendian_uint64_t(&base[0], entry->offset);
|
||||||
put_bigendian_uint32_t(&base[8], entry->crc);
|
put_bigendian_uint32_t(&base[8], entry->crc);
|
||||||
@ -1466,7 +1466,7 @@ static inline void map_assemble(uint8_t *base, map_entry *entry)
|
|||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
map_size_v5 - calculate CHDv5 map size
|
map_size_v5 - calculate CHDv5 map size
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
static inline int map_size_v5(chd_header* header)
|
static INLINE int map_size_v5(chd_header* header)
|
||||||
{
|
{
|
||||||
return header->hunkcount * header->mapentrybytes;
|
return header->hunkcount * header->mapentrybytes;
|
||||||
}
|
}
|
||||||
@ -1525,7 +1525,7 @@ uint16_t crc16(const void *data, uint32_t length)
|
|||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
compressed - test if CHD file is compressed
|
compressed - test if CHD file is compressed
|
||||||
+-------------------------------------------------*/
|
+-------------------------------------------------*/
|
||||||
static inline int chd_compressed(chd_header* header) {
|
static INLINE int chd_compressed(chd_header* header) {
|
||||||
return header->compression[0] != CHD_CODEC_NONE;
|
return header->compression[0] != CHD_CODEC_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1705,7 +1705,7 @@ static chd_error decompress_v5_map(chd_file* chd, chd_header* header)
|
|||||||
entry in old format from the datastream
|
entry in old format from the datastream
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static inline void map_extract_old(const uint8_t *base, map_entry *entry, uint32_t hunkbytes)
|
static INLINE void map_extract_old(const uint8_t *base, map_entry *entry, uint32_t hunkbytes)
|
||||||
{
|
{
|
||||||
entry->offset = get_bigendian_uint64_t(&base[0]);
|
entry->offset = get_bigendian_uint64_t(&base[0]);
|
||||||
entry->crc = 0;
|
entry->crc = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user