update libretro-common

This commit is contained in:
zeromus 2016-03-29 06:10:12 +00:00
parent 7e43d12cc7
commit 6e88f8e5dc
29 changed files with 171 additions and 335 deletions

View File

@ -24,6 +24,7 @@
#include <retro_common.h>
#include <stdio.h>
#include <stdarg.h>
/* http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010 */
@ -50,4 +51,4 @@ int c99_snprintf_retro__(char *outBuf, size_t size, const char *format, ...)
va_end(ap);
return count;
}
}

View File

@ -181,7 +181,7 @@ static void *file_archive_open(const char *path)
if (!data)
return NULL;
read_from_file = retro_read_file(path, &data->data, &ret);
read_from_file = filestream_read_file(path, &data->data, &ret);
/* Failed to open archive? */
if (!read_from_file || ret < 0)
@ -447,7 +447,7 @@ static int file_archive_decompress_data_to_file(
}
#endif
if (!retro_write_file(path, handle->data, size))
if (!filestream_write_file(path, handle->data, size))
{
ret = false;
goto end;
@ -655,7 +655,7 @@ bool file_archive_perform_mode(const char *path, const char *valid_exts,
switch (cmode)
{
case ZLIB_MODE_UNCOMPRESSED:
if (!retro_write_file(path, cdata, size))
if (!filestream_write_file(path, cdata, size))
return false;
break;

View File

@ -1,128 +0,0 @@
/* Copyright (C) 2010-2016 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (config_file_userdata.c).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <file/config_file_userdata.h>
#include <file/file_path.h>
#include <lists/string_list.h>
#define get_array_setup() \
char key[2][256]; \
bool got; \
struct config_file_userdata *usr = (struct config_file_userdata*)userdata; \
char *str = NULL; \
fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0])); \
fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1])); \
got = config_get_string(usr->conf, key[0], &str); \
got = got || config_get_string(usr->conf, key[1], &str);
#define get_array_body(T) \
if (got) \
{ \
unsigned i; \
struct string_list *list = string_split(str, " "); \
*values = (T*)calloc(list->size, sizeof(T)); \
for (i = 0; i < list->size; i++) \
(*values)[i] = (T)strtod(list->elems[i].data, NULL); \
*out_num_values = list->size; \
string_list_free(list); \
return true; \
} \
else \
{ \
*values = (T*)calloc(num_default_values, sizeof(T)); \
memcpy(*values, default_values, sizeof(T) * num_default_values); \
*out_num_values = num_default_values; \
return false; \
}
int config_userdata_get_float(void *userdata, const char *key_str,
float *value, float default_value)
{
bool got;
char key[2][256];
struct config_file_userdata *usr = (struct config_file_userdata*)userdata;
fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0]));
fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1]));
got = config_get_float (usr->conf, key[0], value);
got = got || config_get_float(usr->conf, key[1], value);
if (!got)
*value = default_value;
return got;
}
int config_userdata_get_int(void *userdata, const char *key_str,
int *value, int default_value)
{
bool got;
char key[2][256];
struct config_file_userdata *usr = (struct config_file_userdata*)userdata;
fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0]));
fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1]));
got = config_get_int (usr->conf, key[0], value);
got = got || config_get_int(usr->conf, key[1], value);
if (!got)
*value = default_value;
return got;
}
int config_userdata_get_float_array(void *userdata, const char *key_str,
float **values, unsigned *out_num_values,
const float *default_values, unsigned num_default_values)
{
get_array_setup()
get_array_body(float)
}
int config_userdata_get_int_array(void *userdata, const char *key_str,
int **values, unsigned *out_num_values,
const int *default_values, unsigned num_default_values)
{
get_array_setup()
get_array_body(int)
}
int config_userdata_get_string(void *userdata, const char *key_str,
char **output, const char *default_output)
{
get_array_setup()
if (got)
{
*output = str;
return true;
}
*output = strdup(default_output);
return false;
}
void config_userdata_free(void *ptr)
{
if (ptr)
free(ptr);
}

View File

@ -1,9 +1,14 @@
TARGET := nbio_test
SOURCES := $(wildcard *.c)
LIBRETRO_COMM_DIR := ../../..
SOURCES := \
nbio_test.c \
../nbio_stdio.c
OBJS := $(SOURCES:.c=.o)
CFLAGS += -Wall -pedantic -std=gnu99 -O0 -g -I../../include
CFLAGS += -Wall -pedantic -std=gnu99 -g -I$(LIBRETRO_COMM_DIR)/include
all: $(TARGET)

View File

@ -105,7 +105,7 @@ static bool write_header_bmp(RFILE *file, unsigned width, unsigned height, bool
header[52] = 0;
header[53] = 0;
return retro_fwrite(file, header, sizeof(header)) == sizeof(header);
return filestream_write(file, header, sizeof(header)) == sizeof(header);
}
static void dump_line_565_to_24(uint8_t *line, const uint16_t *src, unsigned width)
@ -161,8 +161,9 @@ static void dump_content(RFILE *file, const void *frame,
int pad = line_size-pitch;
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
{
retro_fwrite(file, u.u8, pitch);
if(pad != 0) retro_fwrite(file, &zeros, pad);
filestream_write(file, u.u8, pitch);
if(pad != 0)
filestream_write(file, &zeros, pad);
}
return;
}
@ -170,9 +171,7 @@ static void dump_content(RFILE *file, const void *frame,
{
/* ARGB8888 byte order input matches output. Can directly copy. */
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
{
retro_fwrite(file, u.u8, line_size);
}
filestream_write(file, u.u8, line_size);
return;
}
@ -186,7 +185,7 @@ static void dump_content(RFILE *file, const void *frame,
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
{
dump_line_32_to_24(line, u.u32, width);
retro_fwrite(file, line, line_size);
filestream_write(file, line, line_size);
}
}
else /* type == RBMP_SOURCE_TYPE_RGB565 */
@ -194,7 +193,7 @@ static void dump_content(RFILE *file, const void *frame,
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
{
dump_line_565_to_24(line, u.u16, width);
retro_fwrite(file, line, line_size);
filestream_write(file, line, line_size);
}
}
@ -205,7 +204,7 @@ bool rbmp_save_image(const char *filename, const void *frame,
unsigned pitch, enum rbmp_source_type type)
{
bool ret;
RFILE *file = retro_fopen(filename, RFILE_MODE_WRITE, -1);
RFILE *file = filestream_open(filename, RFILE_MODE_WRITE, -1);
if (!file)
return false;
@ -214,7 +213,7 @@ bool rbmp_save_image(const char *filename, const void *frame,
if (ret)
dump_content(file, frame, width, height, pitch, type);
retro_fclose(file);
filestream_close(file);
return ret;
}

View File

@ -1,38 +0,0 @@
TARGET := rpng
HAVE_IMLIB2=1
LDFLAGS += -lz
ifeq ($(HAVE_IMLIB2),1)
CFLAGS += -DHAVE_IMLIB2
LDFLAGS += -lImlib2
endif
SOURCES_C := rpng.c \
rpng_encode.c \
rpng_test.c \
../../compat/compat_strl.c \
../../file/nbio/nbio_stdio.c \
../../file/file_archive.c \
../../file/file_archive_zlib.c \
../../file/file_path.c \
../../file/retro_file.c \
../../string/string_list.c
OBJS := $(SOURCES_C:.c=.o)
CFLAGS += -Wall -pedantic -std=gnu99 -O0 -g -DHAVE_ZLIB -DHAVE_ZLIB_DEFLATE -DRPNG_TEST -I../../include
all: $(TARGET)
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS)
$(TARGET): $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
clean:
rm -f $(TARGET) $(OBJS)
.PHONY: clean

View File

@ -53,7 +53,7 @@ static bool png_write_crc(RFILE *file, const uint8_t *data, size_t size)
uint32_t crc = stream_backend->stream_crc_calculate(0, data, size);
dword_write_be(crc_raw, crc);
return retro_fwrite(file, crc_raw, sizeof(crc_raw)) == sizeof(crc_raw);
return filestream_write(file, crc_raw, sizeof(crc_raw)) == sizeof(crc_raw);
}
static bool png_write_ihdr(RFILE *file, const struct png_ihdr *ihdr)
@ -85,7 +85,7 @@ static bool png_write_ihdr(RFILE *file, const struct png_ihdr *ihdr)
dword_write_be(ihdr_raw + 0, sizeof(ihdr_raw) - 8);
dword_write_be(ihdr_raw + 8, ihdr->width);
dword_write_be(ihdr_raw + 12, ihdr->height);
if (retro_fwrite(file, ihdr_raw, sizeof(ihdr_raw)) != sizeof(ihdr_raw))
if (filestream_write(file, ihdr_raw, sizeof(ihdr_raw)) != sizeof(ihdr_raw))
return false;
if (!png_write_crc(file, ihdr_raw + sizeof(uint32_t),
@ -97,7 +97,7 @@ static bool png_write_ihdr(RFILE *file, const struct png_ihdr *ihdr)
static bool png_write_idat(RFILE *file, const uint8_t *data, size_t size)
{
if (retro_fwrite(file, data, size) != (ssize_t)size)
if (filestream_write(file, data, size) != (ssize_t)size)
return false;
if (!png_write_crc(file, data + sizeof(uint32_t), size - sizeof(uint32_t)))
@ -113,7 +113,7 @@ static bool png_write_iend(RFILE *file)
'I', 'E', 'N', 'D',
};
if (retro_fwrite(file, data, sizeof(data)) != sizeof(data))
if (filestream_write(file, data, sizeof(data)) != sizeof(data))
return false;
if (!png_write_crc(file, data + sizeof(uint32_t),
@ -227,13 +227,13 @@ static bool rpng_save_image(const char *path,
uint8_t *prev_encoded = NULL;
uint8_t *encode_target = NULL;
void *stream = NULL;
RFILE *file = retro_fopen(path, RFILE_MODE_WRITE, -1);
RFILE *file = filestream_open(path, RFILE_MODE_WRITE, -1);
if (!file)
GOTO_END_ERROR();
stream_backend = file_archive_get_default_file_backend();
if (retro_fwrite(file, png_magic, sizeof(png_magic)) != sizeof(png_magic))
if (filestream_write(file, png_magic, sizeof(png_magic)) != sizeof(png_magic))
GOTO_END_ERROR();
ihdr.width = width;
@ -356,7 +356,7 @@ static bool rpng_save_image(const char *path,
GOTO_END_ERROR();
end:
retro_fclose(file);
filestream_close(file);
free(encode_buf);
free(deflate_buf);
free(rgba_line);

View File

@ -23,9 +23,9 @@
#ifndef _RPNG_COMMON_H
#define _RPNG_COMMON_H
#include <retro_inline.h>
#include <formats/rpng.h>
#include <stdint.h>
#include <filters.h>
#include <formats/rpng.h>
#undef GOTO_END_ERROR
#define GOTO_END_ERROR() do { \
@ -53,19 +53,4 @@ struct png_ihdr
uint8_t interlace;
};
/* Paeth prediction filter. */
static INLINE int paeth(int a, int b, int c)
{
int p = a + b - c;
int pa = abs(p - a);
int pb = abs(p - b);
int pc = abs(p - c);
if (pa <= pb && pa <= pc)
return a;
else if (pb <= pc)
return b;
return c;
}
#endif

View File

@ -0,0 +1,44 @@
TARGET := rpng
LIBRETRO_PNG_DIR := ..
LIBRETRO_COMM_DIR := ../../..
HAVE_IMLIB2=1
LDFLAGS += -lz
ifeq ($(HAVE_IMLIB2),1)
CFLAGS += -DHAVE_IMLIB2
LDFLAGS += -lImlib2
endif
SOURCES_C := \
rpng_test.c \
$(LIBRETRO_PNG_DIR)/rpng.c \
$(LIBRETRO_PNG_DIR)/rpng_encode.c \
$(LIBRETRO_COMM_DIR)/compat/compat_strl.c \
$(LIBRETRO_COMM_DIR)/file/nbio/nbio_stdio.c \
$(LIBRETRO_COMM_DIR)/file/archive_file.c \
$(LIBRETRO_COMM_DIR)/file/archive_file_zlib.c \
$(LIBRETRO_COMM_DIR)//file/file_path.c \
$(LIBRETRO_COMM_DIR)//file/retro_stat.c \
$(LIBRETRO_COMM_DIR)/streams/file_stream.c \
$(LIBRETRO_COMM_DIR)/lists/string_list.c
OBJS := $(SOURCES_C:.c=.o)
CFLAGS += -Wall -pedantic -std=gnu99 -O0 -g -DHAVE_ZLIB -DHAVE_ZLIB_DEFLATE -DRPNG_TEST -I$(LIBRETRO_COMM_DIR)/include
all: $(TARGET)
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS)
$(TARGET): $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
clean:
rm -f $(TARGET) $(OBJS)
.PHONY: clean

View File

@ -418,7 +418,7 @@ rxml_document_t *rxml_load_document(const char *path)
char *new_memory_buffer = NULL;
const char *mem_ptr = NULL;
long len = 0;
RFILE *file = retro_fopen(path, RFILE_MODE_READ, -1);
RFILE *file = filestream_open(path, RFILE_MODE_READ, -1);
if (!file)
return NULL;
@ -426,19 +426,19 @@ rxml_document_t *rxml_load_document(const char *path)
if (!doc)
goto error;
retro_fseek(file, 0, SEEK_END);
len = retro_ftell(file);
retro_frewind(file);
filestream_seek(file, 0, SEEK_END);
len = filestream_tell(file);
filestream_rewind(file);
memory_buffer = (char*)malloc(len + 1);
if (!memory_buffer)
goto error;
memory_buffer[len] = '\0';
if (retro_fread(file, memory_buffer, len) != (size_t)len)
if (filestream_read(file, memory_buffer, len) != (size_t)len)
goto error;
retro_fclose(file);
filestream_close(file);
file = NULL;
mem_ptr = memory_buffer;
@ -462,7 +462,7 @@ rxml_document_t *rxml_load_document(const char *path)
error:
free(memory_buffer);
retro_fclose(file);
filestream_close(file);
rxml_free_document(doc);
return NULL;
}

View File

@ -1,10 +1,12 @@
TARGET := rxml
LIBRETRO_COMM_DIR := ../..
LIBRETRO_XML_DIR := ..
LIBRETRO_COMM_DIR := ../../..
SOURCES := \
$(wildcard *.c) \
$(LIBRETRO_COMM_DIR)/file/retro_file.c
rxml_test.c \
$(LIBRETRO_XML_DIR)/rxml.c \
$(LIBRETRO_COMM_DIR)/streams/file_stream.c
OBJS := $(SOURCES:.c=.o)

View File

@ -511,7 +511,7 @@ int sha1_calculate(const char *path, char *result)
unsigned char buff[4096] = {0};
SHA1Context sha;
int rv = 1;
RFILE *fd = retro_fopen(path, RFILE_MODE_READ, -1);
RFILE *fd = filestream_open(path, RFILE_MODE_READ, -1);
if (!fd)
goto error;
@ -520,7 +520,7 @@ int sha1_calculate(const char *path, char *result)
do
{
rv = retro_fread(fd, buff, 4096);
rv = filestream_read(fd, buff, 4096);
if (rv < 0)
goto error;
@ -536,12 +536,12 @@ int sha1_calculate(const char *path, char *result)
sha.Message_Digest[2],
sha.Message_Digest[3], sha.Message_Digest[4]);
retro_fclose(fd);
filestream_close(fd);
return 0;
error:
if (fd)
retro_fclose(fd);
filestream_close(fd);
return -1;
}

View File

@ -86,7 +86,8 @@ typedef int ssize_t;
#pragma warning(disable : 4723)
#pragma warning(disable : 4996)
#if _MSC_VER < 1200
/* roundf is available since MSVC 2013 */
#if _MSC_VER < 1800
#define roundf(in) (in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f))
#endif

View File

@ -46,7 +46,8 @@ char *strtok_r(char *str, const char *delim, char **saveptr);
int strcasecmp(const char *a, const char *b);
char *strdup(const char *orig);
#if _MSC_VER < 1200
/* isblank is available since MSVC 2013 */
#if _MSC_VER < 1800
#undef isblank
#define isblank(c) retro_isblank__(c)
int isblank(int c);

View File

@ -1,55 +0,0 @@
/* Copyright (C) 2010-2015 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (config_file_userdata.h).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _LIBRETRO_SDK_CONFIG_FILE_USERDATA_H
#define _LIBRETRO_SDK_CONFIG_FILE_USERDATA_H
#include <string.h>
#include "config_file.h"
struct config_file_userdata
{
config_file_t *conf;
const char *prefix[2];
};
int config_userdata_get_float(void *userdata, const char *key_str,
float *value, float default_value);
int config_userdata_get_int(void *userdata, const char *key_str,
int *value, int default_value);
int config_userdata_get_float_array(void *userdata, const char *key_str,
float **values, unsigned *out_num_values,
const float *default_values, unsigned num_default_values);
int config_userdata_get_int_array(void *userdata, const char *key_str,
int **values, unsigned *out_num_values,
const int *default_values, unsigned num_default_values);
int config_userdata_get_string(void *userdata, const char *key_str,
char **output, const char *default_output);
void config_userdata_free(void *ptr);
#endif

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2010-2015 The RetroArch team
/* Copyright (C) 2010-2016 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (filters.h).
@ -23,6 +23,10 @@
#ifndef _LIBRETRO_SDK_FILTERS_H
#define _LIBRETRO_SDK_FILTERS_H
/* for MSVC; should be benign under any circumstances */
#define _USE_MATH_DEFINES
#include <stdlib.h>
#include <math.h>
#include <retro_inline.h>
@ -33,6 +37,21 @@ static INLINE double sinc(double val)
return sin(val) / val;
}
/* Paeth prediction filter. */
static INLINE int paeth(int a, int b, int c)
{
int p = a + b - c;
int pa = abs(p - a);
int pb = abs(p - b);
int pc = abs(p - c);
if (pa <= pb && pa <= pc)
return a;
else if (pb <= pc)
return b;
return c;
}
/* Modified Bessel function of first order.
* Check Wiki for mathematical definition ... */
static INLINE double besseli0(double x)

View File

@ -61,7 +61,7 @@ void *file_list_get_actiondata_at_offset(const file_list_t *list,
void file_list_free(file_list_t *list);
bool file_list_push(file_list_t *userdata, const char *path,
bool file_list_append(file_list_t *userdata, const char *path,
const char *label, unsigned type, size_t current_directory_ptr,
size_t entry_index);

View File

@ -48,25 +48,25 @@ enum
RFILE_HINT_MMAP = 1<<9 /* requires RFILE_MODE_READ */
};
RFILE *retro_fopen(const char *path, unsigned mode, ssize_t len);
RFILE *filestream_open(const char *path, unsigned mode, ssize_t len);
ssize_t retro_fseek(RFILE *stream, ssize_t offset, int whence);
ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence);
ssize_t retro_fread(RFILE *stream, void *s, size_t len);
ssize_t filestream_read(RFILE *stream, void *data, size_t len);
ssize_t retro_fwrite(RFILE *stream, const void *s, size_t len);
ssize_t filestream_write(RFILE *stream, const void *data, size_t len);
ssize_t retro_ftell(RFILE *stream);
ssize_t filestream_tell(RFILE *stream);
void retro_frewind(RFILE *stream);
void filestream_rewind(RFILE *stream);
int retro_fclose(RFILE *stream);
int filestream_close(RFILE *stream);
int retro_read_file(const char *path, void **buf, ssize_t *len);
int filestream_read_file(const char *path, void **buf, ssize_t *len);
bool retro_write_file(const char *path, const void *data, ssize_t size);
bool filestream_write_file(const char *path, const void *data, ssize_t size);
int retro_get_fd(RFILE *stream);
int filestream_get_fd(RFILE *stream);
#ifdef __cplusplus
}

View File

@ -30,19 +30,19 @@ typedef struct memstream memstream_t;
memstream_t *memstream_open(void);
void memstream_close(memstream_t * stream);
void memstream_close(memstream_t *stream);
size_t memstream_read(memstream_t * stream, void *data, size_t bytes);
size_t memstream_read(memstream_t *stream, void *data, size_t bytes);
size_t memstream_write(memstream_t * stream, const void *data, size_t bytes);
size_t memstream_write(memstream_t *stream, const void *data, size_t bytes);
int memstream_getc(memstream_t * stream);
int memstream_getc(memstream_t *stream);
char *memstream_gets(memstream_t * stream, char *buffer, size_t len);
char *memstream_gets(memstream_t *stream, char *buffer, size_t len);
size_t memstream_pos(memstream_t * stream);
size_t memstream_pos(memstream_t *stream);
int memstream_seek(memstream_t * stream, int offset, int whence);
int memstream_seek(memstream_t *stream, int offset, int whence);
void memstream_set_buffer(uint8_t *buffer, size_t size);

View File

@ -59,7 +59,7 @@ static bool file_list_capacity(file_list_t *list, size_t cap)
return true;
}
bool file_list_push(file_list_t *list,
bool file_list_append(file_list_t *list,
const char *path, const char *label,
unsigned type, size_t directory_ptr,
size_t entry_idx)

View File

@ -1,10 +1,8 @@
TARGETS = http_test net_ifinfo
INCFLAGS = -I../include -I../include/net
LIBRETRO_COMM_DIR := ../..
SOURCES := $(wildcard *.c) \
../compat/compat.c
OBJS := $(SOURCES:.c=.o)
INCFLAGS = -I$(LIBRETRO_COMM_DIR)/include
ifeq ($(DEBUG),1)
CFLAGS += -O0 -g
@ -14,15 +12,15 @@ endif
CFLAGS += -Wall -pedantic -std=gnu99
HTTP_TEST_C = \
net_http.c \
$(LIBRETRO_COMM_DIR)/net/net_http.c \
net_http_test.c \
net_compat.c \
../compat/compat_strl.c
$(LIBRETRO_COMM_DIR)/net/net_compat.c \
$(LIBRETRO_COMM_DIR)/compat/compat_strl.c
HTTP_TEST_OBJS := $(HTTP_TEST_C:.c=.o)
NET_IFINFO_C = \
net_ifinfo.c \
$(LIBRETRO_COMM_DIR)/net/net_ifinfo.c \
net_ifinfo_test.c
NET_IFINFO_OBJS := $(NET_IFINFO_C:.c=.o)

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2010-2015 The RetroArch team
/* Copyright (C) 2010-2016 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (gx_pthread.h).

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2010-2015 The RetroArch team
/* Copyright (C) 2010-2016 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (psp_pthread.h).

View File

@ -90,7 +90,7 @@ struct RFILE
#endif
};
int retro_get_fd(RFILE *stream)
int filestream_get_fd(RFILE *stream)
{
if (!stream)
return -1;
@ -105,7 +105,7 @@ int retro_get_fd(RFILE *stream)
#endif
}
RFILE *retro_fopen(const char *path, unsigned mode, ssize_t len)
RFILE *filestream_open(const char *path, unsigned mode, ssize_t len)
{
int flags = 0;
int mode_int = 0;
@ -213,12 +213,12 @@ RFILE *retro_fopen(const char *path, unsigned mode, ssize_t len)
{
stream->mappos = 0;
stream->mapped = NULL;
stream->mapsize = retro_fseek(stream, 0, SEEK_END);
stream->mapsize = filestream_seek(stream, 0, SEEK_END);
if (stream->mapsize == (uint64_t)-1)
goto error;
retro_frewind(stream);
filestream_rewind(stream);
stream->mapped = (uint8_t*)mmap((void*)0, stream->mapsize, PROT_READ, MAP_SHARED, stream->fd, 0);
@ -237,11 +237,11 @@ RFILE *retro_fopen(const char *path, unsigned mode, ssize_t len)
return stream;
error:
retro_fclose(stream);
filestream_close(stream);
return NULL;
}
ssize_t retro_fseek(RFILE *stream, ssize_t offset, int whence)
ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence)
{
int ret = 0;
if (!stream)
@ -266,7 +266,8 @@ ssize_t retro_fseek(RFILE *stream, ssize_t offset, int whence)
else
#endif
#ifdef HAVE_MMAP
/* Need to check stream->mapped because this function is called in retro_fopen() */
/* Need to check stream->mapped because this function is
* called in filestream_open() */
if (stream->mapped && stream->hints & RFILE_HINT_MMAP)
{
/* fseek() returns error on under/overflow but allows cursor > EOF for
@ -308,7 +309,7 @@ ssize_t retro_fseek(RFILE *stream, ssize_t offset, int whence)
#endif
}
ssize_t retro_ftell(RFILE *stream)
ssize_t filestream_tell(RFILE *stream)
{
if (!stream)
return -1;
@ -326,7 +327,8 @@ ssize_t retro_ftell(RFILE *stream)
else
#endif
#ifdef HAVE_MMAP
/* Need to check stream->mapped because this function is called in retro_fopen() */
/* Need to check stream->mapped because this function
* is called in filestream_open() */
if (stream->mapped && stream->hints & RFILE_HINT_MMAP)
return stream->mappos;
else
@ -335,12 +337,12 @@ ssize_t retro_ftell(RFILE *stream)
#endif
}
void retro_frewind(RFILE *stream)
void filestream_rewind(RFILE *stream)
{
retro_fseek(stream, 0L, SEEK_SET);
filestream_seek(stream, 0L, SEEK_SET);
}
ssize_t retro_fread(RFILE *stream, void *s, size_t len)
ssize_t filestream_read(RFILE *stream, void *s, size_t len)
{
if (!stream || !s)
return -1;
@ -377,7 +379,7 @@ ssize_t retro_fread(RFILE *stream, void *s, size_t len)
#endif
}
ssize_t retro_fwrite(RFILE *stream, const void *s, size_t len)
ssize_t filestream_write(RFILE *stream, const void *s, size_t len)
{
if (!stream)
return -1;
@ -403,7 +405,7 @@ ssize_t retro_fwrite(RFILE *stream, const void *s, size_t len)
#endif
}
int retro_fclose(RFILE *stream)
int filestream_close(RFILE *stream)
{
if (!stream)
return -1;
@ -437,7 +439,7 @@ int retro_fclose(RFILE *stream)
}
/**
* retro_read_file:
* filestream_read_file:
* @path : path to file.
* @buf : buffer to allocate and read the contents of the
* file into. Needs to be freed manually.
@ -446,12 +448,12 @@ int retro_fclose(RFILE *stream)
*
* Returns: number of items read, -1 on error.
*/
int retro_read_file(const char *path, void **buf, ssize_t *len)
int filestream_read_file(const char *path, void **buf, ssize_t *len)
{
ssize_t ret = 0;
ssize_t content_buf_size = 0;
void *content_buf = NULL;
RFILE *file = retro_fopen(path, RFILE_MODE_READ, -1);
RFILE *file = filestream_open(path, RFILE_MODE_READ, -1);
if (!file)
{
@ -463,21 +465,21 @@ int retro_read_file(const char *path, void **buf, ssize_t *len)
goto error;
}
if (retro_fseek(file, 0, SEEK_END) != 0)
if (filestream_seek(file, 0, SEEK_END) != 0)
goto error;
content_buf_size = retro_ftell(file);
content_buf_size = filestream_tell(file);
if (content_buf_size < 0)
goto error;
retro_frewind(file);
filestream_rewind(file);
content_buf = malloc(content_buf_size + 1);
if (!content_buf)
goto error;
ret = retro_fread(file, content_buf, content_buf_size);
ret = filestream_read(file, content_buf, content_buf_size);
if (ret < 0)
{
#if __STDC_VERSION__ >= 199901L
@ -488,7 +490,7 @@ int retro_read_file(const char *path, void **buf, ssize_t *len)
goto error;
}
retro_fclose(file);
filestream_close(file);
*buf = content_buf;
@ -503,7 +505,7 @@ int retro_read_file(const char *path, void **buf, ssize_t *len)
error:
if (file)
retro_fclose(file);
filestream_close(file);
if (content_buf)
free(content_buf);
if (len)
@ -513,7 +515,7 @@ error:
}
/**
* retro_write_file:
* filestream_write_file:
* @path : path to file.
* @data : contents to write to the file.
* @size : size of the contents.
@ -522,15 +524,15 @@ error:
*
* Returns: true (1) on success, false (0) otherwise.
*/
bool retro_write_file(const char *path, const void *data, ssize_t size)
bool filestream_write_file(const char *path, const void *data, ssize_t size)
{
ssize_t ret = 0;
RFILE *file = retro_fopen(path, RFILE_MODE_WRITE, -1);
RFILE *file = filestream_open(path, RFILE_MODE_WRITE, -1);
if (!file)
return false;
ret = retro_fwrite(file, data, size);
retro_fclose(file);
ret = filestream_write(file, data, size);
filestream_close(file);
return (ret == size);
}