From 50cafaa70058aa2f67037a61904ba3e098518051 Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Sun, 18 Dec 2016 05:07:14 +0000 Subject: [PATCH] devkitARM r46 changes --- libctru/include/sys/select.h | 14 +-------- libctru/source/console.c | 4 +-- libctru/source/romfs_dev.c | 18 +++++------ libctru/source/sdmc_dev.c | 40 ++++++++++++------------ libctru/source/services/soc/soc_common.h | 4 --- libctru/source/services/soc/soc_init.c | 14 ++++----- 6 files changed, 39 insertions(+), 55 deletions(-) diff --git a/libctru/include/sys/select.h b/libctru/include/sys/select.h index d75f9d0..f6f6154 100644 --- a/libctru/include/sys/select.h +++ b/libctru/include/sys/select.h @@ -1,13 +1 @@ -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); - -#ifdef __cplusplus -} -#endif +#include_next \ No newline at end of file diff --git a/libctru/source/console.c b/libctru/source/console.c index ca940db..7f084ae 100644 --- a/libctru/source/console.c +++ b/libctru/source/console.c @@ -179,7 +179,7 @@ static void consoleClearLine(char mode) { //--------------------------------------------------------------------------------- -ssize_t con_write(struct _reent *r,int fd,const char *ptr, size_t len) { +ssize_t con_write(struct _reent *r,void *fd,const char *ptr, size_t len) { //--------------------------------------------------------------------------------- char chr; @@ -471,7 +471,7 @@ static const devoptab_t dotab_stdout = { }; //--------------------------------------------------------------------------------- -ssize_t debug_write(struct _reent *r, int fd, const char *ptr, size_t len) { +ssize_t debug_write(struct _reent *r, void *fd, const char *ptr, size_t len) { //--------------------------------------------------------------------------------- svcOutputDebugString(ptr,len); return len; diff --git a/libctru/source/romfs_dev.c b/libctru/source/romfs_dev.c index 072f24c..ba324af 100644 --- a/libctru/source/romfs_dev.c +++ b/libctru/source/romfs_dev.c @@ -58,10 +58,10 @@ static bool _romfs_read_chk(romfs_mount *mount, u64 offset, void* buffer, u32 si //----------------------------------------------------------------------------- static int romfs_open(struct _reent *r, void *fileStruct, const char *path, int flags, int mode); -static int romfs_close(struct _reent *r, int fd); -static ssize_t romfs_read(struct _reent *r, int fd, char *ptr, size_t len); -static off_t romfs_seek(struct _reent *r, int fd, off_t pos, int dir); -static int romfs_fstat(struct _reent *r, int fd, struct stat *st); +static int romfs_close(struct _reent *r, void *fd); +static ssize_t romfs_read(struct _reent *r, void *fd, char *ptr, size_t len); +static off_t romfs_seek(struct _reent *r, void *fd, off_t pos, int dir); +static int romfs_fstat(struct _reent *r, void *fd, struct stat *st); static int romfs_stat(struct _reent *r, const char *path, struct stat *st); static int romfs_chdir(struct _reent *r, const char *path); static DIR_ITER* romfs_diropen(struct _reent *r, DIR_ITER *dirState, const char *path); @@ -101,7 +101,7 @@ static devoptab_t romFS_devoptab = .dirreset_r = romfs_dirreset, .dirnext_r = romfs_dirnext, .dirclose_r = romfs_dirclose, - .deviceData = NULL, + .deviceData = 0, }; //----------------------------------------------------------------------------- @@ -594,12 +594,12 @@ int romfs_open(struct _reent *r, void *fileStruct, const char *path, int flags, return 0; } -int romfs_close(struct _reent *r, int fd) +int romfs_close(struct _reent *r, void *fd) { return 0; } -ssize_t romfs_read(struct _reent *r, int fd, char *ptr, size_t len) +ssize_t romfs_read(struct _reent *r, void *fd, char *ptr, size_t len) { romfs_fileobj* file = (romfs_fileobj*)fd; u64 endPos = file->pos + len; @@ -624,7 +624,7 @@ ssize_t romfs_read(struct _reent *r, int fd, char *ptr, size_t len) return -1; } -off_t romfs_seek(struct _reent *r, int fd, off_t pos, int dir) +off_t romfs_seek(struct _reent *r, void *fd, off_t pos, int dir) { romfs_fileobj* file = (romfs_fileobj*)fd; off_t start; @@ -667,7 +667,7 @@ off_t romfs_seek(struct _reent *r, int fd, off_t pos, int dir) return file->pos; } -int romfs_fstat(struct _reent *r, int fd, struct stat *st) +int romfs_fstat(struct _reent *r, void *fd, struct stat *st) { romfs_fileobj* file = (romfs_fileobj*)fd; memset(st, 0, sizeof(struct stat)); diff --git a/libctru/source/sdmc_dev.c b/libctru/source/sdmc_dev.c index b3bd008..2523f39 100644 --- a/libctru/source/sdmc_dev.c +++ b/libctru/source/sdmc_dev.c @@ -25,12 +25,12 @@ static int sdmc_translate_error(Result error); static int sdmc_open(struct _reent *r, void *fileStruct, const char *path, int flags, int mode); -static int sdmc_close(struct _reent *r, int fd); -static ssize_t sdmc_write(struct _reent *r, int fd, const char *ptr, size_t len); -static ssize_t sdmc_write_safe(struct _reent *r, int fd, const char *ptr, size_t len); -static ssize_t sdmc_read(struct _reent *r, int fd, char *ptr, size_t len); -static off_t sdmc_seek(struct _reent *r, int fd, off_t pos, int dir); -static int sdmc_fstat(struct _reent *r, int fd, struct stat *st); +static int sdmc_close(struct _reent *r, void *fd); +static ssize_t sdmc_write(struct _reent *r, void *fd, const char *ptr, size_t len); +static ssize_t sdmc_write_safe(struct _reent *r, void *fd, const char *ptr, size_t len); +static ssize_t sdmc_read(struct _reent *r, void *fd, char *ptr, size_t len); +static off_t sdmc_seek(struct _reent *r, void *fd, off_t pos, int dir); +static int sdmc_fstat(struct _reent *r, void *fd, struct stat *st); static int sdmc_stat(struct _reent *r, const char *file, struct stat *st); static int sdmc_link(struct _reent *r, const char *existing, const char *newLink); static int sdmc_unlink(struct _reent *r, const char *name); @@ -42,10 +42,10 @@ static int sdmc_dirreset(struct _reent *r, DIR_ITER *dirState); static int sdmc_dirnext(struct _reent *r, DIR_ITER *dirState, char *filename, struct stat *filestat); static int sdmc_dirclose(struct _reent *r, DIR_ITER *dirState); static int sdmc_statvfs(struct _reent *r, const char *path, struct statvfs *buf); -static int sdmc_ftruncate(struct _reent *r, int fd, off_t len); -static int sdmc_fsync(struct _reent *r, int fd); +static int sdmc_ftruncate(struct _reent *r, void *fd, off_t len); +static int sdmc_fsync(struct _reent *r, void *fd); static int sdmc_chmod(struct _reent *r, const char *path, mode_t mode); -static int sdmc_fchmod(struct _reent *r, int fd, mode_t mode); +static int sdmc_fchmod(struct _reent *r, void *fd, mode_t mode); static int sdmc_rmdir(struct _reent *r, const char *name); /*! @cond INTERNAL */ @@ -84,7 +84,7 @@ sdmc_devoptab = .statvfs_r = sdmc_statvfs, .ftruncate_r = sdmc_ftruncate, .fsync_r = sdmc_fsync, - .deviceData = NULL, + .deviceData = 0, .chmod_r = sdmc_chmod, .fchmod_r = sdmc_fchmod, .rmdir_r = sdmc_rmdir, @@ -416,7 +416,7 @@ sdmc_open(struct _reent *r, */ static int sdmc_close(struct _reent *r, - int fd) + void *fd) { Result rc; @@ -443,7 +443,7 @@ sdmc_close(struct _reent *r, */ static ssize_t sdmc_write(struct _reent *r, - int fd, + void *fd, const char *ptr, size_t len) { @@ -501,7 +501,7 @@ sdmc_write(struct _reent *r, */ static ssize_t sdmc_write_safe(struct _reent *r, - int fd, + void *fd, const char *ptr, size_t len) { @@ -581,7 +581,7 @@ sdmc_write_safe(struct _reent *r, */ static ssize_t sdmc_read(struct _reent *r, - int fd, + void *fd, char *ptr, size_t len) { @@ -623,7 +623,7 @@ sdmc_read(struct _reent *r, */ static off_t sdmc_seek(struct _reent *r, - int fd, + void *fd, off_t pos, int whence) { @@ -686,7 +686,7 @@ sdmc_seek(struct _reent *r, */ static int sdmc_fstat(struct _reent *r, - int fd, + void *fd, struct stat *st) { Result rc; @@ -732,7 +732,7 @@ sdmc_stat(struct _reent *r, if(R_SUCCEEDED(rc = FSUSER_OpenFile(&fd, sdmcArchive, fs_path, FS_OPEN_READ, 0))) { sdmc_file_t tmpfd = { .fd = fd }; - rc = sdmc_fstat(r, (int)&tmpfd, st); + rc = sdmc_fstat(r, &tmpfd, st); FSFILE_Close(fd); return rc; @@ -1131,7 +1131,7 @@ sdmc_statvfs(struct _reent *r, */ static int sdmc_ftruncate(struct _reent *r, - int fd, + void *fd, off_t len) { Result rc; @@ -1165,7 +1165,7 @@ sdmc_ftruncate(struct _reent *r, */ static int sdmc_fsync(struct _reent *r, - int fd) + void *fd) { Result rc; @@ -1209,7 +1209,7 @@ sdmc_chmod(struct _reent *r, */ static int sdmc_fchmod(struct _reent *r, - int fd, + void *fd, mode_t mode) { r->_errno = ENOSYS; diff --git a/libctru/source/services/soc/soc_common.h b/libctru/source/services/soc/soc_common.h index a9fd779..e859ac5 100644 --- a/libctru/source/services/soc/soc_common.h +++ b/libctru/source/services/soc/soc_common.h @@ -11,10 +11,6 @@ #define SYNC_ERROR ENODEV -int __alloc_handle(size_t size); -__handle *__get_handle(int fd); -void __release_handle(int fd); - extern Handle SOCU_handle; extern Handle socMemhandle; diff --git a/libctru/source/services/soc/soc_init.c b/libctru/source/services/soc/soc_init.c index 2edc9ae..790042c 100644 --- a/libctru/source/services/soc/soc_init.c +++ b/libctru/source/services/soc/soc_init.c @@ -4,9 +4,9 @@ #include <3ds/ipc.h> static int soc_open(struct _reent *r, void *fileStruct, const char *path, int flags, int mode); -static int soc_close(struct _reent *r, int fd); -static ssize_t soc_write(struct _reent *r, int fd, const char *ptr, size_t len); -static ssize_t soc_read(struct _reent *r, int fd, char *ptr, size_t len); +static int soc_close(struct _reent *r, void *fd); +static ssize_t soc_write(struct _reent *r, void *fd, const char *ptr, size_t len); +static ssize_t soc_read(struct _reent *r, void *fd, char *ptr, size_t len); static devoptab_t soc_devoptab = @@ -33,7 +33,7 @@ soc_devoptab = .statvfs_r = NULL, .ftruncate_r = NULL, .fsync_r = NULL, - .deviceData = NULL, + .deviceData = 0, .chmod_r = NULL, .fchmod_r = NULL, }; @@ -151,7 +151,7 @@ soc_open(struct _reent *r, static int soc_close(struct _reent *r, - int fd) + void *fd) { Handle sockfd = *(Handle*)fd; @@ -182,7 +182,7 @@ soc_close(struct _reent *r, static ssize_t soc_write(struct _reent *r, - int fd, + void *fd, const char *ptr, size_t len) { @@ -192,7 +192,7 @@ soc_write(struct _reent *r, static ssize_t soc_read(struct _reent *r, - int fd, + void *fd, char *ptr, size_t len) {