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

Question: optional ipv6 support #55

Closed
grepwood opened this issue Jun 8, 2020 · 8 comments
Closed

Question: optional ipv6 support #55

grepwood opened this issue Jun 8, 2020 · 8 comments

Comments

@grepwood
Copy link
Contributor

grepwood commented Jun 8, 2020

There is a libre toolchain for the PS3, https://github.com/ps3dev/ps3toolchain
One obstacle I've come across when trying to compile ioQuake3 with it was the toolchain's spotty ipv6 support, more here ps3dev/ps3toolchain#78
How hard would it be to divorce ipv6 support from Quake3e?

@ec-
Copy link
Owner

ec- commented Jun 9, 2020

Try now

@grepwood
Copy link
Contributor Author

Still trying.

@grepwood
Copy link
Contributor Author

Progress so far: everything builds except for

code/qcommon/net_ip.c
code/unix/unix_main.c
code/unix/unix_shared.c

The PS3 build, if it comes to life, will have to have some properties due to how GameOS works:

  • not use dlopen
  • use static dependencies everywhere

@ensiform
Copy link
Contributor

@grepwood

Dang no dlopen? Guess your work can't be brought over to https://github.com/etfdevs/ETe 😔

@grepwood
Copy link
Contributor Author

@ensiform Maybe hope isn't lost. There is dlopen in the toolchain, but I don't know if it works.

@ec-
Copy link
Owner

ec- commented Jun 15, 2020

@grepwood please post recent compilation log somewhere

@grepwood
Copy link
Contributor Author

grepwood commented Jun 16, 2020

Working with commit 5f5bdc9f8a5315dd37a60731c2478b68f0406fc3 of github.com/ec-/Quake3e master branch.

Source files with compilation errors:

  • code/qcommon/net_ip.c
  • code/unix/unix_main.c
  • code/unix/unix_shared.c

Compilation of code/qcommon/net_ip.c, take 1:

DED_CC code/qcommon/net_ip.c
In file included from code/qcommon/../qcommon/q_shared.h:143:0,
                 from code/qcommon/net_ip.c:23:
code/qcommon/../qcommon/q_platform.h:185:2: error: #error "Operating system not supported"
 #error "Operating system not supported"
  ^~~~~
code/qcommon/../qcommon/q_platform.h:189:2: error: #error "Architecture not supported"
 #error "Architecture not supported"
  ^~~~~
code/qcommon/../qcommon/q_platform.h:193:2: error: #error "ID_INLINE not defined"
 #error "ID_INLINE not defined"
  ^~~~~
code/qcommon/../qcommon/q_platform.h:238:2: error: #error "Endianness not defined"
 #error "Endianness not defined"
  ^~~~~
In file included from code/qcommon/net_ip.c:23:0:
code/qcommon/../qcommon/q_shared.h:535:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
 static ID_INLINE int VectorCompare( const vec3_t v1, const vec3_t v2 ) {
                  ^~~
code/qcommon/../qcommon/q_shared.h:542:8: error: unknown type name 'ID_INLINE'
 static ID_INLINE vec_t VectorLength( const vec3_t v ) {
        ^~~~~~~~~
code/qcommon/../qcommon/q_shared.h:542:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'VectorLength'
 static ID_INLINE vec_t VectorLength( const vec3_t v ) {
                        ^~~~~~~~~~~~
code/qcommon/../qcommon/q_shared.h:546:8: error: unknown type name 'ID_INLINE'
 static ID_INLINE vec_t VectorLengthSquared( const vec3_t v ) {
        ^~~~~~~~~
code/qcommon/../qcommon/q_shared.h:546:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'VectorLengthSquared'
 static ID_INLINE vec_t VectorLengthSquared( const vec3_t v ) {
                        ^~~~~~~~~~~~~~~~~~~
code/qcommon/../qcommon/q_shared.h:550:8: error: unknown type name 'ID_INLINE'
 static ID_INLINE vec_t Distance( const vec3_t p1, const vec3_t p2 ) {
        ^~~~~~~~~
code/qcommon/../qcommon/q_shared.h:550:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Distance'
 static ID_INLINE vec_t Distance( const vec3_t p1, const vec3_t p2 ) {
                        ^~~~~~~~
code/qcommon/../qcommon/q_shared.h:557:8: error: unknown type name 'ID_INLINE'
 static ID_INLINE vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ) {
        ^~~~~~~~~
code/qcommon/../qcommon/q_shared.h:557:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'DistanceSquared'
 static ID_INLINE vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ) {
                        ^~~~~~~~~~~~~~~
code/qcommon/../qcommon/q_shared.h:566:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
 static ID_INLINE void VectorNormalizeFast( vec3_t v )
                  ^~~~
code/qcommon/../qcommon/q_shared.h:577:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
 static ID_INLINE void VectorInverse( vec3_t v ){
                  ^~~~
code/qcommon/../qcommon/q_shared.h:583:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
 static ID_INLINE void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) {
                  ^~~~
In file included from code/qcommon/net_ip.c:24:0:
code/qcommon/../qcommon/qcommon.h:410:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'float'
 static ID_INLINE float _vmf(intptr_t x)
                  ^~~~~
code/qcommon/../qcommon/qcommon.h:957:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
 static ID_INLINE unsigned int log2pad( unsigned int v, int roundup )
                  ^~~~~~~~
code/qcommon/net_ip.c:83:11: fatal error: net/if.h: No such file or directory
 # include <net/if.h>
           ^~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:1106: build/release-psl1ght-ppc64/ded/net_ip.o] Błąd 1
make[2]: Opuszczenie katalogu '/home/mdec/git/Quake3e'
make[1]: *** [Makefile:562: targets] Błąd 2
make[1]: Opuszczenie katalogu '/home/mdec/git/Quake3e'
make: *** [Makefile.ps3:680: release] Błąd 2

Conclusion from take 1 - PS3 is not identified as any existing platform, so its support should be defined in code/qcommon/q_platform.h.

Take 2
git diff:

--- a/code/qcommon/q_platform.h
+++ b/code/qcommon/q_platform.h
@@ -149,6 +149,20 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #endif // __FreeBSD__ || __NetBSD__ || __OpenBSD__
 
+// ================================ PS3 ====================================
+
+#if defined(PS3)
+#      define __BSD__
+#      include <sys/types.h>
+#      include <machine/endian.h>
+#      define OS_STRING "GameOS"
+#      define ID_INLINE inline
+#      define PATH_SEP '/'
+#      define ARCH_STRING "ppc64"
+#      define Q3_BIG_ENDIAN
+#      define DLL_EXT ".so"
+#endif
+
 // ================================ Q3VM ===================================
 
 #ifdef Q3_VM

Compilation error in take 2:

DED_CC code/qcommon/net_ip.c
code/qcommon/net_ip.c:83:11: fatal error: net/if.h: No such file or directory
 # include <net/if.h>

Conclusion from take 2:

  • net/if.h does not exist in https://github.com/ps3dev/PSL1GHT
  • find /usr/local/ps3dev -type d -name net yielded /usr/local/ps3dev/ppu/include/net which contains net.h netctl.h netdb.h poll.h select.h socket.h

Take 3: systematically comment out missing headers from code/qcommon/net_ip.c to establish an absolute list of missing headers, to get a better idea of missing functionality in the toolchain

Result of take 3:
Missing headers:

  • net/if.h
  • sys/ioctl.h
  • ifaddrs.h

Compilation error in take 3:

code/qcommon/net_ip.c:158:26: error: field 'addr' has incomplete type
  struct sockaddr_storage addr;
                          ^~~~
code/qcommon/net_ip.c:159:26: error: field 'netmask' has incomplete type
  struct sockaddr_storage netmask;
                          ^~~~~~~
code/qcommon/net_ip.c: In function 'NetadrToSockadr':
code/qcommon/net_ip.c:249:30: error: dereferencing pointer to incomplete type 'struct sockaddr_in6'
    ((struct sockaddr_in6 *)s)->sin6_family = AF_INET6;
                              ^~
code/qcommon/net_ip.c:250:44: error: dereferencing pointer to incomplete type 'struct in6_addr'
    ((struct sockaddr_in6 *)s)->sin6_addr = * ((struct in6_addr *) &a->ipv._6);
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
code/qcommon/net_ip.c:256:52: error: invalid use of undefined type 'struct ipv6_mreq'
    ((struct sockaddr_in6 *)s)->sin6_addr = curgroup.ipv6mr_multiaddr;
                                                    ^
code/qcommon/net_ip.c: In function 'SockadrToNetadr':
code/qcommon/net_ip.c:270:7: error: dereferencing pointer to incomplete type 'const struct sockaddr_storage'
  if (s->ss_family == AF_INET) {
       ^~
code/qcommon/net_ip.c: In function 'gai_error_str':
code/qcommon/net_ip.c:314:8: error: 'EAI_NONAME' undeclared (first use in this function); did you mean 'AI_CANONNAME'?
   case EAI_NONAME:
        ^~~~~~~~~~
        AI_CANONNAME
code/qcommon/net_ip.c:314:8: note: each undeclared identifier is reported only once for each function it appears in
code/qcommon/net_ip.c:317:11: warning: implicit declaration of function 'gai_strerror'; did you mean 'strerror'? [-Wimplicit-function-declaration]
    return gai_strerror( ecode );
           ^~~~~~~~~~~~
           strerror
code/qcommon/net_ip.c:317:11: warning: return makes pointer from integer without a cast [-Wint-conversion]
    return gai_strerror( ecode );
           ^~~~~~~~~~~~~~~~~~~~~
code/qcommon/net_ip.c: In function 'Sys_StringToSockaddr':
code/qcommon/net_ip.c:342:11: warning: implicit declaration of function 'getaddrinfo' [-Wimplicit-function-declaration]
  retval = getaddrinfo(s, NULL, hintsp, &res);
           ^~~~~~~~~~~
code/qcommon/net_ip.c:378:4: warning: implicit declaration of function 'freeaddrinfo'; did you mean 'readlink'? [-Wimplicit-function-declaration]
    freeaddrinfo( res );
    ^~~~~~~~~~~~
    readlink
code/qcommon/net_ip.c: In function 'Sys_SockaddrToString':
code/qcommon/net_ip.c:406:21: error: invalid application of 'sizeof' to incomplete type 'struct sockaddr_in6'
   inputlen = sizeof(struct sockaddr_in6);
                     ^~~~~~
code/qcommon/net_ip.c:411:7: warning: implicit declaration of function 'getnameinfo' [-Wimplicit-function-declaration]
  if ( getnameinfo( (const struct sockaddr *)input, inputlen, dest, destlen, NULL, 0, NI_NUMERICHOST ) && destlen > 0 )
       ^~~~~~~~~~~
code/qcommon/net_ip.c: In function 'Sys_StringToAdr':
code/qcommon/net_ip.c:422:26: error: storage size of 'sadr' isn't known
  struct sockaddr_storage sadr;
                          ^~~~
code/qcommon/net_ip.c:422:26: warning: unused variable 'sadr' [-Wunused-variable]
code/qcommon/net_ip.c: In function 'NET_AdrToString':
code/qcommon/net_ip.c:539:27: error: storage size of 'sadr' isn't known
   struct sockaddr_storage sadr;
                           ^~~~
code/qcommon/net_ip.c:539:27: warning: unused variable 'sadr' [-Wunused-variable]
code/qcommon/net_ip.c: In function 'NET_GetPacket':
code/qcommon/net_ip.c:605:26: error: storage size of 'from' isn't known
  struct sockaddr_storage from;
                          ^~~~
code/qcommon/net_ip.c:605:26: warning: unused variable 'from' [-Wunused-variable]
code/qcommon/net_ip.c: In function 'Sys_SendPacket':
code/qcommon/net_ip.c:726:26: error: storage size of 'addr' isn't known
  struct sockaddr_storage addr;
                          ^~~~
code/qcommon/net_ip.c:773:81: error: invalid application of 'sizeof' to incomplete type 'struct sockaddr_in6'
    ret = sendto( ip6_socket, data, length, 0, (struct sockaddr *) &addr, sizeof(struct sockaddr_in6) );
                                                                                 ^~~~~~
code/qcommon/net_ip.c:726:26: warning: unused variable 'addr' [-Wunused-variable]
  struct sockaddr_storage addr;
                          ^~~~
code/qcommon/net_ip.c: In function 'NET_IPSocket':
code/qcommon/net_ip.c:100:24: warning: implicit declaration of function 'ioctl'; did you mean 'iscntrl'? [-Wimplicit-function-declaration]
 # define ioctlsocket   ioctl
                        ^
code/qcommon/net_ip.c:938:6: note: in expansion of macro 'ioctlsocket'
  if( ioctlsocket( newsocket, FIONBIO, &_true ) == SOCKET_ERROR ) {
      ^~~~~~~~~~~
code/qcommon/net_ip.c:938:30: error: 'FIONBIO' undeclared (first use in this function); did you mean 'SO_NBIO'?
  if( ioctlsocket( newsocket, FIONBIO, &_true ) == SOCKET_ERROR ) {
                              ^~~~~~~
                              SO_NBIO
code/qcommon/net_ip.c: In function 'NET_IP6Socket':
code/qcommon/net_ip.c:989:22: error: storage size of 'address' isn't known
  struct sockaddr_in6 address;
                      ^~~~~~~
code/qcommon/net_ip.c:1012:30: error: 'FIONBIO' undeclared (first use in this function); did you mean 'SO_NBIO'?
  if( ioctlsocket( newsocket, FIONBIO, &_true ) == SOCKET_ERROR ) {
                              ^~~~~~~
                              SO_NBIO
code/qcommon/net_ip.c:1034:23: error: 'in6addr_any' undeclared (first use in this function); did you mean 'in_addr_t'?
   address.sin6_addr = in6addr_any;
                       ^~~~~~~~~~~
                       in_addr_t
code/qcommon/net_ip.c:989:22: warning: unused variable 'address' [-Wunused-variable]
  struct sockaddr_in6 address;
                      ^~~~~~~
code/qcommon/net_ip.c: In function 'NET_SetMulticast6':
code/qcommon/net_ip.c:1074:22: error: storage size of 'addr' isn't known
  struct sockaddr_in6 addr;
                      ^~~~
code/qcommon/net_ip.c:1086:18: error: invalid use of undefined type 'struct ipv6_mreq'
  memcpy(&curgroup.ipv6mr_multiaddr, &addr.sin6_addr, sizeof(curgroup.ipv6mr_multiaddr));
                  ^
code/qcommon/net_ip.c:1086:69: error: invalid use of undefined type 'struct ipv6_mreq'
  memcpy(&curgroup.ipv6mr_multiaddr, &addr.sin6_addr, sizeof(curgroup.ipv6mr_multiaddr));
                                                                     ^
code/qcommon/net_ip.c:1093:11: error: invalid use of undefined type 'struct ipv6_mreq'
   curgroup.ipv6mr_interface = if_nametoindex(net_mcast6iface->string);
           ^
code/qcommon/net_ip.c:1093:31: warning: implicit declaration of function 'if_nametoindex' [-Wimplicit-function-declaration]
   curgroup.ipv6mr_interface = if_nametoindex(net_mcast6iface->string);
                               ^~~~~~~~~~~~~~
code/qcommon/net_ip.c:1097:11: error: invalid use of undefined type 'struct ipv6_mreq'
   curgroup.ipv6mr_interface = 0;
           ^
code/qcommon/net_ip.c:1074:22: warning: unused variable 'addr' [-Wunused-variable]
  struct sockaddr_in6 addr;
                      ^~~~
code/qcommon/net_ip.c: In function 'NET_JoinMulticast6':
code/qcommon/net_ip.c:1114:5: warning: implicit declaration of function 'IN6_IS_ADDR_MULTICAST'; did you mean 'IN_MULTICAST'? [-Wimplicit-function-declaration]
  if(IN6_IS_ADDR_MULTICAST(&boundto.sin6_addr) || IN6_IS_ADDR_UNSPECIFIED(&boundto.sin6_addr))
     ^~~~~~~~~~~~~~~~~~~~~
     IN_MULTICAST
code/qcommon/net_ip.c:1114:35: error: invalid use of undefined type 'struct sockaddr_in6'
  if(IN6_IS_ADDR_MULTICAST(&boundto.sin6_addr) || IN6_IS_ADDR_UNSPECIFIED(&boundto.sin6_addr))
                                   ^
code/qcommon/net_ip.c:1114:50: warning: implicit declaration of function 'IN6_IS_ADDR_UNSPECIFIED' [-Wimplicit-function-declaration]
  if(IN6_IS_ADDR_MULTICAST(&boundto.sin6_addr) || IN6_IS_ADDR_UNSPECIFIED(&boundto.sin6_addr))
                                                  ^~~~~~~~~~~~~~~~~~~~~~~
code/qcommon/net_ip.c:1114:82: error: invalid use of undefined type 'struct sockaddr_in6'
  if(IN6_IS_ADDR_MULTICAST(&boundto.sin6_addr) || IN6_IS_ADDR_UNSPECIFIED(&boundto.sin6_addr))
                                                                                  ^
In file included from /usr/local/ps3dev/ppu/include/netinet/in.h:92:0,
                 from code/qcommon/net_ip.c:81:
code/qcommon/net_ip.c:1121:78: error: invalid use of undefined type 'struct sockaddr_in6'
   if((multicast6_socket = NET_IP6Socket(net_mcast6addr->string, ntohs(boundto.sin6_port), NULL, &err)) == INVALID_SOCKET)
                                                                              ^
/usr/local/ps3dev/ppu/include/arpa/inet.h:10:26: note: in definition of macro 'ntohs'
 #define ntohs(netshort) (netshort)
                          ^~~~~~~~
code/qcommon/net_ip.c:1128:13: error: invalid use of undefined type 'struct ipv6_mreq'
  if(curgroup.ipv6mr_interface)
             ^
code/qcommon/net_ip.c:1130:37: error: 'IPPROTO_IPV6' undeclared (first use in this function); did you mean 'IPPROTO_IP'?
   if (setsockopt(multicast6_socket, IPPROTO_IPV6, IPV6_MULTICAST_IF,
                                     ^~~~~~~~~~~~
                                     IPPROTO_IP
code/qcommon/net_ip.c:1130:51: error: 'IPV6_MULTICAST_IF' undeclared (first use in this function); did you mean 'IP_MULTICAST_IF'?
   if (setsockopt(multicast6_socket, IPPROTO_IPV6, IPV6_MULTICAST_IF,
                                                   ^~~~~~~~~~~~~~~~~
                                                   IP_MULTICAST_IF
code/qcommon/net_ip.c:1131:24: error: invalid use of undefined type 'struct ipv6_mreq'
      (char *) &curgroup.ipv6mr_interface, sizeof(curgroup.ipv6mr_interface)) < 0)
                        ^
code/qcommon/net_ip.c:1131:58: error: invalid use of undefined type 'struct ipv6_mreq'
      (char *) &curgroup.ipv6mr_interface, sizeof(curgroup.ipv6mr_interface)) < 0)
                                                          ^
code/qcommon/net_ip.c:1144:50: error: 'IPV6_JOIN_GROUP' undeclared (first use in this function)
  if (setsockopt(multicast6_socket, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *) &curgroup, sizeof(curgroup)))
                                                  ^~~~~~~~~~~~~~~
code/qcommon/net_ip.c:1144:93: error: invalid application of 'sizeof' to incomplete type 'struct ipv6_mreq'
  if (setsockopt(multicast6_socket, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *) &curgroup, sizeof(curgroup)))
                                                                                             ^
code/qcommon/net_ip.c: In function 'NET_LeaveMulticast6':
code/qcommon/net_ip.c:1165:34: error: 'IPPROTO_IPV6' undeclared (first use in this function); did you mean 'IPPROTO_IP'?
    setsockopt(multicast6_socket, IPPROTO_IPV6, IPV6_LEAVE_GROUP, (char *) &curgroup, sizeof(curgroup));
                                  ^~~~~~~~~~~~
                                  IPPROTO_IP
code/qcommon/net_ip.c:1165:48: error: 'IPV6_LEAVE_GROUP' undeclared (first use in this function)
    setsockopt(multicast6_socket, IPPROTO_IPV6, IPV6_LEAVE_GROUP, (char *) &curgroup, sizeof(curgroup));
                                                ^~~~~~~~~~~~~~~~
code/qcommon/net_ip.c:1165:92: error: invalid application of 'sizeof' to incomplete type 'struct ipv6_mreq'
    setsockopt(multicast6_socket, IPPROTO_IPV6, IPV6_LEAVE_GROUP, (char *) &curgroup, sizeof(curgroup));
                                                                                            ^
code/qcommon/net_ip.c: In function 'NET_AddLocalAddress':
code/qcommon/net_ip.c:1366:21: error: invalid application of 'sizeof' to incomplete type 'struct sockaddr_in6'
    addrlen = sizeof(struct sockaddr_in6);
                     ^~~~~~
code/qcommon/net_ip.c: In function 'NET_GetLocalAddress':
code/qcommon/net_ip.c:1391:7: warning: implicit declaration of function 'gethostname'; did you mean 'gethostbyname'? [-Wimplicit-function-declaration]
  if ( gethostname( hostname, sizeof( hostname ) ) )
       ^~~~~~~~~~~
       gethostbyname
code/qcommon/net_ip.c:1398:7: warning: implicit declaration of function 'getifaddrs'; did you mean 'getitimer'? [-Wimplicit-function-declaration]
  if ( getifaddrs( &ifap ) )
       ^~~~~~~~~~
       getitimer
code/qcommon/net_ip.c:1402:46: error: dereferencing pointer to incomplete type 'struct ifaddrs'
   for( search = ifap; search; search = search->ifa_next )
                                              ^~
code/qcommon/net_ip.c:1405:27: error: 'IFF_UP' undeclared (first use in this function)
    if ( ifap->ifa_flags & IFF_UP )
                           ^~~~~~
code/qcommon/net_ip.c:1409:3: warning: implicit declaration of function 'freeifaddrs' [-Wimplicit-function-declaration]
   freeifaddrs( ifap );
   ^~~~~~~~~~~
code/qcommon/net_ip.c: In function 'NET_Sleep':
code/qcommon/net_ip.c:1853:11: warning: implicit declaration of function 'select'; did you mean 'sleep'? [-Wimplicit-function-declaration]
  retval = select( highestfd + 1, &fdr, NULL, NULL, &tv );
           ^~~~~~
           sleep
code/qcommon/net_ip.c: At top level:
code/qcommon/net_ip.c:137:25: error: storage size of 'curgroup' isn't known
 static struct ipv6_mreq curgroup;
                         ^~~~~~~~
code/qcommon/net_ip.c:139:28: error: storage size of 'boundto' isn't known
 static struct sockaddr_in6 boundto;
                            ^~~~~~~

select from net_ip.c line 1853 is defined in net/select.h, but there are still many problems.

Moving on to code/unix/unix_main.c.

Take 1, compilation, results include previous differences:

code/unix/unix_main.c:32:10: fatal error: sys/ipc.h: No such file or directory
 #include <sys/ipc.h>

There is no ipc.h in ps3dev.

Take 2: remove nonexistent headers until a list of missing headers is complete
Result:

  • sys/ipc.h
  • sys/shm.h
  • sys/mman.h (available in SPU part of the toolchain)
  • dlfcn.h
  • termios.h (broken header in ps3dev, should include machine/termios.h instead of sys/termios.h, this is not Quake's problem)

Take 3: compile code/unix/unix_main.c with all the missing headers gone
Result:

code/unix/unix_main.c: In function 'tty_FlushIn':
code/unix/unix_main.c:163:2: warning: implicit declaration of function 'tcflush'; did you mean 'fflush'? [-Wimplicit-function-declaration]
  tcflush( STDIN_FILENO, TCIFLUSH );
  ^~~~~~~
  fflush
code/unix/unix_main.c:163:25: error: 'TCIFLUSH' undeclared (first use in this function)
  tcflush( STDIN_FILENO, TCIFLUSH );
                         ^~~~~~~~
code/unix/unix_main.c:163:25: note: each undeclared identifier is reported only once for each function it appears in
code/unix/unix_main.c: In function 'Sys_ConsoleInputShutdown':
code/unix/unix_main.c:238:3: warning: implicit declaration of function 'tcsetattr'; did you mean 'tcsetpgrp'? [-Wimplicit-function-declaration]
   tcsetattr( STDIN_FILENO, TCSADRAIN, &tty_tc );
   ^~~~~~~~~
   tcsetpgrp
code/unix/unix_main.c:238:28: error: 'TCSADRAIN' undeclared (first use in this function)
   tcsetattr( STDIN_FILENO, TCSADRAIN, &tty_tc );
                            ^~~~~~~~~
code/unix/unix_main.c: In function 'CON_SigTStp':
code/unix/unix_main.c:282:2: warning: implicit declaration of function 'kill'; did you mean 'ceill'? [-Wimplicit-function-declaration]
  kill( getpid(),  SIGTSTP );
  ^~~~
  ceill
code/unix/unix_main.c: In function 'Sys_ConsoleInputInit':
code/unix/unix_main.c:375:17: error: storage size of 'tc' isn't known
  struct termios tc;
                 ^~
code/unix/unix_main.c:419:2: warning: implicit declaration of function 'tcgetattr'; did you mean 'tcgetpgrp'? [-Wimplicit-function-declaration]
  tcgetattr( STDIN_FILENO, &tty_tc );
  ^~~~~~~~~
  tcgetpgrp
code/unix/unix_main.c:420:20: error: invalid use of undefined type 'struct termios'
  tty_erase = tty_tc.c_cc[ VERASE ];
                    ^
code/unix/unix_main.c:420:27: error: 'VERASE' undeclared (first use in this function); did you mean 'ERANGE'?
  tty_erase = tty_tc.c_cc[ VERASE ];
                           ^~~~~~
                           ERANGE
code/unix/unix_main.c:421:18: error: invalid use of undefined type 'struct termios'
  tty_eof = tty_tc.c_cc[ VEOF ];
                  ^
code/unix/unix_main.c:421:25: error: 'VEOF' undeclared (first use in this function); did you mean 'EOF'?
  tty_eof = tty_tc.c_cc[ VEOF ];
                         ^~~~
                         EOF
code/unix/unix_main.c:432:18: error: 'ECHO' undeclared (first use in this function); did you mean 'EIO'?
  tc.c_lflag &= ~(ECHO | ICANON);
                  ^~~~
                  EIO
code/unix/unix_main.c:432:25: error: 'ICANON' undeclared (first use in this function); did you mean 'TC_NONE'?
  tc.c_lflag &= ~(ECHO | ICANON);
                         ^~~~~~
                         TC_NONE
code/unix/unix_main.c:437:18: error: 'ISTRIP' undeclared (first use in this function); did you mean 'STRING'?
  tc.c_iflag &= ~(ISTRIP | INPCK);
                  ^~~~~~
                  STRING
code/unix/unix_main.c:437:27: error: 'INPCK' undeclared (first use in this function); did you mean 'ENOLCK'?
  tc.c_iflag &= ~(ISTRIP | INPCK);
                           ^~~~~
                           ENOLCK
code/unix/unix_main.c:438:10: error: 'VMIN' undeclared (first use in this function); did you mean 'MIN'?
  tc.c_cc[VMIN] = 1;
          ^~~~
          MIN
code/unix/unix_main.c:439:10: error: 'VTIME' undeclared (first use in this function); did you mean 'ETIME'?
  tc.c_cc[VTIME] = 0;
          ^~~~~
          ETIME
code/unix/unix_main.c:440:27: error: 'TCSADRAIN' undeclared (first use in this function)
  tcsetattr( STDIN_FILENO, TCSADRAIN, &tc );
                           ^~~~~~~~~
code/unix/unix_main.c:375:17: warning: unused variable 'tc' [-Wunused-variable]
  struct termios tc;
                 ^~
code/unix/unix_main.c: In function 'Sys_ConsoleInput':
code/unix/unix_main.c:584:8: warning: implicit declaration of function 'select'; did you mean 'setenv'? [-Wimplicit-function-declaration]
   if ( select( STDIN_FILENO + 1, &fdset, NULL, NULL, &timeout) == -1 || !FD_ISSET( STDIN_FILENO, &fdset ) )
        ^~~~~~
        setenv
code/unix/unix_main.c: In function 'Sys_BinName':
code/unix/unix_main.c:833:21: error: 'PATH_MAX' undeclared (first use in this function); did you mean 'INT8_MAX'?
  static char   dst[ PATH_MAX ];
                     ^~~~~~~~
                     INT8_MAX
code/unix/unix_main.c:833:16: warning: unused variable 'dst' [-Wunused-variable]
  static char   dst[ PATH_MAX ];
                ^~~
code/unix/unix_main.c: At top level:
code/unix/unix_main.c:100:23: error: storage size of 'tty_tc' isn't known
 static struct termios tty_tc;
                       ^~~~~~
code/unix/unix_main.c: In function 'Sys_BinName':
code/unix/unix_main.c:854:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

Conclusions:

  • tcflush function is really missing
  • TCIFLUSH, TCSADRAIN, VERASE, VEOF, ECHO, ICANON, ISTRIP, INPCK, VMIN and VTIME undeclared
  • tcsetattr function is really missing
  • a lot of tc stuff is really undeclared
  • kill function is undeclared, but it is defined as an external function
  • PATH_MAX is undeclared but it is declared in limits.h and sys/syslimits.h although with different values (1k vs 4k)
  • our friend select is back, undeclared again

Next file: code/unix/unix_shared.c
Take 1: compilation
Result:

code/unix/unix_shared.c:30:10: fatal error: sys/mman.h: No such file or directory
 #include <sys/mman.h>

Take 2: remove nonexistent headers until code errors remain
Result:

  • sys/mman.h
  • dlfcn.h

Take 3: compilation without headers
Result:

code/unix/unix_shared.c: In function 'Sys_LoadLibrary':
code/unix/unix_shared.c:497:11: warning: implicit declaration of function 'dlopen'; did you mean 'popen'? [-Wimplicit-function-declaration]
  handle = dlopen( name, RTLD_NOW );
           ^~~~~~
           popen
code/unix/unix_shared.c:497:25: error: 'RTLD_NOW' undeclared (first use in this function); did you mean 'EXEC_NOW'?
  handle = dlopen( name, RTLD_NOW );
                         ^~~~~~~~
                         EXEC_NOW
code/unix/unix_shared.c:497:25: note: each undeclared identifier is reported only once for each function it appears in
code/unix/unix_shared.c: In function 'Sys_UnloadLibrary':
code/unix/unix_shared.c:510:3: warning: implicit declaration of function 'dlclose'; did you mean 'close'? [-Wimplicit-function-declaration]
   dlclose( handle );
   ^~~~~~~
   close
code/unix/unix_shared.c: In function 'Sys_LoadFunction':
code/unix/unix_shared.c:532:2: warning: implicit declaration of function 'dlerror'; did you mean 'perror'? [-Wimplicit-function-declaration]
  dlerror(); /* clear old error state */
  ^~~~~~~
  perror
code/unix/unix_shared.c:533:11: warning: implicit declaration of function 'dlsym' [-Wimplicit-function-declaration]
  symbol = dlsym( handle, name );
           ^~~~~
code/unix/unix_shared.c:533:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
  symbol = dlsym( handle, name );
         ^
code/unix/unix_shared.c:534:8: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
  error = dlerror();
        ^
code/unix/unix_shared.c:543:10: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
   symbol = dlsym( handle, buf );
          ^
code/unix/unix_shared.c: In function 'Sys_SetAffinityMask':
code/unix/unix_shared.c:575:9: error: unknown type name 'cpu_set_t'
  static cpu_set_t old_set;
         ^~~~~~~~~
code/unix/unix_shared.c:576:2: error: unknown type name 'cpu_set_t'; did you mean 'cplane_t'?
  cpu_set_t set;
  ^~~~~~~~~
  cplane_t
code/unix/unix_shared.c:581:8: warning: implicit declaration of function 'sched_getaffinity' [-Wimplicit-function-declaration]
   if ( sched_getaffinity( getpid(), sizeof( old_set ), &old_set ) == 0 )
        ^~~~~~~~~~~~~~~~~
code/unix/unix_shared.c:596:9: warning: implicit declaration of function 'CPU_ISSET'; did you mean 'CPU_SSE'? [-Wimplicit-function-declaration]
    if ( CPU_ISSET( cpu, &set ) )
         ^~~~~~~~~
         CPU_SSE
code/unix/unix_shared.c:602:3: warning: implicit declaration of function 'CPU_ZERO'; did you mean 'FP_ZERO'? [-Wimplicit-function-declaration]
   CPU_ZERO( &set );
   ^~~~~~~~
   FP_ZERO
code/unix/unix_shared.c:606:5: warning: implicit declaration of function 'CPU_SET'; did you mean 'CPU_SSE'? [-Wimplicit-function-declaration]
     CPU_SET( cpu, &set );
     ^~~~~~~
     CPU_SSE
code/unix/unix_shared.c:610:7: warning: implicit declaration of function 'sched_setaffinity' [-Wimplicit-function-declaration]
  if ( sched_setaffinity( getpid(), sizeof( set ), &set ) == 0 ) {
       ^~~~~~~~~~~~~~~~~

Summary:

  • missing cpu_set_t datatype and RTLD_NOW macro

@grepwood
Copy link
Contributor Author

grepwood commented Jul 9, 2020

If anyone is still wondering what is going on with this:

  • thank you @ec- for going a step in the right direction with this, because it appears SPRX does not support IPv6 at all ipv6 support ps3dev/ps3toolchain#78 (comment) so this will be needed in the unforeseeable future
  • hopefully normal support for IPv4 will come with PSL1GHT v3 [RFC] psl1ght "v3" ps3dev/PSL1GHT#67
  • until then there is little point in compiling Quake with v2 other than to just check if everything except 3 source files still compile correctly

@ec- ec- closed this as completed Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants