Skip to content

Commit a82ef0b

Browse files
authored
Merge pull request #498 from uyjulian/fdmap_improvements
Fdmap improvements
2 parents 5645510 + c07050c commit a82ef0b

File tree

36 files changed

+3877
-739
lines changed

36 files changed

+3877
-739
lines changed

common/Rules.release

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,24 @@
66
# Licenced under Academic Free License version 2.0
77
# Review ps2sdk README & LICENSE files for further details.
88

9-
#
10-
# Creates the base common directory structure in target directory.
11-
#
12-
13-
RELEASE_COMMON_DIRS = common/ common/include/ common/include/arpa common/include/netinet common/include/sys
14-
RELEASE_COMMON_DIRS := $(RELEASE_COMMON_DIRS:%=$(PS2SDK)/%)
15-
16-
release-dirs:
17-
$(MKDIR) -p $(RELEASE_COMMON_DIRS)
18-
199
#
2010
# Any file in the include directory will be copied to the common/include
2111
# directory.
2212
#
2313

2414
release-include:
25-
@for file in include/* ; do \
26-
if test -f $$file ; then \
27-
$(ECHO) Installing $$file to $(PS2SDK)/common/include ; \
28-
cp -f $$file $(PS2SDK)/common/include ; \
29-
chmod 644 $(PS2SDK)/common/$$file ; \
30-
fi \
31-
done;
32-
@for file in include/arpa/* ; do \
33-
if test -f $$file ; then \
34-
$(ECHO) Installing $$file to $(PS2SDK)/common/include/arpa ; \
35-
cp -f $$file $(PS2SDK)/common/include/arpa ; \
36-
chmod 644 $(PS2SDK)/common/$$file ; \
37-
fi \
38-
done;
39-
@for file in include/netinet/* ; do \
40-
if test -f $$file ; then \
41-
$(ECHO) Installing $$file to $(PS2SDK)/common/include/netinet ; \
42-
cp -f $$file $(PS2SDK)/common/include/netinet ; \
43-
chmod 644 $(PS2SDK)/common/$$file ; \
44-
fi \
45-
done;
46-
@for file in include/sys/* ; do \
47-
if test -f $$file ; then \
48-
$(ECHO) Installing $$file to $(PS2SDK)/common/include/sys ; \
49-
cp -f $$file $(PS2SDK)/common/include/sys ; \
50-
chmod 644 $(PS2SDK)/common/$$file ; \
51-
fi \
52-
done;
15+
@if test -d include ; then \
16+
for file in $$(find include -type f | cut -d'/' -f2-); do \
17+
if test -f include/$$file ; then \
18+
$(ECHO) Installing include/$$file to $(PS2SDK)/common/include ; \
19+
mkdir -p $(PS2SDK)/common/include/$$(dirname $$file) ; \
20+
cp -t $(PS2SDK)/common/include/$$(dirname $$file) -f include/$$file ; \
21+
chmod 644 $(PS2SDK)/common/include/$$file ; \
22+
fi \
23+
done; \
24+
fi;
5325

54-
release: release-dirs release-include
26+
release: release-include
5527

5628
release-clean:
57-
rm -f -r $(PS2SDK)/common
29+
rm -rf $(PS2SDK)/common/

common/include/arpa/inet.h

Lines changed: 0 additions & 16 deletions
This file was deleted.

common/include/netdb.h

Lines changed: 0 additions & 16 deletions
This file was deleted.

common/include/sys/select.h

Whitespace-only changes.

common/include/sys/socket.h

Lines changed: 0 additions & 16 deletions
This file was deleted.

common/include/tcpip.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#define __TCPIP_H__
1818

1919
#include <tamtypes.h>
20+
#ifdef _EE
21+
/* Use the select related definitions fron newlib. */
22+
#include <sys/select.h>
23+
#endif
2024

2125
/* Some portions of this header fall under the following copyright. The license
2226
is compatible with that of ps2sdk.

ee/Rules.release

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,17 @@ release-ee-bin:
5555

5656
#
5757
# Any file in the include directory will be copied to the ee/include
58-
# directory. This does not currently handle subdirectories.
58+
# directory.
5959
#
6060

6161
release-ee-include:
6262
@if test -d include ; then \
63-
for file in include/*; do \
64-
if test -f $$file ; then \
65-
$(ECHO) Installing $$file to $(PS2SDK)/ee/include ; \
66-
cp -f $$file $(PS2SDK)/ee/include ; \
67-
chmod 644 $(PS2SDK)/ee/include/`basename $$file` ; \
63+
for file in $$(find include -type f | cut -d'/' -f2-); do \
64+
if test -f include/$$file ; then \
65+
$(ECHO) Installing include/$$file to $(PS2SDK)/ee/include ; \
66+
mkdir -p $(PS2SDK)/ee/include/$$(dirname $$file) ; \
67+
cp -t $(PS2SDK)/ee/include/$$(dirname $$file) -f include/$$file ; \
68+
chmod 644 $(PS2SDK)/ee/include/$$file ; \
6869
fi \
6970
done; \
7071
fi;
@@ -85,7 +86,7 @@ release-ee-samples:
8586
release: release-ee-dirs release-ee-lib release-ee-bin release-ee-include release-ee-samples
8687

8788
release-ee-clean:
88-
rm -f $(PS2SDK)/ee/include/*
89-
rm -f $(PS2SDK)/ee/bin/*
90-
rm -f $(PS2SDK)/ee/startup/*
91-
rm -f $(PS2SDK)/ee/lib/*
89+
rm -rf $(PS2SDK)/ee/include/
90+
rm -rf $(PS2SDK)/ee/bin/
91+
rm -rf $(PS2SDK)/ee/startup/
92+
rm -rf $(PS2SDK)/ee/lib/

ee/libcglue/Makefile

Lines changed: 134 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,132 @@ SJIS_OBJS = isSpecialSJIS.o isSpecialASCII.o strcpy_ascii.o strcpy_sjis.o
2424
CWD_OBJS = __cwd.o __get_drive.o getcwd.o __path_absolute.o __init_cwd.o
2525

2626
PS2SDKAPI_OBJS = \
27-
_ps2sdk_close.o _ps2sdk_open.o _ps2sdk_read.o _ps2sdk_lseek.o _ps2sdk_lseek64.o _ps2sdk_write.o _ps2sdk_ioctl.o \
28-
_ps2sdk_remove.o _ps2sdk_rename.o _ps2sdk_mkdir.o _ps2sdk_rmdir.o _ps2sdk_stat.o _ps2sdk_readlink.o _ps2sdk_symlink.o \
29-
_ps2sdk_dopen.o _ps2sdk_dread.o _ps2sdk_dclose.o
30-
31-
32-
GLUE_OBJS = __dummy_passwd.o __transform_errno.o __transform64_errno.o compile_time_check.o __normalized_path.o _open.o _close.o _read.o _write.o \
33-
_stat.o lstat.o _fstat.o access.o _fcntl.o getdents.o _lseek.o lseek64.o chdir.o mkdir.o \
34-
rmdir.o _link.o _unlink.o _rename.o _getpid.o _kill.o _fork.o _wait.o _sbrk.o _gettimeofday.o _times.o ftime.o clock_getres.o clock_gettime.o clock_settime.o \
35-
truncate.o symlink.o readlink.o utime.o fchown.o getrandom.o _getentropy.o _isatty.o chmod.o fchmod.o fchmodat.o pathconf.o \
36-
fsync.o getuid.o geteuid.o getpwuid.o getpwnam.o ps2sdk_get_iop_fd.o
27+
__fioOpsInitialize.o \
28+
__fioOpenHelper.o \
29+
__fioGetFdHelper.o \
30+
__fioGetFilenameHelper.o \
31+
__fioCloseHelper.o \
32+
__fioDcloseHelper.o \
33+
__fioReadHelper.o \
34+
__fioLseekHelper.o \
35+
__fioWriteHelper.o \
36+
__fioIoctlHelper.o \
37+
__fioDreadHelper.o \
38+
__fioLseekDirHelper.o \
39+
__libcglue_init_stdio.o \
40+
__fioMkdirHelper.o \
41+
__fioGetstatHelper.o \
42+
__fioOpsInitializeImpl.o \
43+
_libcglue_fdman_path_ops.o \
44+
_libcglue_fdman_socket_ops.o \
45+
_libcglue_fdman_inet_ops.o
46+
47+
48+
GLUE_OBJS = \
49+
__dummy_passwd.o \
50+
__transform_errno.o \
51+
__transform64_errno.o \
52+
compile_time_check.o \
53+
_open.o \
54+
_close.o \
55+
_read.o \
56+
_write.o \
57+
_stat.o \
58+
lstat.o \
59+
_fstat.o \
60+
access.o \
61+
_fcntl.o \
62+
getdents.o \
63+
_lseek.o \
64+
lseek64.o \
65+
chdir.o \
66+
mkdir.o \
67+
rmdir.o \
68+
_link.o \
69+
_unlink.o \
70+
_rename.o \
71+
_getpid.o \
72+
_kill.o \
73+
_fork.o \
74+
_wait.o \
75+
_sbrk.o \
76+
_gettimeofday.o \
77+
_times.o \
78+
ftime.o \
79+
clock_getres.o \
80+
clock_gettime.o \
81+
clock_settime.o \
82+
truncate.o \
83+
symlink.o \
84+
readlink.o \
85+
utime.o \
86+
fchown.o \
87+
getrandom.o \
88+
_getentropy.o \
89+
_isatty.o \
90+
chmod.o \
91+
fchmod.o \
92+
fchmodat.o \
93+
pathconf.o \
94+
fsync.o \
95+
getuid.o \
96+
geteuid.o \
97+
getpwuid.o \
98+
getpwnam.o \
99+
libcglue_get_fd_info.o
37100

38101
LOCK_OBJS = __retarget_lock_init.o __retarget_lock_acquire.o __retarget_lock_release.o __retarget_lock_try_acquire.o __retarget_lock_close.o \
39102
__retarget_lock_init_recursive.o __retarget_lock_acquire_recursive.o __retarget_lock_release_recursive.o __retarget_lock_try_acquire_recursive.o __retarget_lock_close_recursive.o
40103

41-
EE_OBJS = $(CORE_OBJS) $(TIMEZONE_OBJS) $(SJIS_OBJS) $(TIME_OBJS) $(FDMAN_OBJS) $(INIT_OBJS) $(SLEEP_OBJS) $(TERMINATE_OBJS) $(CWD_OBJS) $(PS2SDKAPI_OBJS) $(GLUE_OBJS) $(LOCK_OBJS)
104+
NETDB_OBJS = \
105+
gethostbyname.o \
106+
gethostbyname_r.o \
107+
freeaddrinfo.o \
108+
getaddrinfo.o
109+
110+
SELECT_OBJS = \
111+
select.o
112+
113+
SOCKET_OBJS = \
114+
socket.o \
115+
accept.o \
116+
bind.o \
117+
connect.o \
118+
listen.o \
119+
recv.o \
120+
recvfrom.o \
121+
send.o \
122+
sendto.o \
123+
getsockopt.o \
124+
setsockopt.o \
125+
shutdown.o \
126+
getpeername.o \
127+
getsockname.o \
128+
libcglue_inet_addr.o \
129+
libcglue_inet_ntoa.o \
130+
libcglue_inet_ntoa_r.o \
131+
libcglue_inet_aton.o \
132+
libcglue_ps2ip_setconfig.o \
133+
libcglue_ps2ip_getconfig.o \
134+
libcglue_dns_setserver.o \
135+
libcglue_dns_getserver.o
136+
137+
EE_OBJS = \
138+
$(CORE_OBJS) \
139+
$(TIMEZONE_OBJS) \
140+
$(SJIS_OBJS) \
141+
$(TIME_OBJS) \
142+
$(FDMAN_OBJS) \
143+
$(INIT_OBJS) \
144+
$(SLEEP_OBJS) \
145+
$(TERMINATE_OBJS) \
146+
$(CWD_OBJS) \
147+
$(PS2SDKAPI_OBJS) \
148+
$(GLUE_OBJS) \
149+
$(LOCK_OBJS) \
150+
$(NETDB_OBJS) \
151+
$(SELECT_OBJS) \
152+
$(SOCKET_OBJS)
42153

43154
include $(PS2SDKSRC)/Defs.make
44155
include $(PS2SDKSRC)/ee/Rules.lib.make
@@ -81,3 +192,15 @@ $(LOCK_OBJS:%=$(EE_OBJS_DIR)%): $(EE_SRC_DIR)lock.c
81192
$(DIR_GUARD)
82193
$(EE_C_COMPILE) -DF_$(*:$(EE_OBJS_DIR)%=%) $< -c -o $@
83194

195+
$(NETDB_OBJS:%=$(EE_OBJS_DIR)%): $(EE_SRC_DIR)netdb.c
196+
$(DIR_GUARD)
197+
$(EE_C_COMPILE) -DF_$(*:$(EE_OBJS_DIR)%=%) $< -c -o $@
198+
199+
$(SELECT_OBJS:%=$(EE_OBJS_DIR)%): $(EE_SRC_DIR)select.c
200+
$(DIR_GUARD)
201+
$(EE_C_COMPILE) -DF_$(*:$(EE_OBJS_DIR)%=%) $< -c -o $@
202+
203+
$(SOCKET_OBJS:%=$(EE_OBJS_DIR)%): $(EE_SRC_DIR)socket.c
204+
$(DIR_GUARD)
205+
$(EE_C_COMPILE) -DF_$(*:$(EE_OBJS_DIR)%=%) $< -c -o $@
206+

ee/libcglue/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# libcglue
2+
3+
This library provides functions to bridge the gap between newlib and libraries provided by ps2sdk.
4+
5+
## About file descriptors
6+
7+
ps2sdk uses multiple libraries to interact with files and sockets.
8+
libcglue fdman unifies the file descriptors provided by these libraries into a single namespace:
9+
10+
```mermaid
11+
flowchart LR
12+
13+
A["libkernel (fileio)"] --> G
14+
B[libfileXio] --> G
15+
C[libtcpip] --> G
16+
D[libtcpips] --> G
17+
G[libcglue] --> H[User code]
18+
```

ee/libcglue/include/arpa/inet.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
# _____ ___ ____ ___ ____
3+
# ____| | ____| | | |____|
4+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5+
#-----------------------------------------------------------------------
6+
# Copyright ps2dev - http://www.ps2dev.org
7+
# Licenced under Academic Free License version 2.0
8+
# Review ps2sdk README & LICENSE files for further details.
9+
*/
10+
11+
#ifndef __PS2SDK_ARPA_INET_H__
12+
#define __PS2SDK_ARPA_INET_H__
13+
14+
#include <sys/cdefs.h>
15+
#include <tcpip.h>
16+
17+
#ifndef LIBCGLUE_ARPA_INET_NO_ALIASES
18+
#define inet_addr(cp) libcglue_inet_addr(cp)
19+
#define inet_ntoa(addr) libcglue_inet_ntoa((const ip4_addr_t*)&(addr))
20+
#define inet_ntoa_r(addr, buf, buflen) libcglue_inet_ntoa_r((const ip4_addr_t*)&(addr), buf, buflen)
21+
#define inet_aton(cp, addr) libcglue_inet_aton(cp, (ip4_addr_t*)addr)
22+
#endif
23+
24+
__BEGIN_DECLS
25+
u32 libcglue_inet_addr(const char *cp);
26+
char *libcglue_inet_ntoa(const ip4_addr_t *addr);
27+
char *libcglue_inet_ntoa_r(const ip4_addr_t *addr, char *buf, int buflen);
28+
int libcglue_inet_aton(const char *cp, ip4_addr_t *addr);
29+
__END_DECLS
30+
31+
#endif

0 commit comments

Comments
 (0)