Skip to content

Commit a3f853a

Browse files
committed
libchdr C89 compliance
1 parent fcab505 commit a3f853a

File tree

5 files changed

+30
-28
lines changed

5 files changed

+30
-28
lines changed

deps/libchdr/include/libchdr/cdrom.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ void ecc_clear(uint8_t *sector);
7272
INLINE FUNCTIONS
7373
***************************************************************************/
7474

75-
static inline uint32_t msf_to_lba(uint32_t msf)
75+
static INLINE uint32_t msf_to_lba(uint32_t msf)
7676
{
7777
return ( ((msf&0x00ff0000)>>16) * 60 * 75) + (((msf&0x0000ff00)>>8) * 75) + ((msf&0x000000ff)>>0);
7878
}
7979

80-
static inline uint32_t lba_to_msf(uint32_t lba)
80+
static INLINE uint32_t lba_to_msf(uint32_t lba)
8181
{
8282
uint8_t m, s, f;
8383

@@ -96,7 +96,7 @@ static inline uint32_t lba_to_msf(uint32_t lba)
9696
* Angelo also says PCE tracks often start playing at the
9797
* wrong address.. related?
9898
**/
99-
static inline uint32_t lba_to_msf_alt(int lba)
99+
static INLINE uint32_t lba_to_msf_alt(int lba)
100100
{
101101
uint32_t ret = 0;
102102

deps/libchdr/include/libchdr/chdconfig.h

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef __CHDCONFIG_H__
22
#define __CHDCONFIG_H__
33

4+
#include <retro_inline.h>
5+
46
/* Configure CHDR features here */
57
#define WANT_RAW_DATA_SECTOR 1
68
#define WANT_SUBCODE 1

deps/libchdr/include/libchdr/coretypes.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <stdint.h>
55
#include <stdio.h>
6-
6+
#include <retro_inline.h>
77
#ifdef USE_LIBRETRO_VFS
88
#include <streams/file_stream_transforms.h>
99
#endif
@@ -45,19 +45,19 @@ typedef struct chd_core_file {
4545
int (*fseek)(struct chd_core_file*, int64_t, int);
4646
} core_file;
4747

48-
static inline int core_fclose(core_file *fp) {
48+
static INLINE int core_fclose(core_file *fp) {
4949
return fp->fclose(fp);
5050
}
5151

52-
static inline size_t core_fread(core_file *fp, void *ptr, size_t len) {
52+
static INLINE size_t core_fread(core_file *fp, void *ptr, size_t len) {
5353
return fp->fread(ptr, 1, len, fp);
5454
}
5555

56-
static inline int core_fseek(core_file* fp, int64_t offset, int whence) {
56+
static INLINE int core_fseek(core_file* fp, int64_t offset, int whence) {
5757
return fp->fseek(fp, offset, whence);
5858
}
5959

60-
static inline uint64_t core_fsize(core_file *fp)
60+
static INLINE uint64_t core_fsize(core_file *fp)
6161
{
6262
return fp->fsize(fp);
6363
}

deps/libchdr/src/libchdr_cdrom.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ static const uint16_t qoffsets[ECC_Q_NUM_BYTES][ECC_Q_COMP] =
304304
*-------------------------------------------------
305305
*/
306306

307-
static inline uint8_t ecc_source_byte(const uint8_t *sector, uint32_t offset)
307+
static INLINE uint8_t ecc_source_byte(const uint8_t *sector, uint32_t offset)
308308
{
309309
/* in mode 2 always treat these as 0 bytes */
310310
return (sector[MODE_OFFSET] == 2 && offset < 4) ? 0x00 : sector[SYNC_OFFSET + SYNC_NUM_BYTES + offset];

deps/libchdr/src/libchdr_chd.c

+19-19
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,7 @@ static void huff_codec_free(void *codec)
833833

834834
static chd_error huff_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
835835
{
836+
uint32_t cur;
836837
huff_codec_data* huff_codec = (huff_codec_data*) codec;
837838
struct bitstream* bitbuf = create_bitstream(src, complen);
838839

@@ -845,7 +846,6 @@ static chd_error huff_codec_decompress(void *codec, const uint8_t *src, uint32_t
845846
}
846847

847848
// then decode the data
848-
uint32_t cur;
849849
for (cur = 0; cur < destlen; cur++)
850850
dest[cur] = huffman_decode_one(huff_codec->decoder, bitbuf);
851851
bitstream_flush(bitbuf);
@@ -1059,6 +1059,9 @@ static void zstd_codec_free(void* codec)
10591059
*/
10601060
static chd_error zstd_codec_decompress(void* codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
10611061
{
1062+
ZSTD_inBuffer input = {src, complen, 0};
1063+
ZSTD_outBuffer output = {dest, destlen, 0 };
1064+
10621065
/* initialize */
10631066
zstd_codec_data* zstd_codec = (zstd_codec_data*) codec;
10641067
//reset decompressor
@@ -1069,9 +1072,6 @@ static chd_error zstd_codec_decompress(void* codec, const uint8_t *src, uint32_t
10691072
return CHDERR_DECOMPRESSION_ERROR;
10701073
}
10711074

1072-
ZSTD_inBuffer input = {src, complen, 0};
1073-
ZSTD_outBuffer output = {dest, destlen, 0 };
1074-
10751075
while ((input.pos < input.size) && (output.pos < output.size))
10761076
{
10771077
zstd_res = ZSTD_decompressStream(zstd_codec->dstream, &output, &input);
@@ -1320,7 +1320,7 @@ static const codec_interface codec_interfaces[] =
13201320
the data stream in bigendian order
13211321
-------------------------------------------------*/
13221322

1323-
static inline uint64_t get_bigendian_uint64_t(const uint8_t *base)
1323+
static INLINE uint64_t get_bigendian_uint64_t(const uint8_t *base)
13241324
{
13251325
return ((uint64_t)base[0] << 56) | ((uint64_t)base[1] << 48) | ((uint64_t)base[2] << 40) | ((uint64_t)base[3] << 32) |
13261326
((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)
13311331
the data stream in bigendian order
13321332
-------------------------------------------------*/
13331333

1334-
static inline void put_bigendian_uint64_t(uint8_t *base, uint64_t value)
1334+
static INLINE void put_bigendian_uint64_t(uint8_t *base, uint64_t value)
13351335
{
13361336
base[0] = value >> 56;
13371337
base[1] = value >> 48;
@@ -1348,7 +1348,7 @@ static inline void put_bigendian_uint64_t(uint8_t *base, uint64_t value)
13481348
the data stream in bigendian order
13491349
-------------------------------------------------*/
13501350

1351-
static inline uint64_t get_bigendian_uint48(const uint8_t *base)
1351+
static INLINE uint64_t get_bigendian_uint48(const uint8_t *base)
13521352
{
13531353
return ((uint64_t)base[0] << 40) | ((uint64_t)base[1] << 32) |
13541354
((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)
13591359
the data stream in bigendian order
13601360
-------------------------------------------------*/
13611361

1362-
static inline void put_bigendian_uint48(uint8_t *base, uint64_t value)
1362+
static INLINE void put_bigendian_uint48(uint8_t *base, uint64_t value)
13631363
{
13641364
value &= 0xffffffffffff;
13651365
base[0] = value >> 40;
@@ -1374,7 +1374,7 @@ static inline void put_bigendian_uint48(uint8_t *base, uint64_t value)
13741374
the data stream in bigendian order
13751375
-------------------------------------------------*/
13761376

1377-
static inline uint32_t get_bigendian_uint32_t(const uint8_t *base)
1377+
static INLINE uint32_t get_bigendian_uint32_t(const uint8_t *base)
13781378
{
13791379
return (base[0] << 24) | (base[1] << 16) | (base[2] << 8) | base[3];
13801380
}
@@ -1384,7 +1384,7 @@ static inline uint32_t get_bigendian_uint32_t(const uint8_t *base)
13841384
the data stream in bigendian order
13851385
-------------------------------------------------*/
13861386

1387-
static inline void put_bigendian_uint32_t(uint8_t *base, uint32_t value)
1387+
static INLINE void put_bigendian_uint32_t(uint8_t *base, uint32_t value)
13881388
{
13891389
base[0] = value >> 24;
13901390
base[1] = value >> 16;
@@ -1397,7 +1397,7 @@ static inline void put_bigendian_uint32_t(uint8_t *base, uint32_t value)
13971397
the data stream in bigendian order
13981398
-------------------------------------------------*/
13991399

1400-
static inline void put_bigendian_uint24(uint8_t *base, uint32_t value)
1400+
static INLINE void put_bigendian_uint24(uint8_t *base, uint32_t value)
14011401
{
14021402
value &= 0xffffff;
14031403
base[0] = value >> 16;
@@ -1410,7 +1410,7 @@ static inline void put_bigendian_uint24(uint8_t *base, uint32_t value)
14101410
the data stream in bigendian order
14111411
-------------------------------------------------*/
14121412

1413-
static inline uint32_t get_bigendian_uint24(const uint8_t *base)
1413+
static INLINE uint32_t get_bigendian_uint24(const uint8_t *base)
14141414
{
14151415
return (base[0] << 16) | (base[1] << 8) | base[2];
14161416
}
@@ -1420,7 +1420,7 @@ static inline uint32_t get_bigendian_uint24(const uint8_t *base)
14201420
the data stream in bigendian order
14211421
-------------------------------------------------*/
14221422

1423-
static inline uint16_t get_bigendian_uint16(const uint8_t *base)
1423+
static INLINE uint16_t get_bigendian_uint16(const uint8_t *base)
14241424
{
14251425
return (base[0] << 8) | base[1];
14261426
}
@@ -1430,7 +1430,7 @@ static inline uint16_t get_bigendian_uint16(const uint8_t *base)
14301430
the data stream in bigendian order
14311431
-------------------------------------------------*/
14321432

1433-
static inline void put_bigendian_uint16(uint8_t *base, uint16_t value)
1433+
static INLINE void put_bigendian_uint16(uint8_t *base, uint16_t value)
14341434
{
14351435
base[0] = value >> 8;
14361436
base[1] = value;
@@ -1441,7 +1441,7 @@ static inline void put_bigendian_uint16(uint8_t *base, uint16_t value)
14411441
entry from the datastream
14421442
-------------------------------------------------*/
14431443

1444-
static inline void map_extract(const uint8_t *base, map_entry *entry)
1444+
static INLINE void map_extract(const uint8_t *base, map_entry *entry)
14451445
{
14461446
entry->offset = get_bigendian_uint64_t(&base[0]);
14471447
entry->crc = get_bigendian_uint32_t(&base[8]);
@@ -1454,7 +1454,7 @@ static inline void map_extract(const uint8_t *base, map_entry *entry)
14541454
entry to the datastream
14551455
-------------------------------------------------*/
14561456

1457-
static inline void map_assemble(uint8_t *base, map_entry *entry)
1457+
static INLINE void map_assemble(uint8_t *base, map_entry *entry)
14581458
{
14591459
put_bigendian_uint64_t(&base[0], entry->offset);
14601460
put_bigendian_uint32_t(&base[8], entry->crc);
@@ -1466,7 +1466,7 @@ static inline void map_assemble(uint8_t *base, map_entry *entry)
14661466
/*-------------------------------------------------
14671467
map_size_v5 - calculate CHDv5 map size
14681468
-------------------------------------------------*/
1469-
static inline int map_size_v5(chd_header* header)
1469+
static INLINE int map_size_v5(chd_header* header)
14701470
{
14711471
return header->hunkcount * header->mapentrybytes;
14721472
}
@@ -1525,7 +1525,7 @@ uint16_t crc16(const void *data, uint32_t length)
15251525
/*-------------------------------------------------
15261526
compressed - test if CHD file is compressed
15271527
+-------------------------------------------------*/
1528-
static inline int chd_compressed(chd_header* header) {
1528+
static INLINE int chd_compressed(chd_header* header) {
15291529
return header->compression[0] != CHD_CODEC_NONE;
15301530
}
15311531

@@ -1705,7 +1705,7 @@ static chd_error decompress_v5_map(chd_file* chd, chd_header* header)
17051705
entry in old format from the datastream
17061706
-------------------------------------------------*/
17071707

1708-
static inline void map_extract_old(const uint8_t *base, map_entry *entry, uint32_t hunkbytes)
1708+
static INLINE void map_extract_old(const uint8_t *base, map_entry *entry, uint32_t hunkbytes)
17091709
{
17101710
entry->offset = get_bigendian_uint64_t(&base[0]);
17111711
entry->crc = 0;

0 commit comments

Comments
 (0)