Skip to content

Commit 7e74808

Browse files
committed
Resync
1 parent 53200fa commit 7e74808

10 files changed

Lines changed: 83 additions & 67 deletions

File tree

formats/cdfs/cdfs.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ static void cdfs_determine_sector_size(cdfs_track_t* track)
3232
return;
3333

3434
/* if this is a CDROM-XA data source, the "CD001" tag will be 25 bytes into the sector */
35-
if ( buffer[25] == 0x43
35+
if ( buffer[25] == 0x43
3636
&& buffer[26] == 0x44
37-
&& buffer[27] == 0x30
38-
&& buffer[28] == 0x30
37+
&& buffer[27] == 0x30
38+
&& buffer[28] == 0x30
3939
&& buffer[29] == 0x31)
4040
{
4141
track->stream_sector_size = 2352;
@@ -44,8 +44,8 @@ static void cdfs_determine_sector_size(cdfs_track_t* track)
4444
/* otherwise it should be 17 bytes into the sector */
4545
else if (buffer[17] == 0x43
4646
&& buffer[18] == 0x44
47-
&& buffer[19] == 0x30
48-
&& buffer[20] == 0x30
47+
&& buffer[19] == 0x30
48+
&& buffer[20] == 0x30
4949
&& buffer[21] == 0x31)
5050
{
5151
track->stream_sector_size = 2352;
@@ -65,7 +65,7 @@ static void cdfs_determine_sector_size(cdfs_track_t* track)
6565
&& buffer[ 7] == 0xFF
6666
&& buffer[ 8] == 0xFF
6767
&& buffer[ 9] == 0xFF
68-
&& buffer[10] == 0xFF
68+
&& buffer[10] == 0xFF
6969
&& buffer[11] == 0)
7070
{
7171
/* if we didn't find a CD001 tag, this format may predate ISO-9660 */
@@ -80,21 +80,21 @@ static void cdfs_determine_sector_size(cdfs_track_t* track)
8080
static void cdfs_determine_sector_size_from_file_size(cdfs_track_t* track)
8181
{
8282
/* attempt to determine stream_sector_size from file size */
83-
size_t size = intfstream_get_size(track->stream);
83+
size_t _len = intfstream_get_size(track->stream);
8484

85-
if ((size % 2352) == 0)
85+
if ((_len % 2352) == 0)
8686
{
8787
/* raw tracks use all 2352 bytes and have a 24 byte header */
8888
track->stream_sector_size = 2352;
8989
track->stream_sector_header_size = 24;
9090
}
91-
else if ((size % 2048) == 0)
91+
else if ((_len % 2048) == 0)
9292
{
9393
/* cooked tracks eliminate all header/footer data */
9494
track->stream_sector_size = 2048;
9595
track->stream_sector_header_size = 0;
9696
}
97-
else if ((size % 2336) == 0)
97+
else if ((_len % 2336) == 0)
9898
{
9999
/* MODE 2 format without 16-byte sync data */
100100
track->stream_sector_size = 2336;
@@ -172,7 +172,7 @@ static int cdfs_find_file(cdfs_file_t* file, const char* path)
172172
intfstream_read(file->track->stream, buffer, sizeof(buffer));
173173

174174
/* the directory_record starts at 156 bytes into the sector.
175-
* the sector containing the root directory contents is a
175+
* the sector containing the root directory contents is a
176176
* 3 byte value that is 2 bytes into the directory_record. */
177177
offset = 156 + 2;
178178
sector = buffer[offset] | (buffer[offset + 1] << 8) | (buffer[offset + 2] << 16);
@@ -187,25 +187,25 @@ static int cdfs_find_file(cdfs_file_t* file, const char* path)
187187

188188
while (tmp < buffer + sizeof(buffer))
189189
{
190-
/* The first byte of the record is the length of
190+
/* The first byte of the record is the length of
191191
* the record - if 0, we reached the end of the data */
192192
if (!*tmp)
193193
break;
194194

195-
/* filename is 33 bytes into the record and
195+
/* filename is 33 bytes into the record and
196196
* the format is "FILENAME;version" or "DIRECTORY" */
197-
if ( (tmp[33 + path_length] == ';'
197+
if ( (tmp[33 + path_length] == ';'
198198
|| (tmp[33 + path_length] == '\0'))
199199
&& strncasecmp((const char*)(tmp + 33), path, path_length) == 0)
200200
{
201201
/* the file size is in bytes 10-13 of the record */
202-
file->size =
202+
file->size =
203203
(tmp[10])
204-
| (tmp[11] << 8)
205-
| (tmp[12] << 16)
204+
| (tmp[11] << 8)
205+
| (tmp[12] << 16)
206206
| (tmp[13] << 24);
207207

208-
/* the file contents are in the sector identified
208+
/* the file contents are in the sector identified
209209
* in bytes 2-4 of the record */
210210
sector = tmp[2] | (tmp[3] << 8) | (tmp[4] << 16);
211211
return sector;
@@ -235,7 +235,7 @@ int cdfs_open_file(cdfs_file_t* file, cdfs_track_t* track, const char* path)
235235
{
236236
file->first_sector = 0;
237237
file->size = (unsigned int)((intfstream_get_size(
238-
file->track->stream) / file->track->stream_sector_size)
238+
file->track->stream) / file->track->stream_sector_size)
239239
* 2048);
240240
return 1;
241241
}
@@ -319,8 +319,8 @@ int64_t cdfs_read_file(cdfs_file_t* file, void* buffer, uint64_t len)
319319

320320
void cdfs_close_file(cdfs_file_t* file)
321321
{
322-
/* Not really anything to do here, just
323-
* clear out the first_sector so
322+
/* Not really anything to do here, just
323+
* clear out the first_sector so
324324
* read() won't do anything */
325325
if (file)
326326
file->first_sector = -1;
@@ -461,7 +461,7 @@ static cdfs_track_t* cdfs_open_cue_track(
461461
while (file_end > file && *file_end != ' ' && *file_end != '\t')
462462
--file_end;
463463

464-
if ( file[0] == '"'
464+
if ( file[0] == '"'
465465
&& file_end[-1] == '"')
466466
{
467467
++file;

formats/libchdr/libchdr_chd.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,14 +1568,14 @@ static chd_error hunk_read_into_cache(chd_file *chd, UINT32 hunknum)
15681568
hunk
15691569
-------------------------------------------------*/
15701570

1571-
static UINT8* hunk_read_compressed(chd_file *chd, UINT64 offset, size_t size)
1571+
static UINT8* hunk_read_compressed(chd_file *chd, UINT64 offset, size_t len)
15721572
{
15731573
int64_t bytes;
15741574
if (chd->file_cache)
15751575
return chd->file_cache + offset;
15761576
filestream_seek(chd->file, offset, SEEK_SET);
1577-
bytes = filestream_read(chd->file, chd->compressed, size);
1578-
if (bytes != (int64_t)size)
1577+
bytes = filestream_read(chd->file, chd->compressed, len);
1578+
if (bytes != (int64_t)len)
15791579
return NULL;
15801580
return chd->compressed;
15811581
}
@@ -1585,17 +1585,17 @@ static UINT8* hunk_read_compressed(chd_file *chd, UINT64 offset, size_t size)
15851585
hunk
15861586
-------------------------------------------------*/
15871587

1588-
static chd_error hunk_read_uncompressed(chd_file *chd, UINT64 offset, size_t size, UINT8 *dest)
1588+
static chd_error hunk_read_uncompressed(chd_file *chd, UINT64 offset, size_t len, UINT8 *dest)
15891589
{
15901590
int64_t bytes;
15911591
if (chd->file_cache)
15921592
{
1593-
memcpy(dest, chd->file_cache + offset, size);
1593+
memcpy(dest, chd->file_cache + offset, len);
15941594
return CHDERR_NONE;
15951595
}
15961596
filestream_seek(chd->file, offset, SEEK_SET);
1597-
bytes = filestream_read(chd->file, dest, size);
1598-
if (bytes != (int64_t)size)
1597+
bytes = filestream_read(chd->file, dest, len);
1598+
if (bytes != (int64_t)len)
15991599
return CHDERR_READ_ERROR;
16001600
return CHDERR_NONE;
16011601
}

formats/wav/rwav.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ struct rwav_iterator
4646
int step;
4747
};
4848

49-
void rwav_init(rwav_iterator_t* iter, rwav_t* out, const void* buf, size_t size)
49+
void rwav_init(rwav_iterator_t* iter, rwav_t* out, const void *s, size_t len)
5050
{
5151
iter->out = out;
52-
iter->data = (const uint8_t*)buf;
53-
iter->size = size;
52+
iter->data = (const uint8_t*)s;
53+
iter->size = len;
5454
iter->step = ITER_BEGIN;
5555

5656
out->samples = NULL;
@@ -159,7 +159,7 @@ enum rwav_state rwav_iterate(rwav_iterator_t *iter)
159159
return RWAV_ITERATE_ERROR;
160160
}
161161

162-
enum rwav_state rwav_load(rwav_t* out, const void* buf, size_t size)
162+
enum rwav_state rwav_load(rwav_t* out, const void *s, size_t len)
163163
{
164164
enum rwav_state res;
165165
rwav_iterator_t iter;
@@ -171,7 +171,7 @@ enum rwav_state rwav_load(rwav_t* out, const void* buf, size_t size)
171171
iter.j = 0;
172172
iter.step = 0;
173173

174-
rwav_init(&iter, out, buf, size);
174+
rwav_init(&iter, out, s, len);
175175

176176
do
177177
{

hash/lrc_hash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static void sha256_block(struct sha256_ctx *p)
123123
}
124124

125125
static void sha256_chunk(struct sha256_ctx *p,
126-
const uint8_t *s, unsigned len)
126+
const uint8_t *s, size_t len)
127127
{
128128
p->len += len;
129129

@@ -191,7 +191,7 @@ void sha256_hash(char *s, const uint8_t *in, size_t len)
191191
} shahash;
192192

193193
sha256_init(&sha);
194-
sha256_chunk(&sha, in, (unsigned)len);
194+
sha256_chunk(&sha, in, len);
195195
sha256_final(&sha);
196196
sha256_subhash(&sha, shahash.u32);
197197

include/formats/image.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ bool image_texture_color_convert(unsigned r_shift,
6868
struct texture_image *out_img);
6969

7070
bool image_texture_load_buffer(struct texture_image *img,
71-
enum image_type_enum type, void *buffer, size_t buffer_len);
71+
enum image_type_enum type, void *s, size_t len);
7272

7373
bool image_texture_load(struct texture_image *img, const char *path);
7474
void image_texture_free(struct texture_image *img);
@@ -90,8 +90,10 @@ void image_transfer_set_buffer_ptr(
9090
int image_transfer_process(
9191
void *data,
9292
enum image_type_enum type,
93-
uint32_t **buf, size_t size,
94-
unsigned *width, unsigned *height);
93+
uint32_t **buf,
94+
size_t len,
95+
unsigned *width,
96+
unsigned *height);
9597

9698
bool image_transfer_iterate(void *data, enum image_type_enum type);
9799

include/formats/rwav.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ typedef struct rwav_iterator rwav_iterator_t;
6262
/**
6363
* Initializes the iterator to fill the out structure with data parsed from buf.
6464
*/
65-
void rwav_init(rwav_iterator_t* iter, rwav_t* out, const void* buf, size_t size);
65+
void rwav_init(rwav_iterator_t *iter, rwav_t *out, const void* buf, size_t len);
6666

6767
/**
6868
* Parses a piece of the data. Continue calling as long as it returns RWAV_ITERATE_MORE.
@@ -75,7 +75,7 @@ enum rwav_state rwav_iterate(rwav_iterator_t *iter);
7575
/**
7676
* Loads the entire data in one go.
7777
*/
78-
enum rwav_state rwav_load(rwav_t* out, const void* buf, size_t size);
78+
enum rwav_state rwav_load(rwav_t *out, const void *buf, size_t len);
7979

8080
/**
8181
* Frees parsed wave data.

include/libretro.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5365,14 +5365,14 @@ typedef bool (RETRO_CALLCONV *retro_set_initial_image_t)(unsigned index, const c
53655365
* on the host's file system.
53665366
*
53675367
* @param index The index of the disk image to get the path of.
5368-
* @param path A buffer to store the path in.
5369-
* @param len The size of \c path, in bytes.
5368+
* @param s A buffer to store the path in.
5369+
* @param len The size of \c s, in bytes.
53705370
* @return \c true if the disk image's location was successfully
5371-
* queried and copied into \c path,
5371+
* queried and copied into \c s,
53725372
* \c false if the index is invalid
53735373
* or the core couldn't locate the disk image.
53745374
*/
5375-
typedef bool (RETRO_CALLCONV *retro_get_image_path_t)(unsigned index, char *path, size_t len);
5375+
typedef bool (RETRO_CALLCONV *retro_get_image_path_t)(unsigned index, char *s, size_t len);
53765376

53775377
/**
53785378
* Returns a friendly label for the given disk image.
@@ -5388,12 +5388,12 @@ typedef bool (RETRO_CALLCONV *retro_get_image_path_t)(unsigned index, char *path
53885388
* so that the frontend can provide better guidance to the player.
53895389
*
53905390
* @param index The index of the disk image to return a label for.
5391-
* @param label A buffer to store the resulting label in.
5392-
* @param len The length of \c label, in bytes.
5391+
* @param s A buffer to store the resulting label in.
5392+
* @param len The length of \c s, in bytes.
53935393
* @return \c true if the disk image at \c index is valid
5394-
* and a label was copied into \c label.
5394+
* and a label was copied into \c s.
53955395
*/
5396-
typedef bool (RETRO_CALLCONV *retro_get_image_label_t)(unsigned index, char *label, size_t len);
5396+
typedef bool (RETRO_CALLCONV *retro_get_image_label_t)(unsigned index, char *s, size_t len);
53975397

53985398
/**
53995399
* An interface that the frontend can use to exchange disks
@@ -7705,7 +7705,7 @@ RETRO_API size_t retro_serialize_size(void);
77057705
* @see retro_serialize_size()
77067706
* @see retro_unserialize()
77077707
*/
7708-
RETRO_API bool retro_serialize(void *data, size_t size);
7708+
RETRO_API bool retro_serialize(void *data, size_t len);
77097709

77107710
/**
77117711
* Unserialize the given state data, and load it into the internal state.
@@ -7714,7 +7714,7 @@ RETRO_API bool retro_serialize(void *data, size_t size);
77147714
*
77157715
* @see retro_serialize()
77167716
*/
7717-
RETRO_API bool retro_unserialize(const void *data, size_t size);
7717+
RETRO_API bool retro_unserialize(const void *data, size_t len);
77187718

77197719
/**
77207720
* Reset all the active cheats to their default disabled state.

include/lrc_hash.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ RETRO_BEGIN_DECLS
3939

4040
/**
4141
* sha256_hash:
42-
* @out : Output.
42+
* @s : Output.
4343
* @in : Input.
44-
* @size : Size of @out.
44+
* @len : Size of @out.
4545
*
4646
* Hashes SHA256 and outputs a human readable string.
4747
**/
48-
void sha256_hash(char *out, const uint8_t *in, size_t size);
48+
void sha256_hash(char *s, const uint8_t *in, size_t len);
4949

5050
int sha1_calculate(const char *path, char *result);
5151

include/retro_math.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define _LIBRETRO_COMMON_MATH_H
2525

2626
#include <stdint.h>
27+
#include <stdlib.h>
2728

2829
#if defined(_WIN32) && !defined(_XBOX)
2930
#define WIN32_LEAN_AND_MEAN
@@ -126,7 +127,7 @@ static INLINE float saturate_value(float v)
126127
*
127128
* Returns: dot product value (derived from @a and @b).
128129
**/
129-
static INLINE float dot_product(const float* a, const float* b)
130+
static INLINE float dot_product(const float* a, const float* b)
130131
{
131132
return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]);
132133
}
@@ -140,7 +141,7 @@ static INLINE float dot_product(const float* a, const float* b)
140141
*
141142
* Returns: Yxy colour space value (derived from @rgb).
142143
**/
143-
static INLINE void convert_rgb_to_yxy(const float* rgb, float* Yxy)
144+
static INLINE void convert_rgb_to_yxy(const float* rgb, float* Yxy)
144145
{
145146
float inv;
146147
float xyz[3];
@@ -156,11 +157,11 @@ static INLINE void convert_rgb_to_yxy(const float* rgb, float* Yxy)
156157
xyz[2] = dot_product(rgb_xyz[2], rgb);
157158

158159
inv = 1.0f / dot_product(xyz, one);
159-
Yxy[0] = xyz[1];
160+
Yxy[0] = xyz[1];
160161
Yxy[1] = xyz[0] * inv;
161162
Yxy[2] = xyz[1] * inv;
162163
}
163-
164+
164165
/**
165166
* convert_yxy_to_rgb:
166167
* @rgb : in Yxy colour space value
@@ -187,4 +188,17 @@ static INLINE void convert_yxy_to_rgb(const float* Yxy, float* rgb)
187188
rgb[2] = dot_product(xyz_rgb[2], xyz);
188189
}
189190

191+
/**
192+
* Picks a random value between a specified range.
193+
*
194+
* @param \c min unsigned minimum possible value.
195+
* @param \c max unsigned maximum possible value.
196+
*
197+
* @return unsigned random value between \c min and \c max (inclusive).
198+
*/
199+
static INLINE size_t random_range(unsigned min, unsigned max)
200+
{
201+
return (min == max) ? min : (size_t)((float)rand() / (float)RAND_MAX * (max + 1 - min) + min);
202+
}
203+
190204
#endif

0 commit comments

Comments
 (0)