Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compatible with newlib #261

Merged
merged 7 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ee_core/include/igs_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#ifndef _IGSAPI_H_
#define _IGSAPI_H_

#include "fileio.h"
#include "ee_core.h"
#include <iopcontrol.h>
#include "iopmgr.h"
Expand Down
2 changes: 2 additions & 0 deletions ee_core/src/igs_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/

#include "include/igs_api.h"
#define NEWLIB_PORT_AWARE
#include "fileio.h"

static void FastDelay(int count)
{
Expand Down
1 change: 0 additions & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ int configReadBuffer(config_set_t *configSet, const void *buffer, int size);
int configReadMulti(int types);
int configWrite(config_set_t *configSet);
int configWriteMulti(int types);
int configGetStat(config_set_t *configSet, iox_stat_t *stat);
void configClear(config_set_t *configSet);

void configGetVMC(config_set_t *configSet, char *vmc, int length, int slot);
Expand Down
8 changes: 6 additions & 2 deletions include/opl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
#include <string.h>
#include <loadfile.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <dirent.h>
#include <errno.h>
#include <limits.h>
#include <sbv_patches.h>
#include <libcdvd.h>
#include <libpad.h>
Expand All @@ -26,13 +32,11 @@
#include <osd_config.h>
#include <libpwroff.h>
#include <usbhdfsd-common.h>
#include <fileXio_rpc.h>
#include <smod.h>
#include <smem.h>
#include <debug.h>
#include <ps2smb.h>
#include "config.h"
#include <sys/fcntl.h>

// Last Played Auto Start
#include <time.h>
Expand Down
2 changes: 1 addition & 1 deletion modules/debug/ps2link/hostlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ typedef struct
unsigned int cmd;
unsigned short len;
int retval;
/* from io_common.h (fio_dirent_t) in ps2lib */
/* from io_common.h (io_dirent_t) in ps2sdk */
unsigned int mode;
unsigned int attr;
unsigned int size;
Expand Down
4 changes: 2 additions & 2 deletions modules/debug/ps2link/net_fio.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ int pko_read_dir(int fd, void *buf)
{
pko_pkt_dread_req *dirreq;
pko_pkt_dread_rly *dirrly;
fio_dirent_t *dirent;
io_dirent_t *dirent;

if (pko_fileio_sock < 0) {
return -1;
Expand Down Expand Up @@ -601,7 +601,7 @@ int pko_read_dir(int fd, void *buf)

dbgprintf("pko_file: dir read reply received (ret %ld)\n", ntohl(dirrly->retval));

dirent = (fio_dirent_t *)buf;
dirent = (io_dirent_t *)buf;
// now handle the return buffer translation, to build reply bit
dirent->stat.mode = ntohl(dirrly->mode);
dirent->stat.attr = ntohl(dirrly->attr);
Expand Down
2 changes: 2 additions & 0 deletions modules/iopcore/cdvdman/ioman_add.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef _IOMAN_ADD_H_
#define _IOMAN_ADD_H_

#include <iox_stat.h>

#define IOP_DT_FSEXT 0x10000000

typedef struct _iop_ext_device
Expand Down
10 changes: 1 addition & 9 deletions modules/network/SMSTCPIP/include/lwip/sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#ifndef __LWIP_SOCKETS_H__
#define __LWIP_SOCKETS_H__
#include "lwip/ip_addr.h"
#include <sys/time.h>

struct sockaddr_in
{
Expand Down Expand Up @@ -210,15 +211,6 @@ typedef struct fd_set
} fd_set;
#endif

#ifndef TIMEVAL
#define TIMEVAL
struct timeval
{
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
#endif

int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int lwip_bind(int s, struct sockaddr *name, socklen_t namelen);
int lwip_shutdown(int s, int how);
Expand Down
11 changes: 2 additions & 9 deletions modules/network/common/smstcpip-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
*
*/

#include <sys/time.h>

typedef signed char err_t; /* lwIP error type. */

/* From src/include/lwip/pbuf.h: */
Expand Down Expand Up @@ -294,15 +296,6 @@ typedef struct fd_set
} fd_set;
#endif

#ifndef TIMEVAL
#define TIMEVAL
struct timeval
{
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
#endif

#if !defined(INVALID_SOCKET)
#define INVALID_SOCKET -1
#endif
Expand Down
5 changes: 4 additions & 1 deletion src/OSDHistory.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#include <limits.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/fcntl.h>
#include <sys/unistd.h>

#include "include/util.h"
#include "include/OSDHistory.h"
Expand All @@ -35,7 +38,7 @@ int CreateSystemDataFolder(const char *path, char FolderRegionLetter)

sprintf(fullpath, "%s/icon.sys", path);
if ((fd = open(fullpath, O_RDONLY)) < 0) {
mkdir(path);
mkdir(path, 0777);
if ((fd = open(fullpath, O_CREAT | O_TRUNC | O_WRONLY)) >= 0) {
switch(FolderRegionLetter) {
case 'I':
Expand Down
6 changes: 3 additions & 3 deletions src/appsupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ static void appDeleteItem(int id)
if (appsList[id].legacy)
{
struct config_value_t *cur = appGetConfigValue(id);
fileXioRemove(cur->val);
unlink(cur->val);
cur->key[0] = '\0';
configApps->modified = 1;
configWrite(configApps);
Expand Down Expand Up @@ -358,9 +358,9 @@ static void appLaunchItem(int id, config_set_t *configSet)
//Retrieve configuration set by appGetConfig()
configGetStr(configSet, CONFIG_ITEM_STARTUP, &filename);

fd = fileXioOpen(filename, O_RDONLY);
fd = open(filename, O_RDONLY);
if (fd >= 0) {
fileXioClose(fd);
close(fd);

//To keep the necessary device accessible, we will assume the mode that owns the device which contains the file to boot.
mode = oplPath2Mode(filename);
Expand Down
1 change: 1 addition & 0 deletions src/atlas.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include <stdio.h>
#include <malloc.h>
#include "include/atlas.h"
#include "include/renderman.h"

Expand Down
1 change: 1 addition & 0 deletions src/cheatman.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* $Id$
*/

#include <unistd.h>
#include "include/cheatman.h"
#include "include/ioman.h"

Expand Down
10 changes: 8 additions & 2 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
#include "include/ioman.h"
#include <string.h>

// FIXME: We should not need this function.
// Use newlib's 'stat' to get GMT time.
#define NEWLIB_PORT_AWARE
#include <fileXio_rpc.h> // iox_stat_t, fileXioGetStat
int configGetStat(config_set_t *configSet, iox_stat_t *stat);

static u32 currentUID = 0;
static config_set_t configFiles[CONFIG_INDEX_COUNT];
static char legacyNetConfigPath[256] = "mc?:SYS-CONF/IPCONFIG.DAT";
Expand Down Expand Up @@ -411,8 +417,8 @@ static int configReadLegacyIP(void)
if (fd >= 0) {
char ipconfig[256];
int size = getFileSize(fd);
fileXioRead(fd, &ipconfig, size);
fileXioClose(fd);
read(fd, &ipconfig, size);
close(fd);

sscanf(ipconfig, "%d.%d.%d.%d %d.%d.%d.%d %d.%d.%d.%d", &ps2_ip[0], &ps2_ip[1], &ps2_ip[2], &ps2_ip[3],
&ps2_netmask[0], &ps2_netmask[1], &ps2_netmask[2], &ps2_netmask[3],
Expand Down
33 changes: 18 additions & 15 deletions src/ethsupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
#include "include/cheatman.h"
#include "modules/iopcore/common/cdvd_config.h"

#define NEWLIB_PORT_AWARE
#include <fileXio_rpc.h> // fileXioDevctl(ethBase, SMB_***)

#include "include/nbns.h"
#include "httpclient.h"

static char ethPrefix[40]; //Contains the full path to the folder where all the games are.
static char *ethBase;
static int ethULSizePrev = -2;
static unsigned char ethModifiedCDPrev[8];
static unsigned char ethModifiedDVDPrev[8];
static time_t ethModifiedCDPrev;
static time_t ethModifiedDVDPrev;
static int ethGameCount = 0;
static unsigned char ethModulesLoaded = 0;
static base_game_info_t *ethGames = NULL;
Expand Down Expand Up @@ -421,8 +424,8 @@ void ethInit(void)
LOG("ETHSUPPORT Init\n");
ethBase = "smb0:";
ethULSizePrev = -2;
memset(ethModifiedCDPrev, 0, sizeof(ethModifiedCDPrev));
memset(ethModifiedDVDPrev, 0, sizeof(ethModifiedDVDPrev));
ethModifiedCDPrev = 0;
ethModifiedDVDPrev = 0;
ethGameCount = 0;
ethGames = NULL;
configGetInt(configGetByType(CONFIG_OPL), "eth_frames_delay", &ethGameList.delay);
Expand All @@ -449,22 +452,22 @@ static int ethNeedsUpdate(void)
result = 1;

if (gNetworkStartup == 0) {
iox_stat_t stat;
struct stat st;
char path[256];

sprintf(path, "%sCD", ethPrefix);
if (fileXioGetStat(path, &stat) != 0)
memset(stat.mtime, 0, sizeof(stat.mtime));
if (memcmp(ethModifiedCDPrev, stat.mtime, sizeof(ethModifiedCDPrev))) {
memcpy(ethModifiedCDPrev, stat.mtime, sizeof(ethModifiedCDPrev));
if (stat(path, &st) != 0)
st.st_mtime = 0;
if (ethModifiedCDPrev != st.st_mtime) {
ethModifiedCDPrev = st.st_mtime;
result = 1;
}

sprintf(path, "%sDVD", ethPrefix);
if (fileXioGetStat(path, &stat) != 0)
memset(stat.mtime, 0, sizeof(stat.mtime));
if (memcmp(ethModifiedDVDPrev, stat.mtime, sizeof(ethModifiedDVDPrev))) {
memcpy(ethModifiedDVDPrev, stat.mtime, sizeof(ethModifiedDVDPrev));
if (stat(path, &st) != 0)
st.st_mtime = 0;
if (ethModifiedDVDPrev != st.st_mtime) {
ethModifiedDVDPrev = st.st_mtime;
result = 1;
}

Expand Down Expand Up @@ -671,10 +674,10 @@ static void ethLaunchGame(int id, config_set_t *configSet)
}

if (gPS2Logo) {
int fd = fileXioOpen(partname, O_RDONLY, 0666);
int fd = open(partname, O_RDONLY, 0666);
if (fd >= 0) {
EnablePS2Logo = CheckPS2Logo(fd, 0);
fileXioClose(fd);
close(fd);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/gsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ void PrepareGSM(char *cmdline)

k576p_fix = 0;
kGsDxDyOffsetSupported = 0;
if((fd = fileXioOpen("rom0:ROMVER", O_RDONLY)) >= 0) {
if((fd = open("rom0:ROMVER", O_RDONLY)) >= 0) {
//Read ROM version
fileXioRead(fd, romver, sizeof(romver));
fileXioClose(fd);
read(fd, romver, sizeof(romver));
close(fd);

strncpy(romverNum, romver, 4);
romverNum[4] = '\0';
Expand Down
Loading